Theme Inspinia
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

jquery-ui.js 427KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040
  1. /*! jQuery UI - v1.10.4 - 2014-01-17
  2. * http://jqueryui.com
  3. * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.effect.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js, jquery.ui.menu.js, jquery.ui.position.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js
  4. * Copyright 2014 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.4",
  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) : 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 ( arguments.length === 1 ) {
  551. return curOption[ key ] === undefined ? null : curOption[ key ];
  552. }
  553. curOption[ key ] = value;
  554. } else {
  555. if ( arguments.length === 1 ) {
  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.4",
  738. options: {
  739. cancel: "input,textarea,button,select,option",
  740. distance: 1,
  741. delay: 0
  742. },
  743. _mouseInit: function() {
  744. var that = this;
  745. this.element
  746. .bind("mousedown."+this.widgetName, function(event) {
  747. return that._mouseDown(event);
  748. })
  749. .bind("click."+this.widgetName, function(event) {
  750. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  751. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  752. event.stopImmediatePropagation();
  753. return false;
  754. }
  755. });
  756. this.started = false;
  757. },
  758. // TODO: make sure destroying one instance of mouse doesn't mess with
  759. // other instances of mouse
  760. _mouseDestroy: function() {
  761. this.element.unbind("."+this.widgetName);
  762. if ( this._mouseMoveDelegate ) {
  763. $(document)
  764. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  765. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  766. }
  767. },
  768. _mouseDown: function(event) {
  769. // don't let more than one widget handle mouseStart
  770. if( mouseHandled ) { return; }
  771. // we may have missed mouseup (out of window)
  772. (this._mouseStarted && this._mouseUp(event));
  773. this._mouseDownEvent = event;
  774. var that = this,
  775. btnIsLeft = (event.which === 1),
  776. // event.target.nodeName works around a bug in IE 8 with
  777. // disabled inputs (#7620)
  778. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  779. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  780. return true;
  781. }
  782. this.mouseDelayMet = !this.options.delay;
  783. if (!this.mouseDelayMet) {
  784. this._mouseDelayTimer = setTimeout(function() {
  785. that.mouseDelayMet = true;
  786. }, this.options.delay);
  787. }
  788. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  789. this._mouseStarted = (this._mouseStart(event) !== false);
  790. if (!this._mouseStarted) {
  791. event.preventDefault();
  792. return true;
  793. }
  794. }
  795. // Click event may never have fired (Gecko & Opera)
  796. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  797. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  798. }
  799. // these delegates are required to keep context
  800. this._mouseMoveDelegate = function(event) {
  801. return that._mouseMove(event);
  802. };
  803. this._mouseUpDelegate = function(event) {
  804. return that._mouseUp(event);
  805. };
  806. $(document)
  807. .bind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  808. .bind("mouseup."+this.widgetName, this._mouseUpDelegate);
  809. event.preventDefault();
  810. mouseHandled = true;
  811. return true;
  812. },
  813. _mouseMove: function(event) {
  814. // IE mouseup check - mouseup happened when mouse was out of window
  815. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  816. return this._mouseUp(event);
  817. }
  818. if (this._mouseStarted) {
  819. this._mouseDrag(event);
  820. return event.preventDefault();
  821. }
  822. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  823. this._mouseStarted =
  824. (this._mouseStart(this._mouseDownEvent, event) !== false);
  825. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  826. }
  827. return !this._mouseStarted;
  828. },
  829. _mouseUp: function(event) {
  830. $(document)
  831. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  832. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  833. if (this._mouseStarted) {
  834. this._mouseStarted = false;
  835. if (event.target === this._mouseDownEvent.target) {
  836. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  837. }
  838. this._mouseStop(event);
  839. }
  840. return false;
  841. },
  842. _mouseDistanceMet: function(event) {
  843. return (Math.max(
  844. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  845. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  846. ) >= this.options.distance
  847. );
  848. },
  849. _mouseDelayMet: function(/* event */) {
  850. return this.mouseDelayMet;
  851. },
  852. // These are placeholder methods, to be overriden by extending plugin
  853. _mouseStart: function(/* event */) {},
  854. _mouseDrag: function(/* event */) {},
  855. _mouseStop: function(/* event */) {},
  856. _mouseCapture: function(/* event */) { return true; }
  857. });
  858. })(jQuery);
  859. (function( $, undefined ) {
  860. $.widget("ui.draggable", $.ui.mouse, {
  861. version: "1.10.4",
  862. widgetEventPrefix: "drag",
  863. options: {
  864. addClasses: true,
  865. appendTo: "parent",
  866. axis: false,
  867. connectToSortable: false,
  868. containment: false,
  869. cursor: "auto",
  870. cursorAt: false,
  871. grid: false,
  872. handle: false,
  873. helper: "original",
  874. iframeFix: false,
  875. opacity: false,
  876. refreshPositions: false,
  877. revert: false,
  878. revertDuration: 500,
  879. scope: "default",
  880. scroll: true,
  881. scrollSensitivity: 20,
  882. scrollSpeed: 20,
  883. snap: false,
  884. snapMode: "both",
  885. snapTolerance: 20,
  886. stack: false,
  887. zIndex: false,
  888. // callbacks
  889. drag: null,
  890. start: null,
  891. stop: null
  892. },
  893. _create: function() {
  894. if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
  895. this.element[0].style.position = "relative";
  896. }
  897. if (this.options.addClasses){
  898. this.element.addClass("ui-draggable");
  899. }
  900. if (this.options.disabled){
  901. this.element.addClass("ui-draggable-disabled");
  902. }
  903. this._mouseInit();
  904. },
  905. _destroy: function() {
  906. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  907. this._mouseDestroy();
  908. },
  909. _mouseCapture: function(event) {
  910. var o = this.options;
  911. // among others, prevent a drag on a resizable-handle
  912. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  913. return false;
  914. }
  915. //Quit if we're not on a valid handle
  916. this.handle = this._getHandle(event);
  917. if (!this.handle) {
  918. return false;
  919. }
  920. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  921. $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
  922. .css({
  923. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  924. position: "absolute", opacity: "0.001", zIndex: 1000
  925. })
  926. .css($(this).offset())
  927. .appendTo("body");
  928. });
  929. return true;
  930. },
  931. _mouseStart: function(event) {
  932. var o = this.options;
  933. //Create and append the visible helper
  934. this.helper = this._createHelper(event);
  935. this.helper.addClass("ui-draggable-dragging");
  936. //Cache the helper size
  937. this._cacheHelperProportions();
  938. //If ddmanager is used for droppables, set the global draggable
  939. if($.ui.ddmanager) {
  940. $.ui.ddmanager.current = this;
  941. }
  942. /*
  943. * - Position generation -
  944. * This block generates everything position related - it's the core of draggables.
  945. */
  946. //Cache the margins of the original element
  947. this._cacheMargins();
  948. //Store the helper's css position
  949. this.cssPosition = this.helper.css( "position" );
  950. this.scrollParent = this.helper.scrollParent();
  951. this.offsetParent = this.helper.offsetParent();
  952. this.offsetParentCssPosition = this.offsetParent.css( "position" );
  953. //The element's absolute position on the page minus margins
  954. this.offset = this.positionAbs = this.element.offset();
  955. this.offset = {
  956. top: this.offset.top - this.margins.top,
  957. left: this.offset.left - this.margins.left
  958. };
  959. //Reset scroll cache
  960. this.offset.scroll = false;
  961. $.extend(this.offset, {
  962. click: { //Where the click happened, relative to the element
  963. left: event.pageX - this.offset.left,
  964. top: event.pageY - this.offset.top
  965. },
  966. parent: this._getParentOffset(),
  967. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  968. });
  969. //Generate the original position
  970. this.originalPosition = this.position = this._generatePosition(event);
  971. this.originalPageX = event.pageX;
  972. this.originalPageY = event.pageY;
  973. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  974. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  975. //Set a containment if given in the options
  976. this._setContainment();
  977. //Trigger event + callbacks
  978. if(this._trigger("start", event) === false) {
  979. this._clear();
  980. return false;
  981. }
  982. //Recache the helper size
  983. this._cacheHelperProportions();
  984. //Prepare the droppable offsets
  985. if ($.ui.ddmanager && !o.dropBehaviour) {
  986. $.ui.ddmanager.prepareOffsets(this, event);
  987. }
  988. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  989. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  990. if ( $.ui.ddmanager ) {
  991. $.ui.ddmanager.dragStart(this, event);
  992. }
  993. return true;
  994. },
  995. _mouseDrag: function(event, noPropagation) {
  996. // reset any necessary cached properties (see #5009)
  997. if ( this.offsetParentCssPosition === "fixed" ) {
  998. this.offset.parent = this._getParentOffset();
  999. }
  1000. //Compute the helpers position
  1001. this.position = this._generatePosition(event);
  1002. this.positionAbs = this._convertPositionTo("absolute");
  1003. //Call plugins and callbacks and use the resulting position if something is returned
  1004. if (!noPropagation) {
  1005. var ui = this._uiHash();
  1006. if(this._trigger("drag", event, ui) === false) {
  1007. this._mouseUp({});
  1008. return false;
  1009. }
  1010. this.position = ui.position;
  1011. }
  1012. if(!this.options.axis || this.options.axis !== "y") {
  1013. this.helper[0].style.left = this.position.left+"px";
  1014. }
  1015. if(!this.options.axis || this.options.axis !== "x") {
  1016. this.helper[0].style.top = this.position.top+"px";
  1017. }
  1018. if($.ui.ddmanager) {
  1019. $.ui.ddmanager.drag(this, event);
  1020. }
  1021. return false;
  1022. },
  1023. _mouseStop: function(event) {
  1024. //If we are using droppables, inform the manager about the drop
  1025. var that = this,
  1026. dropped = false;
  1027. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1028. dropped = $.ui.ddmanager.drop(this, event);
  1029. }
  1030. //if a drop comes from outside (a sortable)
  1031. if(this.dropped) {
  1032. dropped = this.dropped;
  1033. this.dropped = false;
  1034. }
  1035. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  1036. if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
  1037. return false;
  1038. }
  1039. if((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
  1040. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1041. if(that._trigger("stop", event) !== false) {
  1042. that._clear();
  1043. }
  1044. });
  1045. } else {
  1046. if(this._trigger("stop", event) !== false) {
  1047. this._clear();
  1048. }
  1049. }
  1050. return false;
  1051. },
  1052. _mouseUp: function(event) {
  1053. //Remove frame helpers
  1054. $("div.ui-draggable-iframeFix").each(function() {
  1055. this.parentNode.removeChild(this);
  1056. });
  1057. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1058. if( $.ui.ddmanager ) {
  1059. $.ui.ddmanager.dragStop(this, event);
  1060. }
  1061. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1062. },
  1063. cancel: function() {
  1064. if(this.helper.is(".ui-draggable-dragging")) {
  1065. this._mouseUp({});
  1066. } else {
  1067. this._clear();
  1068. }
  1069. return this;
  1070. },
  1071. _getHandle: function(event) {
  1072. return this.options.handle ?
  1073. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1074. true;
  1075. },
  1076. _createHelper: function(event) {
  1077. var o = this.options,
  1078. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
  1079. if(!helper.parents("body").length) {
  1080. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1081. }
  1082. if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1083. helper.css("position", "absolute");
  1084. }
  1085. return helper;
  1086. },
  1087. _adjustOffsetFromHelper: function(obj) {
  1088. if (typeof obj === "string") {
  1089. obj = obj.split(" ");
  1090. }
  1091. if ($.isArray(obj)) {
  1092. obj = {left: +obj[0], top: +obj[1] || 0};
  1093. }
  1094. if ("left" in obj) {
  1095. this.offset.click.left = obj.left + this.margins.left;
  1096. }
  1097. if ("right" in obj) {
  1098. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1099. }
  1100. if ("top" in obj) {
  1101. this.offset.click.top = obj.top + this.margins.top;
  1102. }
  1103. if ("bottom" in obj) {
  1104. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1105. }
  1106. },
  1107. _getParentOffset: function() {
  1108. //Get the offsetParent and cache its position
  1109. var po = this.offsetParent.offset();
  1110. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1111. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1112. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1113. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1114. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1115. po.left += this.scrollParent.scrollLeft();
  1116. po.top += this.scrollParent.scrollTop();
  1117. }
  1118. //This needs to be actually done for all browsers, since pageX/pageY includes this information
  1119. //Ugly IE fix
  1120. if((this.offsetParent[0] === document.body) ||
  1121. (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  1122. po = { top: 0, left: 0 };
  1123. }
  1124. return {
  1125. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  1126. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  1127. };
  1128. },
  1129. _getRelativeOffset: function() {
  1130. if(this.cssPosition === "relative") {
  1131. var p = this.element.position();
  1132. return {
  1133. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  1134. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  1135. };
  1136. } else {
  1137. return { top: 0, left: 0 };
  1138. }
  1139. },
  1140. _cacheMargins: function() {
  1141. this.margins = {
  1142. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  1143. top: (parseInt(this.element.css("marginTop"),10) || 0),
  1144. right: (parseInt(this.element.css("marginRight"),10) || 0),
  1145. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  1146. };
  1147. },
  1148. _cacheHelperProportions: function() {
  1149. this.helperProportions = {
  1150. width: this.helper.outerWidth(),
  1151. height: this.helper.outerHeight()
  1152. };
  1153. },
  1154. _setContainment: function() {
  1155. var over, c, ce,
  1156. o = this.options;
  1157. if ( !o.containment ) {
  1158. this.containment = null;
  1159. return;
  1160. }
  1161. if ( o.containment === "window" ) {
  1162. this.containment = [
  1163. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1164. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1165. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  1166. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1167. ];
  1168. return;
  1169. }
  1170. if ( o.containment === "document") {
  1171. this.containment = [
  1172. 0,
  1173. 0,
  1174. $( document ).width() - this.helperProportions.width - this.margins.left,
  1175. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1176. ];
  1177. return;
  1178. }
  1179. if ( o.containment.constructor === Array ) {
  1180. this.containment = o.containment;
  1181. return;
  1182. }
  1183. if ( o.containment === "parent" ) {
  1184. o.containment = this.helper[ 0 ].parentNode;
  1185. }
  1186. c = $( o.containment );
  1187. ce = c[ 0 ];
  1188. if( !ce ) {
  1189. return;
  1190. }
  1191. over = c.css( "overflow" ) !== "hidden";
  1192. this.containment = [
  1193. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  1194. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) ,
  1195. ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right,
  1196. ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top - this.margins.bottom
  1197. ];
  1198. this.relative_container = c;
  1199. },
  1200. _convertPositionTo: function(d, pos) {
  1201. if(!pos) {
  1202. pos = this.position;
  1203. }
  1204. var mod = d === "absolute" ? 1 : -1,
  1205. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
  1206. //Cache the scroll
  1207. if (!this.offset.scroll) {
  1208. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  1209. }
  1210. return {
  1211. top: (
  1212. pos.top + // The absolute mouse position
  1213. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1214. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1215. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod )
  1216. ),
  1217. left: (
  1218. pos.left + // The absolute mouse position
  1219. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1220. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1221. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod )
  1222. )
  1223. };
  1224. },
  1225. _generatePosition: function(event) {
  1226. var containment, co, top, left,
  1227. o = this.options,
  1228. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
  1229. pageX = event.pageX,
  1230. pageY = event.pageY;
  1231. //Cache the scroll
  1232. if (!this.offset.scroll) {
  1233. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  1234. }
  1235. /*
  1236. * - Position constraining -
  1237. * Constrain the position to a mix of grid, containment.
  1238. */
  1239. // If we are not dragging yet, we won't check for options
  1240. if ( this.originalPosition ) {
  1241. if ( this.containment ) {
  1242. if ( this.relative_container ){
  1243. co = this.relative_container.offset();
  1244. containment = [
  1245. this.containment[ 0 ] + co.left,
  1246. this.containment[ 1 ] + co.top,
  1247. this.containment[ 2 ] + co.left,
  1248. this.containment[ 3 ] + co.top
  1249. ];
  1250. }
  1251. else {
  1252. containment = this.containment;
  1253. }
  1254. if(event.pageX - this.offset.click.left < containment[0]) {
  1255. pageX = containment[0] + this.offset.click.left;
  1256. }
  1257. if(event.pageY - this.offset.click.top < containment[1]) {
  1258. pageY = containment[1] + this.offset.click.top;
  1259. }
  1260. if(event.pageX - this.offset.click.left > containment[2]) {
  1261. pageX = containment[2] + this.offset.click.left;
  1262. }
  1263. if(event.pageY - this.offset.click.top > containment[3]) {
  1264. pageY = containment[3] + this.offset.click.top;
  1265. }
  1266. }
  1267. if(o.grid) {
  1268. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1269. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1270. pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
  1271. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1272. pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
  1273. }
  1274. }
  1275. return {
  1276. top: (
  1277. pageY - // The absolute mouse position
  1278. this.offset.click.top - // Click offset (relative to the element)
  1279. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1280. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1281. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top )
  1282. ),
  1283. left: (
  1284. pageX - // The absolute mouse position
  1285. this.offset.click.left - // Click offset (relative to the element)
  1286. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1287. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1288. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left )
  1289. )
  1290. };
  1291. },
  1292. _clear: function() {
  1293. this.helper.removeClass("ui-draggable-dragging");
  1294. if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1295. this.helper.remove();
  1296. }
  1297. this.helper = null;
  1298. this.cancelHelperRemoval = false;
  1299. },
  1300. // From now on bulk stuff - mainly helpers
  1301. _trigger: function(type, event, ui) {
  1302. ui = ui || this._uiHash();
  1303. $.ui.plugin.call(this, type, [event, ui]);
  1304. //The absolute position has to be recalculated after plugins
  1305. if(type === "drag") {
  1306. this.positionAbs = this._convertPositionTo("absolute");
  1307. }
  1308. return $.Widget.prototype._trigger.call(this, type, event, ui);
  1309. },
  1310. plugins: {},
  1311. _uiHash: function() {
  1312. return {
  1313. helper: this.helper,
  1314. position: this.position,
  1315. originalPosition: this.originalPosition,
  1316. offset: this.positionAbs
  1317. };
  1318. }
  1319. });
  1320. $.ui.plugin.add("draggable", "connectToSortable", {
  1321. start: function(event, ui) {
  1322. var inst = $(this).data("ui-draggable"), o = inst.options,
  1323. uiSortable = $.extend({}, ui, { item: inst.element });
  1324. inst.sortables = [];
  1325. $(o.connectToSortable).each(function() {
  1326. var sortable = $.data(this, "ui-sortable");
  1327. if (sortable && !sortable.options.disabled) {
  1328. inst.sortables.push({
  1329. instance: sortable,
  1330. shouldRevert: sortable.options.revert
  1331. });
  1332. sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
  1333. sortable._trigger("activate", event, uiSortable);
  1334. }
  1335. });
  1336. },
  1337. stop: function(event, ui) {
  1338. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  1339. var inst = $(this).data("ui-draggable"),
  1340. uiSortable = $.extend({}, ui, { item: inst.element });
  1341. $.each(inst.sortables, function() {
  1342. if(this.instance.isOver) {
  1343. this.instance.isOver = 0;
  1344. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  1345. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  1346. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
  1347. if(this.shouldRevert) {
  1348. this.instance.options.revert = this.shouldRevert;
  1349. }
  1350. //Trigger the stop of the sortable
  1351. this.instance._mouseStop(event);
  1352. this.instance.options.helper = this.instance.options._helper;
  1353. //If the helper has been the original item, restore properties in the sortable
  1354. if(inst.options.helper === "original") {
  1355. this.instance.currentItem.css({ top: "auto", left: "auto" });
  1356. }
  1357. } else {
  1358. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  1359. this.instance._trigger("deactivate", event, uiSortable);
  1360. }
  1361. });
  1362. },
  1363. drag: function(event, ui) {
  1364. var inst = $(this).data("ui-draggable"), that = this;
  1365. $.each(inst.sortables, function() {
  1366. var innermostIntersecting = false,
  1367. thisSortable = this;
  1368. //Copy over some variables to allow calling the sortable's native _intersectsWith
  1369. this.instance.positionAbs = inst.positionAbs;
  1370. this.instance.helperProportions = inst.helperProportions;
  1371. this.instance.offset.click = inst.offset.click;
  1372. if(this.instance._intersectsWith(this.instance.containerCache)) {
  1373. innermostIntersecting = true;
  1374. $.each(inst.sortables, function () {
  1375. this.instance.positionAbs = inst.positionAbs;
  1376. this.instance.helperProportions = inst.helperProportions;
  1377. this.instance.offset.click = inst.offset.click;
  1378. if (this !== thisSortable &&
  1379. this.instance._intersectsWith(this.instance.containerCache) &&
  1380. $.contains(thisSortable.instance.element[0], this.instance.element[0])
  1381. ) {
  1382. innermostIntersecting = false;
  1383. }
  1384. return innermostIntersecting;
  1385. });
  1386. }
  1387. if(innermostIntersecting) {
  1388. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  1389. if(!this.instance.isOver) {
  1390. this.instance.isOver = 1;
  1391. //Now we fake the start of dragging for the sortable instance,
  1392. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  1393. //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
  1394. this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
  1395. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  1396. this.instance.options.helper = function() { return ui.helper[0]; };
  1397. event.target = this.instance.currentItem[0];
  1398. this.instance._mouseCapture(event, true);
  1399. this.instance._mouseStart(event, true, true);
  1400. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  1401. this.instance.offset.click.top = inst.offset.click.top;
  1402. this.instance.offset.click.left = inst.offset.click.left;
  1403. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  1404. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  1405. inst._trigger("toSortable", event);
  1406. inst.dropped = this.instance.element; //draggable revert needs that
  1407. //hack so receive/update callbacks work (mostly)
  1408. inst.currentItem = inst.element;
  1409. this.instance.fromOutside = inst;
  1410. }
  1411. //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
  1412. if(this.instance.currentItem) {
  1413. this.instance._mouseDrag(event);
  1414. }
  1415. } else {
  1416. //If it doesn't intersect with the sortable, and it intersected before,
  1417. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  1418. if(this.instance.isOver) {
  1419. this.instance.isOver = 0;
  1420. this.instance.cancelHelperRemoval = true;
  1421. //Prevent reverting on this forced stop
  1422. this.instance.options.revert = false;
  1423. // The out event needs to be triggered independently
  1424. this.instance._trigger("out", event, this.instance._uiHash(this.instance));
  1425. this.instance._mouseStop(event, true);
  1426. this.instance.options.helper = this.instance.options._helper;
  1427. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  1428. this.instance.currentItem.remove();
  1429. if(this.instance.placeholder) {
  1430. this.instance.placeholder.remove();
  1431. }
  1432. inst._trigger("fromSortable", event);
  1433. inst.dropped = false; //draggable revert needs that
  1434. }
  1435. }
  1436. });
  1437. }
  1438. });
  1439. $.ui.plugin.add("draggable", "cursor", {
  1440. start: function() {
  1441. var t = $("body"), o = $(this).data("ui-draggable").options;
  1442. if (t.css("cursor")) {
  1443. o._cursor = t.css("cursor");
  1444. }
  1445. t.css("cursor", o.cursor);
  1446. },
  1447. stop: function() {
  1448. var o = $(this).data("ui-draggable").options;
  1449. if (o._cursor) {
  1450. $("body").css("cursor", o._cursor);
  1451. }
  1452. }
  1453. });
  1454. $.ui.plugin.add("draggable", "opacity", {
  1455. start: function(event, ui) {
  1456. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1457. if(t.css("opacity")) {
  1458. o._opacity = t.css("opacity");
  1459. }
  1460. t.css("opacity", o.opacity);
  1461. },
  1462. stop: function(event, ui) {
  1463. var o = $(this).data("ui-draggable").options;
  1464. if(o._opacity) {
  1465. $(ui.helper).css("opacity", o._opacity);
  1466. }
  1467. }
  1468. });
  1469. $.ui.plugin.add("draggable", "scroll", {
  1470. start: function() {
  1471. var i = $(this).data("ui-draggable");
  1472. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1473. i.overflowOffset = i.scrollParent.offset();
  1474. }
  1475. },
  1476. drag: function( event ) {
  1477. var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
  1478. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1479. if(!o.axis || o.axis !== "x") {
  1480. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  1481. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  1482. } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
  1483. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  1484. }
  1485. }
  1486. if(!o.axis || o.axis !== "y") {
  1487. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  1488. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  1489. } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
  1490. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  1491. }
  1492. }
  1493. } else {
  1494. if(!o.axis || o.axis !== "x") {
  1495. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  1496. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  1497. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  1498. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  1499. }
  1500. }
  1501. if(!o.axis || o.axis !== "y") {
  1502. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  1503. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  1504. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  1505. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  1506. }
  1507. }
  1508. }
  1509. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  1510. $.ui.ddmanager.prepareOffsets(i, event);
  1511. }
  1512. }
  1513. });
  1514. $.ui.plugin.add("draggable", "snap", {
  1515. start: function() {
  1516. var i = $(this).data("ui-draggable"),
  1517. o = i.options;
  1518. i.snapElements = [];
  1519. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  1520. var $t = $(this),
  1521. $o = $t.offset();
  1522. if(this !== i.element[0]) {
  1523. i.snapElements.push({
  1524. item: this,
  1525. width: $t.outerWidth(), height: $t.outerHeight(),
  1526. top: $o.top, left: $o.left
  1527. });
  1528. }
  1529. });
  1530. },
  1531. drag: function(event, ui) {
  1532. var ts, bs, ls, rs, l, r, t, b, i, first,
  1533. inst = $(this).data("ui-draggable"),
  1534. o = inst.options,
  1535. d = o.snapTolerance,
  1536. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1537. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1538. for (i = inst.snapElements.length - 1; i >= 0; i--){
  1539. l = inst.snapElements[i].left;
  1540. r = l + inst.snapElements[i].width;
  1541. t = inst.snapElements[i].top;
  1542. b = t + inst.snapElements[i].height;
  1543. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  1544. if(inst.snapElements[i].snapping) {
  1545. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1546. }
  1547. inst.snapElements[i].snapping = false;
  1548. continue;
  1549. }
  1550. if(o.snapMode !== "inner") {
  1551. ts = Math.abs(t - y2) <= d;
  1552. bs = Math.abs(b - y1) <= d;
  1553. ls = Math.abs(l - x2) <= d;
  1554. rs = Math.abs(r - x1) <= d;
  1555. if(ts) {
  1556. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1557. }
  1558. if(bs) {
  1559. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  1560. }
  1561. if(ls) {
  1562. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  1563. }
  1564. if(rs) {
  1565. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  1566. }
  1567. }
  1568. first = (ts || bs || ls || rs);
  1569. if(o.snapMode !== "outer") {
  1570. ts = Math.abs(t - y1) <= d;
  1571. bs = Math.abs(b - y2) <= d;
  1572. ls = Math.abs(l - x1) <= d;
  1573. rs = Math.abs(r - x2) <= d;
  1574. if(ts) {
  1575. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  1576. }
  1577. if(bs) {
  1578. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1579. }
  1580. if(ls) {
  1581. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  1582. }
  1583. if(rs) {
  1584. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  1585. }
  1586. }
  1587. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  1588. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1589. }
  1590. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  1591. }
  1592. }
  1593. });
  1594. $.ui.plugin.add("draggable", "stack", {
  1595. start: function() {
  1596. var min,
  1597. o = this.data("ui-draggable").options,
  1598. group = $.makeArray($(o.stack)).sort(function(a,b) {
  1599. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  1600. });
  1601. if (!group.length) { return; }
  1602. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  1603. $(group).each(function(i) {
  1604. $(this).css("zIndex", min + i);
  1605. });
  1606. this.css("zIndex", (min + group.length));
  1607. }
  1608. });
  1609. $.ui.plugin.add("draggable", "zIndex", {
  1610. start: function(event, ui) {
  1611. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1612. if(t.css("zIndex")) {
  1613. o._zIndex = t.css("zIndex");
  1614. }
  1615. t.css("zIndex", o.zIndex);
  1616. },
  1617. stop: function(event, ui) {
  1618. var o = $(this).data("ui-draggable").options;
  1619. if(o._zIndex) {
  1620. $(ui.helper).css("zIndex", o._zIndex);
  1621. }
  1622. }
  1623. });
  1624. })(jQuery);
  1625. (function( $, undefined ) {
  1626. function isOverAxis( x, reference, size ) {
  1627. return ( x > reference ) && ( x < ( reference + size ) );
  1628. }
  1629. $.widget("ui.droppable", {
  1630. version: "1.10.4",
  1631. widgetEventPrefix: "drop",
  1632. options: {
  1633. accept: "*",
  1634. activeClass: false,
  1635. addClasses: true,
  1636. greedy: false,
  1637. hoverClass: false,
  1638. scope: "default",
  1639. tolerance: "intersect",
  1640. // callbacks
  1641. activate: null,
  1642. deactivate: null,
  1643. drop: null,
  1644. out: null,
  1645. over: null
  1646. },
  1647. _create: function() {
  1648. var proportions,
  1649. o = this.options,
  1650. accept = o.accept;
  1651. this.isover = false;
  1652. this.isout = true;
  1653. this.accept = $.isFunction(accept) ? accept : function(d) {
  1654. return d.is(accept);
  1655. };
  1656. this.proportions = function( /* valueToWrite */ ) {
  1657. if ( arguments.length ) {
  1658. // Store the droppable's proportions
  1659. proportions = arguments[ 0 ];
  1660. } else {
  1661. // Retrieve or derive the droppable's proportions
  1662. return proportions ?
  1663. proportions :
  1664. proportions = {
  1665. width: this.element[ 0 ].offsetWidth,
  1666. height: this.element[ 0 ].offsetHeight
  1667. };
  1668. }
  1669. };
  1670. // Add the reference and positions to the manager
  1671. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  1672. $.ui.ddmanager.droppables[o.scope].push(this);
  1673. (o.addClasses && this.element.addClass("ui-droppable"));
  1674. },
  1675. _destroy: function() {
  1676. var i = 0,
  1677. drop = $.ui.ddmanager.droppables[this.options.scope];
  1678. for ( ; i < drop.length; i++ ) {
  1679. if ( drop[i] === this ) {
  1680. drop.splice(i, 1);
  1681. }
  1682. }
  1683. this.element.removeClass("ui-droppable ui-droppable-disabled");
  1684. },
  1685. _setOption: function(key, value) {
  1686. if(key === "accept") {
  1687. this.accept = $.isFunction(value) ? value : function(d) {
  1688. return d.is(value);
  1689. };
  1690. }
  1691. $.Widget.prototype._setOption.apply(this, arguments);
  1692. },
  1693. _activate: function(event) {
  1694. var draggable = $.ui.ddmanager.current;
  1695. if(this.options.activeClass) {
  1696. this.element.addClass(this.options.activeClass);
  1697. }
  1698. if(draggable){
  1699. this._trigger("activate", event, this.ui(draggable));
  1700. }
  1701. },
  1702. _deactivate: function(event) {
  1703. var draggable = $.ui.ddmanager.current;
  1704. if(this.options.activeClass) {
  1705. this.element.removeClass(this.options.activeClass);
  1706. }
  1707. if(draggable){
  1708. this._trigger("deactivate", event, this.ui(draggable));
  1709. }
  1710. },
  1711. _over: function(event) {
  1712. var draggable = $.ui.ddmanager.current;
  1713. // Bail if draggable and droppable are same element
  1714. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1715. return;
  1716. }
  1717. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1718. if(this.options.hoverClass) {
  1719. this.element.addClass(this.options.hoverClass);
  1720. }
  1721. this._trigger("over", event, this.ui(draggable));
  1722. }
  1723. },
  1724. _out: function(event) {
  1725. var draggable = $.ui.ddmanager.current;
  1726. // Bail if draggable and droppable are same element
  1727. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1728. return;
  1729. }
  1730. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1731. if(this.options.hoverClass) {
  1732. this.element.removeClass(this.options.hoverClass);
  1733. }
  1734. this._trigger("out", event, this.ui(draggable));
  1735. }
  1736. },
  1737. _drop: function(event,custom) {
  1738. var draggable = custom || $.ui.ddmanager.current,
  1739. childrenIntersection = false;
  1740. // Bail if draggable and droppable are same element
  1741. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1742. return false;
  1743. }
  1744. this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
  1745. var inst = $.data(this, "ui-droppable");
  1746. if(
  1747. inst.options.greedy &&
  1748. !inst.options.disabled &&
  1749. inst.options.scope === draggable.options.scope &&
  1750. inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) &&
  1751. $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  1752. ) { childrenIntersection = true; return false; }
  1753. });
  1754. if(childrenIntersection) {
  1755. return false;
  1756. }
  1757. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1758. if(this.options.activeClass) {
  1759. this.element.removeClass(this.options.activeClass);
  1760. }
  1761. if(this.options.hoverClass) {
  1762. this.element.removeClass(this.options.hoverClass);
  1763. }
  1764. this._trigger("drop", event, this.ui(draggable));
  1765. return this.element;
  1766. }
  1767. return false;
  1768. },
  1769. ui: function(c) {
  1770. return {
  1771. draggable: (c.currentItem || c.element),
  1772. helper: c.helper,
  1773. position: c.position,
  1774. offset: c.positionAbs
  1775. };
  1776. }
  1777. });
  1778. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  1779. if (!droppable.offset) {
  1780. return false;
  1781. }
  1782. var draggableLeft, draggableTop,
  1783. x1 = (draggable.positionAbs || draggable.position.absolute).left,
  1784. y1 = (draggable.positionAbs || draggable.position.absolute).top,
  1785. x2 = x1 + draggable.helperProportions.width,
  1786. y2 = y1 + draggable.helperProportions.height,
  1787. l = droppable.offset.left,
  1788. t = droppable.offset.top,
  1789. r = l + droppable.proportions().width,
  1790. b = t + droppable.proportions().height;
  1791. switch (toleranceMode) {
  1792. case "fit":
  1793. return (l <= x1 && x2 <= r && t <= y1 && y2 <= b);
  1794. case "intersect":
  1795. return (l < x1 + (draggable.helperProportions.width / 2) && // Right Half
  1796. x2 - (draggable.helperProportions.width / 2) < r && // Left Half
  1797. t < y1 + (draggable.helperProportions.height / 2) && // Bottom Half
  1798. y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  1799. case "pointer":
  1800. draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
  1801. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
  1802. return isOverAxis( draggableTop, t, droppable.proportions().height ) && isOverAxis( draggableLeft, l, droppable.proportions().width );
  1803. case "touch":
  1804. return (
  1805. (y1 >= t && y1 <= b) || // Top edge touching
  1806. (y2 >= t && y2 <= b) || // Bottom edge touching
  1807. (y1 < t && y2 > b) // Surrounded vertically
  1808. ) && (
  1809. (x1 >= l && x1 <= r) || // Left edge touching
  1810. (x2 >= l && x2 <= r) || // Right edge touching
  1811. (x1 < l && x2 > r) // Surrounded horizontally
  1812. );
  1813. default:
  1814. return false;
  1815. }
  1816. };
  1817. /*
  1818. This manager tracks offsets of draggables and droppables
  1819. */
  1820. $.ui.ddmanager = {
  1821. current: null,
  1822. droppables: { "default": [] },
  1823. prepareOffsets: function(t, event) {
  1824. var i, j,
  1825. m = $.ui.ddmanager.droppables[t.options.scope] || [],
  1826. type = event ? event.type : null, // workaround for #2317
  1827. list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
  1828. droppablesLoop: for (i = 0; i < m.length; i++) {
  1829. //No disabled and non-accepted
  1830. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) {
  1831. continue;
  1832. }
  1833. // Filter out elements in the current dragged item
  1834. for (j=0; j < list.length; j++) {
  1835. if(list[j] === m[i].element[0]) {
  1836. m[i].proportions().height = 0;
  1837. continue droppablesLoop;
  1838. }
  1839. }
  1840. m[i].visible = m[i].element.css("display") !== "none";
  1841. if(!m[i].visible) {
  1842. continue;
  1843. }
  1844. //Activate the droppable if used directly from draggables
  1845. if(type === "mousedown") {
  1846. m[i]._activate.call(m[i], event);
  1847. }
  1848. m[ i ].offset = m[ i ].element.offset();
  1849. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  1850. }
  1851. },
  1852. drop: function(draggable, event) {
  1853. var dropped = false;
  1854. // Create a copy of the droppables in case the list changes during the drop (#9116)
  1855. $.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function() {
  1856. if(!this.options) {
  1857. return;
  1858. }
  1859. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) {
  1860. dropped = this._drop.call(this, event) || dropped;
  1861. }
  1862. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1863. this.isout = true;
  1864. this.isover = false;
  1865. this._deactivate.call(this, event);
  1866. }
  1867. });
  1868. return dropped;
  1869. },
  1870. dragStart: function( draggable, event ) {
  1871. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  1872. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  1873. if( !draggable.options.refreshPositions ) {
  1874. $.ui.ddmanager.prepareOffsets( draggable, event );
  1875. }
  1876. });
  1877. },
  1878. drag: function(draggable, event) {
  1879. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  1880. if(draggable.options.refreshPositions) {
  1881. $.ui.ddmanager.prepareOffsets(draggable, event);
  1882. }
  1883. //Run through all droppables and check their positions based on specific tolerance options
  1884. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  1885. if(this.options.disabled || this.greedyChild || !this.visible) {
  1886. return;
  1887. }
  1888. var parentInstance, scope, parent,
  1889. intersects = $.ui.intersect(draggable, this, this.options.tolerance),
  1890. c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
  1891. if(!c) {
  1892. return;
  1893. }
  1894. if (this.options.greedy) {
  1895. // find droppable parents with same scope
  1896. scope = this.options.scope;
  1897. parent = this.element.parents(":data(ui-droppable)").filter(function () {
  1898. return $.data(this, "ui-droppable").options.scope === scope;
  1899. });
  1900. if (parent.length) {
  1901. parentInstance = $.data(parent[0], "ui-droppable");
  1902. parentInstance.greedyChild = (c === "isover");
  1903. }
  1904. }
  1905. // we just moved into a greedy child
  1906. if (parentInstance && c === "isover") {
  1907. parentInstance.isover = false;
  1908. parentInstance.isout = true;
  1909. parentInstance._out.call(parentInstance, event);
  1910. }
  1911. this[c] = true;
  1912. this[c === "isout" ? "isover" : "isout"] = false;
  1913. this[c === "isover" ? "_over" : "_out"].call(this, event);
  1914. // we just moved out of a greedy child
  1915. if (parentInstance && c === "isout") {
  1916. parentInstance.isout = false;
  1917. parentInstance.isover = true;
  1918. parentInstance._over.call(parentInstance, event);
  1919. }
  1920. });
  1921. },
  1922. dragStop: function( draggable, event ) {
  1923. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  1924. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  1925. if( !draggable.options.refreshPositions ) {
  1926. $.ui.ddmanager.prepareOffsets( draggable, event );
  1927. }
  1928. }
  1929. };
  1930. })(jQuery);
  1931. (function( $, undefined ) {
  1932. function num(v) {
  1933. return parseInt(v, 10) || 0;
  1934. }
  1935. function isNumber(value) {
  1936. return !isNaN(parseInt(value, 10));
  1937. }
  1938. $.widget("ui.resizable", $.ui.mouse, {
  1939. version: "1.10.4",
  1940. widgetEventPrefix: "resize",
  1941. options: {
  1942. alsoResize: false,
  1943. animate: false,
  1944. animateDuration: "slow",
  1945. animateEasing: "swing",
  1946. aspectRatio: false,
  1947. autoHide: false,
  1948. containment: false,
  1949. ghost: false,
  1950. grid: false,
  1951. handles: "e,s,se",
  1952. helper: false,
  1953. maxHeight: null,
  1954. maxWidth: null,
  1955. minHeight: 10,
  1956. minWidth: 10,
  1957. // See #7960
  1958. zIndex: 90,
  1959. // callbacks
  1960. resize: null,
  1961. start: null,
  1962. stop: null
  1963. },
  1964. _create: function() {
  1965. var n, i, handle, axis, hname,
  1966. that = this,
  1967. o = this.options;
  1968. this.element.addClass("ui-resizable");
  1969. $.extend(this, {
  1970. _aspectRatio: !!(o.aspectRatio),
  1971. aspectRatio: o.aspectRatio,
  1972. originalElement: this.element,
  1973. _proportionallyResizeElements: [],
  1974. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  1975. });
  1976. //Wrap the element if it cannot hold child nodes
  1977. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  1978. //Create a wrapper element and set the wrapper to the new current internal element
  1979. this.element.wrap(
  1980. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  1981. position: this.element.css("position"),
  1982. width: this.element.outerWidth(),
  1983. height: this.element.outerHeight(),
  1984. top: this.element.css("top"),
  1985. left: this.element.css("left")
  1986. })
  1987. );
  1988. //Overwrite the original this.element
  1989. this.element = this.element.parent().data(
  1990. "ui-resizable", this.element.data("ui-resizable")
  1991. );
  1992. this.elementIsWrapper = true;
  1993. //Move margins to the wrapper
  1994. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  1995. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  1996. //Prevent Safari textarea resize
  1997. this.originalResizeStyle = this.originalElement.css("resize");
  1998. this.originalElement.css("resize", "none");
  1999. //Push the actual element to our proportionallyResize internal array
  2000. this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
  2001. // avoid IE jump (hard set the margin)
  2002. this.originalElement.css({ margin: this.originalElement.css("margin") });
  2003. // fix handlers offset
  2004. this._proportionallyResize();
  2005. }
  2006. 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" });
  2007. if(this.handles.constructor === String) {
  2008. if ( this.handles === "all") {
  2009. this.handles = "n,e,s,w,se,sw,ne,nw";
  2010. }
  2011. n = this.handles.split(",");
  2012. this.handles = {};
  2013. for(i = 0; i < n.length; i++) {
  2014. handle = $.trim(n[i]);
  2015. hname = "ui-resizable-"+handle;
  2016. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  2017. // Apply zIndex to all handles - see #7960
  2018. axis.css({ zIndex: o.zIndex });
  2019. //TODO : What's going on here?
  2020. if ("se" === handle) {
  2021. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  2022. }
  2023. //Insert into internal handles object and append to element
  2024. this.handles[handle] = ".ui-resizable-"+handle;
  2025. this.element.append(axis);
  2026. }
  2027. }
  2028. this._renderAxis = function(target) {
  2029. var i, axis, padPos, padWrapper;
  2030. target = target || this.element;
  2031. for(i in this.handles) {
  2032. if(this.handles[i].constructor === String) {
  2033. this.handles[i] = $(this.handles[i], this.element).show();
  2034. }
  2035. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  2036. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  2037. axis = $(this.handles[i], this.element);
  2038. //Checking the correct pad and border
  2039. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2040. //The padding type i have to apply...
  2041. padPos = [ "padding",
  2042. /ne|nw|n/.test(i) ? "Top" :
  2043. /se|sw|s/.test(i) ? "Bottom" :
  2044. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2045. target.css(padPos, padWrapper);
  2046. this._proportionallyResize();
  2047. }
  2048. //TODO: What's that good for? There's not anything to be executed left
  2049. if(!$(this.handles[i]).length) {
  2050. continue;
  2051. }
  2052. }
  2053. };
  2054. //TODO: make renderAxis a prototype function
  2055. this._renderAxis(this.element);
  2056. this._handles = $(".ui-resizable-handle", this.element)
  2057. .disableSelection();
  2058. //Matching axis name
  2059. this._handles.mouseover(function() {
  2060. if (!that.resizing) {
  2061. if (this.className) {
  2062. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2063. }
  2064. //Axis, default = se
  2065. that.axis = axis && axis[1] ? axis[1] : "se";
  2066. }
  2067. });
  2068. //If we want to auto hide the elements
  2069. if (o.autoHide) {
  2070. this._handles.hide();
  2071. $(this.element)
  2072. .addClass("ui-resizable-autohide")
  2073. .mouseenter(function() {
  2074. if (o.disabled) {
  2075. return;
  2076. }
  2077. $(this).removeClass("ui-resizable-autohide");
  2078. that._handles.show();
  2079. })
  2080. .mouseleave(function(){
  2081. if (o.disabled) {
  2082. return;
  2083. }
  2084. if (!that.resizing) {
  2085. $(this).addClass("ui-resizable-autohide");
  2086. that._handles.hide();
  2087. }
  2088. });
  2089. }
  2090. //Initialize the mouse interaction
  2091. this._mouseInit();
  2092. },
  2093. _destroy: function() {
  2094. this._mouseDestroy();
  2095. var wrapper,
  2096. _destroy = function(exp) {
  2097. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2098. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
  2099. };
  2100. //TODO: Unwrap at same DOM position
  2101. if (this.elementIsWrapper) {
  2102. _destroy(this.element);
  2103. wrapper = this.element;
  2104. this.originalElement.css({
  2105. position: wrapper.css("position"),
  2106. width: wrapper.outerWidth(),
  2107. height: wrapper.outerHeight(),
  2108. top: wrapper.css("top"),
  2109. left: wrapper.css("left")
  2110. }).insertAfter( wrapper );
  2111. wrapper.remove();
  2112. }
  2113. this.originalElement.css("resize", this.originalResizeStyle);
  2114. _destroy(this.originalElement);
  2115. return this;
  2116. },
  2117. _mouseCapture: function(event) {
  2118. var i, handle,
  2119. capture = false;
  2120. for (i in this.handles) {
  2121. handle = $(this.handles[i])[0];
  2122. if (handle === event.target || $.contains(handle, event.target)) {
  2123. capture = true;
  2124. }
  2125. }
  2126. return !this.options.disabled && capture;
  2127. },
  2128. _mouseStart: function(event) {
  2129. var curleft, curtop, cursor,
  2130. o = this.options,
  2131. iniPos = this.element.position(),
  2132. el = this.element;
  2133. this.resizing = true;
  2134. // bugfix for http://dev.jquery.com/ticket/1749
  2135. if ( (/absolute/).test( el.css("position") ) ) {
  2136. el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
  2137. } else if (el.is(".ui-draggable")) {
  2138. el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
  2139. }
  2140. this._renderProxy();
  2141. curleft = num(this.helper.css("left"));
  2142. curtop = num(this.helper.css("top"));
  2143. if (o.containment) {
  2144. curleft += $(o.containment).scrollLeft() || 0;
  2145. curtop += $(o.containment).scrollTop() || 0;
  2146. }
  2147. //Store needed variables
  2148. this.offset = this.helper.offset();
  2149. this.position = { left: curleft, top: curtop };
  2150. this.size = this._helper ? { width: this.helper.width(), height: this.helper.height() } : { width: el.width(), height: el.height() };
  2151. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2152. this.originalPosition = { left: curleft, top: curtop };
  2153. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  2154. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2155. //Aspect Ratio
  2156. this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  2157. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2158. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2159. el.addClass("ui-resizable-resizing");
  2160. this._propagate("start", event);
  2161. return true;
  2162. },
  2163. _mouseDrag: function(event) {
  2164. //Increase performance, avoid regex
  2165. var data,
  2166. el = this.helper, props = {},
  2167. smp = this.originalMousePosition,
  2168. a = this.axis,
  2169. prevTop = this.position.top,
  2170. prevLeft = this.position.left,
  2171. prevWidth = this.size.width,
  2172. prevHeight = this.size.height,
  2173. dx = (event.pageX-smp.left)||0,
  2174. dy = (event.pageY-smp.top)||0,
  2175. trigger = this._change[a];
  2176. if (!trigger) {
  2177. return false;
  2178. }
  2179. // Calculate the attrs that will be change
  2180. data = trigger.apply(this, [event, dx, dy]);
  2181. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  2182. this._updateVirtualBoundaries(event.shiftKey);
  2183. if (this._aspectRatio || event.shiftKey) {
  2184. data = this._updateRatio(data, event);
  2185. }
  2186. data = this._respectSize(data, event);
  2187. this._updateCache(data);
  2188. // plugins callbacks need to be called first
  2189. this._propagate("resize", event);
  2190. if (this.position.top !== prevTop) {
  2191. props.top = this.position.top + "px";
  2192. }
  2193. if (this.position.left !== prevLeft) {
  2194. props.left = this.position.left + "px";
  2195. }
  2196. if (this.size.width !== prevWidth) {
  2197. props.width = this.size.width + "px";
  2198. }
  2199. if (this.size.height !== prevHeight) {
  2200. props.height = this.size.height + "px";
  2201. }
  2202. el.css(props);
  2203. if (!this._helper && this._proportionallyResizeElements.length) {
  2204. this._proportionallyResize();
  2205. }
  2206. // Call the user callback if the element was resized
  2207. if ( ! $.isEmptyObject(props) ) {
  2208. this._trigger("resize", event, this.ui());
  2209. }
  2210. return false;
  2211. },
  2212. _mouseStop: function(event) {
  2213. this.resizing = false;
  2214. var pr, ista, soffseth, soffsetw, s, left, top,
  2215. o = this.options, that = this;
  2216. if(this._helper) {
  2217. pr = this._proportionallyResizeElements;
  2218. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2219. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
  2220. soffsetw = ista ? 0 : that.sizeDiff.width;
  2221. s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
  2222. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
  2223. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2224. if (!o.animate) {
  2225. this.element.css($.extend(s, { top: top, left: left }));
  2226. }
  2227. that.helper.height(that.size.height);
  2228. that.helper.width(that.size.width);
  2229. if (this._helper && !o.animate) {
  2230. this._proportionallyResize();
  2231. }
  2232. }
  2233. $("body").css("cursor", "auto");
  2234. this.element.removeClass("ui-resizable-resizing");
  2235. this._propagate("stop", event);
  2236. if (this._helper) {
  2237. this.helper.remove();
  2238. }
  2239. return false;
  2240. },
  2241. _updateVirtualBoundaries: function(forceAspectRatio) {
  2242. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2243. o = this.options;
  2244. b = {
  2245. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  2246. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2247. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  2248. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2249. };
  2250. if(this._aspectRatio || forceAspectRatio) {
  2251. // We want to create an enclosing box whose aspect ration is the requested one
  2252. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  2253. pMinWidth = b.minHeight * this.aspectRatio;
  2254. pMinHeight = b.minWidth / this.aspectRatio;
  2255. pMaxWidth = b.maxHeight * this.aspectRatio;
  2256. pMaxHeight = b.maxWidth / this.aspectRatio;
  2257. if(pMinWidth > b.minWidth) {
  2258. b.minWidth = pMinWidth;
  2259. }
  2260. if(pMinHeight > b.minHeight) {
  2261. b.minHeight = pMinHeight;
  2262. }
  2263. if(pMaxWidth < b.maxWidth) {
  2264. b.maxWidth = pMaxWidth;
  2265. }
  2266. if(pMaxHeight < b.maxHeight) {
  2267. b.maxHeight = pMaxHeight;
  2268. }
  2269. }
  2270. this._vBoundaries = b;
  2271. },
  2272. _updateCache: function(data) {
  2273. this.offset = this.helper.offset();
  2274. if (isNumber(data.left)) {
  2275. this.position.left = data.left;
  2276. }
  2277. if (isNumber(data.top)) {
  2278. this.position.top = data.top;
  2279. }
  2280. if (isNumber(data.height)) {
  2281. this.size.height = data.height;
  2282. }
  2283. if (isNumber(data.width)) {
  2284. this.size.width = data.width;
  2285. }
  2286. },
  2287. _updateRatio: function( data ) {
  2288. var cpos = this.position,
  2289. csize = this.size,
  2290. a = this.axis;
  2291. if (isNumber(data.height)) {
  2292. data.width = (data.height * this.aspectRatio);
  2293. } else if (isNumber(data.width)) {
  2294. data.height = (data.width / this.aspectRatio);
  2295. }
  2296. if (a === "sw") {
  2297. data.left = cpos.left + (csize.width - data.width);
  2298. data.top = null;
  2299. }
  2300. if (a === "nw") {
  2301. data.top = cpos.top + (csize.height - data.height);
  2302. data.left = cpos.left + (csize.width - data.width);
  2303. }
  2304. return data;
  2305. },
  2306. _respectSize: function( data ) {
  2307. var o = this._vBoundaries,
  2308. a = this.axis,
  2309. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  2310. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  2311. dw = this.originalPosition.left + this.originalSize.width,
  2312. dh = this.position.top + this.size.height,
  2313. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  2314. if (isminw) {
  2315. data.width = o.minWidth;
  2316. }
  2317. if (isminh) {
  2318. data.height = o.minHeight;
  2319. }
  2320. if (ismaxw) {
  2321. data.width = o.maxWidth;
  2322. }
  2323. if (ismaxh) {
  2324. data.height = o.maxHeight;
  2325. }
  2326. if (isminw && cw) {
  2327. data.left = dw - o.minWidth;
  2328. }
  2329. if (ismaxw && cw) {
  2330. data.left = dw - o.maxWidth;
  2331. }
  2332. if (isminh && ch) {
  2333. data.top = dh - o.minHeight;
  2334. }
  2335. if (ismaxh && ch) {
  2336. data.top = dh - o.maxHeight;
  2337. }
  2338. // fixing jump error on top/left - bug #2330
  2339. if (!data.width && !data.height && !data.left && data.top) {
  2340. data.top = null;
  2341. } else if (!data.width && !data.height && !data.top && data.left) {
  2342. data.left = null;
  2343. }
  2344. return data;
  2345. },
  2346. _proportionallyResize: function() {
  2347. if (!this._proportionallyResizeElements.length) {
  2348. return;
  2349. }
  2350. var i, j, borders, paddings, prel,
  2351. element = this.helper || this.element;
  2352. for ( i=0; i < this._proportionallyResizeElements.length; i++) {
  2353. prel = this._proportionallyResizeElements[i];
  2354. if (!this.borderDif) {
  2355. this.borderDif = [];
  2356. borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
  2357. paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
  2358. for ( j = 0; j < borders.length; j++ ) {
  2359. this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
  2360. }
  2361. }
  2362. prel.css({
  2363. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  2364. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  2365. });
  2366. }
  2367. },
  2368. _renderProxy: function() {
  2369. var el = this.element, o = this.options;
  2370. this.elementOffset = el.offset();
  2371. if(this._helper) {
  2372. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  2373. this.helper.addClass(this._helper).css({
  2374. width: this.element.outerWidth() - 1,
  2375. height: this.element.outerHeight() - 1,
  2376. position: "absolute",
  2377. left: this.elementOffset.left +"px",
  2378. top: this.elementOffset.top +"px",
  2379. zIndex: ++o.zIndex //TODO: Don't modify option
  2380. });
  2381. this.helper
  2382. .appendTo("body")
  2383. .disableSelection();
  2384. } else {
  2385. this.helper = this.element;
  2386. }
  2387. },
  2388. _change: {
  2389. e: function(event, dx) {
  2390. return { width: this.originalSize.width + dx };
  2391. },
  2392. w: function(event, dx) {
  2393. var cs = this.originalSize, sp = this.originalPosition;
  2394. return { left: sp.left + dx, width: cs.width - dx };
  2395. },
  2396. n: function(event, dx, dy) {
  2397. var cs = this.originalSize, sp = this.originalPosition;
  2398. return { top: sp.top + dy, height: cs.height - dy };
  2399. },
  2400. s: function(event, dx, dy) {
  2401. return { height: this.originalSize.height + dy };
  2402. },
  2403. se: function(event, dx, dy) {
  2404. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2405. },
  2406. sw: function(event, dx, dy) {
  2407. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2408. },
  2409. ne: function(event, dx, dy) {
  2410. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2411. },
  2412. nw: function(event, dx, dy) {
  2413. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2414. }
  2415. },
  2416. _propagate: function(n, event) {
  2417. $.ui.plugin.call(this, n, [event, this.ui()]);
  2418. (n !== "resize" && this._trigger(n, event, this.ui()));
  2419. },
  2420. plugins: {},
  2421. ui: function() {
  2422. return {
  2423. originalElement: this.originalElement,
  2424. element: this.element,
  2425. helper: this.helper,
  2426. position: this.position,
  2427. size: this.size,
  2428. originalSize: this.originalSize,
  2429. originalPosition: this.originalPosition
  2430. };
  2431. }
  2432. });
  2433. /*
  2434. * Resizable Extensions
  2435. */
  2436. $.ui.plugin.add("resizable", "animate", {
  2437. stop: function( event ) {
  2438. var that = $(this).data("ui-resizable"),
  2439. o = that.options,
  2440. pr = that._proportionallyResizeElements,
  2441. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  2442. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  2443. soffsetw = ista ? 0 : that.sizeDiff.width,
  2444. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  2445. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
  2446. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2447. that.element.animate(
  2448. $.extend(style, top && left ? { top: top, left: left } : {}), {
  2449. duration: o.animateDuration,
  2450. easing: o.animateEasing,
  2451. step: function() {
  2452. var data = {
  2453. width: parseInt(that.element.css("width"), 10),
  2454. height: parseInt(that.element.css("height"), 10),
  2455. top: parseInt(that.element.css("top"), 10),
  2456. left: parseInt(that.element.css("left"), 10)
  2457. };
  2458. if (pr && pr.length) {
  2459. $(pr[0]).css({ width: data.width, height: data.height });
  2460. }
  2461. // propagating resize, and updating values for each animation step
  2462. that._updateCache(data);
  2463. that._propagate("resize", event);
  2464. }
  2465. }
  2466. );
  2467. }
  2468. });
  2469. $.ui.plugin.add("resizable", "containment", {
  2470. start: function() {
  2471. var element, p, co, ch, cw, width, height,
  2472. that = $(this).data("ui-resizable"),
  2473. o = that.options,
  2474. el = that.element,
  2475. oc = o.containment,
  2476. ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  2477. if (!ce) {
  2478. return;
  2479. }
  2480. that.containerElement = $(ce);
  2481. if (/document/.test(oc) || oc === document) {
  2482. that.containerOffset = { left: 0, top: 0 };
  2483. that.containerPosition = { left: 0, top: 0 };
  2484. that.parentData = {
  2485. element: $(document), left: 0, top: 0,
  2486. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  2487. };
  2488. }
  2489. // i'm a node, so compute top, left, right, bottom
  2490. else {
  2491. element = $(ce);
  2492. p = [];
  2493. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  2494. that.containerOffset = element.offset();
  2495. that.containerPosition = element.position();
  2496. that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  2497. co = that.containerOffset;
  2498. ch = that.containerSize.height;
  2499. cw = that.containerSize.width;
  2500. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
  2501. height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  2502. that.parentData = {
  2503. element: ce, left: co.left, top: co.top, width: width, height: height
  2504. };
  2505. }
  2506. },
  2507. resize: function( event ) {
  2508. var woset, hoset, isParent, isOffsetRelative,
  2509. that = $(this).data("ui-resizable"),
  2510. o = that.options,
  2511. co = that.containerOffset, cp = that.position,
  2512. pRatio = that._aspectRatio || event.shiftKey,
  2513. cop = { top:0, left:0 }, ce = that.containerElement;
  2514. if (ce[0] !== document && (/static/).test(ce.css("position"))) {
  2515. cop = co;
  2516. }
  2517. if (cp.left < (that._helper ? co.left : 0)) {
  2518. that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
  2519. if (pRatio) {
  2520. that.size.height = that.size.width / that.aspectRatio;
  2521. }
  2522. that.position.left = o.helper ? co.left : 0;
  2523. }
  2524. if (cp.top < (that._helper ? co.top : 0)) {
  2525. that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
  2526. if (pRatio) {
  2527. that.size.width = that.size.height * that.aspectRatio;
  2528. }
  2529. that.position.top = that._helper ? co.top : 0;
  2530. }
  2531. that.offset.left = that.parentData.left+that.position.left;
  2532. that.offset.top = that.parentData.top+that.position.top;
  2533. woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width );
  2534. hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
  2535. isParent = that.containerElement.get(0) === that.element.parent().get(0);
  2536. isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
  2537. if ( isParent && isOffsetRelative ) {
  2538. woset -= Math.abs( that.parentData.left );
  2539. }
  2540. if (woset + that.size.width >= that.parentData.width) {
  2541. that.size.width = that.parentData.width - woset;
  2542. if (pRatio) {
  2543. that.size.height = that.size.width / that.aspectRatio;
  2544. }
  2545. }
  2546. if (hoset + that.size.height >= that.parentData.height) {
  2547. that.size.height = that.parentData.height - hoset;
  2548. if (pRatio) {
  2549. that.size.width = that.size.height * that.aspectRatio;
  2550. }
  2551. }
  2552. },
  2553. stop: function(){
  2554. var that = $(this).data("ui-resizable"),
  2555. o = that.options,
  2556. co = that.containerOffset,
  2557. cop = that.containerPosition,
  2558. ce = that.containerElement,
  2559. helper = $(that.helper),
  2560. ho = helper.offset(),
  2561. w = helper.outerWidth() - that.sizeDiff.width,
  2562. h = helper.outerHeight() - that.sizeDiff.height;
  2563. if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
  2564. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2565. }
  2566. if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
  2567. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2568. }
  2569. }
  2570. });
  2571. $.ui.plugin.add("resizable", "alsoResize", {
  2572. start: function () {
  2573. var that = $(this).data("ui-resizable"),
  2574. o = that.options,
  2575. _store = function (exp) {
  2576. $(exp).each(function() {
  2577. var el = $(this);
  2578. el.data("ui-resizable-alsoresize", {
  2579. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  2580. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  2581. });
  2582. });
  2583. };
  2584. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  2585. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  2586. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  2587. }else{
  2588. _store(o.alsoResize);
  2589. }
  2590. },
  2591. resize: function (event, ui) {
  2592. var that = $(this).data("ui-resizable"),
  2593. o = that.options,
  2594. os = that.originalSize,
  2595. op = that.originalPosition,
  2596. delta = {
  2597. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  2598. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  2599. },
  2600. _alsoResize = function (exp, c) {
  2601. $(exp).each(function() {
  2602. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  2603. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
  2604. $.each(css, function (i, prop) {
  2605. var sum = (start[prop]||0) + (delta[prop]||0);
  2606. if (sum && sum >= 0) {
  2607. style[prop] = sum || null;
  2608. }
  2609. });
  2610. el.css(style);
  2611. });
  2612. };
  2613. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  2614. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  2615. }else{
  2616. _alsoResize(o.alsoResize);
  2617. }
  2618. },
  2619. stop: function () {
  2620. $(this).removeData("resizable-alsoresize");
  2621. }
  2622. });
  2623. $.ui.plugin.add("resizable", "ghost", {
  2624. start: function() {
  2625. var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
  2626. that.ghost = that.originalElement.clone();
  2627. that.ghost
  2628. .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  2629. .addClass("ui-resizable-ghost")
  2630. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  2631. that.ghost.appendTo(that.helper);
  2632. },
  2633. resize: function(){
  2634. var that = $(this).data("ui-resizable");
  2635. if (that.ghost) {
  2636. that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
  2637. }
  2638. },
  2639. stop: function() {
  2640. var that = $(this).data("ui-resizable");
  2641. if (that.ghost && that.helper) {
  2642. that.helper.get(0).removeChild(that.ghost.get(0));
  2643. }
  2644. }
  2645. });
  2646. $.ui.plugin.add("resizable", "grid", {
  2647. resize: function() {
  2648. var that = $(this).data("ui-resizable"),
  2649. o = that.options,
  2650. cs = that.size,
  2651. os = that.originalSize,
  2652. op = that.originalPosition,
  2653. a = that.axis,
  2654. grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
  2655. gridX = (grid[0]||1),
  2656. gridY = (grid[1]||1),
  2657. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  2658. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  2659. newWidth = os.width + ox,
  2660. newHeight = os.height + oy,
  2661. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  2662. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  2663. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  2664. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  2665. o.grid = grid;
  2666. if (isMinWidth) {
  2667. newWidth = newWidth + gridX;
  2668. }
  2669. if (isMinHeight) {
  2670. newHeight = newHeight + gridY;
  2671. }
  2672. if (isMaxWidth) {
  2673. newWidth = newWidth - gridX;
  2674. }
  2675. if (isMaxHeight) {
  2676. newHeight = newHeight - gridY;
  2677. }
  2678. if (/^(se|s|e)$/.test(a)) {
  2679. that.size.width = newWidth;
  2680. that.size.height = newHeight;
  2681. } else if (/^(ne)$/.test(a)) {
  2682. that.size.width = newWidth;
  2683. that.size.height = newHeight;
  2684. that.position.top = op.top - oy;
  2685. } else if (/^(sw)$/.test(a)) {
  2686. that.size.width = newWidth;
  2687. that.size.height = newHeight;
  2688. that.position.left = op.left - ox;
  2689. } else {
  2690. if ( newHeight - gridY > 0 ) {
  2691. that.size.height = newHeight;
  2692. that.position.top = op.top - oy;
  2693. } else {
  2694. that.size.height = gridY;
  2695. that.position.top = op.top + os.height - gridY;
  2696. }
  2697. if ( newWidth - gridX > 0 ) {
  2698. that.size.width = newWidth;
  2699. that.position.left = op.left - ox;
  2700. } else {
  2701. that.size.width = gridX;
  2702. that.position.left = op.left + os.width - gridX;
  2703. }
  2704. }
  2705. }
  2706. });
  2707. })(jQuery);
  2708. (function( $, undefined ) {
  2709. $.widget("ui.selectable", $.ui.mouse, {
  2710. version: "1.10.4",
  2711. options: {
  2712. appendTo: "body",
  2713. autoRefresh: true,
  2714. distance: 0,
  2715. filter: "*",
  2716. tolerance: "touch",
  2717. // callbacks
  2718. selected: null,
  2719. selecting: null,
  2720. start: null,
  2721. stop: null,
  2722. unselected: null,
  2723. unselecting: null
  2724. },
  2725. _create: function() {
  2726. var selectees,
  2727. that = this;
  2728. this.element.addClass("ui-selectable");
  2729. this.dragged = false;
  2730. // cache selectee children based on filter
  2731. this.refresh = function() {
  2732. selectees = $(that.options.filter, that.element[0]);
  2733. selectees.addClass("ui-selectee");
  2734. selectees.each(function() {
  2735. var $this = $(this),
  2736. pos = $this.offset();
  2737. $.data(this, "selectable-item", {
  2738. element: this,
  2739. $element: $this,
  2740. left: pos.left,
  2741. top: pos.top,
  2742. right: pos.left + $this.outerWidth(),
  2743. bottom: pos.top + $this.outerHeight(),
  2744. startselected: false,
  2745. selected: $this.hasClass("ui-selected"),
  2746. selecting: $this.hasClass("ui-selecting"),
  2747. unselecting: $this.hasClass("ui-unselecting")
  2748. });
  2749. });
  2750. };
  2751. this.refresh();
  2752. this.selectees = selectees.addClass("ui-selectee");
  2753. this._mouseInit();
  2754. this.helper = $("<div class='ui-selectable-helper'></div>");
  2755. },
  2756. _destroy: function() {
  2757. this.selectees
  2758. .removeClass("ui-selectee")
  2759. .removeData("selectable-item");
  2760. this.element
  2761. .removeClass("ui-selectable ui-selectable-disabled");
  2762. this._mouseDestroy();
  2763. },
  2764. _mouseStart: function(event) {
  2765. var that = this,
  2766. options = this.options;
  2767. this.opos = [event.pageX, event.pageY];
  2768. if (this.options.disabled) {
  2769. return;
  2770. }
  2771. this.selectees = $(options.filter, this.element[0]);
  2772. this._trigger("start", event);
  2773. $(options.appendTo).append(this.helper);
  2774. // position helper (lasso)
  2775. this.helper.css({
  2776. "left": event.pageX,
  2777. "top": event.pageY,
  2778. "width": 0,
  2779. "height": 0
  2780. });
  2781. if (options.autoRefresh) {
  2782. this.refresh();
  2783. }
  2784. this.selectees.filter(".ui-selected").each(function() {
  2785. var selectee = $.data(this, "selectable-item");
  2786. selectee.startselected = true;
  2787. if (!event.metaKey && !event.ctrlKey) {
  2788. selectee.$element.removeClass("ui-selected");
  2789. selectee.selected = false;
  2790. selectee.$element.addClass("ui-unselecting");
  2791. selectee.unselecting = true;
  2792. // selectable UNSELECTING callback
  2793. that._trigger("unselecting", event, {
  2794. unselecting: selectee.element
  2795. });
  2796. }
  2797. });
  2798. $(event.target).parents().addBack().each(function() {
  2799. var doSelect,
  2800. selectee = $.data(this, "selectable-item");
  2801. if (selectee) {
  2802. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  2803. selectee.$element
  2804. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  2805. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  2806. selectee.unselecting = !doSelect;
  2807. selectee.selecting = doSelect;
  2808. selectee.selected = doSelect;
  2809. // selectable (UN)SELECTING callback
  2810. if (doSelect) {
  2811. that._trigger("selecting", event, {
  2812. selecting: selectee.element
  2813. });
  2814. } else {
  2815. that._trigger("unselecting", event, {
  2816. unselecting: selectee.element
  2817. });
  2818. }
  2819. return false;
  2820. }
  2821. });
  2822. },
  2823. _mouseDrag: function(event) {
  2824. this.dragged = true;
  2825. if (this.options.disabled) {
  2826. return;
  2827. }
  2828. var tmp,
  2829. that = this,
  2830. options = this.options,
  2831. x1 = this.opos[0],
  2832. y1 = this.opos[1],
  2833. x2 = event.pageX,
  2834. y2 = event.pageY;
  2835. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  2836. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  2837. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  2838. this.selectees.each(function() {
  2839. var selectee = $.data(this, "selectable-item"),
  2840. hit = false;
  2841. //prevent helper from being selected if appendTo: selectable
  2842. if (!selectee || selectee.element === that.element[0]) {
  2843. return;
  2844. }
  2845. if (options.tolerance === "touch") {
  2846. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  2847. } else if (options.tolerance === "fit") {
  2848. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  2849. }
  2850. if (hit) {
  2851. // SELECT
  2852. if (selectee.selected) {
  2853. selectee.$element.removeClass("ui-selected");
  2854. selectee.selected = false;
  2855. }
  2856. if (selectee.unselecting) {
  2857. selectee.$element.removeClass("ui-unselecting");
  2858. selectee.unselecting = false;
  2859. }
  2860. if (!selectee.selecting) {
  2861. selectee.$element.addClass("ui-selecting");
  2862. selectee.selecting = true;
  2863. // selectable SELECTING callback
  2864. that._trigger("selecting", event, {
  2865. selecting: selectee.element
  2866. });
  2867. }
  2868. } else {
  2869. // UNSELECT
  2870. if (selectee.selecting) {
  2871. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  2872. selectee.$element.removeClass("ui-selecting");
  2873. selectee.selecting = false;
  2874. selectee.$element.addClass("ui-selected");
  2875. selectee.selected = true;
  2876. } else {
  2877. selectee.$element.removeClass("ui-selecting");
  2878. selectee.selecting = false;
  2879. if (selectee.startselected) {
  2880. selectee.$element.addClass("ui-unselecting");
  2881. selectee.unselecting = true;
  2882. }
  2883. // selectable UNSELECTING callback
  2884. that._trigger("unselecting", event, {
  2885. unselecting: selectee.element
  2886. });
  2887. }
  2888. }
  2889. if (selectee.selected) {
  2890. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  2891. selectee.$element.removeClass("ui-selected");
  2892. selectee.selected = false;
  2893. selectee.$element.addClass("ui-unselecting");
  2894. selectee.unselecting = true;
  2895. // selectable UNSELECTING callback
  2896. that._trigger("unselecting", event, {
  2897. unselecting: selectee.element
  2898. });
  2899. }
  2900. }
  2901. }
  2902. });
  2903. return false;
  2904. },
  2905. _mouseStop: function(event) {
  2906. var that = this;
  2907. this.dragged = false;
  2908. $(".ui-unselecting", this.element[0]).each(function() {
  2909. var selectee = $.data(this, "selectable-item");
  2910. selectee.$element.removeClass("ui-unselecting");
  2911. selectee.unselecting = false;
  2912. selectee.startselected = false;
  2913. that._trigger("unselected", event, {
  2914. unselected: selectee.element
  2915. });
  2916. });
  2917. $(".ui-selecting", this.element[0]).each(function() {
  2918. var selectee = $.data(this, "selectable-item");
  2919. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  2920. selectee.selecting = false;
  2921. selectee.selected = true;
  2922. selectee.startselected = true;
  2923. that._trigger("selected", event, {
  2924. selected: selectee.element
  2925. });
  2926. });
  2927. this._trigger("stop", event);
  2928. this.helper.remove();
  2929. return false;
  2930. }
  2931. });
  2932. })(jQuery);
  2933. (function( $, undefined ) {
  2934. function isOverAxis( x, reference, size ) {
  2935. return ( x > reference ) && ( x < ( reference + size ) );
  2936. }
  2937. function isFloating(item) {
  2938. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  2939. }
  2940. $.widget("ui.sortable", $.ui.mouse, {
  2941. version: "1.10.4",
  2942. widgetEventPrefix: "sort",
  2943. ready: false,
  2944. options: {
  2945. appendTo: "parent",
  2946. axis: false,
  2947. connectWith: false,
  2948. containment: false,
  2949. cursor: "auto",
  2950. cursorAt: false,
  2951. dropOnEmpty: true,
  2952. forcePlaceholderSize: false,
  2953. forceHelperSize: false,
  2954. grid: false,
  2955. handle: false,
  2956. helper: "original",
  2957. items: "> *",
  2958. opacity: false,
  2959. placeholder: false,
  2960. revert: false,
  2961. scroll: true,
  2962. scrollSensitivity: 20,
  2963. scrollSpeed: 20,
  2964. scope: "default",
  2965. tolerance: "intersect",
  2966. zIndex: 1000,
  2967. // callbacks
  2968. activate: null,
  2969. beforeStop: null,
  2970. change: null,
  2971. deactivate: null,
  2972. out: null,
  2973. over: null,
  2974. receive: null,
  2975. remove: null,
  2976. sort: null,
  2977. start: null,
  2978. stop: null,
  2979. update: null
  2980. },
  2981. _create: function() {
  2982. var o = this.options;
  2983. this.containerCache = {};
  2984. this.element.addClass("ui-sortable");
  2985. //Get the items
  2986. this.refresh();
  2987. //Let's determine if the items are being displayed horizontally
  2988. this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
  2989. //Let's determine the parent's offset
  2990. this.offset = this.element.offset();
  2991. //Initialize mouse events for interaction
  2992. this._mouseInit();
  2993. //We're ready to go
  2994. this.ready = true;
  2995. },
  2996. _destroy: function() {
  2997. this.element
  2998. .removeClass("ui-sortable ui-sortable-disabled");
  2999. this._mouseDestroy();
  3000. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  3001. this.items[i].item.removeData(this.widgetName + "-item");
  3002. }
  3003. return this;
  3004. },
  3005. _setOption: function(key, value){
  3006. if ( key === "disabled" ) {
  3007. this.options[ key ] = value;
  3008. this.widget().toggleClass( "ui-sortable-disabled", !!value );
  3009. } else {
  3010. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  3011. $.Widget.prototype._setOption.apply(this, arguments);
  3012. }
  3013. },
  3014. _mouseCapture: function(event, overrideHandle) {
  3015. var currentItem = null,
  3016. validHandle = false,
  3017. that = this;
  3018. if (this.reverting) {
  3019. return false;
  3020. }
  3021. if(this.options.disabled || this.options.type === "static") {
  3022. return false;
  3023. }
  3024. //We have to refresh the items data once first
  3025. this._refreshItems(event);
  3026. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  3027. $(event.target).parents().each(function() {
  3028. if($.data(this, that.widgetName + "-item") === that) {
  3029. currentItem = $(this);
  3030. return false;
  3031. }
  3032. });
  3033. if($.data(event.target, that.widgetName + "-item") === that) {
  3034. currentItem = $(event.target);
  3035. }
  3036. if(!currentItem) {
  3037. return false;
  3038. }
  3039. if(this.options.handle && !overrideHandle) {
  3040. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  3041. if(this === event.target) {
  3042. validHandle = true;
  3043. }
  3044. });
  3045. if(!validHandle) {
  3046. return false;
  3047. }
  3048. }
  3049. this.currentItem = currentItem;
  3050. this._removeCurrentsFromItems();
  3051. return true;
  3052. },
  3053. _mouseStart: function(event, overrideHandle, noActivation) {
  3054. var i, body,
  3055. o = this.options;
  3056. this.currentContainer = this;
  3057. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3058. this.refreshPositions();
  3059. //Create and append the visible helper
  3060. this.helper = this._createHelper(event);
  3061. //Cache the helper size
  3062. this._cacheHelperProportions();
  3063. /*
  3064. * - Position generation -
  3065. * This block generates everything position related - it's the core of draggables.
  3066. */
  3067. //Cache the margins of the original element
  3068. this._cacheMargins();
  3069. //Get the next scrolling parent
  3070. this.scrollParent = this.helper.scrollParent();
  3071. //The element's absolute position on the page minus margins
  3072. this.offset = this.currentItem.offset();
  3073. this.offset = {
  3074. top: this.offset.top - this.margins.top,
  3075. left: this.offset.left - this.margins.left
  3076. };
  3077. $.extend(this.offset, {
  3078. click: { //Where the click happened, relative to the element
  3079. left: event.pageX - this.offset.left,
  3080. top: event.pageY - this.offset.top
  3081. },
  3082. parent: this._getParentOffset(),
  3083. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3084. });
  3085. // Only after we got the offset, we can change the helper's position to absolute
  3086. // TODO: Still need to figure out a way to make relative sorting possible
  3087. this.helper.css("position", "absolute");
  3088. this.cssPosition = this.helper.css("position");
  3089. //Generate the original position
  3090. this.originalPosition = this._generatePosition(event);
  3091. this.originalPageX = event.pageX;
  3092. this.originalPageY = event.pageY;
  3093. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3094. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3095. //Cache the former DOM position
  3096. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3097. //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
  3098. if(this.helper[0] !== this.currentItem[0]) {
  3099. this.currentItem.hide();
  3100. }
  3101. //Create the placeholder
  3102. this._createPlaceholder();
  3103. //Set a containment if given in the options
  3104. if(o.containment) {
  3105. this._setContainment();
  3106. }
  3107. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  3108. body = this.document.find( "body" );
  3109. // support: IE
  3110. this.storedCursor = body.css( "cursor" );
  3111. body.css( "cursor", o.cursor );
  3112. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  3113. }
  3114. if(o.opacity) { // opacity option
  3115. if (this.helper.css("opacity")) {
  3116. this._storedOpacity = this.helper.css("opacity");
  3117. }
  3118. this.helper.css("opacity", o.opacity);
  3119. }
  3120. if(o.zIndex) { // zIndex option
  3121. if (this.helper.css("zIndex")) {
  3122. this._storedZIndex = this.helper.css("zIndex");
  3123. }
  3124. this.helper.css("zIndex", o.zIndex);
  3125. }
  3126. //Prepare scrolling
  3127. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3128. this.overflowOffset = this.scrollParent.offset();
  3129. }
  3130. //Call callbacks
  3131. this._trigger("start", event, this._uiHash());
  3132. //Recache the helper size
  3133. if(!this._preserveHelperProportions) {
  3134. this._cacheHelperProportions();
  3135. }
  3136. //Post "activate" events to possible containers
  3137. if( !noActivation ) {
  3138. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  3139. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  3140. }
  3141. }
  3142. //Prepare possible droppables
  3143. if($.ui.ddmanager) {
  3144. $.ui.ddmanager.current = this;
  3145. }
  3146. if ($.ui.ddmanager && !o.dropBehaviour) {
  3147. $.ui.ddmanager.prepareOffsets(this, event);
  3148. }
  3149. this.dragging = true;
  3150. this.helper.addClass("ui-sortable-helper");
  3151. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  3152. return true;
  3153. },
  3154. _mouseDrag: function(event) {
  3155. var i, item, itemElement, intersection,
  3156. o = this.options,
  3157. scrolled = false;
  3158. //Compute the helpers position
  3159. this.position = this._generatePosition(event);
  3160. this.positionAbs = this._convertPositionTo("absolute");
  3161. if (!this.lastPositionAbs) {
  3162. this.lastPositionAbs = this.positionAbs;
  3163. }
  3164. //Do scrolling
  3165. if(this.options.scroll) {
  3166. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3167. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  3168. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  3169. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  3170. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  3171. }
  3172. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  3173. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  3174. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  3175. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  3176. }
  3177. } else {
  3178. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  3179. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  3180. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  3181. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  3182. }
  3183. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  3184. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  3185. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  3186. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  3187. }
  3188. }
  3189. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  3190. $.ui.ddmanager.prepareOffsets(this, event);
  3191. }
  3192. }
  3193. //Regenerate the absolute position used for position checks
  3194. this.positionAbs = this._convertPositionTo("absolute");
  3195. //Set the helper position
  3196. if(!this.options.axis || this.options.axis !== "y") {
  3197. this.helper[0].style.left = this.position.left+"px";
  3198. }
  3199. if(!this.options.axis || this.options.axis !== "x") {
  3200. this.helper[0].style.top = this.position.top+"px";
  3201. }
  3202. //Rearrange
  3203. for (i = this.items.length - 1; i >= 0; i--) {
  3204. //Cache variables and intersection, continue if no intersection
  3205. item = this.items[i];
  3206. itemElement = item.item[0];
  3207. intersection = this._intersectsWithPointer(item);
  3208. if (!intersection) {
  3209. continue;
  3210. }
  3211. // Only put the placeholder inside the current Container, skip all
  3212. // items from other containers. This works because when moving
  3213. // an item from one container to another the
  3214. // currentContainer is switched before the placeholder is moved.
  3215. //
  3216. // Without this, moving items in "sub-sortables" can cause
  3217. // the placeholder to jitter beetween the outer and inner container.
  3218. if (item.instance !== this.currentContainer) {
  3219. continue;
  3220. }
  3221. // cannot intersect with itself
  3222. // no useless actions that have been done before
  3223. // no action if the item moved is the parent of the item checked
  3224. if (itemElement !== this.currentItem[0] &&
  3225. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  3226. !$.contains(this.placeholder[0], itemElement) &&
  3227. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  3228. ) {
  3229. this.direction = intersection === 1 ? "down" : "up";
  3230. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  3231. this._rearrange(event, item);
  3232. } else {
  3233. break;
  3234. }
  3235. this._trigger("change", event, this._uiHash());
  3236. break;
  3237. }
  3238. }
  3239. //Post events to containers
  3240. this._contactContainers(event);
  3241. //Interconnect with droppables
  3242. if($.ui.ddmanager) {
  3243. $.ui.ddmanager.drag(this, event);
  3244. }
  3245. //Call callbacks
  3246. this._trigger("sort", event, this._uiHash());
  3247. this.lastPositionAbs = this.positionAbs;
  3248. return false;
  3249. },
  3250. _mouseStop: function(event, noPropagation) {
  3251. if(!event) {
  3252. return;
  3253. }
  3254. //If we are using droppables, inform the manager about the drop
  3255. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  3256. $.ui.ddmanager.drop(this, event);
  3257. }
  3258. if(this.options.revert) {
  3259. var that = this,
  3260. cur = this.placeholder.offset(),
  3261. axis = this.options.axis,
  3262. animation = {};
  3263. if ( !axis || axis === "x" ) {
  3264. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  3265. }
  3266. if ( !axis || axis === "y" ) {
  3267. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  3268. }
  3269. this.reverting = true;
  3270. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  3271. that._clear(event);
  3272. });
  3273. } else {
  3274. this._clear(event, noPropagation);
  3275. }
  3276. return false;
  3277. },
  3278. cancel: function() {
  3279. if(this.dragging) {
  3280. this._mouseUp({ target: null });
  3281. if(this.options.helper === "original") {
  3282. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3283. } else {
  3284. this.currentItem.show();
  3285. }
  3286. //Post deactivating events to containers
  3287. for (var i = this.containers.length - 1; i >= 0; i--){
  3288. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  3289. if(this.containers[i].containerCache.over) {
  3290. this.containers[i]._trigger("out", null, this._uiHash(this));
  3291. this.containers[i].containerCache.over = 0;
  3292. }
  3293. }
  3294. }
  3295. if (this.placeholder) {
  3296. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3297. if(this.placeholder[0].parentNode) {
  3298. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3299. }
  3300. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  3301. this.helper.remove();
  3302. }
  3303. $.extend(this, {
  3304. helper: null,
  3305. dragging: false,
  3306. reverting: false,
  3307. _noFinalSort: null
  3308. });
  3309. if(this.domPosition.prev) {
  3310. $(this.domPosition.prev).after(this.currentItem);
  3311. } else {
  3312. $(this.domPosition.parent).prepend(this.currentItem);
  3313. }
  3314. }
  3315. return this;
  3316. },
  3317. serialize: function(o) {
  3318. var items = this._getItemsAsjQuery(o && o.connected),
  3319. str = [];
  3320. o = o || {};
  3321. $(items).each(function() {
  3322. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  3323. if (res) {
  3324. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  3325. }
  3326. });
  3327. if(!str.length && o.key) {
  3328. str.push(o.key + "=");
  3329. }
  3330. return str.join("&");
  3331. },
  3332. toArray: function(o) {
  3333. var items = this._getItemsAsjQuery(o && o.connected),
  3334. ret = [];
  3335. o = o || {};
  3336. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  3337. return ret;
  3338. },
  3339. /* Be careful with the following core functions */
  3340. _intersectsWith: function(item) {
  3341. var x1 = this.positionAbs.left,
  3342. x2 = x1 + this.helperProportions.width,
  3343. y1 = this.positionAbs.top,
  3344. y2 = y1 + this.helperProportions.height,
  3345. l = item.left,
  3346. r = l + item.width,
  3347. t = item.top,
  3348. b = t + item.height,
  3349. dyClick = this.offset.click.top,
  3350. dxClick = this.offset.click.left,
  3351. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  3352. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  3353. isOverElement = isOverElementHeight && isOverElementWidth;
  3354. if ( this.options.tolerance === "pointer" ||
  3355. this.options.forcePointerForContainers ||
  3356. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  3357. ) {
  3358. return isOverElement;
  3359. } else {
  3360. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  3361. x2 - (this.helperProportions.width / 2) < r && // Left Half
  3362. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  3363. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  3364. }
  3365. },
  3366. _intersectsWithPointer: function(item) {
  3367. var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  3368. isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  3369. isOverElement = isOverElementHeight && isOverElementWidth,
  3370. verticalDirection = this._getDragVerticalDirection(),
  3371. horizontalDirection = this._getDragHorizontalDirection();
  3372. if (!isOverElement) {
  3373. return false;
  3374. }
  3375. return this.floating ?
  3376. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  3377. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  3378. },
  3379. _intersectsWithSides: function(item) {
  3380. var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  3381. isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  3382. verticalDirection = this._getDragVerticalDirection(),
  3383. horizontalDirection = this._getDragHorizontalDirection();
  3384. if (this.floating && horizontalDirection) {
  3385. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  3386. } else {
  3387. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  3388. }
  3389. },
  3390. _getDragVerticalDirection: function() {
  3391. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  3392. return delta !== 0 && (delta > 0 ? "down" : "up");
  3393. },
  3394. _getDragHorizontalDirection: function() {
  3395. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  3396. return delta !== 0 && (delta > 0 ? "right" : "left");
  3397. },
  3398. refresh: function(event) {
  3399. this._refreshItems(event);
  3400. this.refreshPositions();
  3401. return this;
  3402. },
  3403. _connectWith: function() {
  3404. var options = this.options;
  3405. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  3406. },
  3407. _getItemsAsjQuery: function(connected) {
  3408. var i, j, cur, inst,
  3409. items = [],
  3410. queries = [],
  3411. connectWith = this._connectWith();
  3412. if(connectWith && connected) {
  3413. for (i = connectWith.length - 1; i >= 0; i--){
  3414. cur = $(connectWith[i]);
  3415. for ( j = cur.length - 1; j >= 0; j--){
  3416. inst = $.data(cur[j], this.widgetFullName);
  3417. if(inst && inst !== this && !inst.options.disabled) {
  3418. 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]);
  3419. }
  3420. }
  3421. }
  3422. }
  3423. 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]);
  3424. function addItems() {
  3425. items.push( this );
  3426. }
  3427. for (i = queries.length - 1; i >= 0; i--){
  3428. queries[i][0].each( addItems );
  3429. }
  3430. return $(items);
  3431. },
  3432. _removeCurrentsFromItems: function() {
  3433. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  3434. this.items = $.grep(this.items, function (item) {
  3435. for (var j=0; j < list.length; j++) {
  3436. if(list[j] === item.item[0]) {
  3437. return false;
  3438. }
  3439. }
  3440. return true;
  3441. });
  3442. },
  3443. _refreshItems: function(event) {
  3444. this.items = [];
  3445. this.containers = [this];
  3446. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  3447. items = this.items,
  3448. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  3449. connectWith = this._connectWith();
  3450. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  3451. for (i = connectWith.length - 1; i >= 0; i--){
  3452. cur = $(connectWith[i]);
  3453. for (j = cur.length - 1; j >= 0; j--){
  3454. inst = $.data(cur[j], this.widgetFullName);
  3455. if(inst && inst !== this && !inst.options.disabled) {
  3456. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  3457. this.containers.push(inst);
  3458. }
  3459. }
  3460. }
  3461. }
  3462. for (i = queries.length - 1; i >= 0; i--) {
  3463. targetData = queries[i][1];
  3464. _queries = queries[i][0];
  3465. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  3466. item = $(_queries[j]);
  3467. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  3468. items.push({
  3469. item: item,
  3470. instance: targetData,
  3471. width: 0, height: 0,
  3472. left: 0, top: 0
  3473. });
  3474. }
  3475. }
  3476. },
  3477. refreshPositions: function(fast) {
  3478. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  3479. if(this.offsetParent && this.helper) {
  3480. this.offset.parent = this._getParentOffset();
  3481. }
  3482. var i, item, t, p;
  3483. for (i = this.items.length - 1; i >= 0; i--){
  3484. item = this.items[i];
  3485. //We ignore calculating positions of all connected containers when we're not over them
  3486. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  3487. continue;
  3488. }
  3489. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  3490. if (!fast) {
  3491. item.width = t.outerWidth();
  3492. item.height = t.outerHeight();
  3493. }
  3494. p = t.offset();
  3495. item.left = p.left;
  3496. item.top = p.top;
  3497. }
  3498. if(this.options.custom && this.options.custom.refreshContainers) {
  3499. this.options.custom.refreshContainers.call(this);
  3500. } else {
  3501. for (i = this.containers.length - 1; i >= 0; i--){
  3502. p = this.containers[i].element.offset();
  3503. this.containers[i].containerCache.left = p.left;
  3504. this.containers[i].containerCache.top = p.top;
  3505. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  3506. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  3507. }
  3508. }
  3509. return this;
  3510. },
  3511. _createPlaceholder: function(that) {
  3512. that = that || this;
  3513. var className,
  3514. o = that.options;
  3515. if(!o.placeholder || o.placeholder.constructor === String) {
  3516. className = o.placeholder;
  3517. o.placeholder = {
  3518. element: function() {
  3519. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  3520. element = $( "<" + nodeName + ">", that.document[0] )
  3521. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  3522. .removeClass("ui-sortable-helper");
  3523. if ( nodeName === "tr" ) {
  3524. that.currentItem.children().each(function() {
  3525. $( "<td>&#160;</td>", that.document[0] )
  3526. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  3527. .appendTo( element );
  3528. });
  3529. } else if ( nodeName === "img" ) {
  3530. element.attr( "src", that.currentItem.attr( "src" ) );
  3531. }
  3532. if ( !className ) {
  3533. element.css( "visibility", "hidden" );
  3534. }
  3535. return element;
  3536. },
  3537. update: function(container, p) {
  3538. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  3539. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  3540. if(className && !o.forcePlaceholderSize) {
  3541. return;
  3542. }
  3543. //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
  3544. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  3545. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  3546. }
  3547. };
  3548. }
  3549. //Create the placeholder
  3550. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  3551. //Append it after the actual current item
  3552. that.currentItem.after(that.placeholder);
  3553. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  3554. o.placeholder.update(that, that.placeholder);
  3555. },
  3556. _contactContainers: function(event) {
  3557. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
  3558. innermostContainer = null,
  3559. innermostIndex = null;
  3560. // get innermost container that intersects with item
  3561. for (i = this.containers.length - 1; i >= 0; i--) {
  3562. // never consider a container that's located within the item itself
  3563. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  3564. continue;
  3565. }
  3566. if(this._intersectsWith(this.containers[i].containerCache)) {
  3567. // if we've already found a container and it's more "inner" than this, then continue
  3568. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  3569. continue;
  3570. }
  3571. innermostContainer = this.containers[i];
  3572. innermostIndex = i;
  3573. } else {
  3574. // container doesn't intersect. trigger "out" event if necessary
  3575. if(this.containers[i].containerCache.over) {
  3576. this.containers[i]._trigger("out", event, this._uiHash(this));
  3577. this.containers[i].containerCache.over = 0;
  3578. }
  3579. }
  3580. }
  3581. // if no intersecting containers found, return
  3582. if(!innermostContainer) {
  3583. return;
  3584. }
  3585. // move the item into the container if it's not there already
  3586. if(this.containers.length === 1) {
  3587. if (!this.containers[innermostIndex].containerCache.over) {
  3588. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  3589. this.containers[innermostIndex].containerCache.over = 1;
  3590. }
  3591. } else {
  3592. //When entering a new container, we will find the item with the least distance and append our item near it
  3593. dist = 10000;
  3594. itemWithLeastDistance = null;
  3595. floating = innermostContainer.floating || isFloating(this.currentItem);
  3596. posProperty = floating ? "left" : "top";
  3597. sizeProperty = floating ? "width" : "height";
  3598. base = this.positionAbs[posProperty] + this.offset.click[posProperty];
  3599. for (j = this.items.length - 1; j >= 0; j--) {
  3600. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  3601. continue;
  3602. }
  3603. if(this.items[j].item[0] === this.currentItem[0]) {
  3604. continue;
  3605. }
  3606. if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
  3607. continue;
  3608. }
  3609. cur = this.items[j].item.offset()[posProperty];
  3610. nearBottom = false;
  3611. if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
  3612. nearBottom = true;
  3613. cur += this.items[j][sizeProperty];
  3614. }
  3615. if(Math.abs(cur - base) < dist) {
  3616. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  3617. this.direction = nearBottom ? "up": "down";
  3618. }
  3619. }
  3620. //Check if dropOnEmpty is enabled
  3621. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  3622. return;
  3623. }
  3624. if(this.currentContainer === this.containers[innermostIndex]) {
  3625. return;
  3626. }
  3627. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  3628. this._trigger("change", event, this._uiHash());
  3629. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  3630. this.currentContainer = this.containers[innermostIndex];
  3631. //Update the placeholder
  3632. this.options.placeholder.update(this.currentContainer, this.placeholder);
  3633. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  3634. this.containers[innermostIndex].containerCache.over = 1;
  3635. }
  3636. },
  3637. _createHelper: function(event) {
  3638. var o = this.options,
  3639. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  3640. //Add the helper to the DOM if that didn't happen already
  3641. if(!helper.parents("body").length) {
  3642. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  3643. }
  3644. if(helper[0] === this.currentItem[0]) {
  3645. 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") };
  3646. }
  3647. if(!helper[0].style.width || o.forceHelperSize) {
  3648. helper.width(this.currentItem.width());
  3649. }
  3650. if(!helper[0].style.height || o.forceHelperSize) {
  3651. helper.height(this.currentItem.height());
  3652. }
  3653. return helper;
  3654. },
  3655. _adjustOffsetFromHelper: function(obj) {
  3656. if (typeof obj === "string") {
  3657. obj = obj.split(" ");
  3658. }
  3659. if ($.isArray(obj)) {
  3660. obj = {left: +obj[0], top: +obj[1] || 0};
  3661. }
  3662. if ("left" in obj) {
  3663. this.offset.click.left = obj.left + this.margins.left;
  3664. }
  3665. if ("right" in obj) {
  3666. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  3667. }
  3668. if ("top" in obj) {
  3669. this.offset.click.top = obj.top + this.margins.top;
  3670. }
  3671. if ("bottom" in obj) {
  3672. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  3673. }
  3674. },
  3675. _getParentOffset: function() {
  3676. //Get the offsetParent and cache its position
  3677. this.offsetParent = this.helper.offsetParent();
  3678. var po = this.offsetParent.offset();
  3679. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  3680. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  3681. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  3682. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  3683. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  3684. po.left += this.scrollParent.scrollLeft();
  3685. po.top += this.scrollParent.scrollTop();
  3686. }
  3687. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  3688. // with an ugly IE fix
  3689. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  3690. po = { top: 0, left: 0 };
  3691. }
  3692. return {
  3693. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  3694. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  3695. };
  3696. },
  3697. _getRelativeOffset: function() {
  3698. if(this.cssPosition === "relative") {
  3699. var p = this.currentItem.position();
  3700. return {
  3701. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  3702. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  3703. };
  3704. } else {
  3705. return { top: 0, left: 0 };
  3706. }
  3707. },
  3708. _cacheMargins: function() {
  3709. this.margins = {
  3710. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  3711. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  3712. };
  3713. },
  3714. _cacheHelperProportions: function() {
  3715. this.helperProportions = {
  3716. width: this.helper.outerWidth(),
  3717. height: this.helper.outerHeight()
  3718. };
  3719. },
  3720. _setContainment: function() {
  3721. var ce, co, over,
  3722. o = this.options;
  3723. if(o.containment === "parent") {
  3724. o.containment = this.helper[0].parentNode;
  3725. }
  3726. if(o.containment === "document" || o.containment === "window") {
  3727. this.containment = [
  3728. 0 - this.offset.relative.left - this.offset.parent.left,
  3729. 0 - this.offset.relative.top - this.offset.parent.top,
  3730. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  3731. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  3732. ];
  3733. }
  3734. if(!(/^(document|window|parent)$/).test(o.containment)) {
  3735. ce = $(o.containment)[0];
  3736. co = $(o.containment).offset();
  3737. over = ($(ce).css("overflow") !== "hidden");
  3738. this.containment = [
  3739. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  3740. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  3741. 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,
  3742. 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
  3743. ];
  3744. }
  3745. },
  3746. _convertPositionTo: function(d, pos) {
  3747. if(!pos) {
  3748. pos = this.position;
  3749. }
  3750. var mod = d === "absolute" ? 1 : -1,
  3751. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  3752. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  3753. return {
  3754. top: (
  3755. pos.top + // The absolute mouse position
  3756. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  3757. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  3758. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  3759. ),
  3760. left: (
  3761. pos.left + // The absolute mouse position
  3762. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  3763. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  3764. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  3765. )
  3766. };
  3767. },
  3768. _generatePosition: function(event) {
  3769. var top, left,
  3770. o = this.options,
  3771. pageX = event.pageX,
  3772. pageY = event.pageY,
  3773. 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);
  3774. // This is another very weird special case that only happens for relative elements:
  3775. // 1. If the css position is relative
  3776. // 2. and the scroll parent is the document or similar to the offset parent
  3777. // we have to refresh the relative offset during the scroll so there are no jumps
  3778. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  3779. this.offset.relative = this._getRelativeOffset();
  3780. }
  3781. /*
  3782. * - Position constraining -
  3783. * Constrain the position to a mix of grid, containment.
  3784. */
  3785. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  3786. if(this.containment) {
  3787. if(event.pageX - this.offset.click.left < this.containment[0]) {
  3788. pageX = this.containment[0] + this.offset.click.left;
  3789. }
  3790. if(event.pageY - this.offset.click.top < this.containment[1]) {
  3791. pageY = this.containment[1] + this.offset.click.top;
  3792. }
  3793. if(event.pageX - this.offset.click.left > this.containment[2]) {
  3794. pageX = this.containment[2] + this.offset.click.left;
  3795. }
  3796. if(event.pageY - this.offset.click.top > this.containment[3]) {
  3797. pageY = this.containment[3] + this.offset.click.top;
  3798. }
  3799. }
  3800. if(o.grid) {
  3801. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  3802. 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;
  3803. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  3804. 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;
  3805. }
  3806. }
  3807. return {
  3808. top: (
  3809. pageY - // The absolute mouse position
  3810. this.offset.click.top - // Click offset (relative to the element)
  3811. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  3812. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  3813. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  3814. ),
  3815. left: (
  3816. pageX - // The absolute mouse position
  3817. this.offset.click.left - // Click offset (relative to the element)
  3818. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  3819. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  3820. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  3821. )
  3822. };
  3823. },
  3824. _rearrange: function(event, i, a, hardRefresh) {
  3825. 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));
  3826. //Various things done here to improve the performance:
  3827. // 1. we create a setTimeout, that calls refreshPositions
  3828. // 2. on the instance, we have a counter variable, that get's higher after every append
  3829. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  3830. // 4. this lets only the last addition to the timeout stack through
  3831. this.counter = this.counter ? ++this.counter : 1;
  3832. var counter = this.counter;
  3833. this._delay(function() {
  3834. if(counter === this.counter) {
  3835. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  3836. }
  3837. });
  3838. },
  3839. _clear: function(event, noPropagation) {
  3840. this.reverting = false;
  3841. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  3842. // everything else normalized again
  3843. var i,
  3844. delayedTriggers = [];
  3845. // We first have to update the dom position of the actual currentItem
  3846. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  3847. if(!this._noFinalSort && this.currentItem.parent().length) {
  3848. this.placeholder.before(this.currentItem);
  3849. }
  3850. this._noFinalSort = null;
  3851. if(this.helper[0] === this.currentItem[0]) {
  3852. for(i in this._storedCSS) {
  3853. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  3854. this._storedCSS[i] = "";
  3855. }
  3856. }
  3857. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3858. } else {
  3859. this.currentItem.show();
  3860. }
  3861. if(this.fromOutside && !noPropagation) {
  3862. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  3863. }
  3864. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  3865. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  3866. }
  3867. // Check if the items Container has Changed and trigger appropriate
  3868. // events.
  3869. if (this !== this.currentContainer) {
  3870. if(!noPropagation) {
  3871. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  3872. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  3873. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  3874. }
  3875. }
  3876. //Post events to containers
  3877. function delayEvent( type, instance, container ) {
  3878. return function( event ) {
  3879. container._trigger( type, event, instance._uiHash( instance ) );
  3880. };
  3881. }
  3882. for (i = this.containers.length - 1; i >= 0; i--){
  3883. if (!noPropagation) {
  3884. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  3885. }
  3886. if(this.containers[i].containerCache.over) {
  3887. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  3888. this.containers[i].containerCache.over = 0;
  3889. }
  3890. }
  3891. //Do what was originally in plugins
  3892. if ( this.storedCursor ) {
  3893. this.document.find( "body" ).css( "cursor", this.storedCursor );
  3894. this.storedStylesheet.remove();
  3895. }
  3896. if(this._storedOpacity) {
  3897. this.helper.css("opacity", this._storedOpacity);
  3898. }
  3899. if(this._storedZIndex) {
  3900. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  3901. }
  3902. this.dragging = false;
  3903. if(this.cancelHelperRemoval) {
  3904. if(!noPropagation) {
  3905. this._trigger("beforeStop", event, this._uiHash());
  3906. for (i=0; i < delayedTriggers.length; i++) {
  3907. delayedTriggers[i].call(this, event);
  3908. } //Trigger all delayed events
  3909. this._trigger("stop", event, this._uiHash());
  3910. }
  3911. this.fromOutside = false;
  3912. return false;
  3913. }
  3914. if(!noPropagation) {
  3915. this._trigger("beforeStop", event, this._uiHash());
  3916. }
  3917. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3918. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3919. if(this.helper[0] !== this.currentItem[0]) {
  3920. this.helper.remove();
  3921. }
  3922. this.helper = null;
  3923. if(!noPropagation) {
  3924. for (i=0; i < delayedTriggers.length; i++) {
  3925. delayedTriggers[i].call(this, event);
  3926. } //Trigger all delayed events
  3927. this._trigger("stop", event, this._uiHash());
  3928. }
  3929. this.fromOutside = false;
  3930. return true;
  3931. },
  3932. _trigger: function() {
  3933. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  3934. this.cancel();
  3935. }
  3936. },
  3937. _uiHash: function(_inst) {
  3938. var inst = _inst || this;
  3939. return {
  3940. helper: inst.helper,
  3941. placeholder: inst.placeholder || $([]),
  3942. position: inst.position,
  3943. originalPosition: inst.originalPosition,
  3944. offset: inst.positionAbs,
  3945. item: inst.currentItem,
  3946. sender: _inst ? _inst.element : null
  3947. };
  3948. }
  3949. });
  3950. })(jQuery);
  3951. (function($, undefined) {
  3952. var dataSpace = "ui-effects-";
  3953. $.effects = {
  3954. effect: {}
  3955. };
  3956. /*!
  3957. * jQuery Color Animations v2.1.2
  3958. * https://github.com/jquery/jquery-color
  3959. *
  3960. * Copyright 2013 jQuery Foundation and other contributors
  3961. * Released under the MIT license.
  3962. * http://jquery.org/license
  3963. *
  3964. * Date: Wed Jan 16 08:47:09 2013 -0600
  3965. */
  3966. (function( jQuery, undefined ) {
  3967. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  3968. // plusequals test for += 100 -= 100
  3969. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  3970. // a set of RE's that can match strings and generate color tuples.
  3971. stringParsers = [{
  3972. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3973. parse: function( execResult ) {
  3974. return [
  3975. execResult[ 1 ],
  3976. execResult[ 2 ],
  3977. execResult[ 3 ],
  3978. execResult[ 4 ]
  3979. ];
  3980. }
  3981. }, {
  3982. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3983. parse: function( execResult ) {
  3984. return [
  3985. execResult[ 1 ] * 2.55,
  3986. execResult[ 2 ] * 2.55,
  3987. execResult[ 3 ] * 2.55,
  3988. execResult[ 4 ]
  3989. ];
  3990. }
  3991. }, {
  3992. // this regex ignores A-F because it's compared against an already lowercased string
  3993. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  3994. parse: function( execResult ) {
  3995. return [
  3996. parseInt( execResult[ 1 ], 16 ),
  3997. parseInt( execResult[ 2 ], 16 ),
  3998. parseInt( execResult[ 3 ], 16 )
  3999. ];
  4000. }
  4001. }, {
  4002. // this regex ignores A-F because it's compared against an already lowercased string
  4003. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  4004. parse: function( execResult ) {
  4005. return [
  4006. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  4007. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  4008. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  4009. ];
  4010. }
  4011. }, {
  4012. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  4013. space: "hsla",
  4014. parse: function( execResult ) {
  4015. return [
  4016. execResult[ 1 ],
  4017. execResult[ 2 ] / 100,
  4018. execResult[ 3 ] / 100,
  4019. execResult[ 4 ]
  4020. ];
  4021. }
  4022. }],
  4023. // jQuery.Color( )
  4024. color = jQuery.Color = function( color, green, blue, alpha ) {
  4025. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  4026. },
  4027. spaces = {
  4028. rgba: {
  4029. props: {
  4030. red: {
  4031. idx: 0,
  4032. type: "byte"
  4033. },
  4034. green: {
  4035. idx: 1,
  4036. type: "byte"
  4037. },
  4038. blue: {
  4039. idx: 2,
  4040. type: "byte"
  4041. }
  4042. }
  4043. },
  4044. hsla: {
  4045. props: {
  4046. hue: {
  4047. idx: 0,
  4048. type: "degrees"
  4049. },
  4050. saturation: {
  4051. idx: 1,
  4052. type: "percent"
  4053. },
  4054. lightness: {
  4055. idx: 2,
  4056. type: "percent"
  4057. }
  4058. }
  4059. }
  4060. },
  4061. propTypes = {
  4062. "byte": {
  4063. floor: true,
  4064. max: 255
  4065. },
  4066. "percent": {
  4067. max: 1
  4068. },
  4069. "degrees": {
  4070. mod: 360,
  4071. floor: true
  4072. }
  4073. },
  4074. support = color.support = {},
  4075. // element for support tests
  4076. supportElem = jQuery( "<p>" )[ 0 ],
  4077. // colors = jQuery.Color.names
  4078. colors,
  4079. // local aliases of functions called often
  4080. each = jQuery.each;
  4081. // determine rgba support immediately
  4082. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  4083. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  4084. // define cache name and alpha properties
  4085. // for rgba and hsla spaces
  4086. each( spaces, function( spaceName, space ) {
  4087. space.cache = "_" + spaceName;
  4088. space.props.alpha = {
  4089. idx: 3,
  4090. type: "percent",
  4091. def: 1
  4092. };
  4093. });
  4094. function clamp( value, prop, allowEmpty ) {
  4095. var type = propTypes[ prop.type ] || {};
  4096. if ( value == null ) {
  4097. return (allowEmpty || !prop.def) ? null : prop.def;
  4098. }
  4099. // ~~ is an short way of doing floor for positive numbers
  4100. value = type.floor ? ~~value : parseFloat( value );
  4101. // IE will pass in empty strings as value for alpha,
  4102. // which will hit this case
  4103. if ( isNaN( value ) ) {
  4104. return prop.def;
  4105. }
  4106. if ( type.mod ) {
  4107. // we add mod before modding to make sure that negatives values
  4108. // get converted properly: -10 -> 350
  4109. return (value + type.mod) % type.mod;
  4110. }
  4111. // for now all property types without mod have min and max
  4112. return 0 > value ? 0 : type.max < value ? type.max : value;
  4113. }
  4114. function stringParse( string ) {
  4115. var inst = color(),
  4116. rgba = inst._rgba = [];
  4117. string = string.toLowerCase();
  4118. each( stringParsers, function( i, parser ) {
  4119. var parsed,
  4120. match = parser.re.exec( string ),
  4121. values = match && parser.parse( match ),
  4122. spaceName = parser.space || "rgba";
  4123. if ( values ) {
  4124. parsed = inst[ spaceName ]( values );
  4125. // if this was an rgba parse the assignment might happen twice
  4126. // oh well....
  4127. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  4128. rgba = inst._rgba = parsed._rgba;
  4129. // exit each( stringParsers ) here because we matched
  4130. return false;
  4131. }
  4132. });
  4133. // Found a stringParser that handled it
  4134. if ( rgba.length ) {
  4135. // if this came from a parsed string, force "transparent" when alpha is 0
  4136. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  4137. if ( rgba.join() === "0,0,0,0" ) {
  4138. jQuery.extend( rgba, colors.transparent );
  4139. }
  4140. return inst;
  4141. }
  4142. // named colors
  4143. return colors[ string ];
  4144. }
  4145. color.fn = jQuery.extend( color.prototype, {
  4146. parse: function( red, green, blue, alpha ) {
  4147. if ( red === undefined ) {
  4148. this._rgba = [ null, null, null, null ];
  4149. return this;
  4150. }
  4151. if ( red.jquery || red.nodeType ) {
  4152. red = jQuery( red ).css( green );
  4153. green = undefined;
  4154. }
  4155. var inst = this,
  4156. type = jQuery.type( red ),
  4157. rgba = this._rgba = [];
  4158. // more than 1 argument specified - assume ( red, green, blue, alpha )
  4159. if ( green !== undefined ) {
  4160. red = [ red, green, blue, alpha ];
  4161. type = "array";
  4162. }
  4163. if ( type === "string" ) {
  4164. return this.parse( stringParse( red ) || colors._default );
  4165. }
  4166. if ( type === "array" ) {
  4167. each( spaces.rgba.props, function( key, prop ) {
  4168. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  4169. });
  4170. return this;
  4171. }
  4172. if ( type === "object" ) {
  4173. if ( red instanceof color ) {
  4174. each( spaces, function( spaceName, space ) {
  4175. if ( red[ space.cache ] ) {
  4176. inst[ space.cache ] = red[ space.cache ].slice();
  4177. }
  4178. });
  4179. } else {
  4180. each( spaces, function( spaceName, space ) {
  4181. var cache = space.cache;
  4182. each( space.props, function( key, prop ) {
  4183. // if the cache doesn't exist, and we know how to convert
  4184. if ( !inst[ cache ] && space.to ) {
  4185. // if the value was null, we don't need to copy it
  4186. // if the key was alpha, we don't need to copy it either
  4187. if ( key === "alpha" || red[ key ] == null ) {
  4188. return;
  4189. }
  4190. inst[ cache ] = space.to( inst._rgba );
  4191. }
  4192. // this is the only case where we allow nulls for ALL properties.
  4193. // call clamp with alwaysAllowEmpty
  4194. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  4195. });
  4196. // everything defined but alpha?
  4197. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  4198. // use the default of 1
  4199. inst[ cache ][ 3 ] = 1;
  4200. if ( space.from ) {
  4201. inst._rgba = space.from( inst[ cache ] );
  4202. }
  4203. }
  4204. });
  4205. }
  4206. return this;
  4207. }
  4208. },
  4209. is: function( compare ) {
  4210. var is = color( compare ),
  4211. same = true,
  4212. inst = this;
  4213. each( spaces, function( _, space ) {
  4214. var localCache,
  4215. isCache = is[ space.cache ];
  4216. if (isCache) {
  4217. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  4218. each( space.props, function( _, prop ) {
  4219. if ( isCache[ prop.idx ] != null ) {
  4220. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  4221. return same;
  4222. }
  4223. });
  4224. }
  4225. return same;
  4226. });
  4227. return same;
  4228. },
  4229. _space: function() {
  4230. var used = [],
  4231. inst = this;
  4232. each( spaces, function( spaceName, space ) {
  4233. if ( inst[ space.cache ] ) {
  4234. used.push( spaceName );
  4235. }
  4236. });
  4237. return used.pop();
  4238. },
  4239. transition: function( other, distance ) {
  4240. var end = color( other ),
  4241. spaceName = end._space(),
  4242. space = spaces[ spaceName ],
  4243. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  4244. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  4245. result = start.slice();
  4246. end = end[ space.cache ];
  4247. each( space.props, function( key, prop ) {
  4248. var index = prop.idx,
  4249. startValue = start[ index ],
  4250. endValue = end[ index ],
  4251. type = propTypes[ prop.type ] || {};
  4252. // if null, don't override start value
  4253. if ( endValue === null ) {
  4254. return;
  4255. }
  4256. // if null - use end
  4257. if ( startValue === null ) {
  4258. result[ index ] = endValue;
  4259. } else {
  4260. if ( type.mod ) {
  4261. if ( endValue - startValue > type.mod / 2 ) {
  4262. startValue += type.mod;
  4263. } else if ( startValue - endValue > type.mod / 2 ) {
  4264. startValue -= type.mod;
  4265. }
  4266. }
  4267. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  4268. }
  4269. });
  4270. return this[ spaceName ]( result );
  4271. },
  4272. blend: function( opaque ) {
  4273. // if we are already opaque - return ourself
  4274. if ( this._rgba[ 3 ] === 1 ) {
  4275. return this;
  4276. }
  4277. var rgb = this._rgba.slice(),
  4278. a = rgb.pop(),
  4279. blend = color( opaque )._rgba;
  4280. return color( jQuery.map( rgb, function( v, i ) {
  4281. return ( 1 - a ) * blend[ i ] + a * v;
  4282. }));
  4283. },
  4284. toRgbaString: function() {
  4285. var prefix = "rgba(",
  4286. rgba = jQuery.map( this._rgba, function( v, i ) {
  4287. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  4288. });
  4289. if ( rgba[ 3 ] === 1 ) {
  4290. rgba.pop();
  4291. prefix = "rgb(";
  4292. }
  4293. return prefix + rgba.join() + ")";
  4294. },
  4295. toHslaString: function() {
  4296. var prefix = "hsla(",
  4297. hsla = jQuery.map( this.hsla(), function( v, i ) {
  4298. if ( v == null ) {
  4299. v = i > 2 ? 1 : 0;
  4300. }
  4301. // catch 1 and 2
  4302. if ( i && i < 3 ) {
  4303. v = Math.round( v * 100 ) + "%";
  4304. }
  4305. return v;
  4306. });
  4307. if ( hsla[ 3 ] === 1 ) {
  4308. hsla.pop();
  4309. prefix = "hsl(";
  4310. }
  4311. return prefix + hsla.join() + ")";
  4312. },
  4313. toHexString: function( includeAlpha ) {
  4314. var rgba = this._rgba.slice(),
  4315. alpha = rgba.pop();
  4316. if ( includeAlpha ) {
  4317. rgba.push( ~~( alpha * 255 ) );
  4318. }
  4319. return "#" + jQuery.map( rgba, function( v ) {
  4320. // default to 0 when nulls exist
  4321. v = ( v || 0 ).toString( 16 );
  4322. return v.length === 1 ? "0" + v : v;
  4323. }).join("");
  4324. },
  4325. toString: function() {
  4326. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  4327. }
  4328. });
  4329. color.fn.parse.prototype = color.fn;
  4330. // hsla conversions adapted from:
  4331. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  4332. function hue2rgb( p, q, h ) {
  4333. h = ( h + 1 ) % 1;
  4334. if ( h * 6 < 1 ) {
  4335. return p + (q - p) * h * 6;
  4336. }
  4337. if ( h * 2 < 1) {
  4338. return q;
  4339. }
  4340. if ( h * 3 < 2 ) {
  4341. return p + (q - p) * ((2/3) - h) * 6;
  4342. }
  4343. return p;
  4344. }
  4345. spaces.hsla.to = function ( rgba ) {
  4346. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  4347. return [ null, null, null, rgba[ 3 ] ];
  4348. }
  4349. var r = rgba[ 0 ] / 255,
  4350. g = rgba[ 1 ] / 255,
  4351. b = rgba[ 2 ] / 255,
  4352. a = rgba[ 3 ],
  4353. max = Math.max( r, g, b ),
  4354. min = Math.min( r, g, b ),
  4355. diff = max - min,
  4356. add = max + min,
  4357. l = add * 0.5,
  4358. h, s;
  4359. if ( min === max ) {
  4360. h = 0;
  4361. } else if ( r === max ) {
  4362. h = ( 60 * ( g - b ) / diff ) + 360;
  4363. } else if ( g === max ) {
  4364. h = ( 60 * ( b - r ) / diff ) + 120;
  4365. } else {
  4366. h = ( 60 * ( r - g ) / diff ) + 240;
  4367. }
  4368. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  4369. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  4370. if ( diff === 0 ) {
  4371. s = 0;
  4372. } else if ( l <= 0.5 ) {
  4373. s = diff / add;
  4374. } else {
  4375. s = diff / ( 2 - add );
  4376. }
  4377. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  4378. };
  4379. spaces.hsla.from = function ( hsla ) {
  4380. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  4381. return [ null, null, null, hsla[ 3 ] ];
  4382. }
  4383. var h = hsla[ 0 ] / 360,
  4384. s = hsla[ 1 ],
  4385. l = hsla[ 2 ],
  4386. a = hsla[ 3 ],
  4387. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  4388. p = 2 * l - q;
  4389. return [
  4390. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  4391. Math.round( hue2rgb( p, q, h ) * 255 ),
  4392. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  4393. a
  4394. ];
  4395. };
  4396. each( spaces, function( spaceName, space ) {
  4397. var props = space.props,
  4398. cache = space.cache,
  4399. to = space.to,
  4400. from = space.from;
  4401. // makes rgba() and hsla()
  4402. color.fn[ spaceName ] = function( value ) {
  4403. // generate a cache for this space if it doesn't exist
  4404. if ( to && !this[ cache ] ) {
  4405. this[ cache ] = to( this._rgba );
  4406. }
  4407. if ( value === undefined ) {
  4408. return this[ cache ].slice();
  4409. }
  4410. var ret,
  4411. type = jQuery.type( value ),
  4412. arr = ( type === "array" || type === "object" ) ? value : arguments,
  4413. local = this[ cache ].slice();
  4414. each( props, function( key, prop ) {
  4415. var val = arr[ type === "object" ? key : prop.idx ];
  4416. if ( val == null ) {
  4417. val = local[ prop.idx ];
  4418. }
  4419. local[ prop.idx ] = clamp( val, prop );
  4420. });
  4421. if ( from ) {
  4422. ret = color( from( local ) );
  4423. ret[ cache ] = local;
  4424. return ret;
  4425. } else {
  4426. return color( local );
  4427. }
  4428. };
  4429. // makes red() green() blue() alpha() hue() saturation() lightness()
  4430. each( props, function( key, prop ) {
  4431. // alpha is included in more than one space
  4432. if ( color.fn[ key ] ) {
  4433. return;
  4434. }
  4435. color.fn[ key ] = function( value ) {
  4436. var vtype = jQuery.type( value ),
  4437. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  4438. local = this[ fn ](),
  4439. cur = local[ prop.idx ],
  4440. match;
  4441. if ( vtype === "undefined" ) {
  4442. return cur;
  4443. }
  4444. if ( vtype === "function" ) {
  4445. value = value.call( this, cur );
  4446. vtype = jQuery.type( value );
  4447. }
  4448. if ( value == null && prop.empty ) {
  4449. return this;
  4450. }
  4451. if ( vtype === "string" ) {
  4452. match = rplusequals.exec( value );
  4453. if ( match ) {
  4454. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  4455. }
  4456. }
  4457. local[ prop.idx ] = value;
  4458. return this[ fn ]( local );
  4459. };
  4460. });
  4461. });
  4462. // add cssHook and .fx.step function for each named hook.
  4463. // accept a space separated string of properties
  4464. color.hook = function( hook ) {
  4465. var hooks = hook.split( " " );
  4466. each( hooks, function( i, hook ) {
  4467. jQuery.cssHooks[ hook ] = {
  4468. set: function( elem, value ) {
  4469. var parsed, curElem,
  4470. backgroundColor = "";
  4471. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  4472. value = color( parsed || value );
  4473. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  4474. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  4475. while (
  4476. (backgroundColor === "" || backgroundColor === "transparent") &&
  4477. curElem && curElem.style
  4478. ) {
  4479. try {
  4480. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  4481. curElem = curElem.parentNode;
  4482. } catch ( e ) {
  4483. }
  4484. }
  4485. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  4486. backgroundColor :
  4487. "_default" );
  4488. }
  4489. value = value.toRgbaString();
  4490. }
  4491. try {
  4492. elem.style[ hook ] = value;
  4493. } catch( e ) {
  4494. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  4495. }
  4496. }
  4497. };
  4498. jQuery.fx.step[ hook ] = function( fx ) {
  4499. if ( !fx.colorInit ) {
  4500. fx.start = color( fx.elem, hook );
  4501. fx.end = color( fx.end );
  4502. fx.colorInit = true;
  4503. }
  4504. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  4505. };
  4506. });
  4507. };
  4508. color.hook( stepHooks );
  4509. jQuery.cssHooks.borderColor = {
  4510. expand: function( value ) {
  4511. var expanded = {};
  4512. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  4513. expanded[ "border" + part + "Color" ] = value;
  4514. });
  4515. return expanded;
  4516. }
  4517. };
  4518. // Basic color names only.
  4519. // Usage of any of the other color names requires adding yourself or including
  4520. // jquery.color.svg-names.js.
  4521. colors = jQuery.Color.names = {
  4522. // 4.1. Basic color keywords
  4523. aqua: "#00ffff",
  4524. black: "#000000",
  4525. blue: "#0000ff",
  4526. fuchsia: "#ff00ff",
  4527. gray: "#808080",
  4528. green: "#008000",
  4529. lime: "#00ff00",
  4530. maroon: "#800000",
  4531. navy: "#000080",
  4532. olive: "#808000",
  4533. purple: "#800080",
  4534. red: "#ff0000",
  4535. silver: "#c0c0c0",
  4536. teal: "#008080",
  4537. white: "#ffffff",
  4538. yellow: "#ffff00",
  4539. // 4.2.3. "transparent" color keyword
  4540. transparent: [ null, null, null, 0 ],
  4541. _default: "#ffffff"
  4542. };
  4543. })( jQuery );
  4544. /******************************************************************************/
  4545. /****************************** CLASS ANIMATIONS ******************************/
  4546. /******************************************************************************/
  4547. (function() {
  4548. var classAnimationActions = [ "add", "remove", "toggle" ],
  4549. shorthandStyles = {
  4550. border: 1,
  4551. borderBottom: 1,
  4552. borderColor: 1,
  4553. borderLeft: 1,
  4554. borderRight: 1,
  4555. borderTop: 1,
  4556. borderWidth: 1,
  4557. margin: 1,
  4558. padding: 1
  4559. };
  4560. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  4561. $.fx.step[ prop ] = function( fx ) {
  4562. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  4563. jQuery.style( fx.elem, prop, fx.end );
  4564. fx.setAttr = true;
  4565. }
  4566. };
  4567. });
  4568. function getElementStyles( elem ) {
  4569. var key, len,
  4570. style = elem.ownerDocument.defaultView ?
  4571. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  4572. elem.currentStyle,
  4573. styles = {};
  4574. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  4575. len = style.length;
  4576. while ( len-- ) {
  4577. key = style[ len ];
  4578. if ( typeof style[ key ] === "string" ) {
  4579. styles[ $.camelCase( key ) ] = style[ key ];
  4580. }
  4581. }
  4582. // support: Opera, IE <9
  4583. } else {
  4584. for ( key in style ) {
  4585. if ( typeof style[ key ] === "string" ) {
  4586. styles[ key ] = style[ key ];
  4587. }
  4588. }
  4589. }
  4590. return styles;
  4591. }
  4592. function styleDifference( oldStyle, newStyle ) {
  4593. var diff = {},
  4594. name, value;
  4595. for ( name in newStyle ) {
  4596. value = newStyle[ name ];
  4597. if ( oldStyle[ name ] !== value ) {
  4598. if ( !shorthandStyles[ name ] ) {
  4599. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  4600. diff[ name ] = value;
  4601. }
  4602. }
  4603. }
  4604. }
  4605. return diff;
  4606. }
  4607. // support: jQuery <1.8
  4608. if ( !$.fn.addBack ) {
  4609. $.fn.addBack = function( selector ) {
  4610. return this.add( selector == null ?
  4611. this.prevObject : this.prevObject.filter( selector )
  4612. );
  4613. };
  4614. }
  4615. $.effects.animateClass = function( value, duration, easing, callback ) {
  4616. var o = $.speed( duration, easing, callback );
  4617. return this.queue( function() {
  4618. var animated = $( this ),
  4619. baseClass = animated.attr( "class" ) || "",
  4620. applyClassChange,
  4621. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  4622. // map the animated objects to store the original styles.
  4623. allAnimations = allAnimations.map(function() {
  4624. var el = $( this );
  4625. return {
  4626. el: el,
  4627. start: getElementStyles( this )
  4628. };
  4629. });
  4630. // apply class change
  4631. applyClassChange = function() {
  4632. $.each( classAnimationActions, function(i, action) {
  4633. if ( value[ action ] ) {
  4634. animated[ action + "Class" ]( value[ action ] );
  4635. }
  4636. });
  4637. };
  4638. applyClassChange();
  4639. // map all animated objects again - calculate new styles and diff
  4640. allAnimations = allAnimations.map(function() {
  4641. this.end = getElementStyles( this.el[ 0 ] );
  4642. this.diff = styleDifference( this.start, this.end );
  4643. return this;
  4644. });
  4645. // apply original class
  4646. animated.attr( "class", baseClass );
  4647. // map all animated objects again - this time collecting a promise
  4648. allAnimations = allAnimations.map(function() {
  4649. var styleInfo = this,
  4650. dfd = $.Deferred(),
  4651. opts = $.extend({}, o, {
  4652. queue: false,
  4653. complete: function() {
  4654. dfd.resolve( styleInfo );
  4655. }
  4656. });
  4657. this.el.animate( this.diff, opts );
  4658. return dfd.promise();
  4659. });
  4660. // once all animations have completed:
  4661. $.when.apply( $, allAnimations.get() ).done(function() {
  4662. // set the final class
  4663. applyClassChange();
  4664. // for each animated element,
  4665. // clear all css properties that were animated
  4666. $.each( arguments, function() {
  4667. var el = this.el;
  4668. $.each( this.diff, function(key) {
  4669. el.css( key, "" );
  4670. });
  4671. });
  4672. // this is guarnteed to be there if you use jQuery.speed()
  4673. // it also handles dequeuing the next anim...
  4674. o.complete.call( animated[ 0 ] );
  4675. });
  4676. });
  4677. };
  4678. $.fn.extend({
  4679. addClass: (function( orig ) {
  4680. return function( classNames, speed, easing, callback ) {
  4681. return speed ?
  4682. $.effects.animateClass.call( this,
  4683. { add: classNames }, speed, easing, callback ) :
  4684. orig.apply( this, arguments );
  4685. };
  4686. })( $.fn.addClass ),
  4687. removeClass: (function( orig ) {
  4688. return function( classNames, speed, easing, callback ) {
  4689. return arguments.length > 1 ?
  4690. $.effects.animateClass.call( this,
  4691. { remove: classNames }, speed, easing, callback ) :
  4692. orig.apply( this, arguments );
  4693. };
  4694. })( $.fn.removeClass ),
  4695. toggleClass: (function( orig ) {
  4696. return function( classNames, force, speed, easing, callback ) {
  4697. if ( typeof force === "boolean" || force === undefined ) {
  4698. if ( !speed ) {
  4699. // without speed parameter
  4700. return orig.apply( this, arguments );
  4701. } else {
  4702. return $.effects.animateClass.call( this,
  4703. (force ? { add: classNames } : { remove: classNames }),
  4704. speed, easing, callback );
  4705. }
  4706. } else {
  4707. // without force parameter
  4708. return $.effects.animateClass.call( this,
  4709. { toggle: classNames }, force, speed, easing );
  4710. }
  4711. };
  4712. })( $.fn.toggleClass ),
  4713. switchClass: function( remove, add, speed, easing, callback) {
  4714. return $.effects.animateClass.call( this, {
  4715. add: add,
  4716. remove: remove
  4717. }, speed, easing, callback );
  4718. }
  4719. });
  4720. })();
  4721. /******************************************************************************/
  4722. /*********************************** EFFECTS **********************************/
  4723. /******************************************************************************/
  4724. (function() {
  4725. $.extend( $.effects, {
  4726. version: "1.10.4",
  4727. // Saves a set of properties in a data storage
  4728. save: function( element, set ) {
  4729. for( var i=0; i < set.length; i++ ) {
  4730. if ( set[ i ] !== null ) {
  4731. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  4732. }
  4733. }
  4734. },
  4735. // Restores a set of previously saved properties from a data storage
  4736. restore: function( element, set ) {
  4737. var val, i;
  4738. for( i=0; i < set.length; i++ ) {
  4739. if ( set[ i ] !== null ) {
  4740. val = element.data( dataSpace + set[ i ] );
  4741. // support: jQuery 1.6.2
  4742. // http://bugs.jquery.com/ticket/9917
  4743. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  4744. // We can't differentiate between "" and 0 here, so we just assume
  4745. // empty string since it's likely to be a more common value...
  4746. if ( val === undefined ) {
  4747. val = "";
  4748. }
  4749. element.css( set[ i ], val );
  4750. }
  4751. }
  4752. },
  4753. setMode: function( el, mode ) {
  4754. if (mode === "toggle") {
  4755. mode = el.is( ":hidden" ) ? "show" : "hide";
  4756. }
  4757. return mode;
  4758. },
  4759. // Translates a [top,left] array into a baseline value
  4760. // this should be a little more flexible in the future to handle a string & hash
  4761. getBaseline: function( origin, original ) {
  4762. var y, x;
  4763. switch ( origin[ 0 ] ) {
  4764. case "top": y = 0; break;
  4765. case "middle": y = 0.5; break;
  4766. case "bottom": y = 1; break;
  4767. default: y = origin[ 0 ] / original.height;
  4768. }
  4769. switch ( origin[ 1 ] ) {
  4770. case "left": x = 0; break;
  4771. case "center": x = 0.5; break;
  4772. case "right": x = 1; break;
  4773. default: x = origin[ 1 ] / original.width;
  4774. }
  4775. return {
  4776. x: x,
  4777. y: y
  4778. };
  4779. },
  4780. // Wraps the element around a wrapper that copies position properties
  4781. createWrapper: function( element ) {
  4782. // if the element is already wrapped, return it
  4783. if ( element.parent().is( ".ui-effects-wrapper" )) {
  4784. return element.parent();
  4785. }
  4786. // wrap the element
  4787. var props = {
  4788. width: element.outerWidth(true),
  4789. height: element.outerHeight(true),
  4790. "float": element.css( "float" )
  4791. },
  4792. wrapper = $( "<div></div>" )
  4793. .addClass( "ui-effects-wrapper" )
  4794. .css({
  4795. fontSize: "100%",
  4796. background: "transparent",
  4797. border: "none",
  4798. margin: 0,
  4799. padding: 0
  4800. }),
  4801. // Store the size in case width/height are defined in % - Fixes #5245
  4802. size = {
  4803. width: element.width(),
  4804. height: element.height()
  4805. },
  4806. active = document.activeElement;
  4807. // support: Firefox
  4808. // Firefox incorrectly exposes anonymous content
  4809. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  4810. try {
  4811. active.id;
  4812. } catch( e ) {
  4813. active = document.body;
  4814. }
  4815. element.wrap( wrapper );
  4816. // Fixes #7595 - Elements lose focus when wrapped.
  4817. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  4818. $( active ).focus();
  4819. }
  4820. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  4821. // transfer positioning properties to the wrapper
  4822. if ( element.css( "position" ) === "static" ) {
  4823. wrapper.css({ position: "relative" });
  4824. element.css({ position: "relative" });
  4825. } else {
  4826. $.extend( props, {
  4827. position: element.css( "position" ),
  4828. zIndex: element.css( "z-index" )
  4829. });
  4830. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  4831. props[ pos ] = element.css( pos );
  4832. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  4833. props[ pos ] = "auto";
  4834. }
  4835. });
  4836. element.css({
  4837. position: "relative",
  4838. top: 0,
  4839. left: 0,
  4840. right: "auto",
  4841. bottom: "auto"
  4842. });
  4843. }
  4844. element.css(size);
  4845. return wrapper.css( props ).show();
  4846. },
  4847. removeWrapper: function( element ) {
  4848. var active = document.activeElement;
  4849. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  4850. element.parent().replaceWith( element );
  4851. // Fixes #7595 - Elements lose focus when wrapped.
  4852. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  4853. $( active ).focus();
  4854. }
  4855. }
  4856. return element;
  4857. },
  4858. setTransition: function( element, list, factor, value ) {
  4859. value = value || {};
  4860. $.each( list, function( i, x ) {
  4861. var unit = element.cssUnit( x );
  4862. if ( unit[ 0 ] > 0 ) {
  4863. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  4864. }
  4865. });
  4866. return value;
  4867. }
  4868. });
  4869. // return an effect options object for the given parameters:
  4870. function _normalizeArguments( effect, options, speed, callback ) {
  4871. // allow passing all options as the first parameter
  4872. if ( $.isPlainObject( effect ) ) {
  4873. options = effect;
  4874. effect = effect.effect;
  4875. }
  4876. // convert to an object
  4877. effect = { effect: effect };
  4878. // catch (effect, null, ...)
  4879. if ( options == null ) {
  4880. options = {};
  4881. }
  4882. // catch (effect, callback)
  4883. if ( $.isFunction( options ) ) {
  4884. callback = options;
  4885. speed = null;
  4886. options = {};
  4887. }
  4888. // catch (effect, speed, ?)
  4889. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  4890. callback = speed;
  4891. speed = options;
  4892. options = {};
  4893. }
  4894. // catch (effect, options, callback)
  4895. if ( $.isFunction( speed ) ) {
  4896. callback = speed;
  4897. speed = null;
  4898. }
  4899. // add options to effect
  4900. if ( options ) {
  4901. $.extend( effect, options );
  4902. }
  4903. speed = speed || options.duration;
  4904. effect.duration = $.fx.off ? 0 :
  4905. typeof speed === "number" ? speed :
  4906. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  4907. $.fx.speeds._default;
  4908. effect.complete = callback || options.complete;
  4909. return effect;
  4910. }
  4911. function standardAnimationOption( option ) {
  4912. // Valid standard speeds (nothing, number, named speed)
  4913. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  4914. return true;
  4915. }
  4916. // Invalid strings - treat as "normal" speed
  4917. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  4918. return true;
  4919. }
  4920. // Complete callback
  4921. if ( $.isFunction( option ) ) {
  4922. return true;
  4923. }
  4924. // Options hash (but not naming an effect)
  4925. if ( typeof option === "object" && !option.effect ) {
  4926. return true;
  4927. }
  4928. // Didn't match any standard API
  4929. return false;
  4930. }
  4931. $.fn.extend({
  4932. effect: function( /* effect, options, speed, callback */ ) {
  4933. var args = _normalizeArguments.apply( this, arguments ),
  4934. mode = args.mode,
  4935. queue = args.queue,
  4936. effectMethod = $.effects.effect[ args.effect ];
  4937. if ( $.fx.off || !effectMethod ) {
  4938. // delegate to the original method (e.g., .show()) if possible
  4939. if ( mode ) {
  4940. return this[ mode ]( args.duration, args.complete );
  4941. } else {
  4942. return this.each( function() {
  4943. if ( args.complete ) {
  4944. args.complete.call( this );
  4945. }
  4946. });
  4947. }
  4948. }
  4949. function run( next ) {
  4950. var elem = $( this ),
  4951. complete = args.complete,
  4952. mode = args.mode;
  4953. function done() {
  4954. if ( $.isFunction( complete ) ) {
  4955. complete.call( elem[0] );
  4956. }
  4957. if ( $.isFunction( next ) ) {
  4958. next();
  4959. }
  4960. }
  4961. // If the element already has the correct final state, delegate to
  4962. // the core methods so the internal tracking of "olddisplay" works.
  4963. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  4964. elem[ mode ]();
  4965. done();
  4966. } else {
  4967. effectMethod.call( elem[0], args, done );
  4968. }
  4969. }
  4970. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  4971. },
  4972. show: (function( orig ) {
  4973. return function( option ) {
  4974. if ( standardAnimationOption( option ) ) {
  4975. return orig.apply( this, arguments );
  4976. } else {
  4977. var args = _normalizeArguments.apply( this, arguments );
  4978. args.mode = "show";
  4979. return this.effect.call( this, args );
  4980. }
  4981. };
  4982. })( $.fn.show ),
  4983. hide: (function( orig ) {
  4984. return function( option ) {
  4985. if ( standardAnimationOption( option ) ) {
  4986. return orig.apply( this, arguments );
  4987. } else {
  4988. var args = _normalizeArguments.apply( this, arguments );
  4989. args.mode = "hide";
  4990. return this.effect.call( this, args );
  4991. }
  4992. };
  4993. })( $.fn.hide ),
  4994. toggle: (function( orig ) {
  4995. return function( option ) {
  4996. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  4997. return orig.apply( this, arguments );
  4998. } else {
  4999. var args = _normalizeArguments.apply( this, arguments );
  5000. args.mode = "toggle";
  5001. return this.effect.call( this, args );
  5002. }
  5003. };
  5004. })( $.fn.toggle ),
  5005. // helper functions
  5006. cssUnit: function(key) {
  5007. var style = this.css( key ),
  5008. val = [];
  5009. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  5010. if ( style.indexOf( unit ) > 0 ) {
  5011. val = [ parseFloat( style ), unit ];
  5012. }
  5013. });
  5014. return val;
  5015. }
  5016. });
  5017. })();
  5018. /******************************************************************************/
  5019. /*********************************** EASING ***********************************/
  5020. /******************************************************************************/
  5021. (function() {
  5022. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  5023. var baseEasings = {};
  5024. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  5025. baseEasings[ name ] = function( p ) {
  5026. return Math.pow( p, i + 2 );
  5027. };
  5028. });
  5029. $.extend( baseEasings, {
  5030. Sine: function ( p ) {
  5031. return 1 - Math.cos( p * Math.PI / 2 );
  5032. },
  5033. Circ: function ( p ) {
  5034. return 1 - Math.sqrt( 1 - p * p );
  5035. },
  5036. Elastic: function( p ) {
  5037. return p === 0 || p === 1 ? p :
  5038. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  5039. },
  5040. Back: function( p ) {
  5041. return p * p * ( 3 * p - 2 );
  5042. },
  5043. Bounce: function ( p ) {
  5044. var pow2,
  5045. bounce = 4;
  5046. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  5047. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  5048. }
  5049. });
  5050. $.each( baseEasings, function( name, easeIn ) {
  5051. $.easing[ "easeIn" + name ] = easeIn;
  5052. $.easing[ "easeOut" + name ] = function( p ) {
  5053. return 1 - easeIn( 1 - p );
  5054. };
  5055. $.easing[ "easeInOut" + name ] = function( p ) {
  5056. return p < 0.5 ?
  5057. easeIn( p * 2 ) / 2 :
  5058. 1 - easeIn( p * -2 + 2 ) / 2;
  5059. };
  5060. });
  5061. })();
  5062. })(jQuery);
  5063. (function( $, undefined ) {
  5064. var uid = 0,
  5065. hideProps = {},
  5066. showProps = {};
  5067. hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
  5068. hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
  5069. showProps.height = showProps.paddingTop = showProps.paddingBottom =
  5070. showProps.borderTopWidth = showProps.borderBottomWidth = "show";
  5071. $.widget( "ui.accordion", {
  5072. version: "1.10.4",
  5073. options: {
  5074. active: 0,
  5075. animate: {},
  5076. collapsible: false,
  5077. event: "click",
  5078. header: "> li > :first-child,> :not(li):even",
  5079. heightStyle: "auto",
  5080. icons: {
  5081. activeHeader: "ui-icon-triangle-1-s",
  5082. header: "ui-icon-triangle-1-e"
  5083. },
  5084. // callbacks
  5085. activate: null,
  5086. beforeActivate: null
  5087. },
  5088. _create: function() {
  5089. var options = this.options;
  5090. this.prevShow = this.prevHide = $();
  5091. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  5092. // ARIA
  5093. .attr( "role", "tablist" );
  5094. // don't allow collapsible: false and active: false / null
  5095. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  5096. options.active = 0;
  5097. }
  5098. this._processPanels();
  5099. // handle negative values
  5100. if ( options.active < 0 ) {
  5101. options.active += this.headers.length;
  5102. }
  5103. this._refresh();
  5104. },
  5105. _getCreateEventData: function() {
  5106. return {
  5107. header: this.active,
  5108. panel: !this.active.length ? $() : this.active.next(),
  5109. content: !this.active.length ? $() : this.active.next()
  5110. };
  5111. },
  5112. _createIcons: function() {
  5113. var icons = this.options.icons;
  5114. if ( icons ) {
  5115. $( "<span>" )
  5116. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  5117. .prependTo( this.headers );
  5118. this.active.children( ".ui-accordion-header-icon" )
  5119. .removeClass( icons.header )
  5120. .addClass( icons.activeHeader );
  5121. this.headers.addClass( "ui-accordion-icons" );
  5122. }
  5123. },
  5124. _destroyIcons: function() {
  5125. this.headers
  5126. .removeClass( "ui-accordion-icons" )
  5127. .children( ".ui-accordion-header-icon" )
  5128. .remove();
  5129. },
  5130. _destroy: function() {
  5131. var contents;
  5132. // clean up main element
  5133. this.element
  5134. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  5135. .removeAttr( "role" );
  5136. // clean up headers
  5137. this.headers
  5138. .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" )
  5139. .removeAttr( "role" )
  5140. .removeAttr( "aria-expanded" )
  5141. .removeAttr( "aria-selected" )
  5142. .removeAttr( "aria-controls" )
  5143. .removeAttr( "tabIndex" )
  5144. .each(function() {
  5145. if ( /^ui-accordion/.test( this.id ) ) {
  5146. this.removeAttribute( "id" );
  5147. }
  5148. });
  5149. this._destroyIcons();
  5150. // clean up content panels
  5151. contents = this.headers.next()
  5152. .css( "display", "" )
  5153. .removeAttr( "role" )
  5154. .removeAttr( "aria-hidden" )
  5155. .removeAttr( "aria-labelledby" )
  5156. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  5157. .each(function() {
  5158. if ( /^ui-accordion/.test( this.id ) ) {
  5159. this.removeAttribute( "id" );
  5160. }
  5161. });
  5162. if ( this.options.heightStyle !== "content" ) {
  5163. contents.css( "height", "" );
  5164. }
  5165. },
  5166. _setOption: function( key, value ) {
  5167. if ( key === "active" ) {
  5168. // _activate() will handle invalid values and update this.options
  5169. this._activate( value );
  5170. return;
  5171. }
  5172. if ( key === "event" ) {
  5173. if ( this.options.event ) {
  5174. this._off( this.headers, this.options.event );
  5175. }
  5176. this._setupEvents( value );
  5177. }
  5178. this._super( key, value );
  5179. // setting collapsible: false while collapsed; open first panel
  5180. if ( key === "collapsible" && !value && this.options.active === false ) {
  5181. this._activate( 0 );
  5182. }
  5183. if ( key === "icons" ) {
  5184. this._destroyIcons();
  5185. if ( value ) {
  5186. this._createIcons();
  5187. }
  5188. }
  5189. // #5332 - opacity doesn't cascade to positioned elements in IE
  5190. // so we need to add the disabled class to the headers and panels
  5191. if ( key === "disabled" ) {
  5192. this.headers.add( this.headers.next() )
  5193. .toggleClass( "ui-state-disabled", !!value );
  5194. }
  5195. },
  5196. _keydown: function( event ) {
  5197. if ( event.altKey || event.ctrlKey ) {
  5198. return;
  5199. }
  5200. var keyCode = $.ui.keyCode,
  5201. length = this.headers.length,
  5202. currentIndex = this.headers.index( event.target ),
  5203. toFocus = false;
  5204. switch ( event.keyCode ) {
  5205. case keyCode.RIGHT:
  5206. case keyCode.DOWN:
  5207. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  5208. break;
  5209. case keyCode.LEFT:
  5210. case keyCode.UP:
  5211. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  5212. break;
  5213. case keyCode.SPACE:
  5214. case keyCode.ENTER:
  5215. this._eventHandler( event );
  5216. break;
  5217. case keyCode.HOME:
  5218. toFocus = this.headers[ 0 ];
  5219. break;
  5220. case keyCode.END:
  5221. toFocus = this.headers[ length - 1 ];
  5222. break;
  5223. }
  5224. if ( toFocus ) {
  5225. $( event.target ).attr( "tabIndex", -1 );
  5226. $( toFocus ).attr( "tabIndex", 0 );
  5227. toFocus.focus();
  5228. event.preventDefault();
  5229. }
  5230. },
  5231. _panelKeyDown : function( event ) {
  5232. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  5233. $( event.currentTarget ).prev().focus();
  5234. }
  5235. },
  5236. refresh: function() {
  5237. var options = this.options;
  5238. this._processPanels();
  5239. // was collapsed or no panel
  5240. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  5241. options.active = false;
  5242. this.active = $();
  5243. // active false only when collapsible is true
  5244. } else if ( options.active === false ) {
  5245. this._activate( 0 );
  5246. // was active, but active panel is gone
  5247. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5248. // all remaining panel are disabled
  5249. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  5250. options.active = false;
  5251. this.active = $();
  5252. // activate previous panel
  5253. } else {
  5254. this._activate( Math.max( 0, options.active - 1 ) );
  5255. }
  5256. // was active, active panel still exists
  5257. } else {
  5258. // make sure active index is correct
  5259. options.active = this.headers.index( this.active );
  5260. }
  5261. this._destroyIcons();
  5262. this._refresh();
  5263. },
  5264. _processPanels: function() {
  5265. this.headers = this.element.find( this.options.header )
  5266. .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
  5267. this.headers.next()
  5268. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  5269. .filter(":not(.ui-accordion-content-active)")
  5270. .hide();
  5271. },
  5272. _refresh: function() {
  5273. var maxHeight,
  5274. options = this.options,
  5275. heightStyle = options.heightStyle,
  5276. parent = this.element.parent(),
  5277. accordionId = this.accordionId = "ui-accordion-" +
  5278. (this.element.attr( "id" ) || ++uid);
  5279. this.active = this._findActive( options.active )
  5280. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  5281. .removeClass( "ui-corner-all" );
  5282. this.active.next()
  5283. .addClass( "ui-accordion-content-active" )
  5284. .show();
  5285. this.headers
  5286. .attr( "role", "tab" )
  5287. .each(function( i ) {
  5288. var header = $( this ),
  5289. headerId = header.attr( "id" ),
  5290. panel = header.next(),
  5291. panelId = panel.attr( "id" );
  5292. if ( !headerId ) {
  5293. headerId = accordionId + "-header-" + i;
  5294. header.attr( "id", headerId );
  5295. }
  5296. if ( !panelId ) {
  5297. panelId = accordionId + "-panel-" + i;
  5298. panel.attr( "id", panelId );
  5299. }
  5300. header.attr( "aria-controls", panelId );
  5301. panel.attr( "aria-labelledby", headerId );
  5302. })
  5303. .next()
  5304. .attr( "role", "tabpanel" );
  5305. this.headers
  5306. .not( this.active )
  5307. .attr({
  5308. "aria-selected": "false",
  5309. "aria-expanded": "false",
  5310. tabIndex: -1
  5311. })
  5312. .next()
  5313. .attr({
  5314. "aria-hidden": "true"
  5315. })
  5316. .hide();
  5317. // make sure at least one header is in the tab order
  5318. if ( !this.active.length ) {
  5319. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  5320. } else {
  5321. this.active.attr({
  5322. "aria-selected": "true",
  5323. "aria-expanded": "true",
  5324. tabIndex: 0
  5325. })
  5326. .next()
  5327. .attr({
  5328. "aria-hidden": "false"
  5329. });
  5330. }
  5331. this._createIcons();
  5332. this._setupEvents( options.event );
  5333. if ( heightStyle === "fill" ) {
  5334. maxHeight = parent.height();
  5335. this.element.siblings( ":visible" ).each(function() {
  5336. var elem = $( this ),
  5337. position = elem.css( "position" );
  5338. if ( position === "absolute" || position === "fixed" ) {
  5339. return;
  5340. }
  5341. maxHeight -= elem.outerHeight( true );
  5342. });
  5343. this.headers.each(function() {
  5344. maxHeight -= $( this ).outerHeight( true );
  5345. });
  5346. this.headers.next()
  5347. .each(function() {
  5348. $( this ).height( Math.max( 0, maxHeight -
  5349. $( this ).innerHeight() + $( this ).height() ) );
  5350. })
  5351. .css( "overflow", "auto" );
  5352. } else if ( heightStyle === "auto" ) {
  5353. maxHeight = 0;
  5354. this.headers.next()
  5355. .each(function() {
  5356. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  5357. })
  5358. .height( maxHeight );
  5359. }
  5360. },
  5361. _activate: function( index ) {
  5362. var active = this._findActive( index )[ 0 ];
  5363. // trying to activate the already active panel
  5364. if ( active === this.active[ 0 ] ) {
  5365. return;
  5366. }
  5367. // trying to collapse, simulate a click on the currently active header
  5368. active = active || this.active[ 0 ];
  5369. this._eventHandler({
  5370. target: active,
  5371. currentTarget: active,
  5372. preventDefault: $.noop
  5373. });
  5374. },
  5375. _findActive: function( selector ) {
  5376. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  5377. },
  5378. _setupEvents: function( event ) {
  5379. var events = {
  5380. keydown: "_keydown"
  5381. };
  5382. if ( event ) {
  5383. $.each( event.split(" "), function( index, eventName ) {
  5384. events[ eventName ] = "_eventHandler";
  5385. });
  5386. }
  5387. this._off( this.headers.add( this.headers.next() ) );
  5388. this._on( this.headers, events );
  5389. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  5390. this._hoverable( this.headers );
  5391. this._focusable( this.headers );
  5392. },
  5393. _eventHandler: function( event ) {
  5394. var options = this.options,
  5395. active = this.active,
  5396. clicked = $( event.currentTarget ),
  5397. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  5398. collapsing = clickedIsActive && options.collapsible,
  5399. toShow = collapsing ? $() : clicked.next(),
  5400. toHide = active.next(),
  5401. eventData = {
  5402. oldHeader: active,
  5403. oldPanel: toHide,
  5404. newHeader: collapsing ? $() : clicked,
  5405. newPanel: toShow
  5406. };
  5407. event.preventDefault();
  5408. if (
  5409. // click on active header, but not collapsible
  5410. ( clickedIsActive && !options.collapsible ) ||
  5411. // allow canceling activation
  5412. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  5413. return;
  5414. }
  5415. options.active = collapsing ? false : this.headers.index( clicked );
  5416. // when the call to ._toggle() comes after the class changes
  5417. // it causes a very odd bug in IE 8 (see #6720)
  5418. this.active = clickedIsActive ? $() : clicked;
  5419. this._toggle( eventData );
  5420. // switch classes
  5421. // corner classes on the previously active header stay after the animation
  5422. active.removeClass( "ui-accordion-header-active ui-state-active" );
  5423. if ( options.icons ) {
  5424. active.children( ".ui-accordion-header-icon" )
  5425. .removeClass( options.icons.activeHeader )
  5426. .addClass( options.icons.header );
  5427. }
  5428. if ( !clickedIsActive ) {
  5429. clicked
  5430. .removeClass( "ui-corner-all" )
  5431. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  5432. if ( options.icons ) {
  5433. clicked.children( ".ui-accordion-header-icon" )
  5434. .removeClass( options.icons.header )
  5435. .addClass( options.icons.activeHeader );
  5436. }
  5437. clicked
  5438. .next()
  5439. .addClass( "ui-accordion-content-active" );
  5440. }
  5441. },
  5442. _toggle: function( data ) {
  5443. var toShow = data.newPanel,
  5444. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  5445. // handle activating a panel during the animation for another activation
  5446. this.prevShow.add( this.prevHide ).stop( true, true );
  5447. this.prevShow = toShow;
  5448. this.prevHide = toHide;
  5449. if ( this.options.animate ) {
  5450. this._animate( toShow, toHide, data );
  5451. } else {
  5452. toHide.hide();
  5453. toShow.show();
  5454. this._toggleComplete( data );
  5455. }
  5456. toHide.attr({
  5457. "aria-hidden": "true"
  5458. });
  5459. toHide.prev().attr( "aria-selected", "false" );
  5460. // if we're switching panels, remove the old header from the tab order
  5461. // if we're opening from collapsed state, remove the previous header from the tab order
  5462. // if we're collapsing, then keep the collapsing header in the tab order
  5463. if ( toShow.length && toHide.length ) {
  5464. toHide.prev().attr({
  5465. "tabIndex": -1,
  5466. "aria-expanded": "false"
  5467. });
  5468. } else if ( toShow.length ) {
  5469. this.headers.filter(function() {
  5470. return $( this ).attr( "tabIndex" ) === 0;
  5471. })
  5472. .attr( "tabIndex", -1 );
  5473. }
  5474. toShow
  5475. .attr( "aria-hidden", "false" )
  5476. .prev()
  5477. .attr({
  5478. "aria-selected": "true",
  5479. tabIndex: 0,
  5480. "aria-expanded": "true"
  5481. });
  5482. },
  5483. _animate: function( toShow, toHide, data ) {
  5484. var total, easing, duration,
  5485. that = this,
  5486. adjust = 0,
  5487. down = toShow.length &&
  5488. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  5489. animate = this.options.animate || {},
  5490. options = down && animate.down || animate,
  5491. complete = function() {
  5492. that._toggleComplete( data );
  5493. };
  5494. if ( typeof options === "number" ) {
  5495. duration = options;
  5496. }
  5497. if ( typeof options === "string" ) {
  5498. easing = options;
  5499. }
  5500. // fall back from options to animation in case of partial down settings
  5501. easing = easing || options.easing || animate.easing;
  5502. duration = duration || options.duration || animate.duration;
  5503. if ( !toHide.length ) {
  5504. return toShow.animate( showProps, duration, easing, complete );
  5505. }
  5506. if ( !toShow.length ) {
  5507. return toHide.animate( hideProps, duration, easing, complete );
  5508. }
  5509. total = toShow.show().outerHeight();
  5510. toHide.animate( hideProps, {
  5511. duration: duration,
  5512. easing: easing,
  5513. step: function( now, fx ) {
  5514. fx.now = Math.round( now );
  5515. }
  5516. });
  5517. toShow
  5518. .hide()
  5519. .animate( showProps, {
  5520. duration: duration,
  5521. easing: easing,
  5522. complete: complete,
  5523. step: function( now, fx ) {
  5524. fx.now = Math.round( now );
  5525. if ( fx.prop !== "height" ) {
  5526. adjust += fx.now;
  5527. } else if ( that.options.heightStyle !== "content" ) {
  5528. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  5529. adjust = 0;
  5530. }
  5531. }
  5532. });
  5533. },
  5534. _toggleComplete: function( data ) {
  5535. var toHide = data.oldPanel;
  5536. toHide
  5537. .removeClass( "ui-accordion-content-active" )
  5538. .prev()
  5539. .removeClass( "ui-corner-top" )
  5540. .addClass( "ui-corner-all" );
  5541. // Work around for rendering bug in IE (#5421)
  5542. if ( toHide.length ) {
  5543. toHide.parent()[0].className = toHide.parent()[0].className;
  5544. }
  5545. this._trigger( "activate", null, data );
  5546. }
  5547. });
  5548. })( jQuery );
  5549. (function( $, undefined ) {
  5550. $.widget( "ui.autocomplete", {
  5551. version: "1.10.4",
  5552. defaultElement: "<input>",
  5553. options: {
  5554. appendTo: null,
  5555. autoFocus: false,
  5556. delay: 300,
  5557. minLength: 1,
  5558. position: {
  5559. my: "left top",
  5560. at: "left bottom",
  5561. collision: "none"
  5562. },
  5563. source: null,
  5564. // callbacks
  5565. change: null,
  5566. close: null,
  5567. focus: null,
  5568. open: null,
  5569. response: null,
  5570. search: null,
  5571. select: null
  5572. },
  5573. requestIndex: 0,
  5574. pending: 0,
  5575. _create: function() {
  5576. // Some browsers only repeat keydown events, not keypress events,
  5577. // so we use the suppressKeyPress flag to determine if we've already
  5578. // handled the keydown event. #7269
  5579. // Unfortunately the code for & in keypress is the same as the up arrow,
  5580. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  5581. // events when we know the keydown event was used to modify the
  5582. // search term. #7799
  5583. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  5584. nodeName = this.element[0].nodeName.toLowerCase(),
  5585. isTextarea = nodeName === "textarea",
  5586. isInput = nodeName === "input";
  5587. this.isMultiLine =
  5588. // Textareas are always multi-line
  5589. isTextarea ? true :
  5590. // Inputs are always single-line, even if inside a contentEditable element
  5591. // IE also treats inputs as contentEditable
  5592. isInput ? false :
  5593. // All other element types are determined by whether or not they're contentEditable
  5594. this.element.prop( "isContentEditable" );
  5595. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  5596. this.isNewMenu = true;
  5597. this.element
  5598. .addClass( "ui-autocomplete-input" )
  5599. .attr( "autocomplete", "off" );
  5600. this._on( this.element, {
  5601. keydown: function( event ) {
  5602. if ( this.element.prop( "readOnly" ) ) {
  5603. suppressKeyPress = true;
  5604. suppressInput = true;
  5605. suppressKeyPressRepeat = true;
  5606. return;
  5607. }
  5608. suppressKeyPress = false;
  5609. suppressInput = false;
  5610. suppressKeyPressRepeat = false;
  5611. var keyCode = $.ui.keyCode;
  5612. switch( event.keyCode ) {
  5613. case keyCode.PAGE_UP:
  5614. suppressKeyPress = true;
  5615. this._move( "previousPage", event );
  5616. break;
  5617. case keyCode.PAGE_DOWN:
  5618. suppressKeyPress = true;
  5619. this._move( "nextPage", event );
  5620. break;
  5621. case keyCode.UP:
  5622. suppressKeyPress = true;
  5623. this._keyEvent( "previous", event );
  5624. break;
  5625. case keyCode.DOWN:
  5626. suppressKeyPress = true;
  5627. this._keyEvent( "next", event );
  5628. break;
  5629. case keyCode.ENTER:
  5630. case keyCode.NUMPAD_ENTER:
  5631. // when menu is open and has focus
  5632. if ( this.menu.active ) {
  5633. // #6055 - Opera still allows the keypress to occur
  5634. // which causes forms to submit
  5635. suppressKeyPress = true;
  5636. event.preventDefault();
  5637. this.menu.select( event );
  5638. }
  5639. break;
  5640. case keyCode.TAB:
  5641. if ( this.menu.active ) {
  5642. this.menu.select( event );
  5643. }
  5644. break;
  5645. case keyCode.ESCAPE:
  5646. if ( this.menu.element.is( ":visible" ) ) {
  5647. this._value( this.term );
  5648. this.close( event );
  5649. // Different browsers have different default behavior for escape
  5650. // Single press can mean undo or clear
  5651. // Double press in IE means clear the whole form
  5652. event.preventDefault();
  5653. }
  5654. break;
  5655. default:
  5656. suppressKeyPressRepeat = true;
  5657. // search timeout should be triggered before the input value is changed
  5658. this._searchTimeout( event );
  5659. break;
  5660. }
  5661. },
  5662. keypress: function( event ) {
  5663. if ( suppressKeyPress ) {
  5664. suppressKeyPress = false;
  5665. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5666. event.preventDefault();
  5667. }
  5668. return;
  5669. }
  5670. if ( suppressKeyPressRepeat ) {
  5671. return;
  5672. }
  5673. // replicate some key handlers to allow them to repeat in Firefox and Opera
  5674. var keyCode = $.ui.keyCode;
  5675. switch( event.keyCode ) {
  5676. case keyCode.PAGE_UP:
  5677. this._move( "previousPage", event );
  5678. break;
  5679. case keyCode.PAGE_DOWN:
  5680. this._move( "nextPage", event );
  5681. break;
  5682. case keyCode.UP:
  5683. this._keyEvent( "previous", event );
  5684. break;
  5685. case keyCode.DOWN:
  5686. this._keyEvent( "next", event );
  5687. break;
  5688. }
  5689. },
  5690. input: function( event ) {
  5691. if ( suppressInput ) {
  5692. suppressInput = false;
  5693. event.preventDefault();
  5694. return;
  5695. }
  5696. this._searchTimeout( event );
  5697. },
  5698. focus: function() {
  5699. this.selectedItem = null;
  5700. this.previous = this._value();
  5701. },
  5702. blur: function( event ) {
  5703. if ( this.cancelBlur ) {
  5704. delete this.cancelBlur;
  5705. return;
  5706. }
  5707. clearTimeout( this.searching );
  5708. this.close( event );
  5709. this._change( event );
  5710. }
  5711. });
  5712. this._initSource();
  5713. this.menu = $( "<ul>" )
  5714. .addClass( "ui-autocomplete ui-front" )
  5715. .appendTo( this._appendTo() )
  5716. .menu({
  5717. // disable ARIA support, the live region takes care of that
  5718. role: null
  5719. })
  5720. .hide()
  5721. .data( "ui-menu" );
  5722. this._on( this.menu.element, {
  5723. mousedown: function( event ) {
  5724. // prevent moving focus out of the text field
  5725. event.preventDefault();
  5726. // IE doesn't prevent moving focus even with event.preventDefault()
  5727. // so we set a flag to know when we should ignore the blur event
  5728. this.cancelBlur = true;
  5729. this._delay(function() {
  5730. delete this.cancelBlur;
  5731. });
  5732. // clicking on the scrollbar causes focus to shift to the body
  5733. // but we can't detect a mouseup or a click immediately afterward
  5734. // so we have to track the next mousedown and close the menu if
  5735. // the user clicks somewhere outside of the autocomplete
  5736. var menuElement = this.menu.element[ 0 ];
  5737. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  5738. this._delay(function() {
  5739. var that = this;
  5740. this.document.one( "mousedown", function( event ) {
  5741. if ( event.target !== that.element[ 0 ] &&
  5742. event.target !== menuElement &&
  5743. !$.contains( menuElement, event.target ) ) {
  5744. that.close();
  5745. }
  5746. });
  5747. });
  5748. }
  5749. },
  5750. menufocus: function( event, ui ) {
  5751. // support: Firefox
  5752. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  5753. if ( this.isNewMenu ) {
  5754. this.isNewMenu = false;
  5755. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  5756. this.menu.blur();
  5757. this.document.one( "mousemove", function() {
  5758. $( event.target ).trigger( event.originalEvent );
  5759. });
  5760. return;
  5761. }
  5762. }
  5763. var item = ui.item.data( "ui-autocomplete-item" );
  5764. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  5765. // use value to match what will end up in the input, if it was a key event
  5766. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  5767. this._value( item.value );
  5768. }
  5769. } else {
  5770. // Normally the input is populated with the item's value as the
  5771. // menu is navigated, causing screen readers to notice a change and
  5772. // announce the item. Since the focus event was canceled, this doesn't
  5773. // happen, so we update the live region so that screen readers can
  5774. // still notice the change and announce it.
  5775. this.liveRegion.text( item.value );
  5776. }
  5777. },
  5778. menuselect: function( event, ui ) {
  5779. var item = ui.item.data( "ui-autocomplete-item" ),
  5780. previous = this.previous;
  5781. // only trigger when focus was lost (click on menu)
  5782. if ( this.element[0] !== this.document[0].activeElement ) {
  5783. this.element.focus();
  5784. this.previous = previous;
  5785. // #6109 - IE triggers two focus events and the second
  5786. // is asynchronous, so we need to reset the previous
  5787. // term synchronously and asynchronously :-(
  5788. this._delay(function() {
  5789. this.previous = previous;
  5790. this.selectedItem = item;
  5791. });
  5792. }
  5793. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  5794. this._value( item.value );
  5795. }
  5796. // reset the term after the select event
  5797. // this allows custom select handling to work properly
  5798. this.term = this._value();
  5799. this.close( event );
  5800. this.selectedItem = item;
  5801. }
  5802. });
  5803. this.liveRegion = $( "<span>", {
  5804. role: "status",
  5805. "aria-live": "polite"
  5806. })
  5807. .addClass( "ui-helper-hidden-accessible" )
  5808. .insertBefore( this.element );
  5809. // turning off autocomplete prevents the browser from remembering the
  5810. // value when navigating through history, so we re-enable autocomplete
  5811. // if the page is unloaded before the widget is destroyed. #7790
  5812. this._on( this.window, {
  5813. beforeunload: function() {
  5814. this.element.removeAttr( "autocomplete" );
  5815. }
  5816. });
  5817. },
  5818. _destroy: function() {
  5819. clearTimeout( this.searching );
  5820. this.element
  5821. .removeClass( "ui-autocomplete-input" )
  5822. .removeAttr( "autocomplete" );
  5823. this.menu.element.remove();
  5824. this.liveRegion.remove();
  5825. },
  5826. _setOption: function( key, value ) {
  5827. this._super( key, value );
  5828. if ( key === "source" ) {
  5829. this._initSource();
  5830. }
  5831. if ( key === "appendTo" ) {
  5832. this.menu.element.appendTo( this._appendTo() );
  5833. }
  5834. if ( key === "disabled" && value && this.xhr ) {
  5835. this.xhr.abort();
  5836. }
  5837. },
  5838. _appendTo: function() {
  5839. var element = this.options.appendTo;
  5840. if ( element ) {
  5841. element = element.jquery || element.nodeType ?
  5842. $( element ) :
  5843. this.document.find( element ).eq( 0 );
  5844. }
  5845. if ( !element ) {
  5846. element = this.element.closest( ".ui-front" );
  5847. }
  5848. if ( !element.length ) {
  5849. element = this.document[0].body;
  5850. }
  5851. return element;
  5852. },
  5853. _initSource: function() {
  5854. var array, url,
  5855. that = this;
  5856. if ( $.isArray(this.options.source) ) {
  5857. array = this.options.source;
  5858. this.source = function( request, response ) {
  5859. response( $.ui.autocomplete.filter( array, request.term ) );
  5860. };
  5861. } else if ( typeof this.options.source === "string" ) {
  5862. url = this.options.source;
  5863. this.source = function( request, response ) {
  5864. if ( that.xhr ) {
  5865. that.xhr.abort();
  5866. }
  5867. that.xhr = $.ajax({
  5868. url: url,
  5869. data: request,
  5870. dataType: "json",
  5871. success: function( data ) {
  5872. response( data );
  5873. },
  5874. error: function() {
  5875. response( [] );
  5876. }
  5877. });
  5878. };
  5879. } else {
  5880. this.source = this.options.source;
  5881. }
  5882. },
  5883. _searchTimeout: function( event ) {
  5884. clearTimeout( this.searching );
  5885. this.searching = this._delay(function() {
  5886. // only search if the value has changed
  5887. if ( this.term !== this._value() ) {
  5888. this.selectedItem = null;
  5889. this.search( null, event );
  5890. }
  5891. }, this.options.delay );
  5892. },
  5893. search: function( value, event ) {
  5894. value = value != null ? value : this._value();
  5895. // always save the actual value, not the one passed as an argument
  5896. this.term = this._value();
  5897. if ( value.length < this.options.minLength ) {
  5898. return this.close( event );
  5899. }
  5900. if ( this._trigger( "search", event ) === false ) {
  5901. return;
  5902. }
  5903. return this._search( value );
  5904. },
  5905. _search: function( value ) {
  5906. this.pending++;
  5907. this.element.addClass( "ui-autocomplete-loading" );
  5908. this.cancelSearch = false;
  5909. this.source( { term: value }, this._response() );
  5910. },
  5911. _response: function() {
  5912. var index = ++this.requestIndex;
  5913. return $.proxy(function( content ) {
  5914. if ( index === this.requestIndex ) {
  5915. this.__response( content );
  5916. }
  5917. this.pending--;
  5918. if ( !this.pending ) {
  5919. this.element.removeClass( "ui-autocomplete-loading" );
  5920. }
  5921. }, this );
  5922. },
  5923. __response: function( content ) {
  5924. if ( content ) {
  5925. content = this._normalize( content );
  5926. }
  5927. this._trigger( "response", null, { content: content } );
  5928. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  5929. this._suggest( content );
  5930. this._trigger( "open" );
  5931. } else {
  5932. // use ._close() instead of .close() so we don't cancel future searches
  5933. this._close();
  5934. }
  5935. },
  5936. close: function( event ) {
  5937. this.cancelSearch = true;
  5938. this._close( event );
  5939. },
  5940. _close: function( event ) {
  5941. if ( this.menu.element.is( ":visible" ) ) {
  5942. this.menu.element.hide();
  5943. this.menu.blur();
  5944. this.isNewMenu = true;
  5945. this._trigger( "close", event );
  5946. }
  5947. },
  5948. _change: function( event ) {
  5949. if ( this.previous !== this._value() ) {
  5950. this._trigger( "change", event, { item: this.selectedItem } );
  5951. }
  5952. },
  5953. _normalize: function( items ) {
  5954. // assume all items have the right format when the first item is complete
  5955. if ( items.length && items[0].label && items[0].value ) {
  5956. return items;
  5957. }
  5958. return $.map( items, function( item ) {
  5959. if ( typeof item === "string" ) {
  5960. return {
  5961. label: item,
  5962. value: item
  5963. };
  5964. }
  5965. return $.extend({
  5966. label: item.label || item.value,
  5967. value: item.value || item.label
  5968. }, item );
  5969. });
  5970. },
  5971. _suggest: function( items ) {
  5972. var ul = this.menu.element.empty();
  5973. this._renderMenu( ul, items );
  5974. this.isNewMenu = true;
  5975. this.menu.refresh();
  5976. // size and position menu
  5977. ul.show();
  5978. this._resizeMenu();
  5979. ul.position( $.extend({
  5980. of: this.element
  5981. }, this.options.position ));
  5982. if ( this.options.autoFocus ) {
  5983. this.menu.next();
  5984. }
  5985. },
  5986. _resizeMenu: function() {
  5987. var ul = this.menu.element;
  5988. ul.outerWidth( Math.max(
  5989. // Firefox wraps long text (possibly a rounding bug)
  5990. // so we add 1px to avoid the wrapping (#7513)
  5991. ul.width( "" ).outerWidth() + 1,
  5992. this.element.outerWidth()
  5993. ) );
  5994. },
  5995. _renderMenu: function( ul, items ) {
  5996. var that = this;
  5997. $.each( items, function( index, item ) {
  5998. that._renderItemData( ul, item );
  5999. });
  6000. },
  6001. _renderItemData: function( ul, item ) {
  6002. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  6003. },
  6004. _renderItem: function( ul, item ) {
  6005. return $( "<li>" )
  6006. .append( $( "<a>" ).text( item.label ) )
  6007. .appendTo( ul );
  6008. },
  6009. _move: function( direction, event ) {
  6010. if ( !this.menu.element.is( ":visible" ) ) {
  6011. this.search( null, event );
  6012. return;
  6013. }
  6014. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  6015. this.menu.isLastItem() && /^next/.test( direction ) ) {
  6016. this._value( this.term );
  6017. this.menu.blur();
  6018. return;
  6019. }
  6020. this.menu[ direction ]( event );
  6021. },
  6022. widget: function() {
  6023. return this.menu.element;
  6024. },
  6025. _value: function() {
  6026. return this.valueMethod.apply( this.element, arguments );
  6027. },
  6028. _keyEvent: function( keyEvent, event ) {
  6029. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  6030. this._move( keyEvent, event );
  6031. // prevents moving cursor to beginning/end of the text field in some browsers
  6032. event.preventDefault();
  6033. }
  6034. }
  6035. });
  6036. $.extend( $.ui.autocomplete, {
  6037. escapeRegex: function( value ) {
  6038. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  6039. },
  6040. filter: function(array, term) {
  6041. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  6042. return $.grep( array, function(value) {
  6043. return matcher.test( value.label || value.value || value );
  6044. });
  6045. }
  6046. });
  6047. // live region extension, adding a `messages` option
  6048. // NOTE: This is an experimental API. We are still investigating
  6049. // a full solution for string manipulation and internationalization.
  6050. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  6051. options: {
  6052. messages: {
  6053. noResults: "No search results.",
  6054. results: function( amount ) {
  6055. return amount + ( amount > 1 ? " results are" : " result is" ) +
  6056. " available, use up and down arrow keys to navigate.";
  6057. }
  6058. }
  6059. },
  6060. __response: function( content ) {
  6061. var message;
  6062. this._superApply( arguments );
  6063. if ( this.options.disabled || this.cancelSearch ) {
  6064. return;
  6065. }
  6066. if ( content && content.length ) {
  6067. message = this.options.messages.results( content.length );
  6068. } else {
  6069. message = this.options.messages.noResults;
  6070. }
  6071. this.liveRegion.text( message );
  6072. }
  6073. });
  6074. }( jQuery ));
  6075. (function( $, undefined ) {
  6076. var lastActive,
  6077. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  6078. 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",
  6079. formResetHandler = function() {
  6080. var form = $( this );
  6081. setTimeout(function() {
  6082. form.find( ":ui-button" ).button( "refresh" );
  6083. }, 1 );
  6084. },
  6085. radioGroup = function( radio ) {
  6086. var name = radio.name,
  6087. form = radio.form,
  6088. radios = $( [] );
  6089. if ( name ) {
  6090. name = name.replace( /'/g, "\\'" );
  6091. if ( form ) {
  6092. radios = $( form ).find( "[name='" + name + "']" );
  6093. } else {
  6094. radios = $( "[name='" + name + "']", radio.ownerDocument )
  6095. .filter(function() {
  6096. return !this.form;
  6097. });
  6098. }
  6099. }
  6100. return radios;
  6101. };
  6102. $.widget( "ui.button", {
  6103. version: "1.10.4",
  6104. defaultElement: "<button>",
  6105. options: {
  6106. disabled: null,
  6107. text: true,
  6108. label: null,
  6109. icons: {
  6110. primary: null,
  6111. secondary: null
  6112. }
  6113. },
  6114. _create: function() {
  6115. this.element.closest( "form" )
  6116. .unbind( "reset" + this.eventNamespace )
  6117. .bind( "reset" + this.eventNamespace, formResetHandler );
  6118. if ( typeof this.options.disabled !== "boolean" ) {
  6119. this.options.disabled = !!this.element.prop( "disabled" );
  6120. } else {
  6121. this.element.prop( "disabled", this.options.disabled );
  6122. }
  6123. this._determineButtonType();
  6124. this.hasTitle = !!this.buttonElement.attr( "title" );
  6125. var that = this,
  6126. options = this.options,
  6127. toggleButton = this.type === "checkbox" || this.type === "radio",
  6128. activeClass = !toggleButton ? "ui-state-active" : "";
  6129. if ( options.label === null ) {
  6130. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  6131. }
  6132. this._hoverable( this.buttonElement );
  6133. this.buttonElement
  6134. .addClass( baseClasses )
  6135. .attr( "role", "button" )
  6136. .bind( "mouseenter" + this.eventNamespace, function() {
  6137. if ( options.disabled ) {
  6138. return;
  6139. }
  6140. if ( this === lastActive ) {
  6141. $( this ).addClass( "ui-state-active" );
  6142. }
  6143. })
  6144. .bind( "mouseleave" + this.eventNamespace, function() {
  6145. if ( options.disabled ) {
  6146. return;
  6147. }
  6148. $( this ).removeClass( activeClass );
  6149. })
  6150. .bind( "click" + this.eventNamespace, function( event ) {
  6151. if ( options.disabled ) {
  6152. event.preventDefault();
  6153. event.stopImmediatePropagation();
  6154. }
  6155. });
  6156. // Can't use _focusable() because the element that receives focus
  6157. // and the element that gets the ui-state-focus class are different
  6158. this._on({
  6159. focus: function() {
  6160. this.buttonElement.addClass( "ui-state-focus" );
  6161. },
  6162. blur: function() {
  6163. this.buttonElement.removeClass( "ui-state-focus" );
  6164. }
  6165. });
  6166. if ( toggleButton ) {
  6167. this.element.bind( "change" + this.eventNamespace, function() {
  6168. that.refresh();
  6169. });
  6170. }
  6171. if ( this.type === "checkbox" ) {
  6172. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6173. if ( options.disabled ) {
  6174. return false;
  6175. }
  6176. });
  6177. } else if ( this.type === "radio" ) {
  6178. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6179. if ( options.disabled ) {
  6180. return false;
  6181. }
  6182. $( this ).addClass( "ui-state-active" );
  6183. that.buttonElement.attr( "aria-pressed", "true" );
  6184. var radio = that.element[ 0 ];
  6185. radioGroup( radio )
  6186. .not( radio )
  6187. .map(function() {
  6188. return $( this ).button( "widget" )[ 0 ];
  6189. })
  6190. .removeClass( "ui-state-active" )
  6191. .attr( "aria-pressed", "false" );
  6192. });
  6193. } else {
  6194. this.buttonElement
  6195. .bind( "mousedown" + this.eventNamespace, function() {
  6196. if ( options.disabled ) {
  6197. return false;
  6198. }
  6199. $( this ).addClass( "ui-state-active" );
  6200. lastActive = this;
  6201. that.document.one( "mouseup", function() {
  6202. lastActive = null;
  6203. });
  6204. })
  6205. .bind( "mouseup" + this.eventNamespace, function() {
  6206. if ( options.disabled ) {
  6207. return false;
  6208. }
  6209. $( this ).removeClass( "ui-state-active" );
  6210. })
  6211. .bind( "keydown" + this.eventNamespace, function(event) {
  6212. if ( options.disabled ) {
  6213. return false;
  6214. }
  6215. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  6216. $( this ).addClass( "ui-state-active" );
  6217. }
  6218. })
  6219. // see #8559, we bind to blur here in case the button element loses
  6220. // focus between keydown and keyup, it would be left in an "active" state
  6221. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  6222. $( this ).removeClass( "ui-state-active" );
  6223. });
  6224. if ( this.buttonElement.is("a") ) {
  6225. this.buttonElement.keyup(function(event) {
  6226. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  6227. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  6228. $( this ).click();
  6229. }
  6230. });
  6231. }
  6232. }
  6233. // TODO: pull out $.Widget's handling for the disabled option into
  6234. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  6235. // be overridden by individual plugins
  6236. this._setOption( "disabled", options.disabled );
  6237. this._resetButton();
  6238. },
  6239. _determineButtonType: function() {
  6240. var ancestor, labelSelector, checked;
  6241. if ( this.element.is("[type=checkbox]") ) {
  6242. this.type = "checkbox";
  6243. } else if ( this.element.is("[type=radio]") ) {
  6244. this.type = "radio";
  6245. } else if ( this.element.is("input") ) {
  6246. this.type = "input";
  6247. } else {
  6248. this.type = "button";
  6249. }
  6250. if ( this.type === "checkbox" || this.type === "radio" ) {
  6251. // we don't search against the document in case the element
  6252. // is disconnected from the DOM
  6253. ancestor = this.element.parents().last();
  6254. labelSelector = "label[for='" + this.element.attr("id") + "']";
  6255. this.buttonElement = ancestor.find( labelSelector );
  6256. if ( !this.buttonElement.length ) {
  6257. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  6258. this.buttonElement = ancestor.filter( labelSelector );
  6259. if ( !this.buttonElement.length ) {
  6260. this.buttonElement = ancestor.find( labelSelector );
  6261. }
  6262. }
  6263. this.element.addClass( "ui-helper-hidden-accessible" );
  6264. checked = this.element.is( ":checked" );
  6265. if ( checked ) {
  6266. this.buttonElement.addClass( "ui-state-active" );
  6267. }
  6268. this.buttonElement.prop( "aria-pressed", checked );
  6269. } else {
  6270. this.buttonElement = this.element;
  6271. }
  6272. },
  6273. widget: function() {
  6274. return this.buttonElement;
  6275. },
  6276. _destroy: function() {
  6277. this.element
  6278. .removeClass( "ui-helper-hidden-accessible" );
  6279. this.buttonElement
  6280. .removeClass( baseClasses + " ui-state-active " + typeClasses )
  6281. .removeAttr( "role" )
  6282. .removeAttr( "aria-pressed" )
  6283. .html( this.buttonElement.find(".ui-button-text").html() );
  6284. if ( !this.hasTitle ) {
  6285. this.buttonElement.removeAttr( "title" );
  6286. }
  6287. },
  6288. _setOption: function( key, value ) {
  6289. this._super( key, value );
  6290. if ( key === "disabled" ) {
  6291. this.element.prop( "disabled", !!value );
  6292. if ( value ) {
  6293. this.buttonElement.removeClass( "ui-state-focus" );
  6294. }
  6295. return;
  6296. }
  6297. this._resetButton();
  6298. },
  6299. refresh: function() {
  6300. //See #8237 & #8828
  6301. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  6302. if ( isDisabled !== this.options.disabled ) {
  6303. this._setOption( "disabled", isDisabled );
  6304. }
  6305. if ( this.type === "radio" ) {
  6306. radioGroup( this.element[0] ).each(function() {
  6307. if ( $( this ).is( ":checked" ) ) {
  6308. $( this ).button( "widget" )
  6309. .addClass( "ui-state-active" )
  6310. .attr( "aria-pressed", "true" );
  6311. } else {
  6312. $( this ).button( "widget" )
  6313. .removeClass( "ui-state-active" )
  6314. .attr( "aria-pressed", "false" );
  6315. }
  6316. });
  6317. } else if ( this.type === "checkbox" ) {
  6318. if ( this.element.is( ":checked" ) ) {
  6319. this.buttonElement
  6320. .addClass( "ui-state-active" )
  6321. .attr( "aria-pressed", "true" );
  6322. } else {
  6323. this.buttonElement
  6324. .removeClass( "ui-state-active" )
  6325. .attr( "aria-pressed", "false" );
  6326. }
  6327. }
  6328. },
  6329. _resetButton: function() {
  6330. if ( this.type === "input" ) {
  6331. if ( this.options.label ) {
  6332. this.element.val( this.options.label );
  6333. }
  6334. return;
  6335. }
  6336. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  6337. buttonText = $( "<span></span>", this.document[0] )
  6338. .addClass( "ui-button-text" )
  6339. .html( this.options.label )
  6340. .appendTo( buttonElement.empty() )
  6341. .text(),
  6342. icons = this.options.icons,
  6343. multipleIcons = icons.primary && icons.secondary,
  6344. buttonClasses = [];
  6345. if ( icons.primary || icons.secondary ) {
  6346. if ( this.options.text ) {
  6347. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  6348. }
  6349. if ( icons.primary ) {
  6350. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  6351. }
  6352. if ( icons.secondary ) {
  6353. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  6354. }
  6355. if ( !this.options.text ) {
  6356. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  6357. if ( !this.hasTitle ) {
  6358. buttonElement.attr( "title", $.trim( buttonText ) );
  6359. }
  6360. }
  6361. } else {
  6362. buttonClasses.push( "ui-button-text-only" );
  6363. }
  6364. buttonElement.addClass( buttonClasses.join( " " ) );
  6365. }
  6366. });
  6367. $.widget( "ui.buttonset", {
  6368. version: "1.10.4",
  6369. options: {
  6370. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  6371. },
  6372. _create: function() {
  6373. this.element.addClass( "ui-buttonset" );
  6374. },
  6375. _init: function() {
  6376. this.refresh();
  6377. },
  6378. _setOption: function( key, value ) {
  6379. if ( key === "disabled" ) {
  6380. this.buttons.button( "option", key, value );
  6381. }
  6382. this._super( key, value );
  6383. },
  6384. refresh: function() {
  6385. var rtl = this.element.css( "direction" ) === "rtl";
  6386. this.buttons = this.element.find( this.options.items )
  6387. .filter( ":ui-button" )
  6388. .button( "refresh" )
  6389. .end()
  6390. .not( ":ui-button" )
  6391. .button()
  6392. .end()
  6393. .map(function() {
  6394. return $( this ).button( "widget" )[ 0 ];
  6395. })
  6396. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  6397. .filter( ":first" )
  6398. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  6399. .end()
  6400. .filter( ":last" )
  6401. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  6402. .end()
  6403. .end();
  6404. },
  6405. _destroy: function() {
  6406. this.element.removeClass( "ui-buttonset" );
  6407. this.buttons
  6408. .map(function() {
  6409. return $( this ).button( "widget" )[ 0 ];
  6410. })
  6411. .removeClass( "ui-corner-left ui-corner-right" )
  6412. .end()
  6413. .button( "destroy" );
  6414. }
  6415. });
  6416. }( jQuery ) );
  6417. (function( $, undefined ) {
  6418. $.extend($.ui, { datepicker: { version: "1.10.4" } });
  6419. var PROP_NAME = "datepicker",
  6420. instActive;
  6421. /* Date picker manager.
  6422. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6423. Settings for (groups of) date pickers are maintained in an instance object,
  6424. allowing multiple different settings on the same page. */
  6425. function Datepicker() {
  6426. this._curInst = null; // The current instance in use
  6427. this._keyEvent = false; // If the last event was a key event
  6428. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6429. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6430. this._inDialog = false; // True if showing within a "dialog", false if not
  6431. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  6432. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  6433. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  6434. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  6435. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  6436. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  6437. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  6438. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  6439. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  6440. this.regional = []; // Available regional settings, indexed by language code
  6441. this.regional[""] = { // Default regional settings
  6442. closeText: "Done", // Display text for close link
  6443. prevText: "Prev", // Display text for previous month link
  6444. nextText: "Next", // Display text for next month link
  6445. currentText: "Today", // Display text for current month link
  6446. monthNames: ["January","February","March","April","May","June",
  6447. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  6448. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  6449. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  6450. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  6451. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  6452. weekHeader: "Wk", // Column header for week of the year
  6453. dateFormat: "mm/dd/yy", // See format options on parseDate
  6454. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6455. isRTL: false, // True if right-to-left language, false if left-to-right
  6456. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6457. yearSuffix: "" // Additional text to append to the year in the month headers
  6458. };
  6459. this._defaults = { // Global defaults for all the date picker instances
  6460. showOn: "focus", // "focus" for popup on focus,
  6461. // "button" for trigger button, or "both" for either
  6462. showAnim: "fadeIn", // Name of jQuery animation for popup
  6463. showOptions: {}, // Options for enhanced animations
  6464. defaultDate: null, // Used when field is blank: actual date,
  6465. // +/-number for offset from today, null for today
  6466. appendText: "", // Display text following the input box, e.g. showing the format
  6467. buttonText: "...", // Text for trigger button
  6468. buttonImage: "", // URL for trigger button image
  6469. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6470. hideIfNoPrevNext: false, // True to hide next/previous month links
  6471. // if not applicable, false to just disable them
  6472. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6473. gotoCurrent: false, // True if today link goes back to current selection instead
  6474. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6475. changeYear: false, // True if year can be selected directly, false if only prev/next
  6476. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  6477. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6478. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6479. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6480. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6481. showWeek: false, // True to show week of the year, false to not show it
  6482. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6483. // takes a Date and returns the number of the week for it
  6484. shortYearCutoff: "+10", // Short year values < this are in the current century,
  6485. // > this are in the previous century,
  6486. // string value starting with "+" for current year + value
  6487. minDate: null, // The earliest selectable date, or null for no limit
  6488. maxDate: null, // The latest selectable date, or null for no limit
  6489. duration: "fast", // Duration of display/closure
  6490. beforeShowDay: null, // Function that takes a date and returns an array with
  6491. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  6492. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6493. beforeShow: null, // Function that takes an input field and
  6494. // returns a set of custom settings for the date picker
  6495. onSelect: null, // Define a callback function when a date is selected
  6496. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6497. onClose: null, // Define a callback function when the datepicker is closed
  6498. numberOfMonths: 1, // Number of months to show at a time
  6499. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6500. stepMonths: 1, // Number of months to step back/forward
  6501. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6502. altField: "", // Selector for an alternate field to store selected dates into
  6503. altFormat: "", // The date format to use for the alternate field
  6504. constrainInput: true, // The input is constrained by the current date format
  6505. showButtonPanel: false, // True to show button panel, false to not show it
  6506. autoSize: false, // True to size the input for the date format, false to leave as is
  6507. disabled: false // The initial disabled state
  6508. };
  6509. $.extend(this._defaults, this.regional[""]);
  6510. this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  6511. }
  6512. $.extend(Datepicker.prototype, {
  6513. /* Class name added to elements to indicate already configured with a date picker. */
  6514. markerClassName: "hasDatepicker",
  6515. //Keep track of the maximum number of rows displayed (see #7043)
  6516. maxRows: 4,
  6517. // TODO rename to "widget" when switching to widget factory
  6518. _widgetDatepicker: function() {
  6519. return this.dpDiv;
  6520. },
  6521. /* Override the default settings for all instances of the date picker.
  6522. * @param settings object - the new settings to use as defaults (anonymous object)
  6523. * @return the manager object
  6524. */
  6525. setDefaults: function(settings) {
  6526. extendRemove(this._defaults, settings || {});
  6527. return this;
  6528. },
  6529. /* Attach the date picker to a jQuery selection.
  6530. * @param target element - the target input field or division or span
  6531. * @param settings object - the new settings to use for this date picker instance (anonymous)
  6532. */
  6533. _attachDatepicker: function(target, settings) {
  6534. var nodeName, inline, inst;
  6535. nodeName = target.nodeName.toLowerCase();
  6536. inline = (nodeName === "div" || nodeName === "span");
  6537. if (!target.id) {
  6538. this.uuid += 1;
  6539. target.id = "dp" + this.uuid;
  6540. }
  6541. inst = this._newInst($(target), inline);
  6542. inst.settings = $.extend({}, settings || {});
  6543. if (nodeName === "input") {
  6544. this._connectDatepicker(target, inst);
  6545. } else if (inline) {
  6546. this._inlineDatepicker(target, inst);
  6547. }
  6548. },
  6549. /* Create a new instance object. */
  6550. _newInst: function(target, inline) {
  6551. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  6552. return {id: id, input: target, // associated target
  6553. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6554. drawMonth: 0, drawYear: 0, // month being drawn
  6555. inline: inline, // is datepicker inline or not
  6556. dpDiv: (!inline ? this.dpDiv : // presentation div
  6557. bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  6558. },
  6559. /* Attach the date picker to an input field. */
  6560. _connectDatepicker: function(target, inst) {
  6561. var input = $(target);
  6562. inst.append = $([]);
  6563. inst.trigger = $([]);
  6564. if (input.hasClass(this.markerClassName)) {
  6565. return;
  6566. }
  6567. this._attachments(input, inst);
  6568. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  6569. keypress(this._doKeyPress).keyup(this._doKeyUp);
  6570. this._autoSize(inst);
  6571. $.data(target, PROP_NAME, inst);
  6572. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  6573. if( inst.settings.disabled ) {
  6574. this._disableDatepicker( target );
  6575. }
  6576. },
  6577. /* Make attachments based on settings. */
  6578. _attachments: function(input, inst) {
  6579. var showOn, buttonText, buttonImage,
  6580. appendText = this._get(inst, "appendText"),
  6581. isRTL = this._get(inst, "isRTL");
  6582. if (inst.append) {
  6583. inst.append.remove();
  6584. }
  6585. if (appendText) {
  6586. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  6587. input[isRTL ? "before" : "after"](inst.append);
  6588. }
  6589. input.unbind("focus", this._showDatepicker);
  6590. if (inst.trigger) {
  6591. inst.trigger.remove();
  6592. }
  6593. showOn = this._get(inst, "showOn");
  6594. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  6595. input.focus(this._showDatepicker);
  6596. }
  6597. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  6598. buttonText = this._get(inst, "buttonText");
  6599. buttonImage = this._get(inst, "buttonImage");
  6600. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  6601. $("<img/>").addClass(this._triggerClass).
  6602. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  6603. $("<button type='button'></button>").addClass(this._triggerClass).
  6604. html(!buttonImage ? buttonText : $("<img/>").attr(
  6605. { src:buttonImage, alt:buttonText, title:buttonText })));
  6606. input[isRTL ? "before" : "after"](inst.trigger);
  6607. inst.trigger.click(function() {
  6608. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  6609. $.datepicker._hideDatepicker();
  6610. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  6611. $.datepicker._hideDatepicker();
  6612. $.datepicker._showDatepicker(input[0]);
  6613. } else {
  6614. $.datepicker._showDatepicker(input[0]);
  6615. }
  6616. return false;
  6617. });
  6618. }
  6619. },
  6620. /* Apply the maximum length for the date format. */
  6621. _autoSize: function(inst) {
  6622. if (this._get(inst, "autoSize") && !inst.inline) {
  6623. var findMax, max, maxI, i,
  6624. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  6625. dateFormat = this._get(inst, "dateFormat");
  6626. if (dateFormat.match(/[DM]/)) {
  6627. findMax = function(names) {
  6628. max = 0;
  6629. maxI = 0;
  6630. for (i = 0; i < names.length; i++) {
  6631. if (names[i].length > max) {
  6632. max = names[i].length;
  6633. maxI = i;
  6634. }
  6635. }
  6636. return maxI;
  6637. };
  6638. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  6639. "monthNames" : "monthNamesShort"))));
  6640. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  6641. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  6642. }
  6643. inst.input.attr("size", this._formatDate(inst, date).length);
  6644. }
  6645. },
  6646. /* Attach an inline date picker to a div. */
  6647. _inlineDatepicker: function(target, inst) {
  6648. var divSpan = $(target);
  6649. if (divSpan.hasClass(this.markerClassName)) {
  6650. return;
  6651. }
  6652. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  6653. $.data(target, PROP_NAME, inst);
  6654. this._setDate(inst, this._getDefaultDate(inst), true);
  6655. this._updateDatepicker(inst);
  6656. this._updateAlternate(inst);
  6657. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  6658. if( inst.settings.disabled ) {
  6659. this._disableDatepicker( target );
  6660. }
  6661. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  6662. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  6663. inst.dpDiv.css( "display", "block" );
  6664. },
  6665. /* Pop-up the date picker in a "dialog" box.
  6666. * @param input element - ignored
  6667. * @param date string or Date - the initial date to display
  6668. * @param onSelect function - the function to call when a date is selected
  6669. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  6670. * @param pos int[2] - coordinates for the dialog's position within the screen or
  6671. * event - with x/y coordinates or
  6672. * leave empty for default (screen centre)
  6673. * @return the manager object
  6674. */
  6675. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  6676. var id, browserWidth, browserHeight, scrollX, scrollY,
  6677. inst = this._dialogInst; // internal instance
  6678. if (!inst) {
  6679. this.uuid += 1;
  6680. id = "dp" + this.uuid;
  6681. this._dialogInput = $("<input type='text' id='" + id +
  6682. "' style='position: absolute; top: -100px; width: 0px;'/>");
  6683. this._dialogInput.keydown(this._doKeyDown);
  6684. $("body").append(this._dialogInput);
  6685. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  6686. inst.settings = {};
  6687. $.data(this._dialogInput[0], PROP_NAME, inst);
  6688. }
  6689. extendRemove(inst.settings, settings || {});
  6690. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  6691. this._dialogInput.val(date);
  6692. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  6693. if (!this._pos) {
  6694. browserWidth = document.documentElement.clientWidth;
  6695. browserHeight = document.documentElement.clientHeight;
  6696. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  6697. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  6698. this._pos = // should use actual width/height below
  6699. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  6700. }
  6701. // move input on screen for focus, but hidden behind dialog
  6702. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  6703. inst.settings.onSelect = onSelect;
  6704. this._inDialog = true;
  6705. this.dpDiv.addClass(this._dialogClass);
  6706. this._showDatepicker(this._dialogInput[0]);
  6707. if ($.blockUI) {
  6708. $.blockUI(this.dpDiv);
  6709. }
  6710. $.data(this._dialogInput[0], PROP_NAME, inst);
  6711. return this;
  6712. },
  6713. /* Detach a datepicker from its control.
  6714. * @param target element - the target input field or division or span
  6715. */
  6716. _destroyDatepicker: function(target) {
  6717. var nodeName,
  6718. $target = $(target),
  6719. inst = $.data(target, PROP_NAME);
  6720. if (!$target.hasClass(this.markerClassName)) {
  6721. return;
  6722. }
  6723. nodeName = target.nodeName.toLowerCase();
  6724. $.removeData(target, PROP_NAME);
  6725. if (nodeName === "input") {
  6726. inst.append.remove();
  6727. inst.trigger.remove();
  6728. $target.removeClass(this.markerClassName).
  6729. unbind("focus", this._showDatepicker).
  6730. unbind("keydown", this._doKeyDown).
  6731. unbind("keypress", this._doKeyPress).
  6732. unbind("keyup", this._doKeyUp);
  6733. } else if (nodeName === "div" || nodeName === "span") {
  6734. $target.removeClass(this.markerClassName).empty();
  6735. }
  6736. },
  6737. /* Enable the date picker to a jQuery selection.
  6738. * @param target element - the target input field or division or span
  6739. */
  6740. _enableDatepicker: function(target) {
  6741. var nodeName, inline,
  6742. $target = $(target),
  6743. inst = $.data(target, PROP_NAME);
  6744. if (!$target.hasClass(this.markerClassName)) {
  6745. return;
  6746. }
  6747. nodeName = target.nodeName.toLowerCase();
  6748. if (nodeName === "input") {
  6749. target.disabled = false;
  6750. inst.trigger.filter("button").
  6751. each(function() { this.disabled = false; }).end().
  6752. filter("img").css({opacity: "1.0", cursor: ""});
  6753. } else if (nodeName === "div" || nodeName === "span") {
  6754. inline = $target.children("." + this._inlineClass);
  6755. inline.children().removeClass("ui-state-disabled");
  6756. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6757. prop("disabled", false);
  6758. }
  6759. this._disabledInputs = $.map(this._disabledInputs,
  6760. function(value) { return (value === target ? null : value); }); // delete entry
  6761. },
  6762. /* Disable the date picker to a jQuery selection.
  6763. * @param target element - the target input field or division or span
  6764. */
  6765. _disableDatepicker: function(target) {
  6766. var nodeName, inline,
  6767. $target = $(target),
  6768. inst = $.data(target, PROP_NAME);
  6769. if (!$target.hasClass(this.markerClassName)) {
  6770. return;
  6771. }
  6772. nodeName = target.nodeName.toLowerCase();
  6773. if (nodeName === "input") {
  6774. target.disabled = true;
  6775. inst.trigger.filter("button").
  6776. each(function() { this.disabled = true; }).end().
  6777. filter("img").css({opacity: "0.5", cursor: "default"});
  6778. } else if (nodeName === "div" || nodeName === "span") {
  6779. inline = $target.children("." + this._inlineClass);
  6780. inline.children().addClass("ui-state-disabled");
  6781. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6782. prop("disabled", true);
  6783. }
  6784. this._disabledInputs = $.map(this._disabledInputs,
  6785. function(value) { return (value === target ? null : value); }); // delete entry
  6786. this._disabledInputs[this._disabledInputs.length] = target;
  6787. },
  6788. /* Is the first field in a jQuery collection disabled as a datepicker?
  6789. * @param target element - the target input field or division or span
  6790. * @return boolean - true if disabled, false if enabled
  6791. */
  6792. _isDisabledDatepicker: function(target) {
  6793. if (!target) {
  6794. return false;
  6795. }
  6796. for (var i = 0; i < this._disabledInputs.length; i++) {
  6797. if (this._disabledInputs[i] === target) {
  6798. return true;
  6799. }
  6800. }
  6801. return false;
  6802. },
  6803. /* Retrieve the instance data for the target control.
  6804. * @param target element - the target input field or division or span
  6805. * @return object - the associated instance data
  6806. * @throws error if a jQuery problem getting data
  6807. */
  6808. _getInst: function(target) {
  6809. try {
  6810. return $.data(target, PROP_NAME);
  6811. }
  6812. catch (err) {
  6813. throw "Missing instance data for this datepicker";
  6814. }
  6815. },
  6816. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6817. * @param target element - the target input field or division or span
  6818. * @param name object - the new settings to update or
  6819. * string - the name of the setting to change or retrieve,
  6820. * when retrieving also "all" for all instance settings or
  6821. * "defaults" for all global defaults
  6822. * @param value any - the new value for the setting
  6823. * (omit if above is an object or to retrieve a value)
  6824. */
  6825. _optionDatepicker: function(target, name, value) {
  6826. var settings, date, minDate, maxDate,
  6827. inst = this._getInst(target);
  6828. if (arguments.length === 2 && typeof name === "string") {
  6829. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  6830. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  6831. this._get(inst, name)) : null));
  6832. }
  6833. settings = name || {};
  6834. if (typeof name === "string") {
  6835. settings = {};
  6836. settings[name] = value;
  6837. }
  6838. if (inst) {
  6839. if (this._curInst === inst) {
  6840. this._hideDatepicker();
  6841. }
  6842. date = this._getDateDatepicker(target, true);
  6843. minDate = this._getMinMaxDate(inst, "min");
  6844. maxDate = this._getMinMaxDate(inst, "max");
  6845. extendRemove(inst.settings, settings);
  6846. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6847. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  6848. inst.settings.minDate = this._formatDate(inst, minDate);
  6849. }
  6850. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  6851. inst.settings.maxDate = this._formatDate(inst, maxDate);
  6852. }
  6853. if ( "disabled" in settings ) {
  6854. if ( settings.disabled ) {
  6855. this._disableDatepicker(target);
  6856. } else {
  6857. this._enableDatepicker(target);
  6858. }
  6859. }
  6860. this._attachments($(target), inst);
  6861. this._autoSize(inst);
  6862. this._setDate(inst, date);
  6863. this._updateAlternate(inst);
  6864. this._updateDatepicker(inst);
  6865. }
  6866. },
  6867. // change method deprecated
  6868. _changeDatepicker: function(target, name, value) {
  6869. this._optionDatepicker(target, name, value);
  6870. },
  6871. /* Redraw the date picker attached to an input field or division.
  6872. * @param target element - the target input field or division or span
  6873. */
  6874. _refreshDatepicker: function(target) {
  6875. var inst = this._getInst(target);
  6876. if (inst) {
  6877. this._updateDatepicker(inst);
  6878. }
  6879. },
  6880. /* Set the dates for a jQuery selection.
  6881. * @param target element - the target input field or division or span
  6882. * @param date Date - the new date
  6883. */
  6884. _setDateDatepicker: function(target, date) {
  6885. var inst = this._getInst(target);
  6886. if (inst) {
  6887. this._setDate(inst, date);
  6888. this._updateDatepicker(inst);
  6889. this._updateAlternate(inst);
  6890. }
  6891. },
  6892. /* Get the date(s) for the first entry in a jQuery selection.
  6893. * @param target element - the target input field or division or span
  6894. * @param noDefault boolean - true if no default date is to be used
  6895. * @return Date - the current date
  6896. */
  6897. _getDateDatepicker: function(target, noDefault) {
  6898. var inst = this._getInst(target);
  6899. if (inst && !inst.inline) {
  6900. this._setDateFromField(inst, noDefault);
  6901. }
  6902. return (inst ? this._getDate(inst) : null);
  6903. },
  6904. /* Handle keystrokes. */
  6905. _doKeyDown: function(event) {
  6906. var onSelect, dateStr, sel,
  6907. inst = $.datepicker._getInst(event.target),
  6908. handled = true,
  6909. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  6910. inst._keyEvent = true;
  6911. if ($.datepicker._datepickerShowing) {
  6912. switch (event.keyCode) {
  6913. case 9: $.datepicker._hideDatepicker();
  6914. handled = false;
  6915. break; // hide on tab out
  6916. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  6917. $.datepicker._currentClass + ")", inst.dpDiv);
  6918. if (sel[0]) {
  6919. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  6920. }
  6921. onSelect = $.datepicker._get(inst, "onSelect");
  6922. if (onSelect) {
  6923. dateStr = $.datepicker._formatDate(inst);
  6924. // trigger custom callback
  6925. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  6926. } else {
  6927. $.datepicker._hideDatepicker();
  6928. }
  6929. return false; // don't submit the form
  6930. case 27: $.datepicker._hideDatepicker();
  6931. break; // hide on escape
  6932. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6933. -$.datepicker._get(inst, "stepBigMonths") :
  6934. -$.datepicker._get(inst, "stepMonths")), "M");
  6935. break; // previous month/year on page up/+ ctrl
  6936. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6937. +$.datepicker._get(inst, "stepBigMonths") :
  6938. +$.datepicker._get(inst, "stepMonths")), "M");
  6939. break; // next month/year on page down/+ ctrl
  6940. case 35: if (event.ctrlKey || event.metaKey) {
  6941. $.datepicker._clearDate(event.target);
  6942. }
  6943. handled = event.ctrlKey || event.metaKey;
  6944. break; // clear on ctrl or command +end
  6945. case 36: if (event.ctrlKey || event.metaKey) {
  6946. $.datepicker._gotoToday(event.target);
  6947. }
  6948. handled = event.ctrlKey || event.metaKey;
  6949. break; // current on ctrl or command +home
  6950. case 37: if (event.ctrlKey || event.metaKey) {
  6951. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  6952. }
  6953. handled = event.ctrlKey || event.metaKey;
  6954. // -1 day on ctrl or command +left
  6955. if (event.originalEvent.altKey) {
  6956. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6957. -$.datepicker._get(inst, "stepBigMonths") :
  6958. -$.datepicker._get(inst, "stepMonths")), "M");
  6959. }
  6960. // next month/year on alt +left on Mac
  6961. break;
  6962. case 38: if (event.ctrlKey || event.metaKey) {
  6963. $.datepicker._adjustDate(event.target, -7, "D");
  6964. }
  6965. handled = event.ctrlKey || event.metaKey;
  6966. break; // -1 week on ctrl or command +up
  6967. case 39: if (event.ctrlKey || event.metaKey) {
  6968. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  6969. }
  6970. handled = event.ctrlKey || event.metaKey;
  6971. // +1 day on ctrl or command +right
  6972. if (event.originalEvent.altKey) {
  6973. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6974. +$.datepicker._get(inst, "stepBigMonths") :
  6975. +$.datepicker._get(inst, "stepMonths")), "M");
  6976. }
  6977. // next month/year on alt +right
  6978. break;
  6979. case 40: if (event.ctrlKey || event.metaKey) {
  6980. $.datepicker._adjustDate(event.target, +7, "D");
  6981. }
  6982. handled = event.ctrlKey || event.metaKey;
  6983. break; // +1 week on ctrl or command +down
  6984. default: handled = false;
  6985. }
  6986. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  6987. $.datepicker._showDatepicker(this);
  6988. } else {
  6989. handled = false;
  6990. }
  6991. if (handled) {
  6992. event.preventDefault();
  6993. event.stopPropagation();
  6994. }
  6995. },
  6996. /* Filter entered characters - based on date format. */
  6997. _doKeyPress: function(event) {
  6998. var chars, chr,
  6999. inst = $.datepicker._getInst(event.target);
  7000. if ($.datepicker._get(inst, "constrainInput")) {
  7001. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  7002. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  7003. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  7004. }
  7005. },
  7006. /* Synchronise manual entry and field/alternate field. */
  7007. _doKeyUp: function(event) {
  7008. var date,
  7009. inst = $.datepicker._getInst(event.target);
  7010. if (inst.input.val() !== inst.lastVal) {
  7011. try {
  7012. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7013. (inst.input ? inst.input.val() : null),
  7014. $.datepicker._getFormatConfig(inst));
  7015. if (date) { // only if valid
  7016. $.datepicker._setDateFromField(inst);
  7017. $.datepicker._updateAlternate(inst);
  7018. $.datepicker._updateDatepicker(inst);
  7019. }
  7020. }
  7021. catch (err) {
  7022. }
  7023. }
  7024. return true;
  7025. },
  7026. /* Pop-up the date picker for a given input field.
  7027. * If false returned from beforeShow event handler do not show.
  7028. * @param input element - the input field attached to the date picker or
  7029. * event - if triggered by focus
  7030. */
  7031. _showDatepicker: function(input) {
  7032. input = input.target || input;
  7033. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  7034. input = $("input", input.parentNode)[0];
  7035. }
  7036. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  7037. return;
  7038. }
  7039. var inst, beforeShow, beforeShowSettings, isFixed,
  7040. offset, showAnim, duration;
  7041. inst = $.datepicker._getInst(input);
  7042. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  7043. $.datepicker._curInst.dpDiv.stop(true, true);
  7044. if ( inst && $.datepicker._datepickerShowing ) {
  7045. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  7046. }
  7047. }
  7048. beforeShow = $.datepicker._get(inst, "beforeShow");
  7049. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  7050. if(beforeShowSettings === false){
  7051. return;
  7052. }
  7053. extendRemove(inst.settings, beforeShowSettings);
  7054. inst.lastVal = null;
  7055. $.datepicker._lastInput = input;
  7056. $.datepicker._setDateFromField(inst);
  7057. if ($.datepicker._inDialog) { // hide cursor
  7058. input.value = "";
  7059. }
  7060. if (!$.datepicker._pos) { // position below input
  7061. $.datepicker._pos = $.datepicker._findPos(input);
  7062. $.datepicker._pos[1] += input.offsetHeight; // add the height
  7063. }
  7064. isFixed = false;
  7065. $(input).parents().each(function() {
  7066. isFixed |= $(this).css("position") === "fixed";
  7067. return !isFixed;
  7068. });
  7069. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  7070. $.datepicker._pos = null;
  7071. //to avoid flashes on Firefox
  7072. inst.dpDiv.empty();
  7073. // determine sizing offscreen
  7074. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  7075. $.datepicker._updateDatepicker(inst);
  7076. // fix width for dynamic number of date pickers
  7077. // and adjust position before showing
  7078. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  7079. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  7080. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  7081. left: offset.left + "px", top: offset.top + "px"});
  7082. if (!inst.inline) {
  7083. showAnim = $.datepicker._get(inst, "showAnim");
  7084. duration = $.datepicker._get(inst, "duration");
  7085. inst.dpDiv.zIndex($(input).zIndex()+1);
  7086. $.datepicker._datepickerShowing = true;
  7087. if ( $.effects && $.effects.effect[ showAnim ] ) {
  7088. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  7089. } else {
  7090. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  7091. }
  7092. if ( $.datepicker._shouldFocusInput( inst ) ) {
  7093. inst.input.focus();
  7094. }
  7095. $.datepicker._curInst = inst;
  7096. }
  7097. },
  7098. /* Generate the date picker content. */
  7099. _updateDatepicker: function(inst) {
  7100. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  7101. instActive = inst; // for delegate hover events
  7102. inst.dpDiv.empty().append(this._generateHTML(inst));
  7103. this._attachHandlers(inst);
  7104. inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
  7105. var origyearshtml,
  7106. numMonths = this._getNumberOfMonths(inst),
  7107. cols = numMonths[1],
  7108. width = 17;
  7109. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  7110. if (cols > 1) {
  7111. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  7112. }
  7113. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  7114. "Class"]("ui-datepicker-multi");
  7115. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  7116. "Class"]("ui-datepicker-rtl");
  7117. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  7118. inst.input.focus();
  7119. }
  7120. // deffered render of the years select (to avoid flashes on Firefox)
  7121. if( inst.yearshtml ){
  7122. origyearshtml = inst.yearshtml;
  7123. setTimeout(function(){
  7124. //assure that inst.yearshtml didn't change.
  7125. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  7126. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  7127. }
  7128. origyearshtml = inst.yearshtml = null;
  7129. }, 0);
  7130. }
  7131. },
  7132. // #6694 - don't focus the input if it's already focused
  7133. // this breaks the change event in IE
  7134. // Support: IE and jQuery <1.9
  7135. _shouldFocusInput: function( inst ) {
  7136. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  7137. },
  7138. /* Check positioning to remain on screen. */
  7139. _checkOffset: function(inst, offset, isFixed) {
  7140. var dpWidth = inst.dpDiv.outerWidth(),
  7141. dpHeight = inst.dpDiv.outerHeight(),
  7142. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  7143. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  7144. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  7145. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  7146. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  7147. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  7148. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  7149. // now check if datepicker is showing outside window viewport - move to a better place if so.
  7150. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  7151. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  7152. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  7153. Math.abs(dpHeight + inputHeight) : 0);
  7154. return offset;
  7155. },
  7156. /* Find an object's position on the screen. */
  7157. _findPos: function(obj) {
  7158. var position,
  7159. inst = this._getInst(obj),
  7160. isRTL = this._get(inst, "isRTL");
  7161. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  7162. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  7163. }
  7164. position = $(obj).offset();
  7165. return [position.left, position.top];
  7166. },
  7167. /* Hide the date picker from view.
  7168. * @param input element - the input field attached to the date picker
  7169. */
  7170. _hideDatepicker: function(input) {
  7171. var showAnim, duration, postProcess, onClose,
  7172. inst = this._curInst;
  7173. if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
  7174. return;
  7175. }
  7176. if (this._datepickerShowing) {
  7177. showAnim = this._get(inst, "showAnim");
  7178. duration = this._get(inst, "duration");
  7179. postProcess = function() {
  7180. $.datepicker._tidyDialog(inst);
  7181. };
  7182. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  7183. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  7184. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  7185. } else {
  7186. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  7187. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  7188. }
  7189. if (!showAnim) {
  7190. postProcess();
  7191. }
  7192. this._datepickerShowing = false;
  7193. onClose = this._get(inst, "onClose");
  7194. if (onClose) {
  7195. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  7196. }
  7197. this._lastInput = null;
  7198. if (this._inDialog) {
  7199. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  7200. if ($.blockUI) {
  7201. $.unblockUI();
  7202. $("body").append(this.dpDiv);
  7203. }
  7204. }
  7205. this._inDialog = false;
  7206. }
  7207. },
  7208. /* Tidy up after a dialog display. */
  7209. _tidyDialog: function(inst) {
  7210. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  7211. },
  7212. /* Close date picker if clicked elsewhere. */
  7213. _checkExternalClick: function(event) {
  7214. if (!$.datepicker._curInst) {
  7215. return;
  7216. }
  7217. var $target = $(event.target),
  7218. inst = $.datepicker._getInst($target[0]);
  7219. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  7220. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  7221. !$target.hasClass($.datepicker.markerClassName) &&
  7222. !$target.closest("." + $.datepicker._triggerClass).length &&
  7223. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  7224. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  7225. $.datepicker._hideDatepicker();
  7226. }
  7227. },
  7228. /* Adjust one of the date sub-fields. */
  7229. _adjustDate: function(id, offset, period) {
  7230. var target = $(id),
  7231. inst = this._getInst(target[0]);
  7232. if (this._isDisabledDatepicker(target[0])) {
  7233. return;
  7234. }
  7235. this._adjustInstDate(inst, offset +
  7236. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  7237. period);
  7238. this._updateDatepicker(inst);
  7239. },
  7240. /* Action for current link. */
  7241. _gotoToday: function(id) {
  7242. var date,
  7243. target = $(id),
  7244. inst = this._getInst(target[0]);
  7245. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  7246. inst.selectedDay = inst.currentDay;
  7247. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  7248. inst.drawYear = inst.selectedYear = inst.currentYear;
  7249. } else {
  7250. date = new Date();
  7251. inst.selectedDay = date.getDate();
  7252. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7253. inst.drawYear = inst.selectedYear = date.getFullYear();
  7254. }
  7255. this._notifyChange(inst);
  7256. this._adjustDate(target);
  7257. },
  7258. /* Action for selecting a new month/year. */
  7259. _selectMonthYear: function(id, select, period) {
  7260. var target = $(id),
  7261. inst = this._getInst(target[0]);
  7262. inst["selected" + (period === "M" ? "Month" : "Year")] =
  7263. inst["draw" + (period === "M" ? "Month" : "Year")] =
  7264. parseInt(select.options[select.selectedIndex].value,10);
  7265. this._notifyChange(inst);
  7266. this._adjustDate(target);
  7267. },
  7268. /* Action for selecting a day. */
  7269. _selectDay: function(id, month, year, td) {
  7270. var inst,
  7271. target = $(id);
  7272. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  7273. return;
  7274. }
  7275. inst = this._getInst(target[0]);
  7276. inst.selectedDay = inst.currentDay = $("a", td).html();
  7277. inst.selectedMonth = inst.currentMonth = month;
  7278. inst.selectedYear = inst.currentYear = year;
  7279. this._selectDate(id, this._formatDate(inst,
  7280. inst.currentDay, inst.currentMonth, inst.currentYear));
  7281. },
  7282. /* Erase the input field and hide the date picker. */
  7283. _clearDate: function(id) {
  7284. var target = $(id);
  7285. this._selectDate(target, "");
  7286. },
  7287. /* Update the input field with the selected date. */
  7288. _selectDate: function(id, dateStr) {
  7289. var onSelect,
  7290. target = $(id),
  7291. inst = this._getInst(target[0]);
  7292. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  7293. if (inst.input) {
  7294. inst.input.val(dateStr);
  7295. }
  7296. this._updateAlternate(inst);
  7297. onSelect = this._get(inst, "onSelect");
  7298. if (onSelect) {
  7299. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  7300. } else if (inst.input) {
  7301. inst.input.trigger("change"); // fire the change event
  7302. }
  7303. if (inst.inline){
  7304. this._updateDatepicker(inst);
  7305. } else {
  7306. this._hideDatepicker();
  7307. this._lastInput = inst.input[0];
  7308. if (typeof(inst.input[0]) !== "object") {
  7309. inst.input.focus(); // restore focus
  7310. }
  7311. this._lastInput = null;
  7312. }
  7313. },
  7314. /* Update any alternate field to synchronise with the main field. */
  7315. _updateAlternate: function(inst) {
  7316. var altFormat, date, dateStr,
  7317. altField = this._get(inst, "altField");
  7318. if (altField) { // update alternate field too
  7319. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  7320. date = this._getDate(inst);
  7321. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  7322. $(altField).each(function() { $(this).val(dateStr); });
  7323. }
  7324. },
  7325. /* Set as beforeShowDay function to prevent selection of weekends.
  7326. * @param date Date - the date to customise
  7327. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  7328. */
  7329. noWeekends: function(date) {
  7330. var day = date.getDay();
  7331. return [(day > 0 && day < 6), ""];
  7332. },
  7333. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  7334. * @param date Date - the date to get the week for
  7335. * @return number - the number of the week within the year that contains this date
  7336. */
  7337. iso8601Week: function(date) {
  7338. var time,
  7339. checkDate = new Date(date.getTime());
  7340. // Find Thursday of this week starting on Monday
  7341. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  7342. time = checkDate.getTime();
  7343. checkDate.setMonth(0); // Compare with Jan 1
  7344. checkDate.setDate(1);
  7345. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  7346. },
  7347. /* Parse a string value into a date object.
  7348. * See formatDate below for the possible formats.
  7349. *
  7350. * @param format string - the expected format of the date
  7351. * @param value string - the date in the above format
  7352. * @param settings Object - attributes include:
  7353. * shortYearCutoff number - the cutoff year for determining the century (optional)
  7354. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7355. * dayNames string[7] - names of the days from Sunday (optional)
  7356. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7357. * monthNames string[12] - names of the months (optional)
  7358. * @return Date - the extracted date value or null if value is blank
  7359. */
  7360. parseDate: function (format, value, settings) {
  7361. if (format == null || value == null) {
  7362. throw "Invalid arguments";
  7363. }
  7364. value = (typeof value === "object" ? value.toString() : value + "");
  7365. if (value === "") {
  7366. return null;
  7367. }
  7368. var iFormat, dim, extra,
  7369. iValue = 0,
  7370. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  7371. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  7372. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  7373. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7374. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7375. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7376. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7377. year = -1,
  7378. month = -1,
  7379. day = -1,
  7380. doy = -1,
  7381. literal = false,
  7382. date,
  7383. // Check whether a format character is doubled
  7384. lookAhead = function(match) {
  7385. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7386. if (matches) {
  7387. iFormat++;
  7388. }
  7389. return matches;
  7390. },
  7391. // Extract a number from the string value
  7392. getNumber = function(match) {
  7393. var isDoubled = lookAhead(match),
  7394. size = (match === "@" ? 14 : (match === "!" ? 20 :
  7395. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  7396. digits = new RegExp("^\\d{1," + size + "}"),
  7397. num = value.substring(iValue).match(digits);
  7398. if (!num) {
  7399. throw "Missing number at position " + iValue;
  7400. }
  7401. iValue += num[0].length;
  7402. return parseInt(num[0], 10);
  7403. },
  7404. // Extract a name from the string value and convert to an index
  7405. getName = function(match, shortNames, longNames) {
  7406. var index = -1,
  7407. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  7408. return [ [k, v] ];
  7409. }).sort(function (a, b) {
  7410. return -(a[1].length - b[1].length);
  7411. });
  7412. $.each(names, function (i, pair) {
  7413. var name = pair[1];
  7414. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  7415. index = pair[0];
  7416. iValue += name.length;
  7417. return false;
  7418. }
  7419. });
  7420. if (index !== -1) {
  7421. return index + 1;
  7422. } else {
  7423. throw "Unknown name at position " + iValue;
  7424. }
  7425. },
  7426. // Confirm that a literal character matches the string value
  7427. checkLiteral = function() {
  7428. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  7429. throw "Unexpected literal at position " + iValue;
  7430. }
  7431. iValue++;
  7432. };
  7433. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7434. if (literal) {
  7435. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7436. literal = false;
  7437. } else {
  7438. checkLiteral();
  7439. }
  7440. } else {
  7441. switch (format.charAt(iFormat)) {
  7442. case "d":
  7443. day = getNumber("d");
  7444. break;
  7445. case "D":
  7446. getName("D", dayNamesShort, dayNames);
  7447. break;
  7448. case "o":
  7449. doy = getNumber("o");
  7450. break;
  7451. case "m":
  7452. month = getNumber("m");
  7453. break;
  7454. case "M":
  7455. month = getName("M", monthNamesShort, monthNames);
  7456. break;
  7457. case "y":
  7458. year = getNumber("y");
  7459. break;
  7460. case "@":
  7461. date = new Date(getNumber("@"));
  7462. year = date.getFullYear();
  7463. month = date.getMonth() + 1;
  7464. day = date.getDate();
  7465. break;
  7466. case "!":
  7467. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  7468. year = date.getFullYear();
  7469. month = date.getMonth() + 1;
  7470. day = date.getDate();
  7471. break;
  7472. case "'":
  7473. if (lookAhead("'")){
  7474. checkLiteral();
  7475. } else {
  7476. literal = true;
  7477. }
  7478. break;
  7479. default:
  7480. checkLiteral();
  7481. }
  7482. }
  7483. }
  7484. if (iValue < value.length){
  7485. extra = value.substr(iValue);
  7486. if (!/^\s+/.test(extra)) {
  7487. throw "Extra/unparsed characters found in date: " + extra;
  7488. }
  7489. }
  7490. if (year === -1) {
  7491. year = new Date().getFullYear();
  7492. } else if (year < 100) {
  7493. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7494. (year <= shortYearCutoff ? 0 : -100);
  7495. }
  7496. if (doy > -1) {
  7497. month = 1;
  7498. day = doy;
  7499. do {
  7500. dim = this._getDaysInMonth(year, month - 1);
  7501. if (day <= dim) {
  7502. break;
  7503. }
  7504. month++;
  7505. day -= dim;
  7506. } while (true);
  7507. }
  7508. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  7509. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  7510. throw "Invalid date"; // E.g. 31/02/00
  7511. }
  7512. return date;
  7513. },
  7514. /* Standard date formats. */
  7515. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  7516. COOKIE: "D, dd M yy",
  7517. ISO_8601: "yy-mm-dd",
  7518. RFC_822: "D, d M y",
  7519. RFC_850: "DD, dd-M-y",
  7520. RFC_1036: "D, d M y",
  7521. RFC_1123: "D, d M yy",
  7522. RFC_2822: "D, d M yy",
  7523. RSS: "D, d M y", // RFC 822
  7524. TICKS: "!",
  7525. TIMESTAMP: "@",
  7526. W3C: "yy-mm-dd", // ISO 8601
  7527. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  7528. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  7529. /* Format a date object into a string value.
  7530. * The format can be combinations of the following:
  7531. * d - day of month (no leading zero)
  7532. * dd - day of month (two digit)
  7533. * o - day of year (no leading zeros)
  7534. * oo - day of year (three digit)
  7535. * D - day name short
  7536. * DD - day name long
  7537. * m - month of year (no leading zero)
  7538. * mm - month of year (two digit)
  7539. * M - month name short
  7540. * MM - month name long
  7541. * y - year (two digit)
  7542. * yy - year (four digit)
  7543. * @ - Unix timestamp (ms since 01/01/1970)
  7544. * ! - Windows ticks (100ns since 01/01/0001)
  7545. * "..." - literal text
  7546. * '' - single quote
  7547. *
  7548. * @param format string - the desired format of the date
  7549. * @param date Date - the date value to format
  7550. * @param settings Object - attributes include:
  7551. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7552. * dayNames string[7] - names of the days from Sunday (optional)
  7553. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7554. * monthNames string[12] - names of the months (optional)
  7555. * @return string - the date in the above format
  7556. */
  7557. formatDate: function (format, date, settings) {
  7558. if (!date) {
  7559. return "";
  7560. }
  7561. var iFormat,
  7562. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7563. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7564. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7565. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7566. // Check whether a format character is doubled
  7567. lookAhead = function(match) {
  7568. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7569. if (matches) {
  7570. iFormat++;
  7571. }
  7572. return matches;
  7573. },
  7574. // Format a number, with leading zero if necessary
  7575. formatNumber = function(match, value, len) {
  7576. var num = "" + value;
  7577. if (lookAhead(match)) {
  7578. while (num.length < len) {
  7579. num = "0" + num;
  7580. }
  7581. }
  7582. return num;
  7583. },
  7584. // Format a name, short or long as requested
  7585. formatName = function(match, value, shortNames, longNames) {
  7586. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  7587. },
  7588. output = "",
  7589. literal = false;
  7590. if (date) {
  7591. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7592. if (literal) {
  7593. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7594. literal = false;
  7595. } else {
  7596. output += format.charAt(iFormat);
  7597. }
  7598. } else {
  7599. switch (format.charAt(iFormat)) {
  7600. case "d":
  7601. output += formatNumber("d", date.getDate(), 2);
  7602. break;
  7603. case "D":
  7604. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  7605. break;
  7606. case "o":
  7607. output += formatNumber("o",
  7608. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  7609. break;
  7610. case "m":
  7611. output += formatNumber("m", date.getMonth() + 1, 2);
  7612. break;
  7613. case "M":
  7614. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  7615. break;
  7616. case "y":
  7617. output += (lookAhead("y") ? date.getFullYear() :
  7618. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  7619. break;
  7620. case "@":
  7621. output += date.getTime();
  7622. break;
  7623. case "!":
  7624. output += date.getTime() * 10000 + this._ticksTo1970;
  7625. break;
  7626. case "'":
  7627. if (lookAhead("'")) {
  7628. output += "'";
  7629. } else {
  7630. literal = true;
  7631. }
  7632. break;
  7633. default:
  7634. output += format.charAt(iFormat);
  7635. }
  7636. }
  7637. }
  7638. }
  7639. return output;
  7640. },
  7641. /* Extract all possible characters from the date format. */
  7642. _possibleChars: function (format) {
  7643. var iFormat,
  7644. chars = "",
  7645. literal = false,
  7646. // Check whether a format character is doubled
  7647. lookAhead = function(match) {
  7648. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7649. if (matches) {
  7650. iFormat++;
  7651. }
  7652. return matches;
  7653. };
  7654. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7655. if (literal) {
  7656. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7657. literal = false;
  7658. } else {
  7659. chars += format.charAt(iFormat);
  7660. }
  7661. } else {
  7662. switch (format.charAt(iFormat)) {
  7663. case "d": case "m": case "y": case "@":
  7664. chars += "0123456789";
  7665. break;
  7666. case "D": case "M":
  7667. return null; // Accept anything
  7668. case "'":
  7669. if (lookAhead("'")) {
  7670. chars += "'";
  7671. } else {
  7672. literal = true;
  7673. }
  7674. break;
  7675. default:
  7676. chars += format.charAt(iFormat);
  7677. }
  7678. }
  7679. }
  7680. return chars;
  7681. },
  7682. /* Get a setting value, defaulting if necessary. */
  7683. _get: function(inst, name) {
  7684. return inst.settings[name] !== undefined ?
  7685. inst.settings[name] : this._defaults[name];
  7686. },
  7687. /* Parse existing date and initialise date picker. */
  7688. _setDateFromField: function(inst, noDefault) {
  7689. if (inst.input.val() === inst.lastVal) {
  7690. return;
  7691. }
  7692. var dateFormat = this._get(inst, "dateFormat"),
  7693. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  7694. defaultDate = this._getDefaultDate(inst),
  7695. date = defaultDate,
  7696. settings = this._getFormatConfig(inst);
  7697. try {
  7698. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  7699. } catch (event) {
  7700. dates = (noDefault ? "" : dates);
  7701. }
  7702. inst.selectedDay = date.getDate();
  7703. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7704. inst.drawYear = inst.selectedYear = date.getFullYear();
  7705. inst.currentDay = (dates ? date.getDate() : 0);
  7706. inst.currentMonth = (dates ? date.getMonth() : 0);
  7707. inst.currentYear = (dates ? date.getFullYear() : 0);
  7708. this._adjustInstDate(inst);
  7709. },
  7710. /* Retrieve the default date shown on opening. */
  7711. _getDefaultDate: function(inst) {
  7712. return this._restrictMinMax(inst,
  7713. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  7714. },
  7715. /* A date may be specified as an exact value or a relative one. */
  7716. _determineDate: function(inst, date, defaultDate) {
  7717. var offsetNumeric = function(offset) {
  7718. var date = new Date();
  7719. date.setDate(date.getDate() + offset);
  7720. return date;
  7721. },
  7722. offsetString = function(offset) {
  7723. try {
  7724. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7725. offset, $.datepicker._getFormatConfig(inst));
  7726. }
  7727. catch (e) {
  7728. // Ignore
  7729. }
  7730. var date = (offset.toLowerCase().match(/^c/) ?
  7731. $.datepicker._getDate(inst) : null) || new Date(),
  7732. year = date.getFullYear(),
  7733. month = date.getMonth(),
  7734. day = date.getDate(),
  7735. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  7736. matches = pattern.exec(offset);
  7737. while (matches) {
  7738. switch (matches[2] || "d") {
  7739. case "d" : case "D" :
  7740. day += parseInt(matches[1],10); break;
  7741. case "w" : case "W" :
  7742. day += parseInt(matches[1],10) * 7; break;
  7743. case "m" : case "M" :
  7744. month += parseInt(matches[1],10);
  7745. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7746. break;
  7747. case "y": case "Y" :
  7748. year += parseInt(matches[1],10);
  7749. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7750. break;
  7751. }
  7752. matches = pattern.exec(offset);
  7753. }
  7754. return new Date(year, month, day);
  7755. },
  7756. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  7757. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  7758. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  7759. if (newDate) {
  7760. newDate.setHours(0);
  7761. newDate.setMinutes(0);
  7762. newDate.setSeconds(0);
  7763. newDate.setMilliseconds(0);
  7764. }
  7765. return this._daylightSavingAdjust(newDate);
  7766. },
  7767. /* Handle switch to/from daylight saving.
  7768. * Hours may be non-zero on daylight saving cut-over:
  7769. * > 12 when midnight changeover, but then cannot generate
  7770. * midnight datetime, so jump to 1AM, otherwise reset.
  7771. * @param date (Date) the date to check
  7772. * @return (Date) the corrected date
  7773. */
  7774. _daylightSavingAdjust: function(date) {
  7775. if (!date) {
  7776. return null;
  7777. }
  7778. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  7779. return date;
  7780. },
  7781. /* Set the date(s) directly. */
  7782. _setDate: function(inst, date, noChange) {
  7783. var clear = !date,
  7784. origMonth = inst.selectedMonth,
  7785. origYear = inst.selectedYear,
  7786. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  7787. inst.selectedDay = inst.currentDay = newDate.getDate();
  7788. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  7789. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  7790. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  7791. this._notifyChange(inst);
  7792. }
  7793. this._adjustInstDate(inst);
  7794. if (inst.input) {
  7795. inst.input.val(clear ? "" : this._formatDate(inst));
  7796. }
  7797. },
  7798. /* Retrieve the date(s) directly. */
  7799. _getDate: function(inst) {
  7800. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  7801. this._daylightSavingAdjust(new Date(
  7802. inst.currentYear, inst.currentMonth, inst.currentDay)));
  7803. return startDate;
  7804. },
  7805. /* Attach the onxxx handlers. These are declared statically so
  7806. * they work with static code transformers like Caja.
  7807. */
  7808. _attachHandlers: function(inst) {
  7809. var stepMonths = this._get(inst, "stepMonths"),
  7810. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  7811. inst.dpDiv.find("[data-handler]").map(function () {
  7812. var handler = {
  7813. prev: function () {
  7814. $.datepicker._adjustDate(id, -stepMonths, "M");
  7815. },
  7816. next: function () {
  7817. $.datepicker._adjustDate(id, +stepMonths, "M");
  7818. },
  7819. hide: function () {
  7820. $.datepicker._hideDatepicker();
  7821. },
  7822. today: function () {
  7823. $.datepicker._gotoToday(id);
  7824. },
  7825. selectDay: function () {
  7826. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  7827. return false;
  7828. },
  7829. selectMonth: function () {
  7830. $.datepicker._selectMonthYear(id, this, "M");
  7831. return false;
  7832. },
  7833. selectYear: function () {
  7834. $.datepicker._selectMonthYear(id, this, "Y");
  7835. return false;
  7836. }
  7837. };
  7838. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  7839. });
  7840. },
  7841. /* Generate the HTML for the current state of the date picker. */
  7842. _generateHTML: function(inst) {
  7843. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  7844. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  7845. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  7846. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  7847. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  7848. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  7849. tempDate = new Date(),
  7850. today = this._daylightSavingAdjust(
  7851. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  7852. isRTL = this._get(inst, "isRTL"),
  7853. showButtonPanel = this._get(inst, "showButtonPanel"),
  7854. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  7855. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  7856. numMonths = this._getNumberOfMonths(inst),
  7857. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  7858. stepMonths = this._get(inst, "stepMonths"),
  7859. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  7860. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  7861. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  7862. minDate = this._getMinMaxDate(inst, "min"),
  7863. maxDate = this._getMinMaxDate(inst, "max"),
  7864. drawMonth = inst.drawMonth - showCurrentAtPos,
  7865. drawYear = inst.drawYear;
  7866. if (drawMonth < 0) {
  7867. drawMonth += 12;
  7868. drawYear--;
  7869. }
  7870. if (maxDate) {
  7871. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  7872. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  7873. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  7874. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  7875. drawMonth--;
  7876. if (drawMonth < 0) {
  7877. drawMonth = 11;
  7878. drawYear--;
  7879. }
  7880. }
  7881. }
  7882. inst.drawMonth = drawMonth;
  7883. inst.drawYear = drawYear;
  7884. prevText = this._get(inst, "prevText");
  7885. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  7886. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  7887. this._getFormatConfig(inst)));
  7888. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  7889. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  7890. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  7891. (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>"));
  7892. nextText = this._get(inst, "nextText");
  7893. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  7894. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  7895. this._getFormatConfig(inst)));
  7896. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  7897. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  7898. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  7899. (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>"));
  7900. currentText = this._get(inst, "currentText");
  7901. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  7902. currentText = (!navigationAsDateFormat ? currentText :
  7903. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  7904. 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'>" +
  7905. this._get(inst, "closeText") + "</button>" : "");
  7906. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  7907. (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'" +
  7908. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  7909. firstDay = parseInt(this._get(inst, "firstDay"),10);
  7910. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  7911. showWeek = this._get(inst, "showWeek");
  7912. dayNames = this._get(inst, "dayNames");
  7913. dayNamesMin = this._get(inst, "dayNamesMin");
  7914. monthNames = this._get(inst, "monthNames");
  7915. monthNamesShort = this._get(inst, "monthNamesShort");
  7916. beforeShowDay = this._get(inst, "beforeShowDay");
  7917. showOtherMonths = this._get(inst, "showOtherMonths");
  7918. selectOtherMonths = this._get(inst, "selectOtherMonths");
  7919. defaultDate = this._getDefaultDate(inst);
  7920. html = "";
  7921. dow;
  7922. for (row = 0; row < numMonths[0]; row++) {
  7923. group = "";
  7924. this.maxRows = 4;
  7925. for (col = 0; col < numMonths[1]; col++) {
  7926. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  7927. cornerClass = " ui-corner-all";
  7928. calender = "";
  7929. if (isMultiMonth) {
  7930. calender += "<div class='ui-datepicker-group";
  7931. if (numMonths[1] > 1) {
  7932. switch (col) {
  7933. case 0: calender += " ui-datepicker-group-first";
  7934. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  7935. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  7936. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  7937. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  7938. }
  7939. }
  7940. calender += "'>";
  7941. }
  7942. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  7943. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  7944. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  7945. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  7946. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  7947. "</div><table class='ui-datepicker-calendar'><thead>" +
  7948. "<tr>";
  7949. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  7950. for (dow = 0; dow < 7; dow++) { // days of the week
  7951. day = (dow + firstDay) % 7;
  7952. thead += "<th" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  7953. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  7954. }
  7955. calender += thead + "</tr></thead><tbody>";
  7956. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  7957. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  7958. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  7959. }
  7960. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  7961. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  7962. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  7963. this.maxRows = numRows;
  7964. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  7965. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  7966. calender += "<tr>";
  7967. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  7968. this._get(inst, "calculateWeek")(printDate) + "</td>");
  7969. for (dow = 0; dow < 7; dow++) { // create date picker days
  7970. daySettings = (beforeShowDay ?
  7971. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  7972. otherMonth = (printDate.getMonth() !== drawMonth);
  7973. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  7974. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  7975. tbody += "<td class='" +
  7976. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  7977. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  7978. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  7979. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  7980. // or defaultDate is current printedDate and defaultDate is selectedDate
  7981. " " + this._dayOverClass : "") + // highlight selected day
  7982. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  7983. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  7984. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  7985. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  7986. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  7987. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  7988. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  7989. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  7990. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  7991. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  7992. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  7993. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  7994. printDate.setDate(printDate.getDate() + 1);
  7995. printDate = this._daylightSavingAdjust(printDate);
  7996. }
  7997. calender += tbody + "</tr>";
  7998. }
  7999. drawMonth++;
  8000. if (drawMonth > 11) {
  8001. drawMonth = 0;
  8002. drawYear++;
  8003. }
  8004. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  8005. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  8006. group += calender;
  8007. }
  8008. html += group;
  8009. }
  8010. html += buttonPanel;
  8011. inst._keyEvent = false;
  8012. return html;
  8013. },
  8014. /* Generate the month and year header. */
  8015. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  8016. secondary, monthNames, monthNamesShort) {
  8017. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  8018. changeMonth = this._get(inst, "changeMonth"),
  8019. changeYear = this._get(inst, "changeYear"),
  8020. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  8021. html = "<div class='ui-datepicker-title'>",
  8022. monthHtml = "";
  8023. // month selection
  8024. if (secondary || !changeMonth) {
  8025. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  8026. } else {
  8027. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  8028. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  8029. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  8030. for ( month = 0; month < 12; month++) {
  8031. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  8032. monthHtml += "<option value='" + month + "'" +
  8033. (month === drawMonth ? " selected='selected'" : "") +
  8034. ">" + monthNamesShort[month] + "</option>";
  8035. }
  8036. }
  8037. monthHtml += "</select>";
  8038. }
  8039. if (!showMonthAfterYear) {
  8040. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  8041. }
  8042. // year selection
  8043. if ( !inst.yearshtml ) {
  8044. inst.yearshtml = "";
  8045. if (secondary || !changeYear) {
  8046. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  8047. } else {
  8048. // determine range of years to display
  8049. years = this._get(inst, "yearRange").split(":");
  8050. thisYear = new Date().getFullYear();
  8051. determineYear = function(value) {
  8052. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  8053. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  8054. parseInt(value, 10)));
  8055. return (isNaN(year) ? thisYear : year);
  8056. };
  8057. year = determineYear(years[0]);
  8058. endYear = Math.max(year, determineYear(years[1] || ""));
  8059. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  8060. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  8061. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  8062. for (; year <= endYear; year++) {
  8063. inst.yearshtml += "<option value='" + year + "'" +
  8064. (year === drawYear ? " selected='selected'" : "") +
  8065. ">" + year + "</option>";
  8066. }
  8067. inst.yearshtml += "</select>";
  8068. html += inst.yearshtml;
  8069. inst.yearshtml = null;
  8070. }
  8071. }
  8072. html += this._get(inst, "yearSuffix");
  8073. if (showMonthAfterYear) {
  8074. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  8075. }
  8076. html += "</div>"; // Close datepicker_header
  8077. return html;
  8078. },
  8079. /* Adjust one of the date sub-fields. */
  8080. _adjustInstDate: function(inst, offset, period) {
  8081. var year = inst.drawYear + (period === "Y" ? offset : 0),
  8082. month = inst.drawMonth + (period === "M" ? offset : 0),
  8083. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  8084. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  8085. inst.selectedDay = date.getDate();
  8086. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8087. inst.drawYear = inst.selectedYear = date.getFullYear();
  8088. if (period === "M" || period === "Y") {
  8089. this._notifyChange(inst);
  8090. }
  8091. },
  8092. /* Ensure a date is within any min/max bounds. */
  8093. _restrictMinMax: function(inst, date) {
  8094. var minDate = this._getMinMaxDate(inst, "min"),
  8095. maxDate = this._getMinMaxDate(inst, "max"),
  8096. newDate = (minDate && date < minDate ? minDate : date);
  8097. return (maxDate && newDate > maxDate ? maxDate : newDate);
  8098. },
  8099. /* Notify change of month/year. */
  8100. _notifyChange: function(inst) {
  8101. var onChange = this._get(inst, "onChangeMonthYear");
  8102. if (onChange) {
  8103. onChange.apply((inst.input ? inst.input[0] : null),
  8104. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  8105. }
  8106. },
  8107. /* Determine the number of months to show. */
  8108. _getNumberOfMonths: function(inst) {
  8109. var numMonths = this._get(inst, "numberOfMonths");
  8110. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  8111. },
  8112. /* Determine the current maximum date - ensure no time components are set. */
  8113. _getMinMaxDate: function(inst, minMax) {
  8114. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  8115. },
  8116. /* Find the number of days in a given month. */
  8117. _getDaysInMonth: function(year, month) {
  8118. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  8119. },
  8120. /* Find the day of the week of the first of a month. */
  8121. _getFirstDayOfMonth: function(year, month) {
  8122. return new Date(year, month, 1).getDay();
  8123. },
  8124. /* Determines if we should allow a "next/prev" month display change. */
  8125. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  8126. var numMonths = this._getNumberOfMonths(inst),
  8127. date = this._daylightSavingAdjust(new Date(curYear,
  8128. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  8129. if (offset < 0) {
  8130. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  8131. }
  8132. return this._isInRange(inst, date);
  8133. },
  8134. /* Is the given date in the accepted range? */
  8135. _isInRange: function(inst, date) {
  8136. var yearSplit, currentYear,
  8137. minDate = this._getMinMaxDate(inst, "min"),
  8138. maxDate = this._getMinMaxDate(inst, "max"),
  8139. minYear = null,
  8140. maxYear = null,
  8141. years = this._get(inst, "yearRange");
  8142. if (years){
  8143. yearSplit = years.split(":");
  8144. currentYear = new Date().getFullYear();
  8145. minYear = parseInt(yearSplit[0], 10);
  8146. maxYear = parseInt(yearSplit[1], 10);
  8147. if ( yearSplit[0].match(/[+\-].*/) ) {
  8148. minYear += currentYear;
  8149. }
  8150. if ( yearSplit[1].match(/[+\-].*/) ) {
  8151. maxYear += currentYear;
  8152. }
  8153. }
  8154. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  8155. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  8156. (!minYear || date.getFullYear() >= minYear) &&
  8157. (!maxYear || date.getFullYear() <= maxYear));
  8158. },
  8159. /* Provide the configuration settings for formatting/parsing. */
  8160. _getFormatConfig: function(inst) {
  8161. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  8162. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  8163. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  8164. return {shortYearCutoff: shortYearCutoff,
  8165. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  8166. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  8167. },
  8168. /* Format the given date for display. */
  8169. _formatDate: function(inst, day, month, year) {
  8170. if (!day) {
  8171. inst.currentDay = inst.selectedDay;
  8172. inst.currentMonth = inst.selectedMonth;
  8173. inst.currentYear = inst.selectedYear;
  8174. }
  8175. var date = (day ? (typeof day === "object" ? day :
  8176. this._daylightSavingAdjust(new Date(year, month, day))) :
  8177. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  8178. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  8179. }
  8180. });
  8181. /*
  8182. * Bind hover events for datepicker elements.
  8183. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  8184. * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  8185. */
  8186. function bindHover(dpDiv) {
  8187. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  8188. return dpDiv.delegate(selector, "mouseout", function() {
  8189. $(this).removeClass("ui-state-hover");
  8190. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8191. $(this).removeClass("ui-datepicker-prev-hover");
  8192. }
  8193. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8194. $(this).removeClass("ui-datepicker-next-hover");
  8195. }
  8196. })
  8197. .delegate(selector, "mouseover", function(){
  8198. if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
  8199. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  8200. $(this).addClass("ui-state-hover");
  8201. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8202. $(this).addClass("ui-datepicker-prev-hover");
  8203. }
  8204. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8205. $(this).addClass("ui-datepicker-next-hover");
  8206. }
  8207. }
  8208. });
  8209. }
  8210. /* jQuery extend now ignores nulls! */
  8211. function extendRemove(target, props) {
  8212. $.extend(target, props);
  8213. for (var name in props) {
  8214. if (props[name] == null) {
  8215. target[name] = props[name];
  8216. }
  8217. }
  8218. return target;
  8219. }
  8220. /* Invoke the datepicker functionality.
  8221. @param options string - a command, optionally followed by additional parameters or
  8222. Object - settings for attaching new datepicker functionality
  8223. @return jQuery object */
  8224. $.fn.datepicker = function(options){
  8225. /* Verify an empty collection wasn't passed - Fixes #6976 */
  8226. if ( !this.length ) {
  8227. return this;
  8228. }
  8229. /* Initialise the date picker. */
  8230. if (!$.datepicker.initialized) {
  8231. $(document).mousedown($.datepicker._checkExternalClick);
  8232. $.datepicker.initialized = true;
  8233. }
  8234. /* Append datepicker main container to body if not exist. */
  8235. if ($("#"+$.datepicker._mainDivId).length === 0) {
  8236. $("body").append($.datepicker.dpDiv);
  8237. }
  8238. var otherArgs = Array.prototype.slice.call(arguments, 1);
  8239. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  8240. return $.datepicker["_" + options + "Datepicker"].
  8241. apply($.datepicker, [this[0]].concat(otherArgs));
  8242. }
  8243. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  8244. return $.datepicker["_" + options + "Datepicker"].
  8245. apply($.datepicker, [this[0]].concat(otherArgs));
  8246. }
  8247. return this.each(function() {
  8248. typeof options === "string" ?
  8249. $.datepicker["_" + options + "Datepicker"].
  8250. apply($.datepicker, [this].concat(otherArgs)) :
  8251. $.datepicker._attachDatepicker(this, options);
  8252. });
  8253. };
  8254. $.datepicker = new Datepicker(); // singleton instance
  8255. $.datepicker.initialized = false;
  8256. $.datepicker.uuid = new Date().getTime();
  8257. $.datepicker.version = "1.10.4";
  8258. })(jQuery);
  8259. (function( $, undefined ) {
  8260. var sizeRelatedOptions = {
  8261. buttons: true,
  8262. height: true,
  8263. maxHeight: true,
  8264. maxWidth: true,
  8265. minHeight: true,
  8266. minWidth: true,
  8267. width: true
  8268. },
  8269. resizableRelatedOptions = {
  8270. maxHeight: true,
  8271. maxWidth: true,
  8272. minHeight: true,
  8273. minWidth: true
  8274. };
  8275. $.widget( "ui.dialog", {
  8276. version: "1.10.4",
  8277. options: {
  8278. appendTo: "body",
  8279. autoOpen: true,
  8280. buttons: [],
  8281. closeOnEscape: true,
  8282. closeText: "close",
  8283. dialogClass: "",
  8284. draggable: true,
  8285. hide: null,
  8286. height: "auto",
  8287. maxHeight: null,
  8288. maxWidth: null,
  8289. minHeight: 150,
  8290. minWidth: 150,
  8291. modal: false,
  8292. position: {
  8293. my: "center",
  8294. at: "center",
  8295. of: window,
  8296. collision: "fit",
  8297. // Ensure the titlebar is always visible
  8298. using: function( pos ) {
  8299. var topOffset = $( this ).css( pos ).offset().top;
  8300. if ( topOffset < 0 ) {
  8301. $( this ).css( "top", pos.top - topOffset );
  8302. }
  8303. }
  8304. },
  8305. resizable: true,
  8306. show: null,
  8307. title: null,
  8308. width: 300,
  8309. // callbacks
  8310. beforeClose: null,
  8311. close: null,
  8312. drag: null,
  8313. dragStart: null,
  8314. dragStop: null,
  8315. focus: null,
  8316. open: null,
  8317. resize: null,
  8318. resizeStart: null,
  8319. resizeStop: null
  8320. },
  8321. _create: function() {
  8322. this.originalCss = {
  8323. display: this.element[0].style.display,
  8324. width: this.element[0].style.width,
  8325. minHeight: this.element[0].style.minHeight,
  8326. maxHeight: this.element[0].style.maxHeight,
  8327. height: this.element[0].style.height
  8328. };
  8329. this.originalPosition = {
  8330. parent: this.element.parent(),
  8331. index: this.element.parent().children().index( this.element )
  8332. };
  8333. this.originalTitle = this.element.attr("title");
  8334. this.options.title = this.options.title || this.originalTitle;
  8335. this._createWrapper();
  8336. this.element
  8337. .show()
  8338. .removeAttr("title")
  8339. .addClass("ui-dialog-content ui-widget-content")
  8340. .appendTo( this.uiDialog );
  8341. this._createTitlebar();
  8342. this._createButtonPane();
  8343. if ( this.options.draggable && $.fn.draggable ) {
  8344. this._makeDraggable();
  8345. }
  8346. if ( this.options.resizable && $.fn.resizable ) {
  8347. this._makeResizable();
  8348. }
  8349. this._isOpen = false;
  8350. },
  8351. _init: function() {
  8352. if ( this.options.autoOpen ) {
  8353. this.open();
  8354. }
  8355. },
  8356. _appendTo: function() {
  8357. var element = this.options.appendTo;
  8358. if ( element && (element.jquery || element.nodeType) ) {
  8359. return $( element );
  8360. }
  8361. return this.document.find( element || "body" ).eq( 0 );
  8362. },
  8363. _destroy: function() {
  8364. var next,
  8365. originalPosition = this.originalPosition;
  8366. this._destroyOverlay();
  8367. this.element
  8368. .removeUniqueId()
  8369. .removeClass("ui-dialog-content ui-widget-content")
  8370. .css( this.originalCss )
  8371. // Without detaching first, the following becomes really slow
  8372. .detach();
  8373. this.uiDialog.stop( true, true ).remove();
  8374. if ( this.originalTitle ) {
  8375. this.element.attr( "title", this.originalTitle );
  8376. }
  8377. next = originalPosition.parent.children().eq( originalPosition.index );
  8378. // Don't try to place the dialog next to itself (#8613)
  8379. if ( next.length && next[0] !== this.element[0] ) {
  8380. next.before( this.element );
  8381. } else {
  8382. originalPosition.parent.append( this.element );
  8383. }
  8384. },
  8385. widget: function() {
  8386. return this.uiDialog;
  8387. },
  8388. disable: $.noop,
  8389. enable: $.noop,
  8390. close: function( event ) {
  8391. var activeElement,
  8392. that = this;
  8393. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  8394. return;
  8395. }
  8396. this._isOpen = false;
  8397. this._destroyOverlay();
  8398. if ( !this.opener.filter(":focusable").focus().length ) {
  8399. // support: IE9
  8400. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  8401. try {
  8402. activeElement = this.document[ 0 ].activeElement;
  8403. // Support: IE9, IE10
  8404. // If the <body> is blurred, IE will switch windows, see #4520
  8405. if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {
  8406. // Hiding a focused element doesn't trigger blur in WebKit
  8407. // so in case we have nothing to focus on, explicitly blur the active element
  8408. // https://bugs.webkit.org/show_bug.cgi?id=47182
  8409. $( activeElement ).blur();
  8410. }
  8411. } catch ( error ) {}
  8412. }
  8413. this._hide( this.uiDialog, this.options.hide, function() {
  8414. that._trigger( "close", event );
  8415. });
  8416. },
  8417. isOpen: function() {
  8418. return this._isOpen;
  8419. },
  8420. moveToTop: function() {
  8421. this._moveToTop();
  8422. },
  8423. _moveToTop: function( event, silent ) {
  8424. var moved = !!this.uiDialog.nextAll(":visible").insertBefore( this.uiDialog ).length;
  8425. if ( moved && !silent ) {
  8426. this._trigger( "focus", event );
  8427. }
  8428. return moved;
  8429. },
  8430. open: function() {
  8431. var that = this;
  8432. if ( this._isOpen ) {
  8433. if ( this._moveToTop() ) {
  8434. this._focusTabbable();
  8435. }
  8436. return;
  8437. }
  8438. this._isOpen = true;
  8439. this.opener = $( this.document[0].activeElement );
  8440. this._size();
  8441. this._position();
  8442. this._createOverlay();
  8443. this._moveToTop( null, true );
  8444. this._show( this.uiDialog, this.options.show, function() {
  8445. that._focusTabbable();
  8446. that._trigger("focus");
  8447. });
  8448. this._trigger("open");
  8449. },
  8450. _focusTabbable: function() {
  8451. // Set focus to the first match:
  8452. // 1. First element inside the dialog matching [autofocus]
  8453. // 2. Tabbable element inside the content element
  8454. // 3. Tabbable element inside the buttonpane
  8455. // 4. The close button
  8456. // 5. The dialog itself
  8457. var hasFocus = this.element.find("[autofocus]");
  8458. if ( !hasFocus.length ) {
  8459. hasFocus = this.element.find(":tabbable");
  8460. }
  8461. if ( !hasFocus.length ) {
  8462. hasFocus = this.uiDialogButtonPane.find(":tabbable");
  8463. }
  8464. if ( !hasFocus.length ) {
  8465. hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
  8466. }
  8467. if ( !hasFocus.length ) {
  8468. hasFocus = this.uiDialog;
  8469. }
  8470. hasFocus.eq( 0 ).focus();
  8471. },
  8472. _keepFocus: function( event ) {
  8473. function checkFocus() {
  8474. var activeElement = this.document[0].activeElement,
  8475. isActive = this.uiDialog[0] === activeElement ||
  8476. $.contains( this.uiDialog[0], activeElement );
  8477. if ( !isActive ) {
  8478. this._focusTabbable();
  8479. }
  8480. }
  8481. event.preventDefault();
  8482. checkFocus.call( this );
  8483. // support: IE
  8484. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  8485. // so we check again later
  8486. this._delay( checkFocus );
  8487. },
  8488. _createWrapper: function() {
  8489. this.uiDialog = $("<div>")
  8490. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  8491. this.options.dialogClass )
  8492. .hide()
  8493. .attr({
  8494. // Setting tabIndex makes the div focusable
  8495. tabIndex: -1,
  8496. role: "dialog"
  8497. })
  8498. .appendTo( this._appendTo() );
  8499. this._on( this.uiDialog, {
  8500. keydown: function( event ) {
  8501. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  8502. event.keyCode === $.ui.keyCode.ESCAPE ) {
  8503. event.preventDefault();
  8504. this.close( event );
  8505. return;
  8506. }
  8507. // prevent tabbing out of dialogs
  8508. if ( event.keyCode !== $.ui.keyCode.TAB ) {
  8509. return;
  8510. }
  8511. var tabbables = this.uiDialog.find(":tabbable"),
  8512. first = tabbables.filter(":first"),
  8513. last = tabbables.filter(":last");
  8514. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  8515. first.focus( 1 );
  8516. event.preventDefault();
  8517. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  8518. last.focus( 1 );
  8519. event.preventDefault();
  8520. }
  8521. },
  8522. mousedown: function( event ) {
  8523. if ( this._moveToTop( event ) ) {
  8524. this._focusTabbable();
  8525. }
  8526. }
  8527. });
  8528. // We assume that any existing aria-describedby attribute means
  8529. // that the dialog content is marked up properly
  8530. // otherwise we brute force the content as the description
  8531. if ( !this.element.find("[aria-describedby]").length ) {
  8532. this.uiDialog.attr({
  8533. "aria-describedby": this.element.uniqueId().attr("id")
  8534. });
  8535. }
  8536. },
  8537. _createTitlebar: function() {
  8538. var uiDialogTitle;
  8539. this.uiDialogTitlebar = $("<div>")
  8540. .addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix")
  8541. .prependTo( this.uiDialog );
  8542. this._on( this.uiDialogTitlebar, {
  8543. mousedown: function( event ) {
  8544. // Don't prevent click on close button (#8838)
  8545. // Focusing a dialog that is partially scrolled out of view
  8546. // causes the browser to scroll it into view, preventing the click event
  8547. if ( !$( event.target ).closest(".ui-dialog-titlebar-close") ) {
  8548. // Dialog isn't getting focus when dragging (#8063)
  8549. this.uiDialog.focus();
  8550. }
  8551. }
  8552. });
  8553. // support: IE
  8554. // Use type="button" to prevent enter keypresses in textboxes from closing the
  8555. // dialog in IE (#9312)
  8556. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  8557. .button({
  8558. label: this.options.closeText,
  8559. icons: {
  8560. primary: "ui-icon-closethick"
  8561. },
  8562. text: false
  8563. })
  8564. .addClass("ui-dialog-titlebar-close")
  8565. .appendTo( this.uiDialogTitlebar );
  8566. this._on( this.uiDialogTitlebarClose, {
  8567. click: function( event ) {
  8568. event.preventDefault();
  8569. this.close( event );
  8570. }
  8571. });
  8572. uiDialogTitle = $("<span>")
  8573. .uniqueId()
  8574. .addClass("ui-dialog-title")
  8575. .prependTo( this.uiDialogTitlebar );
  8576. this._title( uiDialogTitle );
  8577. this.uiDialog.attr({
  8578. "aria-labelledby": uiDialogTitle.attr("id")
  8579. });
  8580. },
  8581. _title: function( title ) {
  8582. if ( !this.options.title ) {
  8583. title.html("&#160;");
  8584. }
  8585. title.text( this.options.title );
  8586. },
  8587. _createButtonPane: function() {
  8588. this.uiDialogButtonPane = $("<div>")
  8589. .addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");
  8590. this.uiButtonSet = $("<div>")
  8591. .addClass("ui-dialog-buttonset")
  8592. .appendTo( this.uiDialogButtonPane );
  8593. this._createButtons();
  8594. },
  8595. _createButtons: function() {
  8596. var that = this,
  8597. buttons = this.options.buttons;
  8598. // if we already have a button pane, remove it
  8599. this.uiDialogButtonPane.remove();
  8600. this.uiButtonSet.empty();
  8601. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  8602. this.uiDialog.removeClass("ui-dialog-buttons");
  8603. return;
  8604. }
  8605. $.each( buttons, function( name, props ) {
  8606. var click, buttonOptions;
  8607. props = $.isFunction( props ) ?
  8608. { click: props, text: name } :
  8609. props;
  8610. // Default to a non-submitting button
  8611. props = $.extend( { type: "button" }, props );
  8612. // Change the context for the click callback to be the main element
  8613. click = props.click;
  8614. props.click = function() {
  8615. click.apply( that.element[0], arguments );
  8616. };
  8617. buttonOptions = {
  8618. icons: props.icons,
  8619. text: props.showText
  8620. };
  8621. delete props.icons;
  8622. delete props.showText;
  8623. $( "<button></button>", props )
  8624. .button( buttonOptions )
  8625. .appendTo( that.uiButtonSet );
  8626. });
  8627. this.uiDialog.addClass("ui-dialog-buttons");
  8628. this.uiDialogButtonPane.appendTo( this.uiDialog );
  8629. },
  8630. _makeDraggable: function() {
  8631. var that = this,
  8632. options = this.options;
  8633. function filteredUi( ui ) {
  8634. return {
  8635. position: ui.position,
  8636. offset: ui.offset
  8637. };
  8638. }
  8639. this.uiDialog.draggable({
  8640. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  8641. handle: ".ui-dialog-titlebar",
  8642. containment: "document",
  8643. start: function( event, ui ) {
  8644. $( this ).addClass("ui-dialog-dragging");
  8645. that._blockFrames();
  8646. that._trigger( "dragStart", event, filteredUi( ui ) );
  8647. },
  8648. drag: function( event, ui ) {
  8649. that._trigger( "drag", event, filteredUi( ui ) );
  8650. },
  8651. stop: function( event, ui ) {
  8652. options.position = [
  8653. ui.position.left - that.document.scrollLeft(),
  8654. ui.position.top - that.document.scrollTop()
  8655. ];
  8656. $( this ).removeClass("ui-dialog-dragging");
  8657. that._unblockFrames();
  8658. that._trigger( "dragStop", event, filteredUi( ui ) );
  8659. }
  8660. });
  8661. },
  8662. _makeResizable: function() {
  8663. var that = this,
  8664. options = this.options,
  8665. handles = options.resizable,
  8666. // .ui-resizable has position: relative defined in the stylesheet
  8667. // but dialogs have to use absolute or fixed positioning
  8668. position = this.uiDialog.css("position"),
  8669. resizeHandles = typeof handles === "string" ?
  8670. handles :
  8671. "n,e,s,w,se,sw,ne,nw";
  8672. function filteredUi( ui ) {
  8673. return {
  8674. originalPosition: ui.originalPosition,
  8675. originalSize: ui.originalSize,
  8676. position: ui.position,
  8677. size: ui.size
  8678. };
  8679. }
  8680. this.uiDialog.resizable({
  8681. cancel: ".ui-dialog-content",
  8682. containment: "document",
  8683. alsoResize: this.element,
  8684. maxWidth: options.maxWidth,
  8685. maxHeight: options.maxHeight,
  8686. minWidth: options.minWidth,
  8687. minHeight: this._minHeight(),
  8688. handles: resizeHandles,
  8689. start: function( event, ui ) {
  8690. $( this ).addClass("ui-dialog-resizing");
  8691. that._blockFrames();
  8692. that._trigger( "resizeStart", event, filteredUi( ui ) );
  8693. },
  8694. resize: function( event, ui ) {
  8695. that._trigger( "resize", event, filteredUi( ui ) );
  8696. },
  8697. stop: function( event, ui ) {
  8698. options.height = $( this ).height();
  8699. options.width = $( this ).width();
  8700. $( this ).removeClass("ui-dialog-resizing");
  8701. that._unblockFrames();
  8702. that._trigger( "resizeStop", event, filteredUi( ui ) );
  8703. }
  8704. })
  8705. .css( "position", position );
  8706. },
  8707. _minHeight: function() {
  8708. var options = this.options;
  8709. return options.height === "auto" ?
  8710. options.minHeight :
  8711. Math.min( options.minHeight, options.height );
  8712. },
  8713. _position: function() {
  8714. // Need to show the dialog to get the actual offset in the position plugin
  8715. var isVisible = this.uiDialog.is(":visible");
  8716. if ( !isVisible ) {
  8717. this.uiDialog.show();
  8718. }
  8719. this.uiDialog.position( this.options.position );
  8720. if ( !isVisible ) {
  8721. this.uiDialog.hide();
  8722. }
  8723. },
  8724. _setOptions: function( options ) {
  8725. var that = this,
  8726. resize = false,
  8727. resizableOptions = {};
  8728. $.each( options, function( key, value ) {
  8729. that._setOption( key, value );
  8730. if ( key in sizeRelatedOptions ) {
  8731. resize = true;
  8732. }
  8733. if ( key in resizableRelatedOptions ) {
  8734. resizableOptions[ key ] = value;
  8735. }
  8736. });
  8737. if ( resize ) {
  8738. this._size();
  8739. this._position();
  8740. }
  8741. if ( this.uiDialog.is(":data(ui-resizable)") ) {
  8742. this.uiDialog.resizable( "option", resizableOptions );
  8743. }
  8744. },
  8745. _setOption: function( key, value ) {
  8746. var isDraggable, isResizable,
  8747. uiDialog = this.uiDialog;
  8748. if ( key === "dialogClass" ) {
  8749. uiDialog
  8750. .removeClass( this.options.dialogClass )
  8751. .addClass( value );
  8752. }
  8753. if ( key === "disabled" ) {
  8754. return;
  8755. }
  8756. this._super( key, value );
  8757. if ( key === "appendTo" ) {
  8758. this.uiDialog.appendTo( this._appendTo() );
  8759. }
  8760. if ( key === "buttons" ) {
  8761. this._createButtons();
  8762. }
  8763. if ( key === "closeText" ) {
  8764. this.uiDialogTitlebarClose.button({
  8765. // Ensure that we always pass a string
  8766. label: "" + value
  8767. });
  8768. }
  8769. if ( key === "draggable" ) {
  8770. isDraggable = uiDialog.is(":data(ui-draggable)");
  8771. if ( isDraggable && !value ) {
  8772. uiDialog.draggable("destroy");
  8773. }
  8774. if ( !isDraggable && value ) {
  8775. this._makeDraggable();
  8776. }
  8777. }
  8778. if ( key === "position" ) {
  8779. this._position();
  8780. }
  8781. if ( key === "resizable" ) {
  8782. // currently resizable, becoming non-resizable
  8783. isResizable = uiDialog.is(":data(ui-resizable)");
  8784. if ( isResizable && !value ) {
  8785. uiDialog.resizable("destroy");
  8786. }
  8787. // currently resizable, changing handles
  8788. if ( isResizable && typeof value === "string" ) {
  8789. uiDialog.resizable( "option", "handles", value );
  8790. }
  8791. // currently non-resizable, becoming resizable
  8792. if ( !isResizable && value !== false ) {
  8793. this._makeResizable();
  8794. }
  8795. }
  8796. if ( key === "title" ) {
  8797. this._title( this.uiDialogTitlebar.find(".ui-dialog-title") );
  8798. }
  8799. },
  8800. _size: function() {
  8801. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  8802. // divs will both have width and height set, so we need to reset them
  8803. var nonContentHeight, minContentHeight, maxContentHeight,
  8804. options = this.options;
  8805. // Reset content sizing
  8806. this.element.show().css({
  8807. width: "auto",
  8808. minHeight: 0,
  8809. maxHeight: "none",
  8810. height: 0
  8811. });
  8812. if ( options.minWidth > options.width ) {
  8813. options.width = options.minWidth;
  8814. }
  8815. // reset wrapper sizing
  8816. // determine the height of all the non-content elements
  8817. nonContentHeight = this.uiDialog.css({
  8818. height: "auto",
  8819. width: options.width
  8820. })
  8821. .outerHeight();
  8822. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  8823. maxContentHeight = typeof options.maxHeight === "number" ?
  8824. Math.max( 0, options.maxHeight - nonContentHeight ) :
  8825. "none";
  8826. if ( options.height === "auto" ) {
  8827. this.element.css({
  8828. minHeight: minContentHeight,
  8829. maxHeight: maxContentHeight,
  8830. height: "auto"
  8831. });
  8832. } else {
  8833. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  8834. }
  8835. if (this.uiDialog.is(":data(ui-resizable)") ) {
  8836. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  8837. }
  8838. },
  8839. _blockFrames: function() {
  8840. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  8841. var iframe = $( this );
  8842. return $( "<div>" )
  8843. .css({
  8844. position: "absolute",
  8845. width: iframe.outerWidth(),
  8846. height: iframe.outerHeight()
  8847. })
  8848. .appendTo( iframe.parent() )
  8849. .offset( iframe.offset() )[0];
  8850. });
  8851. },
  8852. _unblockFrames: function() {
  8853. if ( this.iframeBlocks ) {
  8854. this.iframeBlocks.remove();
  8855. delete this.iframeBlocks;
  8856. }
  8857. },
  8858. _allowInteraction: function( event ) {
  8859. if ( $( event.target ).closest(".ui-dialog").length ) {
  8860. return true;
  8861. }
  8862. // TODO: Remove hack when datepicker implements
  8863. // the .ui-front logic (#8989)
  8864. return !!$( event.target ).closest(".ui-datepicker").length;
  8865. },
  8866. _createOverlay: function() {
  8867. if ( !this.options.modal ) {
  8868. return;
  8869. }
  8870. var that = this,
  8871. widgetFullName = this.widgetFullName;
  8872. if ( !$.ui.dialog.overlayInstances ) {
  8873. // Prevent use of anchors and inputs.
  8874. // We use a delay in case the overlay is created from an
  8875. // event that we're going to be cancelling. (#2804)
  8876. this._delay(function() {
  8877. // Handle .dialog().dialog("close") (#4065)
  8878. if ( $.ui.dialog.overlayInstances ) {
  8879. this.document.bind( "focusin.dialog", function( event ) {
  8880. if ( !that._allowInteraction( event ) ) {
  8881. event.preventDefault();
  8882. $(".ui-dialog:visible:last .ui-dialog-content")
  8883. .data( widgetFullName )._focusTabbable();
  8884. }
  8885. });
  8886. }
  8887. });
  8888. }
  8889. this.overlay = $("<div>")
  8890. .addClass("ui-widget-overlay ui-front")
  8891. .appendTo( this._appendTo() );
  8892. this._on( this.overlay, {
  8893. mousedown: "_keepFocus"
  8894. });
  8895. $.ui.dialog.overlayInstances++;
  8896. },
  8897. _destroyOverlay: function() {
  8898. if ( !this.options.modal ) {
  8899. return;
  8900. }
  8901. if ( this.overlay ) {
  8902. $.ui.dialog.overlayInstances--;
  8903. if ( !$.ui.dialog.overlayInstances ) {
  8904. this.document.unbind( "focusin.dialog" );
  8905. }
  8906. this.overlay.remove();
  8907. this.overlay = null;
  8908. }
  8909. }
  8910. });
  8911. $.ui.dialog.overlayInstances = 0;
  8912. // DEPRECATED
  8913. if ( $.uiBackCompat !== false ) {
  8914. // position option with array notation
  8915. // just override with old implementation
  8916. $.widget( "ui.dialog", $.ui.dialog, {
  8917. _position: function() {
  8918. var position = this.options.position,
  8919. myAt = [],
  8920. offset = [ 0, 0 ],
  8921. isVisible;
  8922. if ( position ) {
  8923. if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
  8924. myAt = position.split ? position.split(" ") : [ position[0], position[1] ];
  8925. if ( myAt.length === 1 ) {
  8926. myAt[1] = myAt[0];
  8927. }
  8928. $.each( [ "left", "top" ], function( i, offsetPosition ) {
  8929. if ( +myAt[ i ] === myAt[ i ] ) {
  8930. offset[ i ] = myAt[ i ];
  8931. myAt[ i ] = offsetPosition;
  8932. }
  8933. });
  8934. position = {
  8935. my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
  8936. myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
  8937. at: myAt.join(" ")
  8938. };
  8939. }
  8940. position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
  8941. } else {
  8942. position = $.ui.dialog.prototype.options.position;
  8943. }
  8944. // need to show the dialog to get the actual offset in the position plugin
  8945. isVisible = this.uiDialog.is(":visible");
  8946. if ( !isVisible ) {
  8947. this.uiDialog.show();
  8948. }
  8949. this.uiDialog.position( position );
  8950. if ( !isVisible ) {
  8951. this.uiDialog.hide();
  8952. }
  8953. }
  8954. });
  8955. }
  8956. }( jQuery ) );
  8957. (function( $, undefined ) {
  8958. var rvertical = /up|down|vertical/,
  8959. rpositivemotion = /up|left|vertical|horizontal/;
  8960. $.effects.effect.blind = function( o, done ) {
  8961. // Create element
  8962. var el = $( this ),
  8963. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  8964. mode = $.effects.setMode( el, o.mode || "hide" ),
  8965. direction = o.direction || "up",
  8966. vertical = rvertical.test( direction ),
  8967. ref = vertical ? "height" : "width",
  8968. ref2 = vertical ? "top" : "left",
  8969. motion = rpositivemotion.test( direction ),
  8970. animation = {},
  8971. show = mode === "show",
  8972. wrapper, distance, margin;
  8973. // if already wrapped, the wrapper's properties are my property. #6245
  8974. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  8975. $.effects.save( el.parent(), props );
  8976. } else {
  8977. $.effects.save( el, props );
  8978. }
  8979. el.show();
  8980. wrapper = $.effects.createWrapper( el ).css({
  8981. overflow: "hidden"
  8982. });
  8983. distance = wrapper[ ref ]();
  8984. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  8985. animation[ ref ] = show ? distance : 0;
  8986. if ( !motion ) {
  8987. el
  8988. .css( vertical ? "bottom" : "right", 0 )
  8989. .css( vertical ? "top" : "left", "auto" )
  8990. .css({ position: "absolute" });
  8991. animation[ ref2 ] = show ? margin : distance + margin;
  8992. }
  8993. // start at 0 if we are showing
  8994. if ( show ) {
  8995. wrapper.css( ref, 0 );
  8996. if ( ! motion ) {
  8997. wrapper.css( ref2, margin + distance );
  8998. }
  8999. }
  9000. // Animate
  9001. wrapper.animate( animation, {
  9002. duration: o.duration,
  9003. easing: o.easing,
  9004. queue: false,
  9005. complete: function() {
  9006. if ( mode === "hide" ) {
  9007. el.hide();
  9008. }
  9009. $.effects.restore( el, props );
  9010. $.effects.removeWrapper( el );
  9011. done();
  9012. }
  9013. });
  9014. };
  9015. })(jQuery);
  9016. (function( $, undefined ) {
  9017. $.effects.effect.bounce = function( o, done ) {
  9018. var el = $( this ),
  9019. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9020. // defaults:
  9021. mode = $.effects.setMode( el, o.mode || "effect" ),
  9022. hide = mode === "hide",
  9023. show = mode === "show",
  9024. direction = o.direction || "up",
  9025. distance = o.distance,
  9026. times = o.times || 5,
  9027. // number of internal animations
  9028. anims = times * 2 + ( show || hide ? 1 : 0 ),
  9029. speed = o.duration / anims,
  9030. easing = o.easing,
  9031. // utility:
  9032. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9033. motion = ( direction === "up" || direction === "left" ),
  9034. i,
  9035. upAnim,
  9036. downAnim,
  9037. // we will need to re-assemble the queue to stack our animations in place
  9038. queue = el.queue(),
  9039. queuelen = queue.length;
  9040. // Avoid touching opacity to prevent clearType and PNG issues in IE
  9041. if ( show || hide ) {
  9042. props.push( "opacity" );
  9043. }
  9044. $.effects.save( el, props );
  9045. el.show();
  9046. $.effects.createWrapper( el ); // Create Wrapper
  9047. // default distance for the BIGGEST bounce is the outer Distance / 3
  9048. if ( !distance ) {
  9049. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  9050. }
  9051. if ( show ) {
  9052. downAnim = { opacity: 1 };
  9053. downAnim[ ref ] = 0;
  9054. // if we are showing, force opacity 0 and set the initial position
  9055. // then do the "first" animation
  9056. el.css( "opacity", 0 )
  9057. .css( ref, motion ? -distance * 2 : distance * 2 )
  9058. .animate( downAnim, speed, easing );
  9059. }
  9060. // start at the smallest distance if we are hiding
  9061. if ( hide ) {
  9062. distance = distance / Math.pow( 2, times - 1 );
  9063. }
  9064. downAnim = {};
  9065. downAnim[ ref ] = 0;
  9066. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  9067. for ( i = 0; i < times; i++ ) {
  9068. upAnim = {};
  9069. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9070. el.animate( upAnim, speed, easing )
  9071. .animate( downAnim, speed, easing );
  9072. distance = hide ? distance * 2 : distance / 2;
  9073. }
  9074. // Last Bounce when Hiding
  9075. if ( hide ) {
  9076. upAnim = { opacity: 0 };
  9077. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9078. el.animate( upAnim, speed, easing );
  9079. }
  9080. el.queue(function() {
  9081. if ( hide ) {
  9082. el.hide();
  9083. }
  9084. $.effects.restore( el, props );
  9085. $.effects.removeWrapper( el );
  9086. done();
  9087. });
  9088. // inject all the animations we just queued to be first in line (after "inprogress")
  9089. if ( queuelen > 1) {
  9090. queue.splice.apply( queue,
  9091. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9092. }
  9093. el.dequeue();
  9094. };
  9095. })(jQuery);
  9096. (function( $, undefined ) {
  9097. $.effects.effect.clip = function( o, done ) {
  9098. // Create element
  9099. var el = $( this ),
  9100. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9101. mode = $.effects.setMode( el, o.mode || "hide" ),
  9102. show = mode === "show",
  9103. direction = o.direction || "vertical",
  9104. vert = direction === "vertical",
  9105. size = vert ? "height" : "width",
  9106. position = vert ? "top" : "left",
  9107. animation = {},
  9108. wrapper, animate, distance;
  9109. // Save & Show
  9110. $.effects.save( el, props );
  9111. el.show();
  9112. // Create Wrapper
  9113. wrapper = $.effects.createWrapper( el ).css({
  9114. overflow: "hidden"
  9115. });
  9116. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  9117. distance = animate[ size ]();
  9118. // Shift
  9119. if ( show ) {
  9120. animate.css( size, 0 );
  9121. animate.css( position, distance / 2 );
  9122. }
  9123. // Create Animation Object:
  9124. animation[ size ] = show ? distance : 0;
  9125. animation[ position ] = show ? 0 : distance / 2;
  9126. // Animate
  9127. animate.animate( animation, {
  9128. queue: false,
  9129. duration: o.duration,
  9130. easing: o.easing,
  9131. complete: function() {
  9132. if ( !show ) {
  9133. el.hide();
  9134. }
  9135. $.effects.restore( el, props );
  9136. $.effects.removeWrapper( el );
  9137. done();
  9138. }
  9139. });
  9140. };
  9141. })(jQuery);
  9142. (function( $, undefined ) {
  9143. $.effects.effect.drop = function( o, done ) {
  9144. var el = $( this ),
  9145. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  9146. mode = $.effects.setMode( el, o.mode || "hide" ),
  9147. show = mode === "show",
  9148. direction = o.direction || "left",
  9149. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9150. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  9151. animation = {
  9152. opacity: show ? 1 : 0
  9153. },
  9154. distance;
  9155. // Adjust
  9156. $.effects.save( el, props );
  9157. el.show();
  9158. $.effects.createWrapper( el );
  9159. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  9160. if ( show ) {
  9161. el
  9162. .css( "opacity", 0 )
  9163. .css( ref, motion === "pos" ? -distance : distance );
  9164. }
  9165. // Animation
  9166. animation[ ref ] = ( show ?
  9167. ( motion === "pos" ? "+=" : "-=" ) :
  9168. ( motion === "pos" ? "-=" : "+=" ) ) +
  9169. distance;
  9170. // Animate
  9171. el.animate( animation, {
  9172. queue: false,
  9173. duration: o.duration,
  9174. easing: o.easing,
  9175. complete: function() {
  9176. if ( mode === "hide" ) {
  9177. el.hide();
  9178. }
  9179. $.effects.restore( el, props );
  9180. $.effects.removeWrapper( el );
  9181. done();
  9182. }
  9183. });
  9184. };
  9185. })(jQuery);
  9186. (function( $, undefined ) {
  9187. $.effects.effect.explode = function( o, done ) {
  9188. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  9189. cells = rows,
  9190. el = $( this ),
  9191. mode = $.effects.setMode( el, o.mode || "hide" ),
  9192. show = mode === "show",
  9193. // show and then visibility:hidden the element before calculating offset
  9194. offset = el.show().css( "visibility", "hidden" ).offset(),
  9195. // width and height of a piece
  9196. width = Math.ceil( el.outerWidth() / cells ),
  9197. height = Math.ceil( el.outerHeight() / rows ),
  9198. pieces = [],
  9199. // loop
  9200. i, j, left, top, mx, my;
  9201. // children animate complete:
  9202. function childComplete() {
  9203. pieces.push( this );
  9204. if ( pieces.length === rows * cells ) {
  9205. animComplete();
  9206. }
  9207. }
  9208. // clone the element for each row and cell.
  9209. for( i = 0; i < rows ; i++ ) { // ===>
  9210. top = offset.top + i * height;
  9211. my = i - ( rows - 1 ) / 2 ;
  9212. for( j = 0; j < cells ; j++ ) { // |||
  9213. left = offset.left + j * width;
  9214. mx = j - ( cells - 1 ) / 2 ;
  9215. // Create a clone of the now hidden main element that will be absolute positioned
  9216. // within a wrapper div off the -left and -top equal to size of our pieces
  9217. el
  9218. .clone()
  9219. .appendTo( "body" )
  9220. .wrap( "<div></div>" )
  9221. .css({
  9222. position: "absolute",
  9223. visibility: "visible",
  9224. left: -j * width,
  9225. top: -i * height
  9226. })
  9227. // select the wrapper - make it overflow: hidden and absolute positioned based on
  9228. // where the original was located +left and +top equal to the size of pieces
  9229. .parent()
  9230. .addClass( "ui-effects-explode" )
  9231. .css({
  9232. position: "absolute",
  9233. overflow: "hidden",
  9234. width: width,
  9235. height: height,
  9236. left: left + ( show ? mx * width : 0 ),
  9237. top: top + ( show ? my * height : 0 ),
  9238. opacity: show ? 0 : 1
  9239. }).animate({
  9240. left: left + ( show ? 0 : mx * width ),
  9241. top: top + ( show ? 0 : my * height ),
  9242. opacity: show ? 1 : 0
  9243. }, o.duration || 500, o.easing, childComplete );
  9244. }
  9245. }
  9246. function animComplete() {
  9247. el.css({
  9248. visibility: "visible"
  9249. });
  9250. $( pieces ).remove();
  9251. if ( !show ) {
  9252. el.hide();
  9253. }
  9254. done();
  9255. }
  9256. };
  9257. })(jQuery);
  9258. (function( $, undefined ) {
  9259. $.effects.effect.fade = function( o, done ) {
  9260. var el = $( this ),
  9261. mode = $.effects.setMode( el, o.mode || "toggle" );
  9262. el.animate({
  9263. opacity: mode
  9264. }, {
  9265. queue: false,
  9266. duration: o.duration,
  9267. easing: o.easing,
  9268. complete: done
  9269. });
  9270. };
  9271. })( jQuery );
  9272. (function( $, undefined ) {
  9273. $.effects.effect.fold = function( o, done ) {
  9274. // Create element
  9275. var el = $( this ),
  9276. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9277. mode = $.effects.setMode( el, o.mode || "hide" ),
  9278. show = mode === "show",
  9279. hide = mode === "hide",
  9280. size = o.size || 15,
  9281. percent = /([0-9]+)%/.exec( size ),
  9282. horizFirst = !!o.horizFirst,
  9283. widthFirst = show !== horizFirst,
  9284. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  9285. duration = o.duration / 2,
  9286. wrapper, distance,
  9287. animation1 = {},
  9288. animation2 = {};
  9289. $.effects.save( el, props );
  9290. el.show();
  9291. // Create Wrapper
  9292. wrapper = $.effects.createWrapper( el ).css({
  9293. overflow: "hidden"
  9294. });
  9295. distance = widthFirst ?
  9296. [ wrapper.width(), wrapper.height() ] :
  9297. [ wrapper.height(), wrapper.width() ];
  9298. if ( percent ) {
  9299. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  9300. }
  9301. if ( show ) {
  9302. wrapper.css( horizFirst ? {
  9303. height: 0,
  9304. width: size
  9305. } : {
  9306. height: size,
  9307. width: 0
  9308. });
  9309. }
  9310. // Animation
  9311. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  9312. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  9313. // Animate
  9314. wrapper
  9315. .animate( animation1, duration, o.easing )
  9316. .animate( animation2, duration, o.easing, function() {
  9317. if ( hide ) {
  9318. el.hide();
  9319. }
  9320. $.effects.restore( el, props );
  9321. $.effects.removeWrapper( el );
  9322. done();
  9323. });
  9324. };
  9325. })(jQuery);
  9326. (function( $, undefined ) {
  9327. $.effects.effect.highlight = function( o, done ) {
  9328. var elem = $( this ),
  9329. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  9330. mode = $.effects.setMode( elem, o.mode || "show" ),
  9331. animation = {
  9332. backgroundColor: elem.css( "backgroundColor" )
  9333. };
  9334. if (mode === "hide") {
  9335. animation.opacity = 0;
  9336. }
  9337. $.effects.save( elem, props );
  9338. elem
  9339. .show()
  9340. .css({
  9341. backgroundImage: "none",
  9342. backgroundColor: o.color || "#ffff99"
  9343. })
  9344. .animate( animation, {
  9345. queue: false,
  9346. duration: o.duration,
  9347. easing: o.easing,
  9348. complete: function() {
  9349. if ( mode === "hide" ) {
  9350. elem.hide();
  9351. }
  9352. $.effects.restore( elem, props );
  9353. done();
  9354. }
  9355. });
  9356. };
  9357. })(jQuery);
  9358. (function( $, undefined ) {
  9359. $.effects.effect.pulsate = function( o, done ) {
  9360. var elem = $( this ),
  9361. mode = $.effects.setMode( elem, o.mode || "show" ),
  9362. show = mode === "show",
  9363. hide = mode === "hide",
  9364. showhide = ( show || mode === "hide" ),
  9365. // showing or hiding leaves of the "last" animation
  9366. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  9367. duration = o.duration / anims,
  9368. animateTo = 0,
  9369. queue = elem.queue(),
  9370. queuelen = queue.length,
  9371. i;
  9372. if ( show || !elem.is(":visible")) {
  9373. elem.css( "opacity", 0 ).show();
  9374. animateTo = 1;
  9375. }
  9376. // anims - 1 opacity "toggles"
  9377. for ( i = 1; i < anims; i++ ) {
  9378. elem.animate({
  9379. opacity: animateTo
  9380. }, duration, o.easing );
  9381. animateTo = 1 - animateTo;
  9382. }
  9383. elem.animate({
  9384. opacity: animateTo
  9385. }, duration, o.easing);
  9386. elem.queue(function() {
  9387. if ( hide ) {
  9388. elem.hide();
  9389. }
  9390. done();
  9391. });
  9392. // We just queued up "anims" animations, we need to put them next in the queue
  9393. if ( queuelen > 1 ) {
  9394. queue.splice.apply( queue,
  9395. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9396. }
  9397. elem.dequeue();
  9398. };
  9399. })(jQuery);
  9400. (function( $, undefined ) {
  9401. $.effects.effect.puff = function( o, done ) {
  9402. var elem = $( this ),
  9403. mode = $.effects.setMode( elem, o.mode || "hide" ),
  9404. hide = mode === "hide",
  9405. percent = parseInt( o.percent, 10 ) || 150,
  9406. factor = percent / 100,
  9407. original = {
  9408. height: elem.height(),
  9409. width: elem.width(),
  9410. outerHeight: elem.outerHeight(),
  9411. outerWidth: elem.outerWidth()
  9412. };
  9413. $.extend( o, {
  9414. effect: "scale",
  9415. queue: false,
  9416. fade: true,
  9417. mode: mode,
  9418. complete: done,
  9419. percent: hide ? percent : 100,
  9420. from: hide ?
  9421. original :
  9422. {
  9423. height: original.height * factor,
  9424. width: original.width * factor,
  9425. outerHeight: original.outerHeight * factor,
  9426. outerWidth: original.outerWidth * factor
  9427. }
  9428. });
  9429. elem.effect( o );
  9430. };
  9431. $.effects.effect.scale = function( o, done ) {
  9432. // Create element
  9433. var el = $( this ),
  9434. options = $.extend( true, {}, o ),
  9435. mode = $.effects.setMode( el, o.mode || "effect" ),
  9436. percent = parseInt( o.percent, 10 ) ||
  9437. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  9438. direction = o.direction || "both",
  9439. origin = o.origin,
  9440. original = {
  9441. height: el.height(),
  9442. width: el.width(),
  9443. outerHeight: el.outerHeight(),
  9444. outerWidth: el.outerWidth()
  9445. },
  9446. factor = {
  9447. y: direction !== "horizontal" ? (percent / 100) : 1,
  9448. x: direction !== "vertical" ? (percent / 100) : 1
  9449. };
  9450. // We are going to pass this effect to the size effect:
  9451. options.effect = "size";
  9452. options.queue = false;
  9453. options.complete = done;
  9454. // Set default origin and restore for show/hide
  9455. if ( mode !== "effect" ) {
  9456. options.origin = origin || ["middle","center"];
  9457. options.restore = true;
  9458. }
  9459. options.from = o.from || ( mode === "show" ? {
  9460. height: 0,
  9461. width: 0,
  9462. outerHeight: 0,
  9463. outerWidth: 0
  9464. } : original );
  9465. options.to = {
  9466. height: original.height * factor.y,
  9467. width: original.width * factor.x,
  9468. outerHeight: original.outerHeight * factor.y,
  9469. outerWidth: original.outerWidth * factor.x
  9470. };
  9471. // Fade option to support puff
  9472. if ( options.fade ) {
  9473. if ( mode === "show" ) {
  9474. options.from.opacity = 0;
  9475. options.to.opacity = 1;
  9476. }
  9477. if ( mode === "hide" ) {
  9478. options.from.opacity = 1;
  9479. options.to.opacity = 0;
  9480. }
  9481. }
  9482. // Animate
  9483. el.effect( options );
  9484. };
  9485. $.effects.effect.size = function( o, done ) {
  9486. // Create element
  9487. var original, baseline, factor,
  9488. el = $( this ),
  9489. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  9490. // Always restore
  9491. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  9492. // Copy for children
  9493. props2 = [ "width", "height", "overflow" ],
  9494. cProps = [ "fontSize" ],
  9495. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  9496. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  9497. // Set options
  9498. mode = $.effects.setMode( el, o.mode || "effect" ),
  9499. restore = o.restore || mode !== "effect",
  9500. scale = o.scale || "both",
  9501. origin = o.origin || [ "middle", "center" ],
  9502. position = el.css( "position" ),
  9503. props = restore ? props0 : props1,
  9504. zero = {
  9505. height: 0,
  9506. width: 0,
  9507. outerHeight: 0,
  9508. outerWidth: 0
  9509. };
  9510. if ( mode === "show" ) {
  9511. el.show();
  9512. }
  9513. original = {
  9514. height: el.height(),
  9515. width: el.width(),
  9516. outerHeight: el.outerHeight(),
  9517. outerWidth: el.outerWidth()
  9518. };
  9519. if ( o.mode === "toggle" && mode === "show" ) {
  9520. el.from = o.to || zero;
  9521. el.to = o.from || original;
  9522. } else {
  9523. el.from = o.from || ( mode === "show" ? zero : original );
  9524. el.to = o.to || ( mode === "hide" ? zero : original );
  9525. }
  9526. // Set scaling factor
  9527. factor = {
  9528. from: {
  9529. y: el.from.height / original.height,
  9530. x: el.from.width / original.width
  9531. },
  9532. to: {
  9533. y: el.to.height / original.height,
  9534. x: el.to.width / original.width
  9535. }
  9536. };
  9537. // Scale the css box
  9538. if ( scale === "box" || scale === "both" ) {
  9539. // Vertical props scaling
  9540. if ( factor.from.y !== factor.to.y ) {
  9541. props = props.concat( vProps );
  9542. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  9543. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  9544. }
  9545. // Horizontal props scaling
  9546. if ( factor.from.x !== factor.to.x ) {
  9547. props = props.concat( hProps );
  9548. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  9549. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  9550. }
  9551. }
  9552. // Scale the content
  9553. if ( scale === "content" || scale === "both" ) {
  9554. // Vertical props scaling
  9555. if ( factor.from.y !== factor.to.y ) {
  9556. props = props.concat( cProps ).concat( props2 );
  9557. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  9558. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  9559. }
  9560. }
  9561. $.effects.save( el, props );
  9562. el.show();
  9563. $.effects.createWrapper( el );
  9564. el.css( "overflow", "hidden" ).css( el.from );
  9565. // Adjust
  9566. if (origin) { // Calculate baseline shifts
  9567. baseline = $.effects.getBaseline( origin, original );
  9568. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  9569. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  9570. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  9571. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  9572. }
  9573. el.css( el.from ); // set top & left
  9574. // Animate
  9575. if ( scale === "content" || scale === "both" ) { // Scale the children
  9576. // Add margins/font-size
  9577. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  9578. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  9579. props2 = props0.concat(vProps).concat(hProps);
  9580. el.find( "*[width]" ).each( function(){
  9581. var child = $( this ),
  9582. c_original = {
  9583. height: child.height(),
  9584. width: child.width(),
  9585. outerHeight: child.outerHeight(),
  9586. outerWidth: child.outerWidth()
  9587. };
  9588. if (restore) {
  9589. $.effects.save(child, props2);
  9590. }
  9591. child.from = {
  9592. height: c_original.height * factor.from.y,
  9593. width: c_original.width * factor.from.x,
  9594. outerHeight: c_original.outerHeight * factor.from.y,
  9595. outerWidth: c_original.outerWidth * factor.from.x
  9596. };
  9597. child.to = {
  9598. height: c_original.height * factor.to.y,
  9599. width: c_original.width * factor.to.x,
  9600. outerHeight: c_original.height * factor.to.y,
  9601. outerWidth: c_original.width * factor.to.x
  9602. };
  9603. // Vertical props scaling
  9604. if ( factor.from.y !== factor.to.y ) {
  9605. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  9606. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  9607. }
  9608. // Horizontal props scaling
  9609. if ( factor.from.x !== factor.to.x ) {
  9610. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  9611. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  9612. }
  9613. // Animate children
  9614. child.css( child.from );
  9615. child.animate( child.to, o.duration, o.easing, function() {
  9616. // Restore children
  9617. if ( restore ) {
  9618. $.effects.restore( child, props2 );
  9619. }
  9620. });
  9621. });
  9622. }
  9623. // Animate
  9624. el.animate( el.to, {
  9625. queue: false,
  9626. duration: o.duration,
  9627. easing: o.easing,
  9628. complete: function() {
  9629. if ( el.to.opacity === 0 ) {
  9630. el.css( "opacity", el.from.opacity );
  9631. }
  9632. if( mode === "hide" ) {
  9633. el.hide();
  9634. }
  9635. $.effects.restore( el, props );
  9636. if ( !restore ) {
  9637. // we need to calculate our new positioning based on the scaling
  9638. if ( position === "static" ) {
  9639. el.css({
  9640. position: "relative",
  9641. top: el.to.top,
  9642. left: el.to.left
  9643. });
  9644. } else {
  9645. $.each([ "top", "left" ], function( idx, pos ) {
  9646. el.css( pos, function( _, str ) {
  9647. var val = parseInt( str, 10 ),
  9648. toRef = idx ? el.to.left : el.to.top;
  9649. // if original was "auto", recalculate the new value from wrapper
  9650. if ( str === "auto" ) {
  9651. return toRef + "px";
  9652. }
  9653. return val + toRef + "px";
  9654. });
  9655. });
  9656. }
  9657. }
  9658. $.effects.removeWrapper( el );
  9659. done();
  9660. }
  9661. });
  9662. };
  9663. })(jQuery);
  9664. (function( $, undefined ) {
  9665. $.effects.effect.shake = function( o, done ) {
  9666. var el = $( this ),
  9667. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9668. mode = $.effects.setMode( el, o.mode || "effect" ),
  9669. direction = o.direction || "left",
  9670. distance = o.distance || 20,
  9671. times = o.times || 3,
  9672. anims = times * 2 + 1,
  9673. speed = Math.round(o.duration/anims),
  9674. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9675. positiveMotion = (direction === "up" || direction === "left"),
  9676. animation = {},
  9677. animation1 = {},
  9678. animation2 = {},
  9679. i,
  9680. // we will need to re-assemble the queue to stack our animations in place
  9681. queue = el.queue(),
  9682. queuelen = queue.length;
  9683. $.effects.save( el, props );
  9684. el.show();
  9685. $.effects.createWrapper( el );
  9686. // Animation
  9687. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  9688. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  9689. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  9690. // Animate
  9691. el.animate( animation, speed, o.easing );
  9692. // Shakes
  9693. for ( i = 1; i < times; i++ ) {
  9694. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  9695. }
  9696. el
  9697. .animate( animation1, speed, o.easing )
  9698. .animate( animation, speed / 2, o.easing )
  9699. .queue(function() {
  9700. if ( mode === "hide" ) {
  9701. el.hide();
  9702. }
  9703. $.effects.restore( el, props );
  9704. $.effects.removeWrapper( el );
  9705. done();
  9706. });
  9707. // inject all the animations we just queued to be first in line (after "inprogress")
  9708. if ( queuelen > 1) {
  9709. queue.splice.apply( queue,
  9710. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9711. }
  9712. el.dequeue();
  9713. };
  9714. })(jQuery);
  9715. (function( $, undefined ) {
  9716. $.effects.effect.slide = function( o, done ) {
  9717. // Create element
  9718. var el = $( this ),
  9719. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  9720. mode = $.effects.setMode( el, o.mode || "show" ),
  9721. show = mode === "show",
  9722. direction = o.direction || "left",
  9723. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9724. positiveMotion = (direction === "up" || direction === "left"),
  9725. distance,
  9726. animation = {};
  9727. // Adjust
  9728. $.effects.save( el, props );
  9729. el.show();
  9730. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  9731. $.effects.createWrapper( el ).css({
  9732. overflow: "hidden"
  9733. });
  9734. if ( show ) {
  9735. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  9736. }
  9737. // Animation
  9738. animation[ ref ] = ( show ?
  9739. ( positiveMotion ? "+=" : "-=") :
  9740. ( positiveMotion ? "-=" : "+=")) +
  9741. distance;
  9742. // Animate
  9743. el.animate( animation, {
  9744. queue: false,
  9745. duration: o.duration,
  9746. easing: o.easing,
  9747. complete: function() {
  9748. if ( mode === "hide" ) {
  9749. el.hide();
  9750. }
  9751. $.effects.restore( el, props );
  9752. $.effects.removeWrapper( el );
  9753. done();
  9754. }
  9755. });
  9756. };
  9757. })(jQuery);
  9758. (function( $, undefined ) {
  9759. $.effects.effect.transfer = function( o, done ) {
  9760. var elem = $( this ),
  9761. target = $( o.to ),
  9762. targetFixed = target.css( "position" ) === "fixed",
  9763. body = $("body"),
  9764. fixTop = targetFixed ? body.scrollTop() : 0,
  9765. fixLeft = targetFixed ? body.scrollLeft() : 0,
  9766. endPosition = target.offset(),
  9767. animation = {
  9768. top: endPosition.top - fixTop ,
  9769. left: endPosition.left - fixLeft ,
  9770. height: target.innerHeight(),
  9771. width: target.innerWidth()
  9772. },
  9773. startPosition = elem.offset(),
  9774. transfer = $( "<div class='ui-effects-transfer'></div>" )
  9775. .appendTo( document.body )
  9776. .addClass( o.className )
  9777. .css({
  9778. top: startPosition.top - fixTop ,
  9779. left: startPosition.left - fixLeft ,
  9780. height: elem.innerHeight(),
  9781. width: elem.innerWidth(),
  9782. position: targetFixed ? "fixed" : "absolute"
  9783. })
  9784. .animate( animation, o.duration, o.easing, function() {
  9785. transfer.remove();
  9786. done();
  9787. });
  9788. };
  9789. })(jQuery);
  9790. (function( $, undefined ) {
  9791. $.widget( "ui.menu", {
  9792. version: "1.10.4",
  9793. defaultElement: "<ul>",
  9794. delay: 300,
  9795. options: {
  9796. icons: {
  9797. submenu: "ui-icon-carat-1-e"
  9798. },
  9799. menus: "ul",
  9800. position: {
  9801. my: "left top",
  9802. at: "right top"
  9803. },
  9804. role: "menu",
  9805. // callbacks
  9806. blur: null,
  9807. focus: null,
  9808. select: null
  9809. },
  9810. _create: function() {
  9811. this.activeMenu = this.element;
  9812. // flag used to prevent firing of the click handler
  9813. // as the event bubbles up through nested menus
  9814. this.mouseHandled = false;
  9815. this.element
  9816. .uniqueId()
  9817. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  9818. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  9819. .attr({
  9820. role: this.options.role,
  9821. tabIndex: 0
  9822. })
  9823. // need to catch all clicks on disabled menu
  9824. // not possible through _on
  9825. .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
  9826. if ( this.options.disabled ) {
  9827. event.preventDefault();
  9828. }
  9829. }, this ));
  9830. if ( this.options.disabled ) {
  9831. this.element
  9832. .addClass( "ui-state-disabled" )
  9833. .attr( "aria-disabled", "true" );
  9834. }
  9835. this._on({
  9836. // Prevent focus from sticking to links inside menu after clicking
  9837. // them (focus should always stay on UL during navigation).
  9838. "mousedown .ui-menu-item > a": function( event ) {
  9839. event.preventDefault();
  9840. },
  9841. "click .ui-state-disabled > a": function( event ) {
  9842. event.preventDefault();
  9843. },
  9844. "click .ui-menu-item:has(a)": function( event ) {
  9845. var target = $( event.target ).closest( ".ui-menu-item" );
  9846. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  9847. this.select( event );
  9848. // Only set the mouseHandled flag if the event will bubble, see #9469.
  9849. if ( !event.isPropagationStopped() ) {
  9850. this.mouseHandled = true;
  9851. }
  9852. // Open submenu on click
  9853. if ( target.has( ".ui-menu" ).length ) {
  9854. this.expand( event );
  9855. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  9856. // Redirect focus to the menu
  9857. this.element.trigger( "focus", [ true ] );
  9858. // If the active item is on the top level, let it stay active.
  9859. // Otherwise, blur the active item since it is no longer visible.
  9860. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  9861. clearTimeout( this.timer );
  9862. }
  9863. }
  9864. }
  9865. },
  9866. "mouseenter .ui-menu-item": function( event ) {
  9867. var target = $( event.currentTarget );
  9868. // Remove ui-state-active class from siblings of the newly focused menu item
  9869. // to avoid a jump caused by adjacent elements both having a class with a border
  9870. target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
  9871. this.focus( event, target );
  9872. },
  9873. mouseleave: "collapseAll",
  9874. "mouseleave .ui-menu": "collapseAll",
  9875. focus: function( event, keepActiveItem ) {
  9876. // If there's already an active item, keep it active
  9877. // If not, activate the first item
  9878. var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
  9879. if ( !keepActiveItem ) {
  9880. this.focus( event, item );
  9881. }
  9882. },
  9883. blur: function( event ) {
  9884. this._delay(function() {
  9885. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  9886. this.collapseAll( event );
  9887. }
  9888. });
  9889. },
  9890. keydown: "_keydown"
  9891. });
  9892. this.refresh();
  9893. // Clicks outside of a menu collapse any open menus
  9894. this._on( this.document, {
  9895. click: function( event ) {
  9896. if ( !$( event.target ).closest( ".ui-menu" ).length ) {
  9897. this.collapseAll( event );
  9898. }
  9899. // Reset the mouseHandled flag
  9900. this.mouseHandled = false;
  9901. }
  9902. });
  9903. },
  9904. _destroy: function() {
  9905. // Destroy (sub)menus
  9906. this.element
  9907. .removeAttr( "aria-activedescendant" )
  9908. .find( ".ui-menu" ).addBack()
  9909. .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
  9910. .removeAttr( "role" )
  9911. .removeAttr( "tabIndex" )
  9912. .removeAttr( "aria-labelledby" )
  9913. .removeAttr( "aria-expanded" )
  9914. .removeAttr( "aria-hidden" )
  9915. .removeAttr( "aria-disabled" )
  9916. .removeUniqueId()
  9917. .show();
  9918. // Destroy menu items
  9919. this.element.find( ".ui-menu-item" )
  9920. .removeClass( "ui-menu-item" )
  9921. .removeAttr( "role" )
  9922. .removeAttr( "aria-disabled" )
  9923. .children( "a" )
  9924. .removeUniqueId()
  9925. .removeClass( "ui-corner-all ui-state-hover" )
  9926. .removeAttr( "tabIndex" )
  9927. .removeAttr( "role" )
  9928. .removeAttr( "aria-haspopup" )
  9929. .children().each( function() {
  9930. var elem = $( this );
  9931. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  9932. elem.remove();
  9933. }
  9934. });
  9935. // Destroy menu dividers
  9936. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  9937. },
  9938. _keydown: function( event ) {
  9939. var match, prev, character, skip, regex,
  9940. preventDefault = true;
  9941. function escape( value ) {
  9942. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  9943. }
  9944. switch ( event.keyCode ) {
  9945. case $.ui.keyCode.PAGE_UP:
  9946. this.previousPage( event );
  9947. break;
  9948. case $.ui.keyCode.PAGE_DOWN:
  9949. this.nextPage( event );
  9950. break;
  9951. case $.ui.keyCode.HOME:
  9952. this._move( "first", "first", event );
  9953. break;
  9954. case $.ui.keyCode.END:
  9955. this._move( "last", "last", event );
  9956. break;
  9957. case $.ui.keyCode.UP:
  9958. this.previous( event );
  9959. break;
  9960. case $.ui.keyCode.DOWN:
  9961. this.next( event );
  9962. break;
  9963. case $.ui.keyCode.LEFT:
  9964. this.collapse( event );
  9965. break;
  9966. case $.ui.keyCode.RIGHT:
  9967. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  9968. this.expand( event );
  9969. }
  9970. break;
  9971. case $.ui.keyCode.ENTER:
  9972. case $.ui.keyCode.SPACE:
  9973. this._activate( event );
  9974. break;
  9975. case $.ui.keyCode.ESCAPE:
  9976. this.collapse( event );
  9977. break;
  9978. default:
  9979. preventDefault = false;
  9980. prev = this.previousFilter || "";
  9981. character = String.fromCharCode( event.keyCode );
  9982. skip = false;
  9983. clearTimeout( this.filterTimer );
  9984. if ( character === prev ) {
  9985. skip = true;
  9986. } else {
  9987. character = prev + character;
  9988. }
  9989. regex = new RegExp( "^" + escape( character ), "i" );
  9990. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  9991. return regex.test( $( this ).children( "a" ).text() );
  9992. });
  9993. match = skip && match.index( this.active.next() ) !== -1 ?
  9994. this.active.nextAll( ".ui-menu-item" ) :
  9995. match;
  9996. // If no matches on the current filter, reset to the last character pressed
  9997. // to move down the menu to the first item that starts with that character
  9998. if ( !match.length ) {
  9999. character = String.fromCharCode( event.keyCode );
  10000. regex = new RegExp( "^" + escape( character ), "i" );
  10001. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  10002. return regex.test( $( this ).children( "a" ).text() );
  10003. });
  10004. }
  10005. if ( match.length ) {
  10006. this.focus( event, match );
  10007. if ( match.length > 1 ) {
  10008. this.previousFilter = character;
  10009. this.filterTimer = this._delay(function() {
  10010. delete this.previousFilter;
  10011. }, 1000 );
  10012. } else {
  10013. delete this.previousFilter;
  10014. }
  10015. } else {
  10016. delete this.previousFilter;
  10017. }
  10018. }
  10019. if ( preventDefault ) {
  10020. event.preventDefault();
  10021. }
  10022. },
  10023. _activate: function( event ) {
  10024. if ( !this.active.is( ".ui-state-disabled" ) ) {
  10025. if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
  10026. this.expand( event );
  10027. } else {
  10028. this.select( event );
  10029. }
  10030. }
  10031. },
  10032. refresh: function() {
  10033. var menus,
  10034. icon = this.options.icons.submenu,
  10035. submenus = this.element.find( this.options.menus );
  10036. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  10037. // Initialize nested menus
  10038. submenus.filter( ":not(.ui-menu)" )
  10039. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  10040. .hide()
  10041. .attr({
  10042. role: this.options.role,
  10043. "aria-hidden": "true",
  10044. "aria-expanded": "false"
  10045. })
  10046. .each(function() {
  10047. var menu = $( this ),
  10048. item = menu.prev( "a" ),
  10049. submenuCarat = $( "<span>" )
  10050. .addClass( "ui-menu-icon ui-icon " + icon )
  10051. .data( "ui-menu-submenu-carat", true );
  10052. item
  10053. .attr( "aria-haspopup", "true" )
  10054. .prepend( submenuCarat );
  10055. menu.attr( "aria-labelledby", item.attr( "id" ) );
  10056. });
  10057. menus = submenus.add( this.element );
  10058. // Don't refresh list items that are already adapted
  10059. menus.children( ":not(.ui-menu-item):has(a)" )
  10060. .addClass( "ui-menu-item" )
  10061. .attr( "role", "presentation" )
  10062. .children( "a" )
  10063. .uniqueId()
  10064. .addClass( "ui-corner-all" )
  10065. .attr({
  10066. tabIndex: -1,
  10067. role: this._itemRole()
  10068. });
  10069. // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
  10070. menus.children( ":not(.ui-menu-item)" ).each(function() {
  10071. var item = $( this );
  10072. // hyphen, em dash, en dash
  10073. if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
  10074. item.addClass( "ui-widget-content ui-menu-divider" );
  10075. }
  10076. });
  10077. // Add aria-disabled attribute to any disabled menu item
  10078. menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  10079. // If the active item has been removed, blur the menu
  10080. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  10081. this.blur();
  10082. }
  10083. },
  10084. _itemRole: function() {
  10085. return {
  10086. menu: "menuitem",
  10087. listbox: "option"
  10088. }[ this.options.role ];
  10089. },
  10090. _setOption: function( key, value ) {
  10091. if ( key === "icons" ) {
  10092. this.element.find( ".ui-menu-icon" )
  10093. .removeClass( this.options.icons.submenu )
  10094. .addClass( value.submenu );
  10095. }
  10096. this._super( key, value );
  10097. },
  10098. focus: function( event, item ) {
  10099. var nested, focused;
  10100. this.blur( event, event && event.type === "focus" );
  10101. this._scrollIntoView( item );
  10102. this.active = item.first();
  10103. focused = this.active.children( "a" ).addClass( "ui-state-focus" );
  10104. // Only update aria-activedescendant if there's a role
  10105. // otherwise we assume focus is managed elsewhere
  10106. if ( this.options.role ) {
  10107. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  10108. }
  10109. // Highlight active parent menu item, if any
  10110. this.active
  10111. .parent()
  10112. .closest( ".ui-menu-item" )
  10113. .children( "a:first" )
  10114. .addClass( "ui-state-active" );
  10115. if ( event && event.type === "keydown" ) {
  10116. this._close();
  10117. } else {
  10118. this.timer = this._delay(function() {
  10119. this._close();
  10120. }, this.delay );
  10121. }
  10122. nested = item.children( ".ui-menu" );
  10123. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  10124. this._startOpening(nested);
  10125. }
  10126. this.activeMenu = item.parent();
  10127. this._trigger( "focus", event, { item: item } );
  10128. },
  10129. _scrollIntoView: function( item ) {
  10130. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  10131. if ( this._hasScroll() ) {
  10132. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  10133. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  10134. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  10135. scroll = this.activeMenu.scrollTop();
  10136. elementHeight = this.activeMenu.height();
  10137. itemHeight = item.height();
  10138. if ( offset < 0 ) {
  10139. this.activeMenu.scrollTop( scroll + offset );
  10140. } else if ( offset + itemHeight > elementHeight ) {
  10141. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  10142. }
  10143. }
  10144. },
  10145. blur: function( event, fromFocus ) {
  10146. if ( !fromFocus ) {
  10147. clearTimeout( this.timer );
  10148. }
  10149. if ( !this.active ) {
  10150. return;
  10151. }
  10152. this.active.children( "a" ).removeClass( "ui-state-focus" );
  10153. this.active = null;
  10154. this._trigger( "blur", event, { item: this.active } );
  10155. },
  10156. _startOpening: function( submenu ) {
  10157. clearTimeout( this.timer );
  10158. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  10159. // shift in the submenu position when mousing over the carat icon
  10160. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  10161. return;
  10162. }
  10163. this.timer = this._delay(function() {
  10164. this._close();
  10165. this._open( submenu );
  10166. }, this.delay );
  10167. },
  10168. _open: function( submenu ) {
  10169. var position = $.extend({
  10170. of: this.active
  10171. }, this.options.position );
  10172. clearTimeout( this.timer );
  10173. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  10174. .hide()
  10175. .attr( "aria-hidden", "true" );
  10176. submenu
  10177. .show()
  10178. .removeAttr( "aria-hidden" )
  10179. .attr( "aria-expanded", "true" )
  10180. .position( position );
  10181. },
  10182. collapseAll: function( event, all ) {
  10183. clearTimeout( this.timer );
  10184. this.timer = this._delay(function() {
  10185. // If we were passed an event, look for the submenu that contains the event
  10186. var currentMenu = all ? this.element :
  10187. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  10188. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  10189. if ( !currentMenu.length ) {
  10190. currentMenu = this.element;
  10191. }
  10192. this._close( currentMenu );
  10193. this.blur( event );
  10194. this.activeMenu = currentMenu;
  10195. }, this.delay );
  10196. },
  10197. // With no arguments, closes the currently active menu - if nothing is active
  10198. // it closes all menus. If passed an argument, it will search for menus BELOW
  10199. _close: function( startMenu ) {
  10200. if ( !startMenu ) {
  10201. startMenu = this.active ? this.active.parent() : this.element;
  10202. }
  10203. startMenu
  10204. .find( ".ui-menu" )
  10205. .hide()
  10206. .attr( "aria-hidden", "true" )
  10207. .attr( "aria-expanded", "false" )
  10208. .end()
  10209. .find( "a.ui-state-active" )
  10210. .removeClass( "ui-state-active" );
  10211. },
  10212. collapse: function( event ) {
  10213. var newItem = this.active &&
  10214. this.active.parent().closest( ".ui-menu-item", this.element );
  10215. if ( newItem && newItem.length ) {
  10216. this._close();
  10217. this.focus( event, newItem );
  10218. }
  10219. },
  10220. expand: function( event ) {
  10221. var newItem = this.active &&
  10222. this.active
  10223. .children( ".ui-menu " )
  10224. .children( ".ui-menu-item" )
  10225. .first();
  10226. if ( newItem && newItem.length ) {
  10227. this._open( newItem.parent() );
  10228. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  10229. this._delay(function() {
  10230. this.focus( event, newItem );
  10231. });
  10232. }
  10233. },
  10234. next: function( event ) {
  10235. this._move( "next", "first", event );
  10236. },
  10237. previous: function( event ) {
  10238. this._move( "prev", "last", event );
  10239. },
  10240. isFirstItem: function() {
  10241. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  10242. },
  10243. isLastItem: function() {
  10244. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  10245. },
  10246. _move: function( direction, filter, event ) {
  10247. var next;
  10248. if ( this.active ) {
  10249. if ( direction === "first" || direction === "last" ) {
  10250. next = this.active
  10251. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  10252. .eq( -1 );
  10253. } else {
  10254. next = this.active
  10255. [ direction + "All" ]( ".ui-menu-item" )
  10256. .eq( 0 );
  10257. }
  10258. }
  10259. if ( !next || !next.length || !this.active ) {
  10260. next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
  10261. }
  10262. this.focus( event, next );
  10263. },
  10264. nextPage: function( event ) {
  10265. var item, base, height;
  10266. if ( !this.active ) {
  10267. this.next( event );
  10268. return;
  10269. }
  10270. if ( this.isLastItem() ) {
  10271. return;
  10272. }
  10273. if ( this._hasScroll() ) {
  10274. base = this.active.offset().top;
  10275. height = this.element.height();
  10276. this.active.nextAll( ".ui-menu-item" ).each(function() {
  10277. item = $( this );
  10278. return item.offset().top - base - height < 0;
  10279. });
  10280. this.focus( event, item );
  10281. } else {
  10282. this.focus( event, this.activeMenu.children( ".ui-menu-item" )
  10283. [ !this.active ? "first" : "last" ]() );
  10284. }
  10285. },
  10286. previousPage: function( event ) {
  10287. var item, base, height;
  10288. if ( !this.active ) {
  10289. this.next( event );
  10290. return;
  10291. }
  10292. if ( this.isFirstItem() ) {
  10293. return;
  10294. }
  10295. if ( this._hasScroll() ) {
  10296. base = this.active.offset().top;
  10297. height = this.element.height();
  10298. this.active.prevAll( ".ui-menu-item" ).each(function() {
  10299. item = $( this );
  10300. return item.offset().top - base + height > 0;
  10301. });
  10302. this.focus( event, item );
  10303. } else {
  10304. this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
  10305. }
  10306. },
  10307. _hasScroll: function() {
  10308. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  10309. },
  10310. select: function( event ) {
  10311. // TODO: It should never be possible to not have an active item at this
  10312. // point, but the tests don't trigger mouseenter before click.
  10313. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  10314. var ui = { item: this.active };
  10315. if ( !this.active.has( ".ui-menu" ).length ) {
  10316. this.collapseAll( event, true );
  10317. }
  10318. this._trigger( "select", event, ui );
  10319. }
  10320. });
  10321. }( jQuery ));
  10322. (function( $, undefined ) {
  10323. $.ui = $.ui || {};
  10324. var cachedScrollbarWidth,
  10325. max = Math.max,
  10326. abs = Math.abs,
  10327. round = Math.round,
  10328. rhorizontal = /left|center|right/,
  10329. rvertical = /top|center|bottom/,
  10330. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  10331. rposition = /^\w+/,
  10332. rpercent = /%$/,
  10333. _position = $.fn.position;
  10334. function getOffsets( offsets, width, height ) {
  10335. return [
  10336. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  10337. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  10338. ];
  10339. }
  10340. function parseCss( element, property ) {
  10341. return parseInt( $.css( element, property ), 10 ) || 0;
  10342. }
  10343. function getDimensions( elem ) {
  10344. var raw = elem[0];
  10345. if ( raw.nodeType === 9 ) {
  10346. return {
  10347. width: elem.width(),
  10348. height: elem.height(),
  10349. offset: { top: 0, left: 0 }
  10350. };
  10351. }
  10352. if ( $.isWindow( raw ) ) {
  10353. return {
  10354. width: elem.width(),
  10355. height: elem.height(),
  10356. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  10357. };
  10358. }
  10359. if ( raw.preventDefault ) {
  10360. return {
  10361. width: 0,
  10362. height: 0,
  10363. offset: { top: raw.pageY, left: raw.pageX }
  10364. };
  10365. }
  10366. return {
  10367. width: elem.outerWidth(),
  10368. height: elem.outerHeight(),
  10369. offset: elem.offset()
  10370. };
  10371. }
  10372. $.position = {
  10373. scrollbarWidth: function() {
  10374. if ( cachedScrollbarWidth !== undefined ) {
  10375. return cachedScrollbarWidth;
  10376. }
  10377. var w1, w2,
  10378. div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  10379. innerDiv = div.children()[0];
  10380. $( "body" ).append( div );
  10381. w1 = innerDiv.offsetWidth;
  10382. div.css( "overflow", "scroll" );
  10383. w2 = innerDiv.offsetWidth;
  10384. if ( w1 === w2 ) {
  10385. w2 = div[0].clientWidth;
  10386. }
  10387. div.remove();
  10388. return (cachedScrollbarWidth = w1 - w2);
  10389. },
  10390. getScrollInfo: function( within ) {
  10391. var overflowX = within.isWindow || within.isDocument ? "" :
  10392. within.element.css( "overflow-x" ),
  10393. overflowY = within.isWindow || within.isDocument ? "" :
  10394. within.element.css( "overflow-y" ),
  10395. hasOverflowX = overflowX === "scroll" ||
  10396. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  10397. hasOverflowY = overflowY === "scroll" ||
  10398. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  10399. return {
  10400. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  10401. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  10402. };
  10403. },
  10404. getWithinInfo: function( element ) {
  10405. var withinElement = $( element || window ),
  10406. isWindow = $.isWindow( withinElement[0] ),
  10407. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
  10408. return {
  10409. element: withinElement,
  10410. isWindow: isWindow,
  10411. isDocument: isDocument,
  10412. offset: withinElement.offset() || { left: 0, top: 0 },
  10413. scrollLeft: withinElement.scrollLeft(),
  10414. scrollTop: withinElement.scrollTop(),
  10415. width: isWindow ? withinElement.width() : withinElement.outerWidth(),
  10416. height: isWindow ? withinElement.height() : withinElement.outerHeight()
  10417. };
  10418. }
  10419. };
  10420. $.fn.position = function( options ) {
  10421. if ( !options || !options.of ) {
  10422. return _position.apply( this, arguments );
  10423. }
  10424. // make a copy, we don't want to modify arguments
  10425. options = $.extend( {}, options );
  10426. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  10427. target = $( options.of ),
  10428. within = $.position.getWithinInfo( options.within ),
  10429. scrollInfo = $.position.getScrollInfo( within ),
  10430. collision = ( options.collision || "flip" ).split( " " ),
  10431. offsets = {};
  10432. dimensions = getDimensions( target );
  10433. if ( target[0].preventDefault ) {
  10434. // force left top to allow flipping
  10435. options.at = "left top";
  10436. }
  10437. targetWidth = dimensions.width;
  10438. targetHeight = dimensions.height;
  10439. targetOffset = dimensions.offset;
  10440. // clone to reuse original targetOffset later
  10441. basePosition = $.extend( {}, targetOffset );
  10442. // force my and at to have valid horizontal and vertical positions
  10443. // if a value is missing or invalid, it will be converted to center
  10444. $.each( [ "my", "at" ], function() {
  10445. var pos = ( options[ this ] || "" ).split( " " ),
  10446. horizontalOffset,
  10447. verticalOffset;
  10448. if ( pos.length === 1) {
  10449. pos = rhorizontal.test( pos[ 0 ] ) ?
  10450. pos.concat( [ "center" ] ) :
  10451. rvertical.test( pos[ 0 ] ) ?
  10452. [ "center" ].concat( pos ) :
  10453. [ "center", "center" ];
  10454. }
  10455. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  10456. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  10457. // calculate offsets
  10458. horizontalOffset = roffset.exec( pos[ 0 ] );
  10459. verticalOffset = roffset.exec( pos[ 1 ] );
  10460. offsets[ this ] = [
  10461. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  10462. verticalOffset ? verticalOffset[ 0 ] : 0
  10463. ];
  10464. // reduce to just the positions without the offsets
  10465. options[ this ] = [
  10466. rposition.exec( pos[ 0 ] )[ 0 ],
  10467. rposition.exec( pos[ 1 ] )[ 0 ]
  10468. ];
  10469. });
  10470. // normalize collision option
  10471. if ( collision.length === 1 ) {
  10472. collision[ 1 ] = collision[ 0 ];
  10473. }
  10474. if ( options.at[ 0 ] === "right" ) {
  10475. basePosition.left += targetWidth;
  10476. } else if ( options.at[ 0 ] === "center" ) {
  10477. basePosition.left += targetWidth / 2;
  10478. }
  10479. if ( options.at[ 1 ] === "bottom" ) {
  10480. basePosition.top += targetHeight;
  10481. } else if ( options.at[ 1 ] === "center" ) {
  10482. basePosition.top += targetHeight / 2;
  10483. }
  10484. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  10485. basePosition.left += atOffset[ 0 ];
  10486. basePosition.top += atOffset[ 1 ];
  10487. return this.each(function() {
  10488. var collisionPosition, using,
  10489. elem = $( this ),
  10490. elemWidth = elem.outerWidth(),
  10491. elemHeight = elem.outerHeight(),
  10492. marginLeft = parseCss( this, "marginLeft" ),
  10493. marginTop = parseCss( this, "marginTop" ),
  10494. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  10495. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  10496. position = $.extend( {}, basePosition ),
  10497. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  10498. if ( options.my[ 0 ] === "right" ) {
  10499. position.left -= elemWidth;
  10500. } else if ( options.my[ 0 ] === "center" ) {
  10501. position.left -= elemWidth / 2;
  10502. }
  10503. if ( options.my[ 1 ] === "bottom" ) {
  10504. position.top -= elemHeight;
  10505. } else if ( options.my[ 1 ] === "center" ) {
  10506. position.top -= elemHeight / 2;
  10507. }
  10508. position.left += myOffset[ 0 ];
  10509. position.top += myOffset[ 1 ];
  10510. // if the browser doesn't support fractions, then round for consistent results
  10511. if ( !$.support.offsetFractions ) {
  10512. position.left = round( position.left );
  10513. position.top = round( position.top );
  10514. }
  10515. collisionPosition = {
  10516. marginLeft: marginLeft,
  10517. marginTop: marginTop
  10518. };
  10519. $.each( [ "left", "top" ], function( i, dir ) {
  10520. if ( $.ui.position[ collision[ i ] ] ) {
  10521. $.ui.position[ collision[ i ] ][ dir ]( position, {
  10522. targetWidth: targetWidth,
  10523. targetHeight: targetHeight,
  10524. elemWidth: elemWidth,
  10525. elemHeight: elemHeight,
  10526. collisionPosition: collisionPosition,
  10527. collisionWidth: collisionWidth,
  10528. collisionHeight: collisionHeight,
  10529. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  10530. my: options.my,
  10531. at: options.at,
  10532. within: within,
  10533. elem : elem
  10534. });
  10535. }
  10536. });
  10537. if ( options.using ) {
  10538. // adds feedback as second argument to using callback, if present
  10539. using = function( props ) {
  10540. var left = targetOffset.left - position.left,
  10541. right = left + targetWidth - elemWidth,
  10542. top = targetOffset.top - position.top,
  10543. bottom = top + targetHeight - elemHeight,
  10544. feedback = {
  10545. target: {
  10546. element: target,
  10547. left: targetOffset.left,
  10548. top: targetOffset.top,
  10549. width: targetWidth,
  10550. height: targetHeight
  10551. },
  10552. element: {
  10553. element: elem,
  10554. left: position.left,
  10555. top: position.top,
  10556. width: elemWidth,
  10557. height: elemHeight
  10558. },
  10559. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  10560. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  10561. };
  10562. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  10563. feedback.horizontal = "center";
  10564. }
  10565. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  10566. feedback.vertical = "middle";
  10567. }
  10568. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  10569. feedback.important = "horizontal";
  10570. } else {
  10571. feedback.important = "vertical";
  10572. }
  10573. options.using.call( this, props, feedback );
  10574. };
  10575. }
  10576. elem.offset( $.extend( position, { using: using } ) );
  10577. });
  10578. };
  10579. $.ui.position = {
  10580. fit: {
  10581. left: function( position, data ) {
  10582. var within = data.within,
  10583. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  10584. outerWidth = within.width,
  10585. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  10586. overLeft = withinOffset - collisionPosLeft,
  10587. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  10588. newOverRight;
  10589. // element is wider than within
  10590. if ( data.collisionWidth > outerWidth ) {
  10591. // element is initially over the left side of within
  10592. if ( overLeft > 0 && overRight <= 0 ) {
  10593. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  10594. position.left += overLeft - newOverRight;
  10595. // element is initially over right side of within
  10596. } else if ( overRight > 0 && overLeft <= 0 ) {
  10597. position.left = withinOffset;
  10598. // element is initially over both left and right sides of within
  10599. } else {
  10600. if ( overLeft > overRight ) {
  10601. position.left = withinOffset + outerWidth - data.collisionWidth;
  10602. } else {
  10603. position.left = withinOffset;
  10604. }
  10605. }
  10606. // too far left -> align with left edge
  10607. } else if ( overLeft > 0 ) {
  10608. position.left += overLeft;
  10609. // too far right -> align with right edge
  10610. } else if ( overRight > 0 ) {
  10611. position.left -= overRight;
  10612. // adjust based on position and margin
  10613. } else {
  10614. position.left = max( position.left - collisionPosLeft, position.left );
  10615. }
  10616. },
  10617. top: function( position, data ) {
  10618. var within = data.within,
  10619. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  10620. outerHeight = data.within.height,
  10621. collisionPosTop = position.top - data.collisionPosition.marginTop,
  10622. overTop = withinOffset - collisionPosTop,
  10623. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  10624. newOverBottom;
  10625. // element is taller than within
  10626. if ( data.collisionHeight > outerHeight ) {
  10627. // element is initially over the top of within
  10628. if ( overTop > 0 && overBottom <= 0 ) {
  10629. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  10630. position.top += overTop - newOverBottom;
  10631. // element is initially over bottom of within
  10632. } else if ( overBottom > 0 && overTop <= 0 ) {
  10633. position.top = withinOffset;
  10634. // element is initially over both top and bottom of within
  10635. } else {
  10636. if ( overTop > overBottom ) {
  10637. position.top = withinOffset + outerHeight - data.collisionHeight;
  10638. } else {
  10639. position.top = withinOffset;
  10640. }
  10641. }
  10642. // too far up -> align with top
  10643. } else if ( overTop > 0 ) {
  10644. position.top += overTop;
  10645. // too far down -> align with bottom edge
  10646. } else if ( overBottom > 0 ) {
  10647. position.top -= overBottom;
  10648. // adjust based on position and margin
  10649. } else {
  10650. position.top = max( position.top - collisionPosTop, position.top );
  10651. }
  10652. }
  10653. },
  10654. flip: {
  10655. left: function( position, data ) {
  10656. var within = data.within,
  10657. withinOffset = within.offset.left + within.scrollLeft,
  10658. outerWidth = within.width,
  10659. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  10660. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  10661. overLeft = collisionPosLeft - offsetLeft,
  10662. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  10663. myOffset = data.my[ 0 ] === "left" ?
  10664. -data.elemWidth :
  10665. data.my[ 0 ] === "right" ?
  10666. data.elemWidth :
  10667. 0,
  10668. atOffset = data.at[ 0 ] === "left" ?
  10669. data.targetWidth :
  10670. data.at[ 0 ] === "right" ?
  10671. -data.targetWidth :
  10672. 0,
  10673. offset = -2 * data.offset[ 0 ],
  10674. newOverRight,
  10675. newOverLeft;
  10676. if ( overLeft < 0 ) {
  10677. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  10678. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  10679. position.left += myOffset + atOffset + offset;
  10680. }
  10681. }
  10682. else if ( overRight > 0 ) {
  10683. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  10684. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  10685. position.left += myOffset + atOffset + offset;
  10686. }
  10687. }
  10688. },
  10689. top: function( position, data ) {
  10690. var within = data.within,
  10691. withinOffset = within.offset.top + within.scrollTop,
  10692. outerHeight = within.height,
  10693. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  10694. collisionPosTop = position.top - data.collisionPosition.marginTop,
  10695. overTop = collisionPosTop - offsetTop,
  10696. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  10697. top = data.my[ 1 ] === "top",
  10698. myOffset = top ?
  10699. -data.elemHeight :
  10700. data.my[ 1 ] === "bottom" ?
  10701. data.elemHeight :
  10702. 0,
  10703. atOffset = data.at[ 1 ] === "top" ?
  10704. data.targetHeight :
  10705. data.at[ 1 ] === "bottom" ?
  10706. -data.targetHeight :
  10707. 0,
  10708. offset = -2 * data.offset[ 1 ],
  10709. newOverTop,
  10710. newOverBottom;
  10711. if ( overTop < 0 ) {
  10712. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  10713. if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
  10714. position.top += myOffset + atOffset + offset;
  10715. }
  10716. }
  10717. else if ( overBottom > 0 ) {
  10718. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  10719. if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
  10720. position.top += myOffset + atOffset + offset;
  10721. }
  10722. }
  10723. }
  10724. },
  10725. flipfit: {
  10726. left: function() {
  10727. $.ui.position.flip.left.apply( this, arguments );
  10728. $.ui.position.fit.left.apply( this, arguments );
  10729. },
  10730. top: function() {
  10731. $.ui.position.flip.top.apply( this, arguments );
  10732. $.ui.position.fit.top.apply( this, arguments );
  10733. }
  10734. }
  10735. };
  10736. // fraction support test
  10737. (function () {
  10738. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  10739. body = document.getElementsByTagName( "body" )[ 0 ],
  10740. div = document.createElement( "div" );
  10741. //Create a "fake body" for testing based on method used in jQuery.support
  10742. testElement = document.createElement( body ? "div" : "body" );
  10743. testElementStyle = {
  10744. visibility: "hidden",
  10745. width: 0,
  10746. height: 0,
  10747. border: 0,
  10748. margin: 0,
  10749. background: "none"
  10750. };
  10751. if ( body ) {
  10752. $.extend( testElementStyle, {
  10753. position: "absolute",
  10754. left: "-1000px",
  10755. top: "-1000px"
  10756. });
  10757. }
  10758. for ( i in testElementStyle ) {
  10759. testElement.style[ i ] = testElementStyle[ i ];
  10760. }
  10761. testElement.appendChild( div );
  10762. testElementParent = body || document.documentElement;
  10763. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  10764. div.style.cssText = "position: absolute; left: 10.7432222px;";
  10765. offsetLeft = $( div ).offset().left;
  10766. $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
  10767. testElement.innerHTML = "";
  10768. testElementParent.removeChild( testElement );
  10769. })();
  10770. }( jQuery ) );
  10771. (function( $, undefined ) {
  10772. $.widget( "ui.progressbar", {
  10773. version: "1.10.4",
  10774. options: {
  10775. max: 100,
  10776. value: 0,
  10777. change: null,
  10778. complete: null
  10779. },
  10780. min: 0,
  10781. _create: function() {
  10782. // Constrain initial value
  10783. this.oldValue = this.options.value = this._constrainedValue();
  10784. this.element
  10785. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10786. .attr({
  10787. // Only set static values, aria-valuenow and aria-valuemax are
  10788. // set inside _refreshValue()
  10789. role: "progressbar",
  10790. "aria-valuemin": this.min
  10791. });
  10792. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  10793. .appendTo( this.element );
  10794. this._refreshValue();
  10795. },
  10796. _destroy: function() {
  10797. this.element
  10798. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10799. .removeAttr( "role" )
  10800. .removeAttr( "aria-valuemin" )
  10801. .removeAttr( "aria-valuemax" )
  10802. .removeAttr( "aria-valuenow" );
  10803. this.valueDiv.remove();
  10804. },
  10805. value: function( newValue ) {
  10806. if ( newValue === undefined ) {
  10807. return this.options.value;
  10808. }
  10809. this.options.value = this._constrainedValue( newValue );
  10810. this._refreshValue();
  10811. },
  10812. _constrainedValue: function( newValue ) {
  10813. if ( newValue === undefined ) {
  10814. newValue = this.options.value;
  10815. }
  10816. this.indeterminate = newValue === false;
  10817. // sanitize value
  10818. if ( typeof newValue !== "number" ) {
  10819. newValue = 0;
  10820. }
  10821. return this.indeterminate ? false :
  10822. Math.min( this.options.max, Math.max( this.min, newValue ) );
  10823. },
  10824. _setOptions: function( options ) {
  10825. // Ensure "value" option is set after other values (like max)
  10826. var value = options.value;
  10827. delete options.value;
  10828. this._super( options );
  10829. this.options.value = this._constrainedValue( value );
  10830. this._refreshValue();
  10831. },
  10832. _setOption: function( key, value ) {
  10833. if ( key === "max" ) {
  10834. // Don't allow a max less than min
  10835. value = Math.max( this.min, value );
  10836. }
  10837. this._super( key, value );
  10838. },
  10839. _percentage: function() {
  10840. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  10841. },
  10842. _refreshValue: function() {
  10843. var value = this.options.value,
  10844. percentage = this._percentage();
  10845. this.valueDiv
  10846. .toggle( this.indeterminate || value > this.min )
  10847. .toggleClass( "ui-corner-right", value === this.options.max )
  10848. .width( percentage.toFixed(0) + "%" );
  10849. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  10850. if ( this.indeterminate ) {
  10851. this.element.removeAttr( "aria-valuenow" );
  10852. if ( !this.overlayDiv ) {
  10853. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  10854. }
  10855. } else {
  10856. this.element.attr({
  10857. "aria-valuemax": this.options.max,
  10858. "aria-valuenow": value
  10859. });
  10860. if ( this.overlayDiv ) {
  10861. this.overlayDiv.remove();
  10862. this.overlayDiv = null;
  10863. }
  10864. }
  10865. if ( this.oldValue !== value ) {
  10866. this.oldValue = value;
  10867. this._trigger( "change" );
  10868. }
  10869. if ( value === this.options.max ) {
  10870. this._trigger( "complete" );
  10871. }
  10872. }
  10873. });
  10874. })( jQuery );
  10875. (function( $, undefined ) {
  10876. // number of pages in a slider
  10877. // (how many times can you page up/down to go through the whole range)
  10878. var numPages = 5;
  10879. $.widget( "ui.slider", $.ui.mouse, {
  10880. version: "1.10.4",
  10881. widgetEventPrefix: "slide",
  10882. options: {
  10883. animate: false,
  10884. distance: 0,
  10885. max: 100,
  10886. min: 0,
  10887. orientation: "horizontal",
  10888. range: false,
  10889. step: 1,
  10890. value: 0,
  10891. values: null,
  10892. // callbacks
  10893. change: null,
  10894. slide: null,
  10895. start: null,
  10896. stop: null
  10897. },
  10898. _create: function() {
  10899. this._keySliding = false;
  10900. this._mouseSliding = false;
  10901. this._animateOff = true;
  10902. this._handleIndex = null;
  10903. this._detectOrientation();
  10904. this._mouseInit();
  10905. this.element
  10906. .addClass( "ui-slider" +
  10907. " ui-slider-" + this.orientation +
  10908. " ui-widget" +
  10909. " ui-widget-content" +
  10910. " ui-corner-all");
  10911. this._refresh();
  10912. this._setOption( "disabled", this.options.disabled );
  10913. this._animateOff = false;
  10914. },
  10915. _refresh: function() {
  10916. this._createRange();
  10917. this._createHandles();
  10918. this._setupEvents();
  10919. this._refreshValue();
  10920. },
  10921. _createHandles: function() {
  10922. var i, handleCount,
  10923. options = this.options,
  10924. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  10925. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  10926. handles = [];
  10927. handleCount = ( options.values && options.values.length ) || 1;
  10928. if ( existingHandles.length > handleCount ) {
  10929. existingHandles.slice( handleCount ).remove();
  10930. existingHandles = existingHandles.slice( 0, handleCount );
  10931. }
  10932. for ( i = existingHandles.length; i < handleCount; i++ ) {
  10933. handles.push( handle );
  10934. }
  10935. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  10936. this.handle = this.handles.eq( 0 );
  10937. this.handles.each(function( i ) {
  10938. $( this ).data( "ui-slider-handle-index", i );
  10939. });
  10940. },
  10941. _createRange: function() {
  10942. var options = this.options,
  10943. classes = "";
  10944. if ( options.range ) {
  10945. if ( options.range === true ) {
  10946. if ( !options.values ) {
  10947. options.values = [ this._valueMin(), this._valueMin() ];
  10948. } else if ( options.values.length && options.values.length !== 2 ) {
  10949. options.values = [ options.values[0], options.values[0] ];
  10950. } else if ( $.isArray( options.values ) ) {
  10951. options.values = options.values.slice(0);
  10952. }
  10953. }
  10954. if ( !this.range || !this.range.length ) {
  10955. this.range = $( "<div></div>" )
  10956. .appendTo( this.element );
  10957. classes = "ui-slider-range" +
  10958. // note: this isn't the most fittingly semantic framework class for this element,
  10959. // but worked best visually with a variety of themes
  10960. " ui-widget-header ui-corner-all";
  10961. } else {
  10962. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  10963. // Handle range switching from true to min/max
  10964. .css({
  10965. "left": "",
  10966. "bottom": ""
  10967. });
  10968. }
  10969. this.range.addClass( classes +
  10970. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  10971. } else {
  10972. if ( this.range ) {
  10973. this.range.remove();
  10974. }
  10975. this.range = null;
  10976. }
  10977. },
  10978. _setupEvents: function() {
  10979. var elements = this.handles.add( this.range ).filter( "a" );
  10980. this._off( elements );
  10981. this._on( elements, this._handleEvents );
  10982. this._hoverable( elements );
  10983. this._focusable( elements );
  10984. },
  10985. _destroy: function() {
  10986. this.handles.remove();
  10987. if ( this.range ) {
  10988. this.range.remove();
  10989. }
  10990. this.element
  10991. .removeClass( "ui-slider" +
  10992. " ui-slider-horizontal" +
  10993. " ui-slider-vertical" +
  10994. " ui-widget" +
  10995. " ui-widget-content" +
  10996. " ui-corner-all" );
  10997. this._mouseDestroy();
  10998. },
  10999. _mouseCapture: function( event ) {
  11000. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  11001. that = this,
  11002. o = this.options;
  11003. if ( o.disabled ) {
  11004. return false;
  11005. }
  11006. this.elementSize = {
  11007. width: this.element.outerWidth(),
  11008. height: this.element.outerHeight()
  11009. };
  11010. this.elementOffset = this.element.offset();
  11011. position = { x: event.pageX, y: event.pageY };
  11012. normValue = this._normValueFromMouse( position );
  11013. distance = this._valueMax() - this._valueMin() + 1;
  11014. this.handles.each(function( i ) {
  11015. var thisDistance = Math.abs( normValue - that.values(i) );
  11016. if (( distance > thisDistance ) ||
  11017. ( distance === thisDistance &&
  11018. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  11019. distance = thisDistance;
  11020. closestHandle = $( this );
  11021. index = i;
  11022. }
  11023. });
  11024. allowed = this._start( event, index );
  11025. if ( allowed === false ) {
  11026. return false;
  11027. }
  11028. this._mouseSliding = true;
  11029. this._handleIndex = index;
  11030. closestHandle
  11031. .addClass( "ui-state-active" )
  11032. .focus();
  11033. offset = closestHandle.offset();
  11034. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  11035. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  11036. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  11037. top: event.pageY - offset.top -
  11038. ( closestHandle.height() / 2 ) -
  11039. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  11040. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  11041. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  11042. };
  11043. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  11044. this._slide( event, index, normValue );
  11045. }
  11046. this._animateOff = true;
  11047. return true;
  11048. },
  11049. _mouseStart: function() {
  11050. return true;
  11051. },
  11052. _mouseDrag: function( event ) {
  11053. var position = { x: event.pageX, y: event.pageY },
  11054. normValue = this._normValueFromMouse( position );
  11055. this._slide( event, this._handleIndex, normValue );
  11056. return false;
  11057. },
  11058. _mouseStop: function( event ) {
  11059. this.handles.removeClass( "ui-state-active" );
  11060. this._mouseSliding = false;
  11061. this._stop( event, this._handleIndex );
  11062. this._change( event, this._handleIndex );
  11063. this._handleIndex = null;
  11064. this._clickOffset = null;
  11065. this._animateOff = false;
  11066. return false;
  11067. },
  11068. _detectOrientation: function() {
  11069. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  11070. },
  11071. _normValueFromMouse: function( position ) {
  11072. var pixelTotal,
  11073. pixelMouse,
  11074. percentMouse,
  11075. valueTotal,
  11076. valueMouse;
  11077. if ( this.orientation === "horizontal" ) {
  11078. pixelTotal = this.elementSize.width;
  11079. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  11080. } else {
  11081. pixelTotal = this.elementSize.height;
  11082. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  11083. }
  11084. percentMouse = ( pixelMouse / pixelTotal );
  11085. if ( percentMouse > 1 ) {
  11086. percentMouse = 1;
  11087. }
  11088. if ( percentMouse < 0 ) {
  11089. percentMouse = 0;
  11090. }
  11091. if ( this.orientation === "vertical" ) {
  11092. percentMouse = 1 - percentMouse;
  11093. }
  11094. valueTotal = this._valueMax() - this._valueMin();
  11095. valueMouse = this._valueMin() + percentMouse * valueTotal;
  11096. return this._trimAlignValue( valueMouse );
  11097. },
  11098. _start: function( event, index ) {
  11099. var uiHash = {
  11100. handle: this.handles[ index ],
  11101. value: this.value()
  11102. };
  11103. if ( this.options.values && this.options.values.length ) {
  11104. uiHash.value = this.values( index );
  11105. uiHash.values = this.values();
  11106. }
  11107. return this._trigger( "start", event, uiHash );
  11108. },
  11109. _slide: function( event, index, newVal ) {
  11110. var otherVal,
  11111. newValues,
  11112. allowed;
  11113. if ( this.options.values && this.options.values.length ) {
  11114. otherVal = this.values( index ? 0 : 1 );
  11115. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  11116. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  11117. ) {
  11118. newVal = otherVal;
  11119. }
  11120. if ( newVal !== this.values( index ) ) {
  11121. newValues = this.values();
  11122. newValues[ index ] = newVal;
  11123. // A slide can be canceled by returning false from the slide callback
  11124. allowed = this._trigger( "slide", event, {
  11125. handle: this.handles[ index ],
  11126. value: newVal,
  11127. values: newValues
  11128. } );
  11129. otherVal = this.values( index ? 0 : 1 );
  11130. if ( allowed !== false ) {
  11131. this.values( index, newVal );
  11132. }
  11133. }
  11134. } else {
  11135. if ( newVal !== this.value() ) {
  11136. // A slide can be canceled by returning false from the slide callback
  11137. allowed = this._trigger( "slide", event, {
  11138. handle: this.handles[ index ],
  11139. value: newVal
  11140. } );
  11141. if ( allowed !== false ) {
  11142. this.value( newVal );
  11143. }
  11144. }
  11145. }
  11146. },
  11147. _stop: function( event, index ) {
  11148. var uiHash = {
  11149. handle: this.handles[ index ],
  11150. value: this.value()
  11151. };
  11152. if ( this.options.values && this.options.values.length ) {
  11153. uiHash.value = this.values( index );
  11154. uiHash.values = this.values();
  11155. }
  11156. this._trigger( "stop", event, uiHash );
  11157. },
  11158. _change: function( event, index ) {
  11159. if ( !this._keySliding && !this._mouseSliding ) {
  11160. var uiHash = {
  11161. handle: this.handles[ index ],
  11162. value: this.value()
  11163. };
  11164. if ( this.options.values && this.options.values.length ) {
  11165. uiHash.value = this.values( index );
  11166. uiHash.values = this.values();
  11167. }
  11168. //store the last changed value index for reference when handles overlap
  11169. this._lastChangedValue = index;
  11170. this._trigger( "change", event, uiHash );
  11171. }
  11172. },
  11173. value: function( newValue ) {
  11174. if ( arguments.length ) {
  11175. this.options.value = this._trimAlignValue( newValue );
  11176. this._refreshValue();
  11177. this._change( null, 0 );
  11178. return;
  11179. }
  11180. return this._value();
  11181. },
  11182. values: function( index, newValue ) {
  11183. var vals,
  11184. newValues,
  11185. i;
  11186. if ( arguments.length > 1 ) {
  11187. this.options.values[ index ] = this._trimAlignValue( newValue );
  11188. this._refreshValue();
  11189. this._change( null, index );
  11190. return;
  11191. }
  11192. if ( arguments.length ) {
  11193. if ( $.isArray( arguments[ 0 ] ) ) {
  11194. vals = this.options.values;
  11195. newValues = arguments[ 0 ];
  11196. for ( i = 0; i < vals.length; i += 1 ) {
  11197. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  11198. this._change( null, i );
  11199. }
  11200. this._refreshValue();
  11201. } else {
  11202. if ( this.options.values && this.options.values.length ) {
  11203. return this._values( index );
  11204. } else {
  11205. return this.value();
  11206. }
  11207. }
  11208. } else {
  11209. return this._values();
  11210. }
  11211. },
  11212. _setOption: function( key, value ) {
  11213. var i,
  11214. valsLength = 0;
  11215. if ( key === "range" && this.options.range === true ) {
  11216. if ( value === "min" ) {
  11217. this.options.value = this._values( 0 );
  11218. this.options.values = null;
  11219. } else if ( value === "max" ) {
  11220. this.options.value = this._values( this.options.values.length-1 );
  11221. this.options.values = null;
  11222. }
  11223. }
  11224. if ( $.isArray( this.options.values ) ) {
  11225. valsLength = this.options.values.length;
  11226. }
  11227. $.Widget.prototype._setOption.apply( this, arguments );
  11228. switch ( key ) {
  11229. case "orientation":
  11230. this._detectOrientation();
  11231. this.element
  11232. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  11233. .addClass( "ui-slider-" + this.orientation );
  11234. this._refreshValue();
  11235. break;
  11236. case "value":
  11237. this._animateOff = true;
  11238. this._refreshValue();
  11239. this._change( null, 0 );
  11240. this._animateOff = false;
  11241. break;
  11242. case "values":
  11243. this._animateOff = true;
  11244. this._refreshValue();
  11245. for ( i = 0; i < valsLength; i += 1 ) {
  11246. this._change( null, i );
  11247. }
  11248. this._animateOff = false;
  11249. break;
  11250. case "min":
  11251. case "max":
  11252. this._animateOff = true;
  11253. this._refreshValue();
  11254. this._animateOff = false;
  11255. break;
  11256. case "range":
  11257. this._animateOff = true;
  11258. this._refresh();
  11259. this._animateOff = false;
  11260. break;
  11261. }
  11262. },
  11263. //internal value getter
  11264. // _value() returns value trimmed by min and max, aligned by step
  11265. _value: function() {
  11266. var val = this.options.value;
  11267. val = this._trimAlignValue( val );
  11268. return val;
  11269. },
  11270. //internal values getter
  11271. // _values() returns array of values trimmed by min and max, aligned by step
  11272. // _values( index ) returns single value trimmed by min and max, aligned by step
  11273. _values: function( index ) {
  11274. var val,
  11275. vals,
  11276. i;
  11277. if ( arguments.length ) {
  11278. val = this.options.values[ index ];
  11279. val = this._trimAlignValue( val );
  11280. return val;
  11281. } else if ( this.options.values && this.options.values.length ) {
  11282. // .slice() creates a copy of the array
  11283. // this copy gets trimmed by min and max and then returned
  11284. vals = this.options.values.slice();
  11285. for ( i = 0; i < vals.length; i+= 1) {
  11286. vals[ i ] = this._trimAlignValue( vals[ i ] );
  11287. }
  11288. return vals;
  11289. } else {
  11290. return [];
  11291. }
  11292. },
  11293. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  11294. _trimAlignValue: function( val ) {
  11295. if ( val <= this._valueMin() ) {
  11296. return this._valueMin();
  11297. }
  11298. if ( val >= this._valueMax() ) {
  11299. return this._valueMax();
  11300. }
  11301. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  11302. valModStep = (val - this._valueMin()) % step,
  11303. alignValue = val - valModStep;
  11304. if ( Math.abs(valModStep) * 2 >= step ) {
  11305. alignValue += ( valModStep > 0 ) ? step : ( -step );
  11306. }
  11307. // Since JavaScript has problems with large floats, round
  11308. // the final value to 5 digits after the decimal point (see #4124)
  11309. return parseFloat( alignValue.toFixed(5) );
  11310. },
  11311. _valueMin: function() {
  11312. return this.options.min;
  11313. },
  11314. _valueMax: function() {
  11315. return this.options.max;
  11316. },
  11317. _refreshValue: function() {
  11318. var lastValPercent, valPercent, value, valueMin, valueMax,
  11319. oRange = this.options.range,
  11320. o = this.options,
  11321. that = this,
  11322. animate = ( !this._animateOff ) ? o.animate : false,
  11323. _set = {};
  11324. if ( this.options.values && this.options.values.length ) {
  11325. this.handles.each(function( i ) {
  11326. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  11327. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11328. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11329. if ( that.options.range === true ) {
  11330. if ( that.orientation === "horizontal" ) {
  11331. if ( i === 0 ) {
  11332. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  11333. }
  11334. if ( i === 1 ) {
  11335. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11336. }
  11337. } else {
  11338. if ( i === 0 ) {
  11339. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  11340. }
  11341. if ( i === 1 ) {
  11342. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11343. }
  11344. }
  11345. }
  11346. lastValPercent = valPercent;
  11347. });
  11348. } else {
  11349. value = this.value();
  11350. valueMin = this._valueMin();
  11351. valueMax = this._valueMax();
  11352. valPercent = ( valueMax !== valueMin ) ?
  11353. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  11354. 0;
  11355. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11356. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11357. if ( oRange === "min" && this.orientation === "horizontal" ) {
  11358. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  11359. }
  11360. if ( oRange === "max" && this.orientation === "horizontal" ) {
  11361. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11362. }
  11363. if ( oRange === "min" && this.orientation === "vertical" ) {
  11364. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  11365. }
  11366. if ( oRange === "max" && this.orientation === "vertical" ) {
  11367. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11368. }
  11369. }
  11370. },
  11371. _handleEvents: {
  11372. keydown: function( event ) {
  11373. var allowed, curVal, newVal, step,
  11374. index = $( event.target ).data( "ui-slider-handle-index" );
  11375. switch ( event.keyCode ) {
  11376. case $.ui.keyCode.HOME:
  11377. case $.ui.keyCode.END:
  11378. case $.ui.keyCode.PAGE_UP:
  11379. case $.ui.keyCode.PAGE_DOWN:
  11380. case $.ui.keyCode.UP:
  11381. case $.ui.keyCode.RIGHT:
  11382. case $.ui.keyCode.DOWN:
  11383. case $.ui.keyCode.LEFT:
  11384. event.preventDefault();
  11385. if ( !this._keySliding ) {
  11386. this._keySliding = true;
  11387. $( event.target ).addClass( "ui-state-active" );
  11388. allowed = this._start( event, index );
  11389. if ( allowed === false ) {
  11390. return;
  11391. }
  11392. }
  11393. break;
  11394. }
  11395. step = this.options.step;
  11396. if ( this.options.values && this.options.values.length ) {
  11397. curVal = newVal = this.values( index );
  11398. } else {
  11399. curVal = newVal = this.value();
  11400. }
  11401. switch ( event.keyCode ) {
  11402. case $.ui.keyCode.HOME:
  11403. newVal = this._valueMin();
  11404. break;
  11405. case $.ui.keyCode.END:
  11406. newVal = this._valueMax();
  11407. break;
  11408. case $.ui.keyCode.PAGE_UP:
  11409. newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
  11410. break;
  11411. case $.ui.keyCode.PAGE_DOWN:
  11412. newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
  11413. break;
  11414. case $.ui.keyCode.UP:
  11415. case $.ui.keyCode.RIGHT:
  11416. if ( curVal === this._valueMax() ) {
  11417. return;
  11418. }
  11419. newVal = this._trimAlignValue( curVal + step );
  11420. break;
  11421. case $.ui.keyCode.DOWN:
  11422. case $.ui.keyCode.LEFT:
  11423. if ( curVal === this._valueMin() ) {
  11424. return;
  11425. }
  11426. newVal = this._trimAlignValue( curVal - step );
  11427. break;
  11428. }
  11429. this._slide( event, index, newVal );
  11430. },
  11431. click: function( event ) {
  11432. event.preventDefault();
  11433. },
  11434. keyup: function( event ) {
  11435. var index = $( event.target ).data( "ui-slider-handle-index" );
  11436. if ( this._keySliding ) {
  11437. this._keySliding = false;
  11438. this._stop( event, index );
  11439. this._change( event, index );
  11440. $( event.target ).removeClass( "ui-state-active" );
  11441. }
  11442. }
  11443. }
  11444. });
  11445. }(jQuery));
  11446. (function( $ ) {
  11447. function modifier( fn ) {
  11448. return function() {
  11449. var previous = this.element.val();
  11450. fn.apply( this, arguments );
  11451. this._refresh();
  11452. if ( previous !== this.element.val() ) {
  11453. this._trigger( "change" );
  11454. }
  11455. };
  11456. }
  11457. $.widget( "ui.spinner", {
  11458. version: "1.10.4",
  11459. defaultElement: "<input>",
  11460. widgetEventPrefix: "spin",
  11461. options: {
  11462. culture: null,
  11463. icons: {
  11464. down: "ui-icon-triangle-1-s",
  11465. up: "ui-icon-triangle-1-n"
  11466. },
  11467. incremental: true,
  11468. max: null,
  11469. min: null,
  11470. numberFormat: null,
  11471. page: 10,
  11472. step: 1,
  11473. change: null,
  11474. spin: null,
  11475. start: null,
  11476. stop: null
  11477. },
  11478. _create: function() {
  11479. // handle string values that need to be parsed
  11480. this._setOption( "max", this.options.max );
  11481. this._setOption( "min", this.options.min );
  11482. this._setOption( "step", this.options.step );
  11483. // Only format if there is a value, prevents the field from being marked
  11484. // as invalid in Firefox, see #9573.
  11485. if ( this.value() !== "" ) {
  11486. // Format the value, but don't constrain.
  11487. this._value( this.element.val(), true );
  11488. }
  11489. this._draw();
  11490. this._on( this._events );
  11491. this._refresh();
  11492. // turning off autocomplete prevents the browser from remembering the
  11493. // value when navigating through history, so we re-enable autocomplete
  11494. // if the page is unloaded before the widget is destroyed. #7790
  11495. this._on( this.window, {
  11496. beforeunload: function() {
  11497. this.element.removeAttr( "autocomplete" );
  11498. }
  11499. });
  11500. },
  11501. _getCreateOptions: function() {
  11502. var options = {},
  11503. element = this.element;
  11504. $.each( [ "min", "max", "step" ], function( i, option ) {
  11505. var value = element.attr( option );
  11506. if ( value !== undefined && value.length ) {
  11507. options[ option ] = value;
  11508. }
  11509. });
  11510. return options;
  11511. },
  11512. _events: {
  11513. keydown: function( event ) {
  11514. if ( this._start( event ) && this._keydown( event ) ) {
  11515. event.preventDefault();
  11516. }
  11517. },
  11518. keyup: "_stop",
  11519. focus: function() {
  11520. this.previous = this.element.val();
  11521. },
  11522. blur: function( event ) {
  11523. if ( this.cancelBlur ) {
  11524. delete this.cancelBlur;
  11525. return;
  11526. }
  11527. this._stop();
  11528. this._refresh();
  11529. if ( this.previous !== this.element.val() ) {
  11530. this._trigger( "change", event );
  11531. }
  11532. },
  11533. mousewheel: function( event, delta ) {
  11534. if ( !delta ) {
  11535. return;
  11536. }
  11537. if ( !this.spinning && !this._start( event ) ) {
  11538. return false;
  11539. }
  11540. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  11541. clearTimeout( this.mousewheelTimer );
  11542. this.mousewheelTimer = this._delay(function() {
  11543. if ( this.spinning ) {
  11544. this._stop( event );
  11545. }
  11546. }, 100 );
  11547. event.preventDefault();
  11548. },
  11549. "mousedown .ui-spinner-button": function( event ) {
  11550. var previous;
  11551. // We never want the buttons to have focus; whenever the user is
  11552. // interacting with the spinner, the focus should be on the input.
  11553. // If the input is focused then this.previous is properly set from
  11554. // when the input first received focus. If the input is not focused
  11555. // then we need to set this.previous based on the value before spinning.
  11556. previous = this.element[0] === this.document[0].activeElement ?
  11557. this.previous : this.element.val();
  11558. function checkFocus() {
  11559. var isActive = this.element[0] === this.document[0].activeElement;
  11560. if ( !isActive ) {
  11561. this.element.focus();
  11562. this.previous = previous;
  11563. // support: IE
  11564. // IE sets focus asynchronously, so we need to check if focus
  11565. // moved off of the input because the user clicked on the button.
  11566. this._delay(function() {
  11567. this.previous = previous;
  11568. });
  11569. }
  11570. }
  11571. // ensure focus is on (or stays on) the text field
  11572. event.preventDefault();
  11573. checkFocus.call( this );
  11574. // support: IE
  11575. // IE doesn't prevent moving focus even with event.preventDefault()
  11576. // so we set a flag to know when we should ignore the blur event
  11577. // and check (again) if focus moved off of the input.
  11578. this.cancelBlur = true;
  11579. this._delay(function() {
  11580. delete this.cancelBlur;
  11581. checkFocus.call( this );
  11582. });
  11583. if ( this._start( event ) === false ) {
  11584. return;
  11585. }
  11586. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11587. },
  11588. "mouseup .ui-spinner-button": "_stop",
  11589. "mouseenter .ui-spinner-button": function( event ) {
  11590. // button will add ui-state-active if mouse was down while mouseleave and kept down
  11591. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  11592. return;
  11593. }
  11594. if ( this._start( event ) === false ) {
  11595. return false;
  11596. }
  11597. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11598. },
  11599. // TODO: do we really want to consider this a stop?
  11600. // shouldn't we just stop the repeater and wait until mouseup before
  11601. // we trigger the stop event?
  11602. "mouseleave .ui-spinner-button": "_stop"
  11603. },
  11604. _draw: function() {
  11605. var uiSpinner = this.uiSpinner = this.element
  11606. .addClass( "ui-spinner-input" )
  11607. .attr( "autocomplete", "off" )
  11608. .wrap( this._uiSpinnerHtml() )
  11609. .parent()
  11610. // add buttons
  11611. .append( this._buttonHtml() );
  11612. this.element.attr( "role", "spinbutton" );
  11613. // button bindings
  11614. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  11615. .attr( "tabIndex", -1 )
  11616. .button()
  11617. .removeClass( "ui-corner-all" );
  11618. // IE 6 doesn't understand height: 50% for the buttons
  11619. // unless the wrapper has an explicit height
  11620. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  11621. uiSpinner.height() > 0 ) {
  11622. uiSpinner.height( uiSpinner.height() );
  11623. }
  11624. // disable spinner if element was already disabled
  11625. if ( this.options.disabled ) {
  11626. this.disable();
  11627. }
  11628. },
  11629. _keydown: function( event ) {
  11630. var options = this.options,
  11631. keyCode = $.ui.keyCode;
  11632. switch ( event.keyCode ) {
  11633. case keyCode.UP:
  11634. this._repeat( null, 1, event );
  11635. return true;
  11636. case keyCode.DOWN:
  11637. this._repeat( null, -1, event );
  11638. return true;
  11639. case keyCode.PAGE_UP:
  11640. this._repeat( null, options.page, event );
  11641. return true;
  11642. case keyCode.PAGE_DOWN:
  11643. this._repeat( null, -options.page, event );
  11644. return true;
  11645. }
  11646. return false;
  11647. },
  11648. _uiSpinnerHtml: function() {
  11649. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  11650. },
  11651. _buttonHtml: function() {
  11652. return "" +
  11653. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  11654. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  11655. "</a>" +
  11656. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  11657. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  11658. "</a>";
  11659. },
  11660. _start: function( event ) {
  11661. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  11662. return false;
  11663. }
  11664. if ( !this.counter ) {
  11665. this.counter = 1;
  11666. }
  11667. this.spinning = true;
  11668. return true;
  11669. },
  11670. _repeat: function( i, steps, event ) {
  11671. i = i || 500;
  11672. clearTimeout( this.timer );
  11673. this.timer = this._delay(function() {
  11674. this._repeat( 40, steps, event );
  11675. }, i );
  11676. this._spin( steps * this.options.step, event );
  11677. },
  11678. _spin: function( step, event ) {
  11679. var value = this.value() || 0;
  11680. if ( !this.counter ) {
  11681. this.counter = 1;
  11682. }
  11683. value = this._adjustValue( value + step * this._increment( this.counter ) );
  11684. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  11685. this._value( value );
  11686. this.counter++;
  11687. }
  11688. },
  11689. _increment: function( i ) {
  11690. var incremental = this.options.incremental;
  11691. if ( incremental ) {
  11692. return $.isFunction( incremental ) ?
  11693. incremental( i ) :
  11694. Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
  11695. }
  11696. return 1;
  11697. },
  11698. _precision: function() {
  11699. var precision = this._precisionOf( this.options.step );
  11700. if ( this.options.min !== null ) {
  11701. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  11702. }
  11703. return precision;
  11704. },
  11705. _precisionOf: function( num ) {
  11706. var str = num.toString(),
  11707. decimal = str.indexOf( "." );
  11708. return decimal === -1 ? 0 : str.length - decimal - 1;
  11709. },
  11710. _adjustValue: function( value ) {
  11711. var base, aboveMin,
  11712. options = this.options;
  11713. // make sure we're at a valid step
  11714. // - find out where we are relative to the base (min or 0)
  11715. base = options.min !== null ? options.min : 0;
  11716. aboveMin = value - base;
  11717. // - round to the nearest step
  11718. aboveMin = Math.round(aboveMin / options.step) * options.step;
  11719. // - rounding is based on 0, so adjust back to our base
  11720. value = base + aboveMin;
  11721. // fix precision from bad JS floating point math
  11722. value = parseFloat( value.toFixed( this._precision() ) );
  11723. // clamp the value
  11724. if ( options.max !== null && value > options.max) {
  11725. return options.max;
  11726. }
  11727. if ( options.min !== null && value < options.min ) {
  11728. return options.min;
  11729. }
  11730. return value;
  11731. },
  11732. _stop: function( event ) {
  11733. if ( !this.spinning ) {
  11734. return;
  11735. }
  11736. clearTimeout( this.timer );
  11737. clearTimeout( this.mousewheelTimer );
  11738. this.counter = 0;
  11739. this.spinning = false;
  11740. this._trigger( "stop", event );
  11741. },
  11742. _setOption: function( key, value ) {
  11743. if ( key === "culture" || key === "numberFormat" ) {
  11744. var prevValue = this._parse( this.element.val() );
  11745. this.options[ key ] = value;
  11746. this.element.val( this._format( prevValue ) );
  11747. return;
  11748. }
  11749. if ( key === "max" || key === "min" || key === "step" ) {
  11750. if ( typeof value === "string" ) {
  11751. value = this._parse( value );
  11752. }
  11753. }
  11754. if ( key === "icons" ) {
  11755. this.buttons.first().find( ".ui-icon" )
  11756. .removeClass( this.options.icons.up )
  11757. .addClass( value.up );
  11758. this.buttons.last().find( ".ui-icon" )
  11759. .removeClass( this.options.icons.down )
  11760. .addClass( value.down );
  11761. }
  11762. this._super( key, value );
  11763. if ( key === "disabled" ) {
  11764. if ( value ) {
  11765. this.element.prop( "disabled", true );
  11766. this.buttons.button( "disable" );
  11767. } else {
  11768. this.element.prop( "disabled", false );
  11769. this.buttons.button( "enable" );
  11770. }
  11771. }
  11772. },
  11773. _setOptions: modifier(function( options ) {
  11774. this._super( options );
  11775. this._value( this.element.val() );
  11776. }),
  11777. _parse: function( val ) {
  11778. if ( typeof val === "string" && val !== "" ) {
  11779. val = window.Globalize && this.options.numberFormat ?
  11780. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  11781. }
  11782. return val === "" || isNaN( val ) ? null : val;
  11783. },
  11784. _format: function( value ) {
  11785. if ( value === "" ) {
  11786. return "";
  11787. }
  11788. return window.Globalize && this.options.numberFormat ?
  11789. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  11790. value;
  11791. },
  11792. _refresh: function() {
  11793. this.element.attr({
  11794. "aria-valuemin": this.options.min,
  11795. "aria-valuemax": this.options.max,
  11796. // TODO: what should we do with values that can't be parsed?
  11797. "aria-valuenow": this._parse( this.element.val() )
  11798. });
  11799. },
  11800. // update the value without triggering change
  11801. _value: function( value, allowAny ) {
  11802. var parsed;
  11803. if ( value !== "" ) {
  11804. parsed = this._parse( value );
  11805. if ( parsed !== null ) {
  11806. if ( !allowAny ) {
  11807. parsed = this._adjustValue( parsed );
  11808. }
  11809. value = this._format( parsed );
  11810. }
  11811. }
  11812. this.element.val( value );
  11813. this._refresh();
  11814. },
  11815. _destroy: function() {
  11816. this.element
  11817. .removeClass( "ui-spinner-input" )
  11818. .prop( "disabled", false )
  11819. .removeAttr( "autocomplete" )
  11820. .removeAttr( "role" )
  11821. .removeAttr( "aria-valuemin" )
  11822. .removeAttr( "aria-valuemax" )
  11823. .removeAttr( "aria-valuenow" );
  11824. this.uiSpinner.replaceWith( this.element );
  11825. },
  11826. stepUp: modifier(function( steps ) {
  11827. this._stepUp( steps );
  11828. }),
  11829. _stepUp: function( steps ) {
  11830. if ( this._start() ) {
  11831. this._spin( (steps || 1) * this.options.step );
  11832. this._stop();
  11833. }
  11834. },
  11835. stepDown: modifier(function( steps ) {
  11836. this._stepDown( steps );
  11837. }),
  11838. _stepDown: function( steps ) {
  11839. if ( this._start() ) {
  11840. this._spin( (steps || 1) * -this.options.step );
  11841. this._stop();
  11842. }
  11843. },
  11844. pageUp: modifier(function( pages ) {
  11845. this._stepUp( (pages || 1) * this.options.page );
  11846. }),
  11847. pageDown: modifier(function( pages ) {
  11848. this._stepDown( (pages || 1) * this.options.page );
  11849. }),
  11850. value: function( newVal ) {
  11851. if ( !arguments.length ) {
  11852. return this._parse( this.element.val() );
  11853. }
  11854. modifier( this._value ).call( this, newVal );
  11855. },
  11856. widget: function() {
  11857. return this.uiSpinner;
  11858. }
  11859. });
  11860. }( jQuery ) );
  11861. (function( $, undefined ) {
  11862. var tabId = 0,
  11863. rhash = /#.*$/;
  11864. function getNextTabId() {
  11865. return ++tabId;
  11866. }
  11867. function isLocal( anchor ) {
  11868. // support: IE7
  11869. // IE7 doesn't normalize the href property when set via script (#9317)
  11870. anchor = anchor.cloneNode( false );
  11871. return anchor.hash.length > 1 &&
  11872. decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
  11873. decodeURIComponent( location.href.replace( rhash, "" ) );
  11874. }
  11875. $.widget( "ui.tabs", {
  11876. version: "1.10.4",
  11877. delay: 300,
  11878. options: {
  11879. active: null,
  11880. collapsible: false,
  11881. event: "click",
  11882. heightStyle: "content",
  11883. hide: null,
  11884. show: null,
  11885. // callbacks
  11886. activate: null,
  11887. beforeActivate: null,
  11888. beforeLoad: null,
  11889. load: null
  11890. },
  11891. _create: function() {
  11892. var that = this,
  11893. options = this.options;
  11894. this.running = false;
  11895. this.element
  11896. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  11897. .toggleClass( "ui-tabs-collapsible", options.collapsible )
  11898. // Prevent users from focusing disabled tabs via click
  11899. .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
  11900. if ( $( this ).is( ".ui-state-disabled" ) ) {
  11901. event.preventDefault();
  11902. }
  11903. })
  11904. // support: IE <9
  11905. // Preventing the default action in mousedown doesn't prevent IE
  11906. // from focusing the element, so if the anchor gets focused, blur.
  11907. // We don't have to worry about focusing the previously focused
  11908. // element since clicking on a non-focusable element should focus
  11909. // the body anyway.
  11910. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  11911. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  11912. this.blur();
  11913. }
  11914. });
  11915. this._processTabs();
  11916. options.active = this._initialActive();
  11917. // Take disabling tabs via class attribute from HTML
  11918. // into account and update option properly.
  11919. if ( $.isArray( options.disabled ) ) {
  11920. options.disabled = $.unique( options.disabled.concat(
  11921. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  11922. return that.tabs.index( li );
  11923. })
  11924. ) ).sort();
  11925. }
  11926. // check for length avoids error when initializing empty list
  11927. if ( this.options.active !== false && this.anchors.length ) {
  11928. this.active = this._findActive( options.active );
  11929. } else {
  11930. this.active = $();
  11931. }
  11932. this._refresh();
  11933. if ( this.active.length ) {
  11934. this.load( options.active );
  11935. }
  11936. },
  11937. _initialActive: function() {
  11938. var active = this.options.active,
  11939. collapsible = this.options.collapsible,
  11940. locationHash = location.hash.substring( 1 );
  11941. if ( active === null ) {
  11942. // check the fragment identifier in the URL
  11943. if ( locationHash ) {
  11944. this.tabs.each(function( i, tab ) {
  11945. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  11946. active = i;
  11947. return false;
  11948. }
  11949. });
  11950. }
  11951. // check for a tab marked active via a class
  11952. if ( active === null ) {
  11953. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  11954. }
  11955. // no active tab, set to false
  11956. if ( active === null || active === -1 ) {
  11957. active = this.tabs.length ? 0 : false;
  11958. }
  11959. }
  11960. // handle numbers: negative, out of range
  11961. if ( active !== false ) {
  11962. active = this.tabs.index( this.tabs.eq( active ) );
  11963. if ( active === -1 ) {
  11964. active = collapsible ? false : 0;
  11965. }
  11966. }
  11967. // don't allow collapsible: false and active: false
  11968. if ( !collapsible && active === false && this.anchors.length ) {
  11969. active = 0;
  11970. }
  11971. return active;
  11972. },
  11973. _getCreateEventData: function() {
  11974. return {
  11975. tab: this.active,
  11976. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  11977. };
  11978. },
  11979. _tabKeydown: function( event ) {
  11980. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  11981. selectedIndex = this.tabs.index( focusedTab ),
  11982. goingForward = true;
  11983. if ( this._handlePageNav( event ) ) {
  11984. return;
  11985. }
  11986. switch ( event.keyCode ) {
  11987. case $.ui.keyCode.RIGHT:
  11988. case $.ui.keyCode.DOWN:
  11989. selectedIndex++;
  11990. break;
  11991. case $.ui.keyCode.UP:
  11992. case $.ui.keyCode.LEFT:
  11993. goingForward = false;
  11994. selectedIndex--;
  11995. break;
  11996. case $.ui.keyCode.END:
  11997. selectedIndex = this.anchors.length - 1;
  11998. break;
  11999. case $.ui.keyCode.HOME:
  12000. selectedIndex = 0;
  12001. break;
  12002. case $.ui.keyCode.SPACE:
  12003. // Activate only, no collapsing
  12004. event.preventDefault();
  12005. clearTimeout( this.activating );
  12006. this._activate( selectedIndex );
  12007. return;
  12008. case $.ui.keyCode.ENTER:
  12009. // Toggle (cancel delayed activation, allow collapsing)
  12010. event.preventDefault();
  12011. clearTimeout( this.activating );
  12012. // Determine if we should collapse or activate
  12013. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  12014. return;
  12015. default:
  12016. return;
  12017. }
  12018. // Focus the appropriate tab, based on which key was pressed
  12019. event.preventDefault();
  12020. clearTimeout( this.activating );
  12021. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  12022. // Navigating with control key will prevent automatic activation
  12023. if ( !event.ctrlKey ) {
  12024. // Update aria-selected immediately so that AT think the tab is already selected.
  12025. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  12026. // but the tab will already be activated by the time the announcement finishes.
  12027. focusedTab.attr( "aria-selected", "false" );
  12028. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  12029. this.activating = this._delay(function() {
  12030. this.option( "active", selectedIndex );
  12031. }, this.delay );
  12032. }
  12033. },
  12034. _panelKeydown: function( event ) {
  12035. if ( this._handlePageNav( event ) ) {
  12036. return;
  12037. }
  12038. // Ctrl+up moves focus to the current tab
  12039. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  12040. event.preventDefault();
  12041. this.active.focus();
  12042. }
  12043. },
  12044. // Alt+page up/down moves focus to the previous/next tab (and activates)
  12045. _handlePageNav: function( event ) {
  12046. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  12047. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  12048. return true;
  12049. }
  12050. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  12051. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  12052. return true;
  12053. }
  12054. },
  12055. _findNextTab: function( index, goingForward ) {
  12056. var lastTabIndex = this.tabs.length - 1;
  12057. function constrain() {
  12058. if ( index > lastTabIndex ) {
  12059. index = 0;
  12060. }
  12061. if ( index < 0 ) {
  12062. index = lastTabIndex;
  12063. }
  12064. return index;
  12065. }
  12066. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  12067. index = goingForward ? index + 1 : index - 1;
  12068. }
  12069. return index;
  12070. },
  12071. _focusNextTab: function( index, goingForward ) {
  12072. index = this._findNextTab( index, goingForward );
  12073. this.tabs.eq( index ).focus();
  12074. return index;
  12075. },
  12076. _setOption: function( key, value ) {
  12077. if ( key === "active" ) {
  12078. // _activate() will handle invalid values and update this.options
  12079. this._activate( value );
  12080. return;
  12081. }
  12082. if ( key === "disabled" ) {
  12083. // don't use the widget factory's disabled handling
  12084. this._setupDisabled( value );
  12085. return;
  12086. }
  12087. this._super( key, value);
  12088. if ( key === "collapsible" ) {
  12089. this.element.toggleClass( "ui-tabs-collapsible", value );
  12090. // Setting collapsible: false while collapsed; open first panel
  12091. if ( !value && this.options.active === false ) {
  12092. this._activate( 0 );
  12093. }
  12094. }
  12095. if ( key === "event" ) {
  12096. this._setupEvents( value );
  12097. }
  12098. if ( key === "heightStyle" ) {
  12099. this._setupHeightStyle( value );
  12100. }
  12101. },
  12102. _tabId: function( tab ) {
  12103. return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
  12104. },
  12105. _sanitizeSelector: function( hash ) {
  12106. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  12107. },
  12108. refresh: function() {
  12109. var options = this.options,
  12110. lis = this.tablist.children( ":has(a[href])" );
  12111. // get disabled tabs from class attribute from HTML
  12112. // this will get converted to a boolean if needed in _refresh()
  12113. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  12114. return lis.index( tab );
  12115. });
  12116. this._processTabs();
  12117. // was collapsed or no tabs
  12118. if ( options.active === false || !this.anchors.length ) {
  12119. options.active = false;
  12120. this.active = $();
  12121. // was active, but active tab is gone
  12122. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  12123. // all remaining tabs are disabled
  12124. if ( this.tabs.length === options.disabled.length ) {
  12125. options.active = false;
  12126. this.active = $();
  12127. // activate previous tab
  12128. } else {
  12129. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  12130. }
  12131. // was active, active tab still exists
  12132. } else {
  12133. // make sure active index is correct
  12134. options.active = this.tabs.index( this.active );
  12135. }
  12136. this._refresh();
  12137. },
  12138. _refresh: function() {
  12139. this._setupDisabled( this.options.disabled );
  12140. this._setupEvents( this.options.event );
  12141. this._setupHeightStyle( this.options.heightStyle );
  12142. this.tabs.not( this.active ).attr({
  12143. "aria-selected": "false",
  12144. tabIndex: -1
  12145. });
  12146. this.panels.not( this._getPanelForTab( this.active ) )
  12147. .hide()
  12148. .attr({
  12149. "aria-expanded": "false",
  12150. "aria-hidden": "true"
  12151. });
  12152. // Make sure one tab is in the tab order
  12153. if ( !this.active.length ) {
  12154. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  12155. } else {
  12156. this.active
  12157. .addClass( "ui-tabs-active ui-state-active" )
  12158. .attr({
  12159. "aria-selected": "true",
  12160. tabIndex: 0
  12161. });
  12162. this._getPanelForTab( this.active )
  12163. .show()
  12164. .attr({
  12165. "aria-expanded": "true",
  12166. "aria-hidden": "false"
  12167. });
  12168. }
  12169. },
  12170. _processTabs: function() {
  12171. var that = this;
  12172. this.tablist = this._getList()
  12173. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12174. .attr( "role", "tablist" );
  12175. this.tabs = this.tablist.find( "> li:has(a[href])" )
  12176. .addClass( "ui-state-default ui-corner-top" )
  12177. .attr({
  12178. role: "tab",
  12179. tabIndex: -1
  12180. });
  12181. this.anchors = this.tabs.map(function() {
  12182. return $( "a", this )[ 0 ];
  12183. })
  12184. .addClass( "ui-tabs-anchor" )
  12185. .attr({
  12186. role: "presentation",
  12187. tabIndex: -1
  12188. });
  12189. this.panels = $();
  12190. this.anchors.each(function( i, anchor ) {
  12191. var selector, panel, panelId,
  12192. anchorId = $( anchor ).uniqueId().attr( "id" ),
  12193. tab = $( anchor ).closest( "li" ),
  12194. originalAriaControls = tab.attr( "aria-controls" );
  12195. // inline tab
  12196. if ( isLocal( anchor ) ) {
  12197. selector = anchor.hash;
  12198. panel = that.element.find( that._sanitizeSelector( selector ) );
  12199. // remote tab
  12200. } else {
  12201. panelId = that._tabId( tab );
  12202. selector = "#" + panelId;
  12203. panel = that.element.find( selector );
  12204. if ( !panel.length ) {
  12205. panel = that._createPanel( panelId );
  12206. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  12207. }
  12208. panel.attr( "aria-live", "polite" );
  12209. }
  12210. if ( panel.length) {
  12211. that.panels = that.panels.add( panel );
  12212. }
  12213. if ( originalAriaControls ) {
  12214. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  12215. }
  12216. tab.attr({
  12217. "aria-controls": selector.substring( 1 ),
  12218. "aria-labelledby": anchorId
  12219. });
  12220. panel.attr( "aria-labelledby", anchorId );
  12221. });
  12222. this.panels
  12223. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12224. .attr( "role", "tabpanel" );
  12225. },
  12226. // allow overriding how to find the list for rare usage scenarios (#7715)
  12227. _getList: function() {
  12228. return this.tablist || this.element.find( "ol,ul" ).eq( 0 );
  12229. },
  12230. _createPanel: function( id ) {
  12231. return $( "<div>" )
  12232. .attr( "id", id )
  12233. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12234. .data( "ui-tabs-destroy", true );
  12235. },
  12236. _setupDisabled: function( disabled ) {
  12237. if ( $.isArray( disabled ) ) {
  12238. if ( !disabled.length ) {
  12239. disabled = false;
  12240. } else if ( disabled.length === this.anchors.length ) {
  12241. disabled = true;
  12242. }
  12243. }
  12244. // disable tabs
  12245. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  12246. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  12247. $( li )
  12248. .addClass( "ui-state-disabled" )
  12249. .attr( "aria-disabled", "true" );
  12250. } else {
  12251. $( li )
  12252. .removeClass( "ui-state-disabled" )
  12253. .removeAttr( "aria-disabled" );
  12254. }
  12255. }
  12256. this.options.disabled = disabled;
  12257. },
  12258. _setupEvents: function( event ) {
  12259. var events = {
  12260. click: function( event ) {
  12261. event.preventDefault();
  12262. }
  12263. };
  12264. if ( event ) {
  12265. $.each( event.split(" "), function( index, eventName ) {
  12266. events[ eventName ] = "_eventHandler";
  12267. });
  12268. }
  12269. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  12270. this._on( this.anchors, events );
  12271. this._on( this.tabs, { keydown: "_tabKeydown" } );
  12272. this._on( this.panels, { keydown: "_panelKeydown" } );
  12273. this._focusable( this.tabs );
  12274. this._hoverable( this.tabs );
  12275. },
  12276. _setupHeightStyle: function( heightStyle ) {
  12277. var maxHeight,
  12278. parent = this.element.parent();
  12279. if ( heightStyle === "fill" ) {
  12280. maxHeight = parent.height();
  12281. maxHeight -= this.element.outerHeight() - this.element.height();
  12282. this.element.siblings( ":visible" ).each(function() {
  12283. var elem = $( this ),
  12284. position = elem.css( "position" );
  12285. if ( position === "absolute" || position === "fixed" ) {
  12286. return;
  12287. }
  12288. maxHeight -= elem.outerHeight( true );
  12289. });
  12290. this.element.children().not( this.panels ).each(function() {
  12291. maxHeight -= $( this ).outerHeight( true );
  12292. });
  12293. this.panels.each(function() {
  12294. $( this ).height( Math.max( 0, maxHeight -
  12295. $( this ).innerHeight() + $( this ).height() ) );
  12296. })
  12297. .css( "overflow", "auto" );
  12298. } else if ( heightStyle === "auto" ) {
  12299. maxHeight = 0;
  12300. this.panels.each(function() {
  12301. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  12302. }).height( maxHeight );
  12303. }
  12304. },
  12305. _eventHandler: function( event ) {
  12306. var options = this.options,
  12307. active = this.active,
  12308. anchor = $( event.currentTarget ),
  12309. tab = anchor.closest( "li" ),
  12310. clickedIsActive = tab[ 0 ] === active[ 0 ],
  12311. collapsing = clickedIsActive && options.collapsible,
  12312. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  12313. toHide = !active.length ? $() : this._getPanelForTab( active ),
  12314. eventData = {
  12315. oldTab: active,
  12316. oldPanel: toHide,
  12317. newTab: collapsing ? $() : tab,
  12318. newPanel: toShow
  12319. };
  12320. event.preventDefault();
  12321. if ( tab.hasClass( "ui-state-disabled" ) ||
  12322. // tab is already loading
  12323. tab.hasClass( "ui-tabs-loading" ) ||
  12324. // can't switch durning an animation
  12325. this.running ||
  12326. // click on active header, but not collapsible
  12327. ( clickedIsActive && !options.collapsible ) ||
  12328. // allow canceling activation
  12329. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  12330. return;
  12331. }
  12332. options.active = collapsing ? false : this.tabs.index( tab );
  12333. this.active = clickedIsActive ? $() : tab;
  12334. if ( this.xhr ) {
  12335. this.xhr.abort();
  12336. }
  12337. if ( !toHide.length && !toShow.length ) {
  12338. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  12339. }
  12340. if ( toShow.length ) {
  12341. this.load( this.tabs.index( tab ), event );
  12342. }
  12343. this._toggle( event, eventData );
  12344. },
  12345. // handles show/hide for selecting tabs
  12346. _toggle: function( event, eventData ) {
  12347. var that = this,
  12348. toShow = eventData.newPanel,
  12349. toHide = eventData.oldPanel;
  12350. this.running = true;
  12351. function complete() {
  12352. that.running = false;
  12353. that._trigger( "activate", event, eventData );
  12354. }
  12355. function show() {
  12356. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  12357. if ( toShow.length && that.options.show ) {
  12358. that._show( toShow, that.options.show, complete );
  12359. } else {
  12360. toShow.show();
  12361. complete();
  12362. }
  12363. }
  12364. // start out by hiding, then showing, then completing
  12365. if ( toHide.length && this.options.hide ) {
  12366. this._hide( toHide, this.options.hide, function() {
  12367. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12368. show();
  12369. });
  12370. } else {
  12371. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12372. toHide.hide();
  12373. show();
  12374. }
  12375. toHide.attr({
  12376. "aria-expanded": "false",
  12377. "aria-hidden": "true"
  12378. });
  12379. eventData.oldTab.attr( "aria-selected", "false" );
  12380. // If we're switching tabs, remove the old tab from the tab order.
  12381. // If we're opening from collapsed state, remove the previous tab from the tab order.
  12382. // If we're collapsing, then keep the collapsing tab in the tab order.
  12383. if ( toShow.length && toHide.length ) {
  12384. eventData.oldTab.attr( "tabIndex", -1 );
  12385. } else if ( toShow.length ) {
  12386. this.tabs.filter(function() {
  12387. return $( this ).attr( "tabIndex" ) === 0;
  12388. })
  12389. .attr( "tabIndex", -1 );
  12390. }
  12391. toShow.attr({
  12392. "aria-expanded": "true",
  12393. "aria-hidden": "false"
  12394. });
  12395. eventData.newTab.attr({
  12396. "aria-selected": "true",
  12397. tabIndex: 0
  12398. });
  12399. },
  12400. _activate: function( index ) {
  12401. var anchor,
  12402. active = this._findActive( index );
  12403. // trying to activate the already active panel
  12404. if ( active[ 0 ] === this.active[ 0 ] ) {
  12405. return;
  12406. }
  12407. // trying to collapse, simulate a click on the current active header
  12408. if ( !active.length ) {
  12409. active = this.active;
  12410. }
  12411. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  12412. this._eventHandler({
  12413. target: anchor,
  12414. currentTarget: anchor,
  12415. preventDefault: $.noop
  12416. });
  12417. },
  12418. _findActive: function( index ) {
  12419. return index === false ? $() : this.tabs.eq( index );
  12420. },
  12421. _getIndex: function( index ) {
  12422. // meta-function to give users option to provide a href string instead of a numerical index.
  12423. if ( typeof index === "string" ) {
  12424. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  12425. }
  12426. return index;
  12427. },
  12428. _destroy: function() {
  12429. if ( this.xhr ) {
  12430. this.xhr.abort();
  12431. }
  12432. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  12433. this.tablist
  12434. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12435. .removeAttr( "role" );
  12436. this.anchors
  12437. .removeClass( "ui-tabs-anchor" )
  12438. .removeAttr( "role" )
  12439. .removeAttr( "tabIndex" )
  12440. .removeUniqueId();
  12441. this.tabs.add( this.panels ).each(function() {
  12442. if ( $.data( this, "ui-tabs-destroy" ) ) {
  12443. $( this ).remove();
  12444. } else {
  12445. $( this )
  12446. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  12447. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  12448. .removeAttr( "tabIndex" )
  12449. .removeAttr( "aria-live" )
  12450. .removeAttr( "aria-busy" )
  12451. .removeAttr( "aria-selected" )
  12452. .removeAttr( "aria-labelledby" )
  12453. .removeAttr( "aria-hidden" )
  12454. .removeAttr( "aria-expanded" )
  12455. .removeAttr( "role" );
  12456. }
  12457. });
  12458. this.tabs.each(function() {
  12459. var li = $( this ),
  12460. prev = li.data( "ui-tabs-aria-controls" );
  12461. if ( prev ) {
  12462. li
  12463. .attr( "aria-controls", prev )
  12464. .removeData( "ui-tabs-aria-controls" );
  12465. } else {
  12466. li.removeAttr( "aria-controls" );
  12467. }
  12468. });
  12469. this.panels.show();
  12470. if ( this.options.heightStyle !== "content" ) {
  12471. this.panels.css( "height", "" );
  12472. }
  12473. },
  12474. enable: function( index ) {
  12475. var disabled = this.options.disabled;
  12476. if ( disabled === false ) {
  12477. return;
  12478. }
  12479. if ( index === undefined ) {
  12480. disabled = false;
  12481. } else {
  12482. index = this._getIndex( index );
  12483. if ( $.isArray( disabled ) ) {
  12484. disabled = $.map( disabled, function( num ) {
  12485. return num !== index ? num : null;
  12486. });
  12487. } else {
  12488. disabled = $.map( this.tabs, function( li, num ) {
  12489. return num !== index ? num : null;
  12490. });
  12491. }
  12492. }
  12493. this._setupDisabled( disabled );
  12494. },
  12495. disable: function( index ) {
  12496. var disabled = this.options.disabled;
  12497. if ( disabled === true ) {
  12498. return;
  12499. }
  12500. if ( index === undefined ) {
  12501. disabled = true;
  12502. } else {
  12503. index = this._getIndex( index );
  12504. if ( $.inArray( index, disabled ) !== -1 ) {
  12505. return;
  12506. }
  12507. if ( $.isArray( disabled ) ) {
  12508. disabled = $.merge( [ index ], disabled ).sort();
  12509. } else {
  12510. disabled = [ index ];
  12511. }
  12512. }
  12513. this._setupDisabled( disabled );
  12514. },
  12515. load: function( index, event ) {
  12516. index = this._getIndex( index );
  12517. var that = this,
  12518. tab = this.tabs.eq( index ),
  12519. anchor = tab.find( ".ui-tabs-anchor" ),
  12520. panel = this._getPanelForTab( tab ),
  12521. eventData = {
  12522. tab: tab,
  12523. panel: panel
  12524. };
  12525. // not remote
  12526. if ( isLocal( anchor[ 0 ] ) ) {
  12527. return;
  12528. }
  12529. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  12530. // support: jQuery <1.8
  12531. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  12532. // but as of 1.8, $.ajax() always returns a jqXHR object.
  12533. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  12534. tab.addClass( "ui-tabs-loading" );
  12535. panel.attr( "aria-busy", "true" );
  12536. this.xhr
  12537. .success(function( response ) {
  12538. // support: jQuery <1.8
  12539. // http://bugs.jquery.com/ticket/11778
  12540. setTimeout(function() {
  12541. panel.html( response );
  12542. that._trigger( "load", event, eventData );
  12543. }, 1 );
  12544. })
  12545. .complete(function( jqXHR, status ) {
  12546. // support: jQuery <1.8
  12547. // http://bugs.jquery.com/ticket/11778
  12548. setTimeout(function() {
  12549. if ( status === "abort" ) {
  12550. that.panels.stop( false, true );
  12551. }
  12552. tab.removeClass( "ui-tabs-loading" );
  12553. panel.removeAttr( "aria-busy" );
  12554. if ( jqXHR === that.xhr ) {
  12555. delete that.xhr;
  12556. }
  12557. }, 1 );
  12558. });
  12559. }
  12560. },
  12561. _ajaxSettings: function( anchor, event, eventData ) {
  12562. var that = this;
  12563. return {
  12564. url: anchor.attr( "href" ),
  12565. beforeSend: function( jqXHR, settings ) {
  12566. return that._trigger( "beforeLoad", event,
  12567. $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
  12568. }
  12569. };
  12570. },
  12571. _getPanelForTab: function( tab ) {
  12572. var id = $( tab ).attr( "aria-controls" );
  12573. return this.element.find( this._sanitizeSelector( "#" + id ) );
  12574. }
  12575. });
  12576. })( jQuery );
  12577. (function( $ ) {
  12578. var increments = 0;
  12579. function addDescribedBy( elem, id ) {
  12580. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  12581. describedby.push( id );
  12582. elem
  12583. .data( "ui-tooltip-id", id )
  12584. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  12585. }
  12586. function removeDescribedBy( elem ) {
  12587. var id = elem.data( "ui-tooltip-id" ),
  12588. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  12589. index = $.inArray( id, describedby );
  12590. if ( index !== -1 ) {
  12591. describedby.splice( index, 1 );
  12592. }
  12593. elem.removeData( "ui-tooltip-id" );
  12594. describedby = $.trim( describedby.join( " " ) );
  12595. if ( describedby ) {
  12596. elem.attr( "aria-describedby", describedby );
  12597. } else {
  12598. elem.removeAttr( "aria-describedby" );
  12599. }
  12600. }
  12601. $.widget( "ui.tooltip", {
  12602. version: "1.10.4",
  12603. options: {
  12604. content: function() {
  12605. // support: IE<9, Opera in jQuery <1.7
  12606. // .text() can't accept undefined, so coerce to a string
  12607. var title = $( this ).attr( "title" ) || "";
  12608. // Escape title, since we're going from an attribute to raw HTML
  12609. return $( "<a>" ).text( title ).html();
  12610. },
  12611. hide: true,
  12612. // Disabled elements have inconsistent behavior across browsers (#8661)
  12613. items: "[title]:not([disabled])",
  12614. position: {
  12615. my: "left top+15",
  12616. at: "left bottom",
  12617. collision: "flipfit flip"
  12618. },
  12619. show: true,
  12620. tooltipClass: null,
  12621. track: false,
  12622. // callbacks
  12623. close: null,
  12624. open: null
  12625. },
  12626. _create: function() {
  12627. this._on({
  12628. mouseover: "open",
  12629. focusin: "open"
  12630. });
  12631. // IDs of generated tooltips, needed for destroy
  12632. this.tooltips = {};
  12633. // IDs of parent tooltips where we removed the title attribute
  12634. this.parents = {};
  12635. if ( this.options.disabled ) {
  12636. this._disable();
  12637. }
  12638. },
  12639. _setOption: function( key, value ) {
  12640. var that = this;
  12641. if ( key === "disabled" ) {
  12642. this[ value ? "_disable" : "_enable" ]();
  12643. this.options[ key ] = value;
  12644. // disable element style changes
  12645. return;
  12646. }
  12647. this._super( key, value );
  12648. if ( key === "content" ) {
  12649. $.each( this.tooltips, function( id, element ) {
  12650. that._updateContent( element );
  12651. });
  12652. }
  12653. },
  12654. _disable: function() {
  12655. var that = this;
  12656. // close open tooltips
  12657. $.each( this.tooltips, function( id, element ) {
  12658. var event = $.Event( "blur" );
  12659. event.target = event.currentTarget = element[0];
  12660. that.close( event, true );
  12661. });
  12662. // remove title attributes to prevent native tooltips
  12663. this.element.find( this.options.items ).addBack().each(function() {
  12664. var element = $( this );
  12665. if ( element.is( "[title]" ) ) {
  12666. element
  12667. .data( "ui-tooltip-title", element.attr( "title" ) )
  12668. .attr( "title", "" );
  12669. }
  12670. });
  12671. },
  12672. _enable: function() {
  12673. // restore title attributes
  12674. this.element.find( this.options.items ).addBack().each(function() {
  12675. var element = $( this );
  12676. if ( element.data( "ui-tooltip-title" ) ) {
  12677. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12678. }
  12679. });
  12680. },
  12681. open: function( event ) {
  12682. var that = this,
  12683. target = $( event ? event.target : this.element )
  12684. // we need closest here due to mouseover bubbling,
  12685. // but always pointing at the same event target
  12686. .closest( this.options.items );
  12687. // No element to show a tooltip for or the tooltip is already open
  12688. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  12689. return;
  12690. }
  12691. if ( target.attr( "title" ) ) {
  12692. target.data( "ui-tooltip-title", target.attr( "title" ) );
  12693. }
  12694. target.data( "ui-tooltip-open", true );
  12695. // kill parent tooltips, custom or native, for hover
  12696. if ( event && event.type === "mouseover" ) {
  12697. target.parents().each(function() {
  12698. var parent = $( this ),
  12699. blurEvent;
  12700. if ( parent.data( "ui-tooltip-open" ) ) {
  12701. blurEvent = $.Event( "blur" );
  12702. blurEvent.target = blurEvent.currentTarget = this;
  12703. that.close( blurEvent, true );
  12704. }
  12705. if ( parent.attr( "title" ) ) {
  12706. parent.uniqueId();
  12707. that.parents[ this.id ] = {
  12708. element: this,
  12709. title: parent.attr( "title" )
  12710. };
  12711. parent.attr( "title", "" );
  12712. }
  12713. });
  12714. }
  12715. this._updateContent( target, event );
  12716. },
  12717. _updateContent: function( target, event ) {
  12718. var content,
  12719. contentOption = this.options.content,
  12720. that = this,
  12721. eventType = event ? event.type : null;
  12722. if ( typeof contentOption === "string" ) {
  12723. return this._open( event, target, contentOption );
  12724. }
  12725. content = contentOption.call( target[0], function( response ) {
  12726. // ignore async response if tooltip was closed already
  12727. if ( !target.data( "ui-tooltip-open" ) ) {
  12728. return;
  12729. }
  12730. // IE may instantly serve a cached response for ajax requests
  12731. // delay this call to _open so the other call to _open runs first
  12732. that._delay(function() {
  12733. // jQuery creates a special event for focusin when it doesn't
  12734. // exist natively. To improve performance, the native event
  12735. // object is reused and the type is changed. Therefore, we can't
  12736. // rely on the type being correct after the event finished
  12737. // bubbling, so we set it back to the previous value. (#8740)
  12738. if ( event ) {
  12739. event.type = eventType;
  12740. }
  12741. this._open( event, target, response );
  12742. });
  12743. });
  12744. if ( content ) {
  12745. this._open( event, target, content );
  12746. }
  12747. },
  12748. _open: function( event, target, content ) {
  12749. var tooltip, events, delayedShow,
  12750. positionOption = $.extend( {}, this.options.position );
  12751. if ( !content ) {
  12752. return;
  12753. }
  12754. // Content can be updated multiple times. If the tooltip already
  12755. // exists, then just update the content and bail.
  12756. tooltip = this._find( target );
  12757. if ( tooltip.length ) {
  12758. tooltip.find( ".ui-tooltip-content" ).html( content );
  12759. return;
  12760. }
  12761. // if we have a title, clear it to prevent the native tooltip
  12762. // we have to check first to avoid defining a title if none exists
  12763. // (we don't want to cause an element to start matching [title])
  12764. //
  12765. // We use removeAttr only for key events, to allow IE to export the correct
  12766. // accessible attributes. For mouse events, set to empty string to avoid
  12767. // native tooltip showing up (happens only when removing inside mouseover).
  12768. if ( target.is( "[title]" ) ) {
  12769. if ( event && event.type === "mouseover" ) {
  12770. target.attr( "title", "" );
  12771. } else {
  12772. target.removeAttr( "title" );
  12773. }
  12774. }
  12775. tooltip = this._tooltip( target );
  12776. addDescribedBy( target, tooltip.attr( "id" ) );
  12777. tooltip.find( ".ui-tooltip-content" ).html( content );
  12778. function position( event ) {
  12779. positionOption.of = event;
  12780. if ( tooltip.is( ":hidden" ) ) {
  12781. return;
  12782. }
  12783. tooltip.position( positionOption );
  12784. }
  12785. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  12786. this._on( this.document, {
  12787. mousemove: position
  12788. });
  12789. // trigger once to override element-relative positioning
  12790. position( event );
  12791. } else {
  12792. tooltip.position( $.extend({
  12793. of: target
  12794. }, this.options.position ) );
  12795. }
  12796. tooltip.hide();
  12797. this._show( tooltip, this.options.show );
  12798. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  12799. // as the tooltip is visible, position the tooltip using the most recent
  12800. // event.
  12801. if ( this.options.show && this.options.show.delay ) {
  12802. delayedShow = this.delayedShow = setInterval(function() {
  12803. if ( tooltip.is( ":visible" ) ) {
  12804. position( positionOption.of );
  12805. clearInterval( delayedShow );
  12806. }
  12807. }, $.fx.interval );
  12808. }
  12809. this._trigger( "open", event, { tooltip: tooltip } );
  12810. events = {
  12811. keyup: function( event ) {
  12812. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  12813. var fakeEvent = $.Event(event);
  12814. fakeEvent.currentTarget = target[0];
  12815. this.close( fakeEvent, true );
  12816. }
  12817. },
  12818. remove: function() {
  12819. this._removeTooltip( tooltip );
  12820. }
  12821. };
  12822. if ( !event || event.type === "mouseover" ) {
  12823. events.mouseleave = "close";
  12824. }
  12825. if ( !event || event.type === "focusin" ) {
  12826. events.focusout = "close";
  12827. }
  12828. this._on( true, target, events );
  12829. },
  12830. close: function( event ) {
  12831. var that = this,
  12832. target = $( event ? event.currentTarget : this.element ),
  12833. tooltip = this._find( target );
  12834. // disabling closes the tooltip, so we need to track when we're closing
  12835. // to avoid an infinite loop in case the tooltip becomes disabled on close
  12836. if ( this.closing ) {
  12837. return;
  12838. }
  12839. // Clear the interval for delayed tracking tooltips
  12840. clearInterval( this.delayedShow );
  12841. // only set title if we had one before (see comment in _open())
  12842. if ( target.data( "ui-tooltip-title" ) ) {
  12843. target.attr( "title", target.data( "ui-tooltip-title" ) );
  12844. }
  12845. removeDescribedBy( target );
  12846. tooltip.stop( true );
  12847. this._hide( tooltip, this.options.hide, function() {
  12848. that._removeTooltip( $( this ) );
  12849. });
  12850. target.removeData( "ui-tooltip-open" );
  12851. this._off( target, "mouseleave focusout keyup" );
  12852. // Remove 'remove' binding only on delegated targets
  12853. if ( target[0] !== this.element[0] ) {
  12854. this._off( target, "remove" );
  12855. }
  12856. this._off( this.document, "mousemove" );
  12857. if ( event && event.type === "mouseleave" ) {
  12858. $.each( this.parents, function( id, parent ) {
  12859. $( parent.element ).attr( "title", parent.title );
  12860. delete that.parents[ id ];
  12861. });
  12862. }
  12863. this.closing = true;
  12864. this._trigger( "close", event, { tooltip: tooltip } );
  12865. this.closing = false;
  12866. },
  12867. _tooltip: function( element ) {
  12868. var id = "ui-tooltip-" + increments++,
  12869. tooltip = $( "<div>" )
  12870. .attr({
  12871. id: id,
  12872. role: "tooltip"
  12873. })
  12874. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  12875. ( this.options.tooltipClass || "" ) );
  12876. $( "<div>" )
  12877. .addClass( "ui-tooltip-content" )
  12878. .appendTo( tooltip );
  12879. tooltip.appendTo( this.document[0].body );
  12880. this.tooltips[ id ] = element;
  12881. return tooltip;
  12882. },
  12883. _find: function( target ) {
  12884. var id = target.data( "ui-tooltip-id" );
  12885. return id ? $( "#" + id ) : $();
  12886. },
  12887. _removeTooltip: function( tooltip ) {
  12888. tooltip.remove();
  12889. delete this.tooltips[ tooltip.attr( "id" ) ];
  12890. },
  12891. _destroy: function() {
  12892. var that = this;
  12893. // close open tooltips
  12894. $.each( this.tooltips, function( id, element ) {
  12895. // Delegate to close method to handle common cleanup
  12896. var event = $.Event( "blur" );
  12897. event.target = event.currentTarget = element[0];
  12898. that.close( event, true );
  12899. // Remove immediately; destroying an open tooltip doesn't use the
  12900. // hide animation
  12901. $( "#" + id ).remove();
  12902. // Restore the title
  12903. if ( element.data( "ui-tooltip-title" ) ) {
  12904. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12905. element.removeData( "ui-tooltip-title" );
  12906. }
  12907. });
  12908. }
  12909. });
  12910. }( jQuery ) );