jquery-ui-1.10.4.custom.js 426 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008
  1. /*! jQuery UI - v1.10.4 - 2014-03-23
  2. * http://jqueryui.com
  3. * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.menu.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js, jquery.ui.effect.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js
  4. * Copyright 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. $.ui = $.ui || {};
  861. var cachedScrollbarWidth,
  862. max = Math.max,
  863. abs = Math.abs,
  864. round = Math.round,
  865. rhorizontal = /left|center|right/,
  866. rvertical = /top|center|bottom/,
  867. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  868. rposition = /^\w+/,
  869. rpercent = /%$/,
  870. _position = $.fn.position;
  871. function getOffsets( offsets, width, height ) {
  872. return [
  873. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  874. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  875. ];
  876. }
  877. function parseCss( element, property ) {
  878. return parseInt( $.css( element, property ), 10 ) || 0;
  879. }
  880. function getDimensions( elem ) {
  881. var raw = elem[0];
  882. if ( raw.nodeType === 9 ) {
  883. return {
  884. width: elem.width(),
  885. height: elem.height(),
  886. offset: { top: 0, left: 0 }
  887. };
  888. }
  889. if ( $.isWindow( raw ) ) {
  890. return {
  891. width: elem.width(),
  892. height: elem.height(),
  893. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  894. };
  895. }
  896. if ( raw.preventDefault ) {
  897. return {
  898. width: 0,
  899. height: 0,
  900. offset: { top: raw.pageY, left: raw.pageX }
  901. };
  902. }
  903. return {
  904. width: elem.outerWidth(),
  905. height: elem.outerHeight(),
  906. offset: elem.offset()
  907. };
  908. }
  909. $.position = {
  910. scrollbarWidth: function() {
  911. if ( cachedScrollbarWidth !== undefined ) {
  912. return cachedScrollbarWidth;
  913. }
  914. var w1, w2,
  915. div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  916. innerDiv = div.children()[0];
  917. $( "body" ).append( div );
  918. w1 = innerDiv.offsetWidth;
  919. div.css( "overflow", "scroll" );
  920. w2 = innerDiv.offsetWidth;
  921. if ( w1 === w2 ) {
  922. w2 = div[0].clientWidth;
  923. }
  924. div.remove();
  925. return (cachedScrollbarWidth = w1 - w2);
  926. },
  927. getScrollInfo: function( within ) {
  928. var overflowX = within.isWindow || within.isDocument ? "" :
  929. within.element.css( "overflow-x" ),
  930. overflowY = within.isWindow || within.isDocument ? "" :
  931. within.element.css( "overflow-y" ),
  932. hasOverflowX = overflowX === "scroll" ||
  933. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  934. hasOverflowY = overflowY === "scroll" ||
  935. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  936. return {
  937. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  938. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  939. };
  940. },
  941. getWithinInfo: function( element ) {
  942. var withinElement = $( element || window ),
  943. isWindow = $.isWindow( withinElement[0] ),
  944. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
  945. return {
  946. element: withinElement,
  947. isWindow: isWindow,
  948. isDocument: isDocument,
  949. offset: withinElement.offset() || { left: 0, top: 0 },
  950. scrollLeft: withinElement.scrollLeft(),
  951. scrollTop: withinElement.scrollTop(),
  952. width: isWindow ? withinElement.width() : withinElement.outerWidth(),
  953. height: isWindow ? withinElement.height() : withinElement.outerHeight()
  954. };
  955. }
  956. };
  957. $.fn.position = function( options ) {
  958. if ( !options || !options.of ) {
  959. return _position.apply( this, arguments );
  960. }
  961. // make a copy, we don't want to modify arguments
  962. options = $.extend( {}, options );
  963. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  964. target = $( options.of ),
  965. within = $.position.getWithinInfo( options.within ),
  966. scrollInfo = $.position.getScrollInfo( within ),
  967. collision = ( options.collision || "flip" ).split( " " ),
  968. offsets = {};
  969. dimensions = getDimensions( target );
  970. if ( target[0].preventDefault ) {
  971. // force left top to allow flipping
  972. options.at = "left top";
  973. }
  974. targetWidth = dimensions.width;
  975. targetHeight = dimensions.height;
  976. targetOffset = dimensions.offset;
  977. // clone to reuse original targetOffset later
  978. basePosition = $.extend( {}, targetOffset );
  979. // force my and at to have valid horizontal and vertical positions
  980. // if a value is missing or invalid, it will be converted to center
  981. $.each( [ "my", "at" ], function() {
  982. var pos = ( options[ this ] || "" ).split( " " ),
  983. horizontalOffset,
  984. verticalOffset;
  985. if ( pos.length === 1) {
  986. pos = rhorizontal.test( pos[ 0 ] ) ?
  987. pos.concat( [ "center" ] ) :
  988. rvertical.test( pos[ 0 ] ) ?
  989. [ "center" ].concat( pos ) :
  990. [ "center", "center" ];
  991. }
  992. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  993. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  994. // calculate offsets
  995. horizontalOffset = roffset.exec( pos[ 0 ] );
  996. verticalOffset = roffset.exec( pos[ 1 ] );
  997. offsets[ this ] = [
  998. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  999. verticalOffset ? verticalOffset[ 0 ] : 0
  1000. ];
  1001. // reduce to just the positions without the offsets
  1002. options[ this ] = [
  1003. rposition.exec( pos[ 0 ] )[ 0 ],
  1004. rposition.exec( pos[ 1 ] )[ 0 ]
  1005. ];
  1006. });
  1007. // normalize collision option
  1008. if ( collision.length === 1 ) {
  1009. collision[ 1 ] = collision[ 0 ];
  1010. }
  1011. if ( options.at[ 0 ] === "right" ) {
  1012. basePosition.left += targetWidth;
  1013. } else if ( options.at[ 0 ] === "center" ) {
  1014. basePosition.left += targetWidth / 2;
  1015. }
  1016. if ( options.at[ 1 ] === "bottom" ) {
  1017. basePosition.top += targetHeight;
  1018. } else if ( options.at[ 1 ] === "center" ) {
  1019. basePosition.top += targetHeight / 2;
  1020. }
  1021. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  1022. basePosition.left += atOffset[ 0 ];
  1023. basePosition.top += atOffset[ 1 ];
  1024. return this.each(function() {
  1025. var collisionPosition, using,
  1026. elem = $( this ),
  1027. elemWidth = elem.outerWidth(),
  1028. elemHeight = elem.outerHeight(),
  1029. marginLeft = parseCss( this, "marginLeft" ),
  1030. marginTop = parseCss( this, "marginTop" ),
  1031. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  1032. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  1033. position = $.extend( {}, basePosition ),
  1034. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  1035. if ( options.my[ 0 ] === "right" ) {
  1036. position.left -= elemWidth;
  1037. } else if ( options.my[ 0 ] === "center" ) {
  1038. position.left -= elemWidth / 2;
  1039. }
  1040. if ( options.my[ 1 ] === "bottom" ) {
  1041. position.top -= elemHeight;
  1042. } else if ( options.my[ 1 ] === "center" ) {
  1043. position.top -= elemHeight / 2;
  1044. }
  1045. position.left += myOffset[ 0 ];
  1046. position.top += myOffset[ 1 ];
  1047. // if the browser doesn't support fractions, then round for consistent results
  1048. if ( !$.support.offsetFractions ) {
  1049. position.left = round( position.left );
  1050. position.top = round( position.top );
  1051. }
  1052. collisionPosition = {
  1053. marginLeft: marginLeft,
  1054. marginTop: marginTop
  1055. };
  1056. $.each( [ "left", "top" ], function( i, dir ) {
  1057. if ( $.ui.position[ collision[ i ] ] ) {
  1058. $.ui.position[ collision[ i ] ][ dir ]( position, {
  1059. targetWidth: targetWidth,
  1060. targetHeight: targetHeight,
  1061. elemWidth: elemWidth,
  1062. elemHeight: elemHeight,
  1063. collisionPosition: collisionPosition,
  1064. collisionWidth: collisionWidth,
  1065. collisionHeight: collisionHeight,
  1066. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  1067. my: options.my,
  1068. at: options.at,
  1069. within: within,
  1070. elem : elem
  1071. });
  1072. }
  1073. });
  1074. if ( options.using ) {
  1075. // adds feedback as second argument to using callback, if present
  1076. using = function( props ) {
  1077. var left = targetOffset.left - position.left,
  1078. right = left + targetWidth - elemWidth,
  1079. top = targetOffset.top - position.top,
  1080. bottom = top + targetHeight - elemHeight,
  1081. feedback = {
  1082. target: {
  1083. element: target,
  1084. left: targetOffset.left,
  1085. top: targetOffset.top,
  1086. width: targetWidth,
  1087. height: targetHeight
  1088. },
  1089. element: {
  1090. element: elem,
  1091. left: position.left,
  1092. top: position.top,
  1093. width: elemWidth,
  1094. height: elemHeight
  1095. },
  1096. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1097. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1098. };
  1099. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1100. feedback.horizontal = "center";
  1101. }
  1102. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1103. feedback.vertical = "middle";
  1104. }
  1105. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1106. feedback.important = "horizontal";
  1107. } else {
  1108. feedback.important = "vertical";
  1109. }
  1110. options.using.call( this, props, feedback );
  1111. };
  1112. }
  1113. elem.offset( $.extend( position, { using: using } ) );
  1114. });
  1115. };
  1116. $.ui.position = {
  1117. fit: {
  1118. left: function( position, data ) {
  1119. var within = data.within,
  1120. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1121. outerWidth = within.width,
  1122. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1123. overLeft = withinOffset - collisionPosLeft,
  1124. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1125. newOverRight;
  1126. // element is wider than within
  1127. if ( data.collisionWidth > outerWidth ) {
  1128. // element is initially over the left side of within
  1129. if ( overLeft > 0 && overRight <= 0 ) {
  1130. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1131. position.left += overLeft - newOverRight;
  1132. // element is initially over right side of within
  1133. } else if ( overRight > 0 && overLeft <= 0 ) {
  1134. position.left = withinOffset;
  1135. // element is initially over both left and right sides of within
  1136. } else {
  1137. if ( overLeft > overRight ) {
  1138. position.left = withinOffset + outerWidth - data.collisionWidth;
  1139. } else {
  1140. position.left = withinOffset;
  1141. }
  1142. }
  1143. // too far left -> align with left edge
  1144. } else if ( overLeft > 0 ) {
  1145. position.left += overLeft;
  1146. // too far right -> align with right edge
  1147. } else if ( overRight > 0 ) {
  1148. position.left -= overRight;
  1149. // adjust based on position and margin
  1150. } else {
  1151. position.left = max( position.left - collisionPosLeft, position.left );
  1152. }
  1153. },
  1154. top: function( position, data ) {
  1155. var within = data.within,
  1156. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1157. outerHeight = data.within.height,
  1158. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1159. overTop = withinOffset - collisionPosTop,
  1160. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1161. newOverBottom;
  1162. // element is taller than within
  1163. if ( data.collisionHeight > outerHeight ) {
  1164. // element is initially over the top of within
  1165. if ( overTop > 0 && overBottom <= 0 ) {
  1166. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1167. position.top += overTop - newOverBottom;
  1168. // element is initially over bottom of within
  1169. } else if ( overBottom > 0 && overTop <= 0 ) {
  1170. position.top = withinOffset;
  1171. // element is initially over both top and bottom of within
  1172. } else {
  1173. if ( overTop > overBottom ) {
  1174. position.top = withinOffset + outerHeight - data.collisionHeight;
  1175. } else {
  1176. position.top = withinOffset;
  1177. }
  1178. }
  1179. // too far up -> align with top
  1180. } else if ( overTop > 0 ) {
  1181. position.top += overTop;
  1182. // too far down -> align with bottom edge
  1183. } else if ( overBottom > 0 ) {
  1184. position.top -= overBottom;
  1185. // adjust based on position and margin
  1186. } else {
  1187. position.top = max( position.top - collisionPosTop, position.top );
  1188. }
  1189. }
  1190. },
  1191. flip: {
  1192. left: function( position, data ) {
  1193. var within = data.within,
  1194. withinOffset = within.offset.left + within.scrollLeft,
  1195. outerWidth = within.width,
  1196. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1197. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1198. overLeft = collisionPosLeft - offsetLeft,
  1199. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1200. myOffset = data.my[ 0 ] === "left" ?
  1201. -data.elemWidth :
  1202. data.my[ 0 ] === "right" ?
  1203. data.elemWidth :
  1204. 0,
  1205. atOffset = data.at[ 0 ] === "left" ?
  1206. data.targetWidth :
  1207. data.at[ 0 ] === "right" ?
  1208. -data.targetWidth :
  1209. 0,
  1210. offset = -2 * data.offset[ 0 ],
  1211. newOverRight,
  1212. newOverLeft;
  1213. if ( overLeft < 0 ) {
  1214. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1215. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1216. position.left += myOffset + atOffset + offset;
  1217. }
  1218. }
  1219. else if ( overRight > 0 ) {
  1220. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1221. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1222. position.left += myOffset + atOffset + offset;
  1223. }
  1224. }
  1225. },
  1226. top: function( position, data ) {
  1227. var within = data.within,
  1228. withinOffset = within.offset.top + within.scrollTop,
  1229. outerHeight = within.height,
  1230. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1231. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1232. overTop = collisionPosTop - offsetTop,
  1233. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1234. top = data.my[ 1 ] === "top",
  1235. myOffset = top ?
  1236. -data.elemHeight :
  1237. data.my[ 1 ] === "bottom" ?
  1238. data.elemHeight :
  1239. 0,
  1240. atOffset = data.at[ 1 ] === "top" ?
  1241. data.targetHeight :
  1242. data.at[ 1 ] === "bottom" ?
  1243. -data.targetHeight :
  1244. 0,
  1245. offset = -2 * data.offset[ 1 ],
  1246. newOverTop,
  1247. newOverBottom;
  1248. if ( overTop < 0 ) {
  1249. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1250. if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
  1251. position.top += myOffset + atOffset + offset;
  1252. }
  1253. }
  1254. else if ( overBottom > 0 ) {
  1255. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1256. if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
  1257. position.top += myOffset + atOffset + offset;
  1258. }
  1259. }
  1260. }
  1261. },
  1262. flipfit: {
  1263. left: function() {
  1264. $.ui.position.flip.left.apply( this, arguments );
  1265. $.ui.position.fit.left.apply( this, arguments );
  1266. },
  1267. top: function() {
  1268. $.ui.position.flip.top.apply( this, arguments );
  1269. $.ui.position.fit.top.apply( this, arguments );
  1270. }
  1271. }
  1272. };
  1273. // fraction support test
  1274. (function () {
  1275. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1276. body = document.getElementsByTagName( "body" )[ 0 ],
  1277. div = document.createElement( "div" );
  1278. //Create a "fake body" for testing based on method used in jQuery.support
  1279. testElement = document.createElement( body ? "div" : "body" );
  1280. testElementStyle = {
  1281. visibility: "hidden",
  1282. width: 0,
  1283. height: 0,
  1284. border: 0,
  1285. margin: 0,
  1286. background: "none"
  1287. };
  1288. if ( body ) {
  1289. $.extend( testElementStyle, {
  1290. position: "absolute",
  1291. left: "-1000px",
  1292. top: "-1000px"
  1293. });
  1294. }
  1295. for ( i in testElementStyle ) {
  1296. testElement.style[ i ] = testElementStyle[ i ];
  1297. }
  1298. testElement.appendChild( div );
  1299. testElementParent = body || document.documentElement;
  1300. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1301. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1302. offsetLeft = $( div ).offset().left;
  1303. $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1304. testElement.innerHTML = "";
  1305. testElementParent.removeChild( testElement );
  1306. })();
  1307. }( jQuery ) );
  1308. (function( $, undefined ) {
  1309. $.widget("ui.draggable", $.ui.mouse, {
  1310. version: "1.10.4",
  1311. widgetEventPrefix: "drag",
  1312. options: {
  1313. addClasses: true,
  1314. appendTo: "parent",
  1315. axis: false,
  1316. connectToSortable: false,
  1317. containment: false,
  1318. cursor: "auto",
  1319. cursorAt: false,
  1320. grid: false,
  1321. handle: false,
  1322. helper: "original",
  1323. iframeFix: false,
  1324. opacity: false,
  1325. refreshPositions: false,
  1326. revert: false,
  1327. revertDuration: 500,
  1328. scope: "default",
  1329. scroll: true,
  1330. scrollSensitivity: 20,
  1331. scrollSpeed: 20,
  1332. snap: false,
  1333. snapMode: "both",
  1334. snapTolerance: 20,
  1335. stack: false,
  1336. zIndex: false,
  1337. // callbacks
  1338. drag: null,
  1339. start: null,
  1340. stop: null
  1341. },
  1342. _create: function() {
  1343. if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
  1344. this.element[0].style.position = "relative";
  1345. }
  1346. if (this.options.addClasses){
  1347. this.element.addClass("ui-draggable");
  1348. }
  1349. if (this.options.disabled){
  1350. this.element.addClass("ui-draggable-disabled");
  1351. }
  1352. this._mouseInit();
  1353. },
  1354. _destroy: function() {
  1355. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  1356. this._mouseDestroy();
  1357. },
  1358. _mouseCapture: function(event) {
  1359. var o = this.options;
  1360. // among others, prevent a drag on a resizable-handle
  1361. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  1362. return false;
  1363. }
  1364. //Quit if we're not on a valid handle
  1365. this.handle = this._getHandle(event);
  1366. if (!this.handle) {
  1367. return false;
  1368. }
  1369. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  1370. $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
  1371. .css({
  1372. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  1373. position: "absolute", opacity: "0.001", zIndex: 1000
  1374. })
  1375. .css($(this).offset())
  1376. .appendTo("body");
  1377. });
  1378. return true;
  1379. },
  1380. _mouseStart: function(event) {
  1381. var o = this.options;
  1382. //Create and append the visible helper
  1383. this.helper = this._createHelper(event);
  1384. this.helper.addClass("ui-draggable-dragging");
  1385. //Cache the helper size
  1386. this._cacheHelperProportions();
  1387. //If ddmanager is used for droppables, set the global draggable
  1388. if($.ui.ddmanager) {
  1389. $.ui.ddmanager.current = this;
  1390. }
  1391. /*
  1392. * - Position generation -
  1393. * This block generates everything position related - it's the core of draggables.
  1394. */
  1395. //Cache the margins of the original element
  1396. this._cacheMargins();
  1397. //Store the helper's css position
  1398. this.cssPosition = this.helper.css( "position" );
  1399. this.scrollParent = this.helper.scrollParent();
  1400. this.offsetParent = this.helper.offsetParent();
  1401. this.offsetParentCssPosition = this.offsetParent.css( "position" );
  1402. //The element's absolute position on the page minus margins
  1403. this.offset = this.positionAbs = this.element.offset();
  1404. this.offset = {
  1405. top: this.offset.top - this.margins.top,
  1406. left: this.offset.left - this.margins.left
  1407. };
  1408. //Reset scroll cache
  1409. this.offset.scroll = false;
  1410. $.extend(this.offset, {
  1411. click: { //Where the click happened, relative to the element
  1412. left: event.pageX - this.offset.left,
  1413. top: event.pageY - this.offset.top
  1414. },
  1415. parent: this._getParentOffset(),
  1416. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  1417. });
  1418. //Generate the original position
  1419. this.originalPosition = this.position = this._generatePosition(event);
  1420. this.originalPageX = event.pageX;
  1421. this.originalPageY = event.pageY;
  1422. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1423. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  1424. //Set a containment if given in the options
  1425. this._setContainment();
  1426. //Trigger event + callbacks
  1427. if(this._trigger("start", event) === false) {
  1428. this._clear();
  1429. return false;
  1430. }
  1431. //Recache the helper size
  1432. this._cacheHelperProportions();
  1433. //Prepare the droppable offsets
  1434. if ($.ui.ddmanager && !o.dropBehaviour) {
  1435. $.ui.ddmanager.prepareOffsets(this, event);
  1436. }
  1437. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  1438. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  1439. if ( $.ui.ddmanager ) {
  1440. $.ui.ddmanager.dragStart(this, event);
  1441. }
  1442. return true;
  1443. },
  1444. _mouseDrag: function(event, noPropagation) {
  1445. // reset any necessary cached properties (see #5009)
  1446. if ( this.offsetParentCssPosition === "fixed" ) {
  1447. this.offset.parent = this._getParentOffset();
  1448. }
  1449. //Compute the helpers position
  1450. this.position = this._generatePosition(event);
  1451. this.positionAbs = this._convertPositionTo("absolute");
  1452. //Call plugins and callbacks and use the resulting position if something is returned
  1453. if (!noPropagation) {
  1454. var ui = this._uiHash();
  1455. if(this._trigger("drag", event, ui) === false) {
  1456. this._mouseUp({});
  1457. return false;
  1458. }
  1459. this.position = ui.position;
  1460. }
  1461. if(!this.options.axis || this.options.axis !== "y") {
  1462. this.helper[0].style.left = this.position.left+"px";
  1463. }
  1464. if(!this.options.axis || this.options.axis !== "x") {
  1465. this.helper[0].style.top = this.position.top+"px";
  1466. }
  1467. if($.ui.ddmanager) {
  1468. $.ui.ddmanager.drag(this, event);
  1469. }
  1470. return false;
  1471. },
  1472. _mouseStop: function(event) {
  1473. //If we are using droppables, inform the manager about the drop
  1474. var that = this,
  1475. dropped = false;
  1476. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1477. dropped = $.ui.ddmanager.drop(this, event);
  1478. }
  1479. //if a drop comes from outside (a sortable)
  1480. if(this.dropped) {
  1481. dropped = this.dropped;
  1482. this.dropped = false;
  1483. }
  1484. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  1485. if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
  1486. return false;
  1487. }
  1488. 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))) {
  1489. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1490. if(that._trigger("stop", event) !== false) {
  1491. that._clear();
  1492. }
  1493. });
  1494. } else {
  1495. if(this._trigger("stop", event) !== false) {
  1496. this._clear();
  1497. }
  1498. }
  1499. return false;
  1500. },
  1501. _mouseUp: function(event) {
  1502. //Remove frame helpers
  1503. $("div.ui-draggable-iframeFix").each(function() {
  1504. this.parentNode.removeChild(this);
  1505. });
  1506. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1507. if( $.ui.ddmanager ) {
  1508. $.ui.ddmanager.dragStop(this, event);
  1509. }
  1510. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1511. },
  1512. cancel: function() {
  1513. if(this.helper.is(".ui-draggable-dragging")) {
  1514. this._mouseUp({});
  1515. } else {
  1516. this._clear();
  1517. }
  1518. return this;
  1519. },
  1520. _getHandle: function(event) {
  1521. return this.options.handle ?
  1522. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1523. true;
  1524. },
  1525. _createHelper: function(event) {
  1526. var o = this.options,
  1527. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
  1528. if(!helper.parents("body").length) {
  1529. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1530. }
  1531. if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1532. helper.css("position", "absolute");
  1533. }
  1534. return helper;
  1535. },
  1536. _adjustOffsetFromHelper: function(obj) {
  1537. if (typeof obj === "string") {
  1538. obj = obj.split(" ");
  1539. }
  1540. if ($.isArray(obj)) {
  1541. obj = {left: +obj[0], top: +obj[1] || 0};
  1542. }
  1543. if ("left" in obj) {
  1544. this.offset.click.left = obj.left + this.margins.left;
  1545. }
  1546. if ("right" in obj) {
  1547. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1548. }
  1549. if ("top" in obj) {
  1550. this.offset.click.top = obj.top + this.margins.top;
  1551. }
  1552. if ("bottom" in obj) {
  1553. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1554. }
  1555. },
  1556. _getParentOffset: function() {
  1557. //Get the offsetParent and cache its position
  1558. var po = this.offsetParent.offset();
  1559. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1560. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1561. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1562. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1563. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1564. po.left += this.scrollParent.scrollLeft();
  1565. po.top += this.scrollParent.scrollTop();
  1566. }
  1567. //This needs to be actually done for all browsers, since pageX/pageY includes this information
  1568. //Ugly IE fix
  1569. if((this.offsetParent[0] === document.body) ||
  1570. (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  1571. po = { top: 0, left: 0 };
  1572. }
  1573. return {
  1574. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  1575. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  1576. };
  1577. },
  1578. _getRelativeOffset: function() {
  1579. if(this.cssPosition === "relative") {
  1580. var p = this.element.position();
  1581. return {
  1582. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  1583. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  1584. };
  1585. } else {
  1586. return { top: 0, left: 0 };
  1587. }
  1588. },
  1589. _cacheMargins: function() {
  1590. this.margins = {
  1591. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  1592. top: (parseInt(this.element.css("marginTop"),10) || 0),
  1593. right: (parseInt(this.element.css("marginRight"),10) || 0),
  1594. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  1595. };
  1596. },
  1597. _cacheHelperProportions: function() {
  1598. this.helperProportions = {
  1599. width: this.helper.outerWidth(),
  1600. height: this.helper.outerHeight()
  1601. };
  1602. },
  1603. _setContainment: function() {
  1604. var over, c, ce,
  1605. o = this.options;
  1606. if ( !o.containment ) {
  1607. this.containment = null;
  1608. return;
  1609. }
  1610. if ( o.containment === "window" ) {
  1611. this.containment = [
  1612. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1613. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1614. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  1615. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1616. ];
  1617. return;
  1618. }
  1619. if ( o.containment === "document") {
  1620. this.containment = [
  1621. 0,
  1622. 0,
  1623. $( document ).width() - this.helperProportions.width - this.margins.left,
  1624. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1625. ];
  1626. return;
  1627. }
  1628. if ( o.containment.constructor === Array ) {
  1629. this.containment = o.containment;
  1630. return;
  1631. }
  1632. if ( o.containment === "parent" ) {
  1633. o.containment = this.helper[ 0 ].parentNode;
  1634. }
  1635. c = $( o.containment );
  1636. ce = c[ 0 ];
  1637. if( !ce ) {
  1638. return;
  1639. }
  1640. over = c.css( "overflow" ) !== "hidden";
  1641. this.containment = [
  1642. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  1643. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) ,
  1644. ( 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,
  1645. ( 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
  1646. ];
  1647. this.relative_container = c;
  1648. },
  1649. _convertPositionTo: function(d, pos) {
  1650. if(!pos) {
  1651. pos = this.position;
  1652. }
  1653. var mod = d === "absolute" ? 1 : -1,
  1654. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
  1655. //Cache the scroll
  1656. if (!this.offset.scroll) {
  1657. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  1658. }
  1659. return {
  1660. top: (
  1661. pos.top + // The absolute mouse position
  1662. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1663. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1664. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod )
  1665. ),
  1666. left: (
  1667. pos.left + // The absolute mouse position
  1668. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1669. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1670. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod )
  1671. )
  1672. };
  1673. },
  1674. _generatePosition: function(event) {
  1675. var containment, co, top, left,
  1676. o = this.options,
  1677. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
  1678. pageX = event.pageX,
  1679. pageY = event.pageY;
  1680. //Cache the scroll
  1681. if (!this.offset.scroll) {
  1682. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  1683. }
  1684. /*
  1685. * - Position constraining -
  1686. * Constrain the position to a mix of grid, containment.
  1687. */
  1688. // If we are not dragging yet, we won't check for options
  1689. if ( this.originalPosition ) {
  1690. if ( this.containment ) {
  1691. if ( this.relative_container ){
  1692. co = this.relative_container.offset();
  1693. containment = [
  1694. this.containment[ 0 ] + co.left,
  1695. this.containment[ 1 ] + co.top,
  1696. this.containment[ 2 ] + co.left,
  1697. this.containment[ 3 ] + co.top
  1698. ];
  1699. }
  1700. else {
  1701. containment = this.containment;
  1702. }
  1703. if(event.pageX - this.offset.click.left < containment[0]) {
  1704. pageX = containment[0] + this.offset.click.left;
  1705. }
  1706. if(event.pageY - this.offset.click.top < containment[1]) {
  1707. pageY = containment[1] + this.offset.click.top;
  1708. }
  1709. if(event.pageX - this.offset.click.left > containment[2]) {
  1710. pageX = containment[2] + this.offset.click.left;
  1711. }
  1712. if(event.pageY - this.offset.click.top > containment[3]) {
  1713. pageY = containment[3] + this.offset.click.top;
  1714. }
  1715. }
  1716. if(o.grid) {
  1717. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1718. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1719. 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;
  1720. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1721. 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;
  1722. }
  1723. }
  1724. return {
  1725. top: (
  1726. pageY - // The absolute mouse position
  1727. this.offset.click.top - // Click offset (relative to the element)
  1728. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1729. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1730. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top )
  1731. ),
  1732. left: (
  1733. pageX - // The absolute mouse position
  1734. this.offset.click.left - // Click offset (relative to the element)
  1735. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1736. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1737. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left )
  1738. )
  1739. };
  1740. },
  1741. _clear: function() {
  1742. this.helper.removeClass("ui-draggable-dragging");
  1743. if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1744. this.helper.remove();
  1745. }
  1746. this.helper = null;
  1747. this.cancelHelperRemoval = false;
  1748. },
  1749. // From now on bulk stuff - mainly helpers
  1750. _trigger: function(type, event, ui) {
  1751. ui = ui || this._uiHash();
  1752. $.ui.plugin.call(this, type, [event, ui]);
  1753. //The absolute position has to be recalculated after plugins
  1754. if(type === "drag") {
  1755. this.positionAbs = this._convertPositionTo("absolute");
  1756. }
  1757. return $.Widget.prototype._trigger.call(this, type, event, ui);
  1758. },
  1759. plugins: {},
  1760. _uiHash: function() {
  1761. return {
  1762. helper: this.helper,
  1763. position: this.position,
  1764. originalPosition: this.originalPosition,
  1765. offset: this.positionAbs
  1766. };
  1767. }
  1768. });
  1769. $.ui.plugin.add("draggable", "connectToSortable", {
  1770. start: function(event, ui) {
  1771. var inst = $(this).data("ui-draggable"), o = inst.options,
  1772. uiSortable = $.extend({}, ui, { item: inst.element });
  1773. inst.sortables = [];
  1774. $(o.connectToSortable).each(function() {
  1775. var sortable = $.data(this, "ui-sortable");
  1776. if (sortable && !sortable.options.disabled) {
  1777. inst.sortables.push({
  1778. instance: sortable,
  1779. shouldRevert: sortable.options.revert
  1780. });
  1781. 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).
  1782. sortable._trigger("activate", event, uiSortable);
  1783. }
  1784. });
  1785. },
  1786. stop: function(event, ui) {
  1787. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  1788. var inst = $(this).data("ui-draggable"),
  1789. uiSortable = $.extend({}, ui, { item: inst.element });
  1790. $.each(inst.sortables, function() {
  1791. if(this.instance.isOver) {
  1792. this.instance.isOver = 0;
  1793. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  1794. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  1795. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
  1796. if(this.shouldRevert) {
  1797. this.instance.options.revert = this.shouldRevert;
  1798. }
  1799. //Trigger the stop of the sortable
  1800. this.instance._mouseStop(event);
  1801. this.instance.options.helper = this.instance.options._helper;
  1802. //If the helper has been the original item, restore properties in the sortable
  1803. if(inst.options.helper === "original") {
  1804. this.instance.currentItem.css({ top: "auto", left: "auto" });
  1805. }
  1806. } else {
  1807. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  1808. this.instance._trigger("deactivate", event, uiSortable);
  1809. }
  1810. });
  1811. },
  1812. drag: function(event, ui) {
  1813. var inst = $(this).data("ui-draggable"), that = this;
  1814. $.each(inst.sortables, function() {
  1815. var innermostIntersecting = false,
  1816. thisSortable = this;
  1817. //Copy over some variables to allow calling the sortable's native _intersectsWith
  1818. this.instance.positionAbs = inst.positionAbs;
  1819. this.instance.helperProportions = inst.helperProportions;
  1820. this.instance.offset.click = inst.offset.click;
  1821. if(this.instance._intersectsWith(this.instance.containerCache)) {
  1822. innermostIntersecting = true;
  1823. $.each(inst.sortables, function () {
  1824. this.instance.positionAbs = inst.positionAbs;
  1825. this.instance.helperProportions = inst.helperProportions;
  1826. this.instance.offset.click = inst.offset.click;
  1827. if (this !== thisSortable &&
  1828. this.instance._intersectsWith(this.instance.containerCache) &&
  1829. $.contains(thisSortable.instance.element[0], this.instance.element[0])
  1830. ) {
  1831. innermostIntersecting = false;
  1832. }
  1833. return innermostIntersecting;
  1834. });
  1835. }
  1836. if(innermostIntersecting) {
  1837. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  1838. if(!this.instance.isOver) {
  1839. this.instance.isOver = 1;
  1840. //Now we fake the start of dragging for the sortable instance,
  1841. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  1842. //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)
  1843. this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
  1844. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  1845. this.instance.options.helper = function() { return ui.helper[0]; };
  1846. event.target = this.instance.currentItem[0];
  1847. this.instance._mouseCapture(event, true);
  1848. this.instance._mouseStart(event, true, true);
  1849. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  1850. this.instance.offset.click.top = inst.offset.click.top;
  1851. this.instance.offset.click.left = inst.offset.click.left;
  1852. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  1853. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  1854. inst._trigger("toSortable", event);
  1855. inst.dropped = this.instance.element; //draggable revert needs that
  1856. //hack so receive/update callbacks work (mostly)
  1857. inst.currentItem = inst.element;
  1858. this.instance.fromOutside = inst;
  1859. }
  1860. //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
  1861. if(this.instance.currentItem) {
  1862. this.instance._mouseDrag(event);
  1863. }
  1864. } else {
  1865. //If it doesn't intersect with the sortable, and it intersected before,
  1866. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  1867. if(this.instance.isOver) {
  1868. this.instance.isOver = 0;
  1869. this.instance.cancelHelperRemoval = true;
  1870. //Prevent reverting on this forced stop
  1871. this.instance.options.revert = false;
  1872. // The out event needs to be triggered independently
  1873. this.instance._trigger("out", event, this.instance._uiHash(this.instance));
  1874. this.instance._mouseStop(event, true);
  1875. this.instance.options.helper = this.instance.options._helper;
  1876. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  1877. this.instance.currentItem.remove();
  1878. if(this.instance.placeholder) {
  1879. this.instance.placeholder.remove();
  1880. }
  1881. inst._trigger("fromSortable", event);
  1882. inst.dropped = false; //draggable revert needs that
  1883. }
  1884. }
  1885. });
  1886. }
  1887. });
  1888. $.ui.plugin.add("draggable", "cursor", {
  1889. start: function() {
  1890. var t = $("body"), o = $(this).data("ui-draggable").options;
  1891. if (t.css("cursor")) {
  1892. o._cursor = t.css("cursor");
  1893. }
  1894. t.css("cursor", o.cursor);
  1895. },
  1896. stop: function() {
  1897. var o = $(this).data("ui-draggable").options;
  1898. if (o._cursor) {
  1899. $("body").css("cursor", o._cursor);
  1900. }
  1901. }
  1902. });
  1903. $.ui.plugin.add("draggable", "opacity", {
  1904. start: function(event, ui) {
  1905. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1906. if(t.css("opacity")) {
  1907. o._opacity = t.css("opacity");
  1908. }
  1909. t.css("opacity", o.opacity);
  1910. },
  1911. stop: function(event, ui) {
  1912. var o = $(this).data("ui-draggable").options;
  1913. if(o._opacity) {
  1914. $(ui.helper).css("opacity", o._opacity);
  1915. }
  1916. }
  1917. });
  1918. $.ui.plugin.add("draggable", "scroll", {
  1919. start: function() {
  1920. var i = $(this).data("ui-draggable");
  1921. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1922. i.overflowOffset = i.scrollParent.offset();
  1923. }
  1924. },
  1925. drag: function( event ) {
  1926. var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
  1927. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1928. if(!o.axis || o.axis !== "x") {
  1929. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  1930. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  1931. } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
  1932. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  1933. }
  1934. }
  1935. if(!o.axis || o.axis !== "y") {
  1936. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  1937. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  1938. } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
  1939. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  1940. }
  1941. }
  1942. } else {
  1943. if(!o.axis || o.axis !== "x") {
  1944. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  1945. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  1946. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  1947. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  1948. }
  1949. }
  1950. if(!o.axis || o.axis !== "y") {
  1951. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  1952. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  1953. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  1954. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  1955. }
  1956. }
  1957. }
  1958. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  1959. $.ui.ddmanager.prepareOffsets(i, event);
  1960. }
  1961. }
  1962. });
  1963. $.ui.plugin.add("draggable", "snap", {
  1964. start: function() {
  1965. var i = $(this).data("ui-draggable"),
  1966. o = i.options;
  1967. i.snapElements = [];
  1968. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  1969. var $t = $(this),
  1970. $o = $t.offset();
  1971. if(this !== i.element[0]) {
  1972. i.snapElements.push({
  1973. item: this,
  1974. width: $t.outerWidth(), height: $t.outerHeight(),
  1975. top: $o.top, left: $o.left
  1976. });
  1977. }
  1978. });
  1979. },
  1980. drag: function(event, ui) {
  1981. var ts, bs, ls, rs, l, r, t, b, i, first,
  1982. inst = $(this).data("ui-draggable"),
  1983. o = inst.options,
  1984. d = o.snapTolerance,
  1985. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1986. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1987. for (i = inst.snapElements.length - 1; i >= 0; i--){
  1988. l = inst.snapElements[i].left;
  1989. r = l + inst.snapElements[i].width;
  1990. t = inst.snapElements[i].top;
  1991. b = t + inst.snapElements[i].height;
  1992. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  1993. if(inst.snapElements[i].snapping) {
  1994. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1995. }
  1996. inst.snapElements[i].snapping = false;
  1997. continue;
  1998. }
  1999. if(o.snapMode !== "inner") {
  2000. ts = Math.abs(t - y2) <= d;
  2001. bs = Math.abs(b - y1) <= d;
  2002. ls = Math.abs(l - x2) <= d;
  2003. rs = Math.abs(r - x1) <= d;
  2004. if(ts) {
  2005. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  2006. }
  2007. if(bs) {
  2008. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  2009. }
  2010. if(ls) {
  2011. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  2012. }
  2013. if(rs) {
  2014. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  2015. }
  2016. }
  2017. first = (ts || bs || ls || rs);
  2018. if(o.snapMode !== "outer") {
  2019. ts = Math.abs(t - y1) <= d;
  2020. bs = Math.abs(b - y2) <= d;
  2021. ls = Math.abs(l - x1) <= d;
  2022. rs = Math.abs(r - x2) <= d;
  2023. if(ts) {
  2024. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  2025. }
  2026. if(bs) {
  2027. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  2028. }
  2029. if(ls) {
  2030. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  2031. }
  2032. if(rs) {
  2033. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  2034. }
  2035. }
  2036. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  2037. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2038. }
  2039. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  2040. }
  2041. }
  2042. });
  2043. $.ui.plugin.add("draggable", "stack", {
  2044. start: function() {
  2045. var min,
  2046. o = this.data("ui-draggable").options,
  2047. group = $.makeArray($(o.stack)).sort(function(a,b) {
  2048. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  2049. });
  2050. if (!group.length) { return; }
  2051. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  2052. $(group).each(function(i) {
  2053. $(this).css("zIndex", min + i);
  2054. });
  2055. this.css("zIndex", (min + group.length));
  2056. }
  2057. });
  2058. $.ui.plugin.add("draggable", "zIndex", {
  2059. start: function(event, ui) {
  2060. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  2061. if(t.css("zIndex")) {
  2062. o._zIndex = t.css("zIndex");
  2063. }
  2064. t.css("zIndex", o.zIndex);
  2065. },
  2066. stop: function(event, ui) {
  2067. var o = $(this).data("ui-draggable").options;
  2068. if(o._zIndex) {
  2069. $(ui.helper).css("zIndex", o._zIndex);
  2070. }
  2071. }
  2072. });
  2073. })(jQuery);
  2074. (function( $, undefined ) {
  2075. function isOverAxis( x, reference, size ) {
  2076. return ( x > reference ) && ( x < ( reference + size ) );
  2077. }
  2078. $.widget("ui.droppable", {
  2079. version: "1.10.4",
  2080. widgetEventPrefix: "drop",
  2081. options: {
  2082. accept: "*",
  2083. activeClass: false,
  2084. addClasses: true,
  2085. greedy: false,
  2086. hoverClass: false,
  2087. scope: "default",
  2088. tolerance: "intersect",
  2089. // callbacks
  2090. activate: null,
  2091. deactivate: null,
  2092. drop: null,
  2093. out: null,
  2094. over: null
  2095. },
  2096. _create: function() {
  2097. var proportions,
  2098. o = this.options,
  2099. accept = o.accept;
  2100. this.isover = false;
  2101. this.isout = true;
  2102. this.accept = $.isFunction(accept) ? accept : function(d) {
  2103. return d.is(accept);
  2104. };
  2105. this.proportions = function( /* valueToWrite */ ) {
  2106. if ( arguments.length ) {
  2107. // Store the droppable's proportions
  2108. proportions = arguments[ 0 ];
  2109. } else {
  2110. // Retrieve or derive the droppable's proportions
  2111. return proportions ?
  2112. proportions :
  2113. proportions = {
  2114. width: this.element[ 0 ].offsetWidth,
  2115. height: this.element[ 0 ].offsetHeight
  2116. };
  2117. }
  2118. };
  2119. // Add the reference and positions to the manager
  2120. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  2121. $.ui.ddmanager.droppables[o.scope].push(this);
  2122. (o.addClasses && this.element.addClass("ui-droppable"));
  2123. },
  2124. _destroy: function() {
  2125. var i = 0,
  2126. drop = $.ui.ddmanager.droppables[this.options.scope];
  2127. for ( ; i < drop.length; i++ ) {
  2128. if ( drop[i] === this ) {
  2129. drop.splice(i, 1);
  2130. }
  2131. }
  2132. this.element.removeClass("ui-droppable ui-droppable-disabled");
  2133. },
  2134. _setOption: function(key, value) {
  2135. if(key === "accept") {
  2136. this.accept = $.isFunction(value) ? value : function(d) {
  2137. return d.is(value);
  2138. };
  2139. }
  2140. $.Widget.prototype._setOption.apply(this, arguments);
  2141. },
  2142. _activate: function(event) {
  2143. var draggable = $.ui.ddmanager.current;
  2144. if(this.options.activeClass) {
  2145. this.element.addClass(this.options.activeClass);
  2146. }
  2147. if(draggable){
  2148. this._trigger("activate", event, this.ui(draggable));
  2149. }
  2150. },
  2151. _deactivate: function(event) {
  2152. var draggable = $.ui.ddmanager.current;
  2153. if(this.options.activeClass) {
  2154. this.element.removeClass(this.options.activeClass);
  2155. }
  2156. if(draggable){
  2157. this._trigger("deactivate", event, this.ui(draggable));
  2158. }
  2159. },
  2160. _over: function(event) {
  2161. var draggable = $.ui.ddmanager.current;
  2162. // Bail if draggable and droppable are same element
  2163. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  2164. return;
  2165. }
  2166. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2167. if(this.options.hoverClass) {
  2168. this.element.addClass(this.options.hoverClass);
  2169. }
  2170. this._trigger("over", event, this.ui(draggable));
  2171. }
  2172. },
  2173. _out: function(event) {
  2174. var draggable = $.ui.ddmanager.current;
  2175. // Bail if draggable and droppable are same element
  2176. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  2177. return;
  2178. }
  2179. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2180. if(this.options.hoverClass) {
  2181. this.element.removeClass(this.options.hoverClass);
  2182. }
  2183. this._trigger("out", event, this.ui(draggable));
  2184. }
  2185. },
  2186. _drop: function(event,custom) {
  2187. var draggable = custom || $.ui.ddmanager.current,
  2188. childrenIntersection = false;
  2189. // Bail if draggable and droppable are same element
  2190. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  2191. return false;
  2192. }
  2193. this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
  2194. var inst = $.data(this, "ui-droppable");
  2195. if(
  2196. inst.options.greedy &&
  2197. !inst.options.disabled &&
  2198. inst.options.scope === draggable.options.scope &&
  2199. inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) &&
  2200. $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  2201. ) { childrenIntersection = true; return false; }
  2202. });
  2203. if(childrenIntersection) {
  2204. return false;
  2205. }
  2206. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2207. if(this.options.activeClass) {
  2208. this.element.removeClass(this.options.activeClass);
  2209. }
  2210. if(this.options.hoverClass) {
  2211. this.element.removeClass(this.options.hoverClass);
  2212. }
  2213. this._trigger("drop", event, this.ui(draggable));
  2214. return this.element;
  2215. }
  2216. return false;
  2217. },
  2218. ui: function(c) {
  2219. return {
  2220. draggable: (c.currentItem || c.element),
  2221. helper: c.helper,
  2222. position: c.position,
  2223. offset: c.positionAbs
  2224. };
  2225. }
  2226. });
  2227. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  2228. if (!droppable.offset) {
  2229. return false;
  2230. }
  2231. var draggableLeft, draggableTop,
  2232. x1 = (draggable.positionAbs || draggable.position.absolute).left,
  2233. y1 = (draggable.positionAbs || draggable.position.absolute).top,
  2234. x2 = x1 + draggable.helperProportions.width,
  2235. y2 = y1 + draggable.helperProportions.height,
  2236. l = droppable.offset.left,
  2237. t = droppable.offset.top,
  2238. r = l + droppable.proportions().width,
  2239. b = t + droppable.proportions().height;
  2240. switch (toleranceMode) {
  2241. case "fit":
  2242. return (l <= x1 && x2 <= r && t <= y1 && y2 <= b);
  2243. case "intersect":
  2244. return (l < x1 + (draggable.helperProportions.width / 2) && // Right Half
  2245. x2 - (draggable.helperProportions.width / 2) < r && // Left Half
  2246. t < y1 + (draggable.helperProportions.height / 2) && // Bottom Half
  2247. y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  2248. case "pointer":
  2249. draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
  2250. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
  2251. return isOverAxis( draggableTop, t, droppable.proportions().height ) && isOverAxis( draggableLeft, l, droppable.proportions().width );
  2252. case "touch":
  2253. return (
  2254. (y1 >= t && y1 <= b) || // Top edge touching
  2255. (y2 >= t && y2 <= b) || // Bottom edge touching
  2256. (y1 < t && y2 > b) // Surrounded vertically
  2257. ) && (
  2258. (x1 >= l && x1 <= r) || // Left edge touching
  2259. (x2 >= l && x2 <= r) || // Right edge touching
  2260. (x1 < l && x2 > r) // Surrounded horizontally
  2261. );
  2262. default:
  2263. return false;
  2264. }
  2265. };
  2266. /*
  2267. This manager tracks offsets of draggables and droppables
  2268. */
  2269. $.ui.ddmanager = {
  2270. current: null,
  2271. droppables: { "default": [] },
  2272. prepareOffsets: function(t, event) {
  2273. var i, j,
  2274. m = $.ui.ddmanager.droppables[t.options.scope] || [],
  2275. type = event ? event.type : null, // workaround for #2317
  2276. list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
  2277. droppablesLoop: for (i = 0; i < m.length; i++) {
  2278. //No disabled and non-accepted
  2279. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) {
  2280. continue;
  2281. }
  2282. // Filter out elements in the current dragged item
  2283. for (j=0; j < list.length; j++) {
  2284. if(list[j] === m[i].element[0]) {
  2285. m[i].proportions().height = 0;
  2286. continue droppablesLoop;
  2287. }
  2288. }
  2289. m[i].visible = m[i].element.css("display") !== "none";
  2290. if(!m[i].visible) {
  2291. continue;
  2292. }
  2293. //Activate the droppable if used directly from draggables
  2294. if(type === "mousedown") {
  2295. m[i]._activate.call(m[i], event);
  2296. }
  2297. m[ i ].offset = m[ i ].element.offset();
  2298. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  2299. }
  2300. },
  2301. drop: function(draggable, event) {
  2302. var dropped = false;
  2303. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2304. $.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function() {
  2305. if(!this.options) {
  2306. return;
  2307. }
  2308. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) {
  2309. dropped = this._drop.call(this, event) || dropped;
  2310. }
  2311. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2312. this.isout = true;
  2313. this.isover = false;
  2314. this._deactivate.call(this, event);
  2315. }
  2316. });
  2317. return dropped;
  2318. },
  2319. dragStart: function( draggable, event ) {
  2320. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  2321. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  2322. if( !draggable.options.refreshPositions ) {
  2323. $.ui.ddmanager.prepareOffsets( draggable, event );
  2324. }
  2325. });
  2326. },
  2327. drag: function(draggable, event) {
  2328. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  2329. if(draggable.options.refreshPositions) {
  2330. $.ui.ddmanager.prepareOffsets(draggable, event);
  2331. }
  2332. //Run through all droppables and check their positions based on specific tolerance options
  2333. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  2334. if(this.options.disabled || this.greedyChild || !this.visible) {
  2335. return;
  2336. }
  2337. var parentInstance, scope, parent,
  2338. intersects = $.ui.intersect(draggable, this, this.options.tolerance),
  2339. c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
  2340. if(!c) {
  2341. return;
  2342. }
  2343. if (this.options.greedy) {
  2344. // find droppable parents with same scope
  2345. scope = this.options.scope;
  2346. parent = this.element.parents(":data(ui-droppable)").filter(function () {
  2347. return $.data(this, "ui-droppable").options.scope === scope;
  2348. });
  2349. if (parent.length) {
  2350. parentInstance = $.data(parent[0], "ui-droppable");
  2351. parentInstance.greedyChild = (c === "isover");
  2352. }
  2353. }
  2354. // we just moved into a greedy child
  2355. if (parentInstance && c === "isover") {
  2356. parentInstance.isover = false;
  2357. parentInstance.isout = true;
  2358. parentInstance._out.call(parentInstance, event);
  2359. }
  2360. this[c] = true;
  2361. this[c === "isout" ? "isover" : "isout"] = false;
  2362. this[c === "isover" ? "_over" : "_out"].call(this, event);
  2363. // we just moved out of a greedy child
  2364. if (parentInstance && c === "isout") {
  2365. parentInstance.isout = false;
  2366. parentInstance.isover = true;
  2367. parentInstance._over.call(parentInstance, event);
  2368. }
  2369. });
  2370. },
  2371. dragStop: function( draggable, event ) {
  2372. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  2373. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  2374. if( !draggable.options.refreshPositions ) {
  2375. $.ui.ddmanager.prepareOffsets( draggable, event );
  2376. }
  2377. }
  2378. };
  2379. })(jQuery);
  2380. (function( $, undefined ) {
  2381. function num(v) {
  2382. return parseInt(v, 10) || 0;
  2383. }
  2384. function isNumber(value) {
  2385. return !isNaN(parseInt(value, 10));
  2386. }
  2387. $.widget("ui.resizable", $.ui.mouse, {
  2388. version: "1.10.4",
  2389. widgetEventPrefix: "resize",
  2390. options: {
  2391. alsoResize: false,
  2392. animate: false,
  2393. animateDuration: "slow",
  2394. animateEasing: "swing",
  2395. aspectRatio: false,
  2396. autoHide: false,
  2397. containment: false,
  2398. ghost: false,
  2399. grid: false,
  2400. handles: "e,s,se",
  2401. helper: false,
  2402. maxHeight: null,
  2403. maxWidth: null,
  2404. minHeight: 10,
  2405. minWidth: 10,
  2406. // See #7960
  2407. zIndex: 90,
  2408. // callbacks
  2409. resize: null,
  2410. start: null,
  2411. stop: null
  2412. },
  2413. _create: function() {
  2414. var n, i, handle, axis, hname,
  2415. that = this,
  2416. o = this.options;
  2417. this.element.addClass("ui-resizable");
  2418. $.extend(this, {
  2419. _aspectRatio: !!(o.aspectRatio),
  2420. aspectRatio: o.aspectRatio,
  2421. originalElement: this.element,
  2422. _proportionallyResizeElements: [],
  2423. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  2424. });
  2425. //Wrap the element if it cannot hold child nodes
  2426. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  2427. //Create a wrapper element and set the wrapper to the new current internal element
  2428. this.element.wrap(
  2429. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  2430. position: this.element.css("position"),
  2431. width: this.element.outerWidth(),
  2432. height: this.element.outerHeight(),
  2433. top: this.element.css("top"),
  2434. left: this.element.css("left")
  2435. })
  2436. );
  2437. //Overwrite the original this.element
  2438. this.element = this.element.parent().data(
  2439. "ui-resizable", this.element.data("ui-resizable")
  2440. );
  2441. this.elementIsWrapper = true;
  2442. //Move margins to the wrapper
  2443. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  2444. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  2445. //Prevent Safari textarea resize
  2446. this.originalResizeStyle = this.originalElement.css("resize");
  2447. this.originalElement.css("resize", "none");
  2448. //Push the actual element to our proportionallyResize internal array
  2449. this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
  2450. // avoid IE jump (hard set the margin)
  2451. this.originalElement.css({ margin: this.originalElement.css("margin") });
  2452. // fix handlers offset
  2453. this._proportionallyResize();
  2454. }
  2455. 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" });
  2456. if(this.handles.constructor === String) {
  2457. if ( this.handles === "all") {
  2458. this.handles = "n,e,s,w,se,sw,ne,nw";
  2459. }
  2460. n = this.handles.split(",");
  2461. this.handles = {};
  2462. for(i = 0; i < n.length; i++) {
  2463. handle = $.trim(n[i]);
  2464. hname = "ui-resizable-"+handle;
  2465. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  2466. // Apply zIndex to all handles - see #7960
  2467. axis.css({ zIndex: o.zIndex });
  2468. //TODO : What's going on here?
  2469. if ("se" === handle) {
  2470. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  2471. }
  2472. //Insert into internal handles object and append to element
  2473. this.handles[handle] = ".ui-resizable-"+handle;
  2474. this.element.append(axis);
  2475. }
  2476. }
  2477. this._renderAxis = function(target) {
  2478. var i, axis, padPos, padWrapper;
  2479. target = target || this.element;
  2480. for(i in this.handles) {
  2481. if(this.handles[i].constructor === String) {
  2482. this.handles[i] = $(this.handles[i], this.element).show();
  2483. }
  2484. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  2485. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  2486. axis = $(this.handles[i], this.element);
  2487. //Checking the correct pad and border
  2488. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2489. //The padding type i have to apply...
  2490. padPos = [ "padding",
  2491. /ne|nw|n/.test(i) ? "Top" :
  2492. /se|sw|s/.test(i) ? "Bottom" :
  2493. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2494. target.css(padPos, padWrapper);
  2495. this._proportionallyResize();
  2496. }
  2497. //TODO: What's that good for? There's not anything to be executed left
  2498. if(!$(this.handles[i]).length) {
  2499. continue;
  2500. }
  2501. }
  2502. };
  2503. //TODO: make renderAxis a prototype function
  2504. this._renderAxis(this.element);
  2505. this._handles = $(".ui-resizable-handle", this.element)
  2506. .disableSelection();
  2507. //Matching axis name
  2508. this._handles.mouseover(function() {
  2509. if (!that.resizing) {
  2510. if (this.className) {
  2511. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2512. }
  2513. //Axis, default = se
  2514. that.axis = axis && axis[1] ? axis[1] : "se";
  2515. }
  2516. });
  2517. //If we want to auto hide the elements
  2518. if (o.autoHide) {
  2519. this._handles.hide();
  2520. $(this.element)
  2521. .addClass("ui-resizable-autohide")
  2522. .mouseenter(function() {
  2523. if (o.disabled) {
  2524. return;
  2525. }
  2526. $(this).removeClass("ui-resizable-autohide");
  2527. that._handles.show();
  2528. })
  2529. .mouseleave(function(){
  2530. if (o.disabled) {
  2531. return;
  2532. }
  2533. if (!that.resizing) {
  2534. $(this).addClass("ui-resizable-autohide");
  2535. that._handles.hide();
  2536. }
  2537. });
  2538. }
  2539. //Initialize the mouse interaction
  2540. this._mouseInit();
  2541. },
  2542. _destroy: function() {
  2543. this._mouseDestroy();
  2544. var wrapper,
  2545. _destroy = function(exp) {
  2546. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2547. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
  2548. };
  2549. //TODO: Unwrap at same DOM position
  2550. if (this.elementIsWrapper) {
  2551. _destroy(this.element);
  2552. wrapper = this.element;
  2553. this.originalElement.css({
  2554. position: wrapper.css("position"),
  2555. width: wrapper.outerWidth(),
  2556. height: wrapper.outerHeight(),
  2557. top: wrapper.css("top"),
  2558. left: wrapper.css("left")
  2559. }).insertAfter( wrapper );
  2560. wrapper.remove();
  2561. }
  2562. this.originalElement.css("resize", this.originalResizeStyle);
  2563. _destroy(this.originalElement);
  2564. return this;
  2565. },
  2566. _mouseCapture: function(event) {
  2567. var i, handle,
  2568. capture = false;
  2569. for (i in this.handles) {
  2570. handle = $(this.handles[i])[0];
  2571. if (handle === event.target || $.contains(handle, event.target)) {
  2572. capture = true;
  2573. }
  2574. }
  2575. return !this.options.disabled && capture;
  2576. },
  2577. _mouseStart: function(event) {
  2578. var curleft, curtop, cursor,
  2579. o = this.options,
  2580. iniPos = this.element.position(),
  2581. el = this.element;
  2582. this.resizing = true;
  2583. // bugfix for http://dev.jquery.com/ticket/1749
  2584. if ( (/absolute/).test( el.css("position") ) ) {
  2585. el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
  2586. } else if (el.is(".ui-draggable")) {
  2587. el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
  2588. }
  2589. this._renderProxy();
  2590. curleft = num(this.helper.css("left"));
  2591. curtop = num(this.helper.css("top"));
  2592. if (o.containment) {
  2593. curleft += $(o.containment).scrollLeft() || 0;
  2594. curtop += $(o.containment).scrollTop() || 0;
  2595. }
  2596. //Store needed variables
  2597. this.offset = this.helper.offset();
  2598. this.position = { left: curleft, top: curtop };
  2599. this.size = this._helper ? { width: this.helper.width(), height: this.helper.height() } : { width: el.width(), height: el.height() };
  2600. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2601. this.originalPosition = { left: curleft, top: curtop };
  2602. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  2603. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2604. //Aspect Ratio
  2605. this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  2606. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2607. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2608. el.addClass("ui-resizable-resizing");
  2609. this._propagate("start", event);
  2610. return true;
  2611. },
  2612. _mouseDrag: function(event) {
  2613. //Increase performance, avoid regex
  2614. var data,
  2615. el = this.helper, props = {},
  2616. smp = this.originalMousePosition,
  2617. a = this.axis,
  2618. prevTop = this.position.top,
  2619. prevLeft = this.position.left,
  2620. prevWidth = this.size.width,
  2621. prevHeight = this.size.height,
  2622. dx = (event.pageX-smp.left)||0,
  2623. dy = (event.pageY-smp.top)||0,
  2624. trigger = this._change[a];
  2625. if (!trigger) {
  2626. return false;
  2627. }
  2628. // Calculate the attrs that will be change
  2629. data = trigger.apply(this, [event, dx, dy]);
  2630. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  2631. this._updateVirtualBoundaries(event.shiftKey);
  2632. if (this._aspectRatio || event.shiftKey) {
  2633. data = this._updateRatio(data, event);
  2634. }
  2635. data = this._respectSize(data, event);
  2636. this._updateCache(data);
  2637. // plugins callbacks need to be called first
  2638. this._propagate("resize", event);
  2639. if (this.position.top !== prevTop) {
  2640. props.top = this.position.top + "px";
  2641. }
  2642. if (this.position.left !== prevLeft) {
  2643. props.left = this.position.left + "px";
  2644. }
  2645. if (this.size.width !== prevWidth) {
  2646. props.width = this.size.width + "px";
  2647. }
  2648. if (this.size.height !== prevHeight) {
  2649. props.height = this.size.height + "px";
  2650. }
  2651. el.css(props);
  2652. if (!this._helper && this._proportionallyResizeElements.length) {
  2653. this._proportionallyResize();
  2654. }
  2655. // Call the user callback if the element was resized
  2656. if ( ! $.isEmptyObject(props) ) {
  2657. this._trigger("resize", event, this.ui());
  2658. }
  2659. return false;
  2660. },
  2661. _mouseStop: function(event) {
  2662. this.resizing = false;
  2663. var pr, ista, soffseth, soffsetw, s, left, top,
  2664. o = this.options, that = this;
  2665. if(this._helper) {
  2666. pr = this._proportionallyResizeElements;
  2667. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2668. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
  2669. soffsetw = ista ? 0 : that.sizeDiff.width;
  2670. s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
  2671. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
  2672. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2673. if (!o.animate) {
  2674. this.element.css($.extend(s, { top: top, left: left }));
  2675. }
  2676. that.helper.height(that.size.height);
  2677. that.helper.width(that.size.width);
  2678. if (this._helper && !o.animate) {
  2679. this._proportionallyResize();
  2680. }
  2681. }
  2682. $("body").css("cursor", "auto");
  2683. this.element.removeClass("ui-resizable-resizing");
  2684. this._propagate("stop", event);
  2685. if (this._helper) {
  2686. this.helper.remove();
  2687. }
  2688. return false;
  2689. },
  2690. _updateVirtualBoundaries: function(forceAspectRatio) {
  2691. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2692. o = this.options;
  2693. b = {
  2694. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  2695. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2696. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  2697. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2698. };
  2699. if(this._aspectRatio || forceAspectRatio) {
  2700. // We want to create an enclosing box whose aspect ration is the requested one
  2701. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  2702. pMinWidth = b.minHeight * this.aspectRatio;
  2703. pMinHeight = b.minWidth / this.aspectRatio;
  2704. pMaxWidth = b.maxHeight * this.aspectRatio;
  2705. pMaxHeight = b.maxWidth / this.aspectRatio;
  2706. if(pMinWidth > b.minWidth) {
  2707. b.minWidth = pMinWidth;
  2708. }
  2709. if(pMinHeight > b.minHeight) {
  2710. b.minHeight = pMinHeight;
  2711. }
  2712. if(pMaxWidth < b.maxWidth) {
  2713. b.maxWidth = pMaxWidth;
  2714. }
  2715. if(pMaxHeight < b.maxHeight) {
  2716. b.maxHeight = pMaxHeight;
  2717. }
  2718. }
  2719. this._vBoundaries = b;
  2720. },
  2721. _updateCache: function(data) {
  2722. this.offset = this.helper.offset();
  2723. if (isNumber(data.left)) {
  2724. this.position.left = data.left;
  2725. }
  2726. if (isNumber(data.top)) {
  2727. this.position.top = data.top;
  2728. }
  2729. if (isNumber(data.height)) {
  2730. this.size.height = data.height;
  2731. }
  2732. if (isNumber(data.width)) {
  2733. this.size.width = data.width;
  2734. }
  2735. },
  2736. _updateRatio: function( data ) {
  2737. var cpos = this.position,
  2738. csize = this.size,
  2739. a = this.axis;
  2740. if (isNumber(data.height)) {
  2741. data.width = (data.height * this.aspectRatio);
  2742. } else if (isNumber(data.width)) {
  2743. data.height = (data.width / this.aspectRatio);
  2744. }
  2745. if (a === "sw") {
  2746. data.left = cpos.left + (csize.width - data.width);
  2747. data.top = null;
  2748. }
  2749. if (a === "nw") {
  2750. data.top = cpos.top + (csize.height - data.height);
  2751. data.left = cpos.left + (csize.width - data.width);
  2752. }
  2753. return data;
  2754. },
  2755. _respectSize: function( data ) {
  2756. var o = this._vBoundaries,
  2757. a = this.axis,
  2758. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  2759. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  2760. dw = this.originalPosition.left + this.originalSize.width,
  2761. dh = this.position.top + this.size.height,
  2762. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  2763. if (isminw) {
  2764. data.width = o.minWidth;
  2765. }
  2766. if (isminh) {
  2767. data.height = o.minHeight;
  2768. }
  2769. if (ismaxw) {
  2770. data.width = o.maxWidth;
  2771. }
  2772. if (ismaxh) {
  2773. data.height = o.maxHeight;
  2774. }
  2775. if (isminw && cw) {
  2776. data.left = dw - o.minWidth;
  2777. }
  2778. if (ismaxw && cw) {
  2779. data.left = dw - o.maxWidth;
  2780. }
  2781. if (isminh && ch) {
  2782. data.top = dh - o.minHeight;
  2783. }
  2784. if (ismaxh && ch) {
  2785. data.top = dh - o.maxHeight;
  2786. }
  2787. // fixing jump error on top/left - bug #2330
  2788. if (!data.width && !data.height && !data.left && data.top) {
  2789. data.top = null;
  2790. } else if (!data.width && !data.height && !data.top && data.left) {
  2791. data.left = null;
  2792. }
  2793. return data;
  2794. },
  2795. _proportionallyResize: function() {
  2796. if (!this._proportionallyResizeElements.length) {
  2797. return;
  2798. }
  2799. var i, j, borders, paddings, prel,
  2800. element = this.helper || this.element;
  2801. for ( i=0; i < this._proportionallyResizeElements.length; i++) {
  2802. prel = this._proportionallyResizeElements[i];
  2803. if (!this.borderDif) {
  2804. this.borderDif = [];
  2805. borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
  2806. paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
  2807. for ( j = 0; j < borders.length; j++ ) {
  2808. this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
  2809. }
  2810. }
  2811. prel.css({
  2812. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  2813. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  2814. });
  2815. }
  2816. },
  2817. _renderProxy: function() {
  2818. var el = this.element, o = this.options;
  2819. this.elementOffset = el.offset();
  2820. if(this._helper) {
  2821. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  2822. this.helper.addClass(this._helper).css({
  2823. width: this.element.outerWidth() - 1,
  2824. height: this.element.outerHeight() - 1,
  2825. position: "absolute",
  2826. left: this.elementOffset.left +"px",
  2827. top: this.elementOffset.top +"px",
  2828. zIndex: ++o.zIndex //TODO: Don't modify option
  2829. });
  2830. this.helper
  2831. .appendTo("body")
  2832. .disableSelection();
  2833. } else {
  2834. this.helper = this.element;
  2835. }
  2836. },
  2837. _change: {
  2838. e: function(event, dx) {
  2839. return { width: this.originalSize.width + dx };
  2840. },
  2841. w: function(event, dx) {
  2842. var cs = this.originalSize, sp = this.originalPosition;
  2843. return { left: sp.left + dx, width: cs.width - dx };
  2844. },
  2845. n: function(event, dx, dy) {
  2846. var cs = this.originalSize, sp = this.originalPosition;
  2847. return { top: sp.top + dy, height: cs.height - dy };
  2848. },
  2849. s: function(event, dx, dy) {
  2850. return { height: this.originalSize.height + dy };
  2851. },
  2852. se: function(event, dx, dy) {
  2853. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2854. },
  2855. sw: function(event, dx, dy) {
  2856. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2857. },
  2858. ne: function(event, dx, dy) {
  2859. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2860. },
  2861. nw: function(event, dx, dy) {
  2862. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2863. }
  2864. },
  2865. _propagate: function(n, event) {
  2866. $.ui.plugin.call(this, n, [event, this.ui()]);
  2867. (n !== "resize" && this._trigger(n, event, this.ui()));
  2868. },
  2869. plugins: {},
  2870. ui: function() {
  2871. return {
  2872. originalElement: this.originalElement,
  2873. element: this.element,
  2874. helper: this.helper,
  2875. position: this.position,
  2876. size: this.size,
  2877. originalSize: this.originalSize,
  2878. originalPosition: this.originalPosition
  2879. };
  2880. }
  2881. });
  2882. /*
  2883. * Resizable Extensions
  2884. */
  2885. $.ui.plugin.add("resizable", "animate", {
  2886. stop: function( event ) {
  2887. var that = $(this).data("ui-resizable"),
  2888. o = that.options,
  2889. pr = that._proportionallyResizeElements,
  2890. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  2891. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  2892. soffsetw = ista ? 0 : that.sizeDiff.width,
  2893. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  2894. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
  2895. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2896. that.element.animate(
  2897. $.extend(style, top && left ? { top: top, left: left } : {}), {
  2898. duration: o.animateDuration,
  2899. easing: o.animateEasing,
  2900. step: function() {
  2901. var data = {
  2902. width: parseInt(that.element.css("width"), 10),
  2903. height: parseInt(that.element.css("height"), 10),
  2904. top: parseInt(that.element.css("top"), 10),
  2905. left: parseInt(that.element.css("left"), 10)
  2906. };
  2907. if (pr && pr.length) {
  2908. $(pr[0]).css({ width: data.width, height: data.height });
  2909. }
  2910. // propagating resize, and updating values for each animation step
  2911. that._updateCache(data);
  2912. that._propagate("resize", event);
  2913. }
  2914. }
  2915. );
  2916. }
  2917. });
  2918. $.ui.plugin.add("resizable", "containment", {
  2919. start: function() {
  2920. var element, p, co, ch, cw, width, height,
  2921. that = $(this).data("ui-resizable"),
  2922. o = that.options,
  2923. el = that.element,
  2924. oc = o.containment,
  2925. ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  2926. if (!ce) {
  2927. return;
  2928. }
  2929. that.containerElement = $(ce);
  2930. if (/document/.test(oc) || oc === document) {
  2931. that.containerOffset = { left: 0, top: 0 };
  2932. that.containerPosition = { left: 0, top: 0 };
  2933. that.parentData = {
  2934. element: $(document), left: 0, top: 0,
  2935. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  2936. };
  2937. }
  2938. // i'm a node, so compute top, left, right, bottom
  2939. else {
  2940. element = $(ce);
  2941. p = [];
  2942. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  2943. that.containerOffset = element.offset();
  2944. that.containerPosition = element.position();
  2945. that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  2946. co = that.containerOffset;
  2947. ch = that.containerSize.height;
  2948. cw = that.containerSize.width;
  2949. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
  2950. height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  2951. that.parentData = {
  2952. element: ce, left: co.left, top: co.top, width: width, height: height
  2953. };
  2954. }
  2955. },
  2956. resize: function( event ) {
  2957. var woset, hoset, isParent, isOffsetRelative,
  2958. that = $(this).data("ui-resizable"),
  2959. o = that.options,
  2960. co = that.containerOffset, cp = that.position,
  2961. pRatio = that._aspectRatio || event.shiftKey,
  2962. cop = { top:0, left:0 }, ce = that.containerElement;
  2963. if (ce[0] !== document && (/static/).test(ce.css("position"))) {
  2964. cop = co;
  2965. }
  2966. if (cp.left < (that._helper ? co.left : 0)) {
  2967. that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
  2968. if (pRatio) {
  2969. that.size.height = that.size.width / that.aspectRatio;
  2970. }
  2971. that.position.left = o.helper ? co.left : 0;
  2972. }
  2973. if (cp.top < (that._helper ? co.top : 0)) {
  2974. that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
  2975. if (pRatio) {
  2976. that.size.width = that.size.height * that.aspectRatio;
  2977. }
  2978. that.position.top = that._helper ? co.top : 0;
  2979. }
  2980. that.offset.left = that.parentData.left+that.position.left;
  2981. that.offset.top = that.parentData.top+that.position.top;
  2982. woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width );
  2983. hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
  2984. isParent = that.containerElement.get(0) === that.element.parent().get(0);
  2985. isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
  2986. if ( isParent && isOffsetRelative ) {
  2987. woset -= Math.abs( that.parentData.left );
  2988. }
  2989. if (woset + that.size.width >= that.parentData.width) {
  2990. that.size.width = that.parentData.width - woset;
  2991. if (pRatio) {
  2992. that.size.height = that.size.width / that.aspectRatio;
  2993. }
  2994. }
  2995. if (hoset + that.size.height >= that.parentData.height) {
  2996. that.size.height = that.parentData.height - hoset;
  2997. if (pRatio) {
  2998. that.size.width = that.size.height * that.aspectRatio;
  2999. }
  3000. }
  3001. },
  3002. stop: function(){
  3003. var that = $(this).data("ui-resizable"),
  3004. o = that.options,
  3005. co = that.containerOffset,
  3006. cop = that.containerPosition,
  3007. ce = that.containerElement,
  3008. helper = $(that.helper),
  3009. ho = helper.offset(),
  3010. w = helper.outerWidth() - that.sizeDiff.width,
  3011. h = helper.outerHeight() - that.sizeDiff.height;
  3012. if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
  3013. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  3014. }
  3015. if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
  3016. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  3017. }
  3018. }
  3019. });
  3020. $.ui.plugin.add("resizable", "alsoResize", {
  3021. start: function () {
  3022. var that = $(this).data("ui-resizable"),
  3023. o = that.options,
  3024. _store = function (exp) {
  3025. $(exp).each(function() {
  3026. var el = $(this);
  3027. el.data("ui-resizable-alsoresize", {
  3028. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  3029. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  3030. });
  3031. });
  3032. };
  3033. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  3034. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  3035. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  3036. }else{
  3037. _store(o.alsoResize);
  3038. }
  3039. },
  3040. resize: function (event, ui) {
  3041. var that = $(this).data("ui-resizable"),
  3042. o = that.options,
  3043. os = that.originalSize,
  3044. op = that.originalPosition,
  3045. delta = {
  3046. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  3047. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  3048. },
  3049. _alsoResize = function (exp, c) {
  3050. $(exp).each(function() {
  3051. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  3052. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
  3053. $.each(css, function (i, prop) {
  3054. var sum = (start[prop]||0) + (delta[prop]||0);
  3055. if (sum && sum >= 0) {
  3056. style[prop] = sum || null;
  3057. }
  3058. });
  3059. el.css(style);
  3060. });
  3061. };
  3062. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  3063. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  3064. }else{
  3065. _alsoResize(o.alsoResize);
  3066. }
  3067. },
  3068. stop: function () {
  3069. $(this).removeData("resizable-alsoresize");
  3070. }
  3071. });
  3072. $.ui.plugin.add("resizable", "ghost", {
  3073. start: function() {
  3074. var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
  3075. that.ghost = that.originalElement.clone();
  3076. that.ghost
  3077. .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  3078. .addClass("ui-resizable-ghost")
  3079. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  3080. that.ghost.appendTo(that.helper);
  3081. },
  3082. resize: function(){
  3083. var that = $(this).data("ui-resizable");
  3084. if (that.ghost) {
  3085. that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
  3086. }
  3087. },
  3088. stop: function() {
  3089. var that = $(this).data("ui-resizable");
  3090. if (that.ghost && that.helper) {
  3091. that.helper.get(0).removeChild(that.ghost.get(0));
  3092. }
  3093. }
  3094. });
  3095. $.ui.plugin.add("resizable", "grid", {
  3096. resize: function() {
  3097. var that = $(this).data("ui-resizable"),
  3098. o = that.options,
  3099. cs = that.size,
  3100. os = that.originalSize,
  3101. op = that.originalPosition,
  3102. a = that.axis,
  3103. grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
  3104. gridX = (grid[0]||1),
  3105. gridY = (grid[1]||1),
  3106. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  3107. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  3108. newWidth = os.width + ox,
  3109. newHeight = os.height + oy,
  3110. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  3111. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  3112. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  3113. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  3114. o.grid = grid;
  3115. if (isMinWidth) {
  3116. newWidth = newWidth + gridX;
  3117. }
  3118. if (isMinHeight) {
  3119. newHeight = newHeight + gridY;
  3120. }
  3121. if (isMaxWidth) {
  3122. newWidth = newWidth - gridX;
  3123. }
  3124. if (isMaxHeight) {
  3125. newHeight = newHeight - gridY;
  3126. }
  3127. if (/^(se|s|e)$/.test(a)) {
  3128. that.size.width = newWidth;
  3129. that.size.height = newHeight;
  3130. } else if (/^(ne)$/.test(a)) {
  3131. that.size.width = newWidth;
  3132. that.size.height = newHeight;
  3133. that.position.top = op.top - oy;
  3134. } else if (/^(sw)$/.test(a)) {
  3135. that.size.width = newWidth;
  3136. that.size.height = newHeight;
  3137. that.position.left = op.left - ox;
  3138. } else {
  3139. if ( newHeight - gridY > 0 ) {
  3140. that.size.height = newHeight;
  3141. that.position.top = op.top - oy;
  3142. } else {
  3143. that.size.height = gridY;
  3144. that.position.top = op.top + os.height - gridY;
  3145. }
  3146. if ( newWidth - gridX > 0 ) {
  3147. that.size.width = newWidth;
  3148. that.position.left = op.left - ox;
  3149. } else {
  3150. that.size.width = gridX;
  3151. that.position.left = op.left + os.width - gridX;
  3152. }
  3153. }
  3154. }
  3155. });
  3156. })(jQuery);
  3157. (function( $, undefined ) {
  3158. $.widget("ui.selectable", $.ui.mouse, {
  3159. version: "1.10.4",
  3160. options: {
  3161. appendTo: "body",
  3162. autoRefresh: true,
  3163. distance: 0,
  3164. filter: "*",
  3165. tolerance: "touch",
  3166. // callbacks
  3167. selected: null,
  3168. selecting: null,
  3169. start: null,
  3170. stop: null,
  3171. unselected: null,
  3172. unselecting: null
  3173. },
  3174. _create: function() {
  3175. var selectees,
  3176. that = this;
  3177. this.element.addClass("ui-selectable");
  3178. this.dragged = false;
  3179. // cache selectee children based on filter
  3180. this.refresh = function() {
  3181. selectees = $(that.options.filter, that.element[0]);
  3182. selectees.addClass("ui-selectee");
  3183. selectees.each(function() {
  3184. var $this = $(this),
  3185. pos = $this.offset();
  3186. $.data(this, "selectable-item", {
  3187. element: this,
  3188. $element: $this,
  3189. left: pos.left,
  3190. top: pos.top,
  3191. right: pos.left + $this.outerWidth(),
  3192. bottom: pos.top + $this.outerHeight(),
  3193. startselected: false,
  3194. selected: $this.hasClass("ui-selected"),
  3195. selecting: $this.hasClass("ui-selecting"),
  3196. unselecting: $this.hasClass("ui-unselecting")
  3197. });
  3198. });
  3199. };
  3200. this.refresh();
  3201. this.selectees = selectees.addClass("ui-selectee");
  3202. this._mouseInit();
  3203. this.helper = $("<div class='ui-selectable-helper'></div>");
  3204. },
  3205. _destroy: function() {
  3206. this.selectees
  3207. .removeClass("ui-selectee")
  3208. .removeData("selectable-item");
  3209. this.element
  3210. .removeClass("ui-selectable ui-selectable-disabled");
  3211. this._mouseDestroy();
  3212. },
  3213. _mouseStart: function(event) {
  3214. var that = this,
  3215. options = this.options;
  3216. this.opos = [event.pageX, event.pageY];
  3217. if (this.options.disabled) {
  3218. return;
  3219. }
  3220. this.selectees = $(options.filter, this.element[0]);
  3221. this._trigger("start", event);
  3222. $(options.appendTo).append(this.helper);
  3223. // position helper (lasso)
  3224. this.helper.css({
  3225. "left": event.pageX,
  3226. "top": event.pageY,
  3227. "width": 0,
  3228. "height": 0
  3229. });
  3230. if (options.autoRefresh) {
  3231. this.refresh();
  3232. }
  3233. this.selectees.filter(".ui-selected").each(function() {
  3234. var selectee = $.data(this, "selectable-item");
  3235. selectee.startselected = true;
  3236. if (!event.metaKey && !event.ctrlKey) {
  3237. selectee.$element.removeClass("ui-selected");
  3238. selectee.selected = false;
  3239. selectee.$element.addClass("ui-unselecting");
  3240. selectee.unselecting = true;
  3241. // selectable UNSELECTING callback
  3242. that._trigger("unselecting", event, {
  3243. unselecting: selectee.element
  3244. });
  3245. }
  3246. });
  3247. $(event.target).parents().addBack().each(function() {
  3248. var doSelect,
  3249. selectee = $.data(this, "selectable-item");
  3250. if (selectee) {
  3251. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  3252. selectee.$element
  3253. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  3254. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  3255. selectee.unselecting = !doSelect;
  3256. selectee.selecting = doSelect;
  3257. selectee.selected = doSelect;
  3258. // selectable (UN)SELECTING callback
  3259. if (doSelect) {
  3260. that._trigger("selecting", event, {
  3261. selecting: selectee.element
  3262. });
  3263. } else {
  3264. that._trigger("unselecting", event, {
  3265. unselecting: selectee.element
  3266. });
  3267. }
  3268. return false;
  3269. }
  3270. });
  3271. },
  3272. _mouseDrag: function(event) {
  3273. this.dragged = true;
  3274. if (this.options.disabled) {
  3275. return;
  3276. }
  3277. var tmp,
  3278. that = this,
  3279. options = this.options,
  3280. x1 = this.opos[0],
  3281. y1 = this.opos[1],
  3282. x2 = event.pageX,
  3283. y2 = event.pageY;
  3284. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  3285. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  3286. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  3287. this.selectees.each(function() {
  3288. var selectee = $.data(this, "selectable-item"),
  3289. hit = false;
  3290. //prevent helper from being selected if appendTo: selectable
  3291. if (!selectee || selectee.element === that.element[0]) {
  3292. return;
  3293. }
  3294. if (options.tolerance === "touch") {
  3295. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  3296. } else if (options.tolerance === "fit") {
  3297. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  3298. }
  3299. if (hit) {
  3300. // SELECT
  3301. if (selectee.selected) {
  3302. selectee.$element.removeClass("ui-selected");
  3303. selectee.selected = false;
  3304. }
  3305. if (selectee.unselecting) {
  3306. selectee.$element.removeClass("ui-unselecting");
  3307. selectee.unselecting = false;
  3308. }
  3309. if (!selectee.selecting) {
  3310. selectee.$element.addClass("ui-selecting");
  3311. selectee.selecting = true;
  3312. // selectable SELECTING callback
  3313. that._trigger("selecting", event, {
  3314. selecting: selectee.element
  3315. });
  3316. }
  3317. } else {
  3318. // UNSELECT
  3319. if (selectee.selecting) {
  3320. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  3321. selectee.$element.removeClass("ui-selecting");
  3322. selectee.selecting = false;
  3323. selectee.$element.addClass("ui-selected");
  3324. selectee.selected = true;
  3325. } else {
  3326. selectee.$element.removeClass("ui-selecting");
  3327. selectee.selecting = false;
  3328. if (selectee.startselected) {
  3329. selectee.$element.addClass("ui-unselecting");
  3330. selectee.unselecting = true;
  3331. }
  3332. // selectable UNSELECTING callback
  3333. that._trigger("unselecting", event, {
  3334. unselecting: selectee.element
  3335. });
  3336. }
  3337. }
  3338. if (selectee.selected) {
  3339. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  3340. selectee.$element.removeClass("ui-selected");
  3341. selectee.selected = false;
  3342. selectee.$element.addClass("ui-unselecting");
  3343. selectee.unselecting = true;
  3344. // selectable UNSELECTING callback
  3345. that._trigger("unselecting", event, {
  3346. unselecting: selectee.element
  3347. });
  3348. }
  3349. }
  3350. }
  3351. });
  3352. return false;
  3353. },
  3354. _mouseStop: function(event) {
  3355. var that = this;
  3356. this.dragged = false;
  3357. $(".ui-unselecting", this.element[0]).each(function() {
  3358. var selectee = $.data(this, "selectable-item");
  3359. selectee.$element.removeClass("ui-unselecting");
  3360. selectee.unselecting = false;
  3361. selectee.startselected = false;
  3362. that._trigger("unselected", event, {
  3363. unselected: selectee.element
  3364. });
  3365. });
  3366. $(".ui-selecting", this.element[0]).each(function() {
  3367. var selectee = $.data(this, "selectable-item");
  3368. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  3369. selectee.selecting = false;
  3370. selectee.selected = true;
  3371. selectee.startselected = true;
  3372. that._trigger("selected", event, {
  3373. selected: selectee.element
  3374. });
  3375. });
  3376. this._trigger("stop", event);
  3377. this.helper.remove();
  3378. return false;
  3379. }
  3380. });
  3381. })(jQuery);
  3382. (function( $, undefined ) {
  3383. function isOverAxis( x, reference, size ) {
  3384. return ( x > reference ) && ( x < ( reference + size ) );
  3385. }
  3386. function isFloating(item) {
  3387. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  3388. }
  3389. $.widget("ui.sortable", $.ui.mouse, {
  3390. version: "1.10.4",
  3391. widgetEventPrefix: "sort",
  3392. ready: false,
  3393. options: {
  3394. appendTo: "parent",
  3395. axis: false,
  3396. connectWith: false,
  3397. containment: false,
  3398. cursor: "auto",
  3399. cursorAt: false,
  3400. dropOnEmpty: true,
  3401. forcePlaceholderSize: false,
  3402. forceHelperSize: false,
  3403. grid: false,
  3404. handle: false,
  3405. helper: "original",
  3406. items: "> *",
  3407. opacity: false,
  3408. placeholder: false,
  3409. revert: false,
  3410. scroll: true,
  3411. scrollSensitivity: 20,
  3412. scrollSpeed: 20,
  3413. scope: "default",
  3414. tolerance: "intersect",
  3415. zIndex: 1000,
  3416. // callbacks
  3417. activate: null,
  3418. beforeStop: null,
  3419. change: null,
  3420. deactivate: null,
  3421. out: null,
  3422. over: null,
  3423. receive: null,
  3424. remove: null,
  3425. sort: null,
  3426. start: null,
  3427. stop: null,
  3428. update: null
  3429. },
  3430. _create: function() {
  3431. var o = this.options;
  3432. this.containerCache = {};
  3433. this.element.addClass("ui-sortable");
  3434. //Get the items
  3435. this.refresh();
  3436. //Let's determine if the items are being displayed horizontally
  3437. this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
  3438. //Let's determine the parent's offset
  3439. this.offset = this.element.offset();
  3440. //Initialize mouse events for interaction
  3441. this._mouseInit();
  3442. //We're ready to go
  3443. this.ready = true;
  3444. },
  3445. _destroy: function() {
  3446. this.element
  3447. .removeClass("ui-sortable ui-sortable-disabled");
  3448. this._mouseDestroy();
  3449. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  3450. this.items[i].item.removeData(this.widgetName + "-item");
  3451. }
  3452. return this;
  3453. },
  3454. _setOption: function(key, value){
  3455. if ( key === "disabled" ) {
  3456. this.options[ key ] = value;
  3457. this.widget().toggleClass( "ui-sortable-disabled", !!value );
  3458. } else {
  3459. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  3460. $.Widget.prototype._setOption.apply(this, arguments);
  3461. }
  3462. },
  3463. _mouseCapture: function(event, overrideHandle) {
  3464. var currentItem = null,
  3465. validHandle = false,
  3466. that = this;
  3467. if (this.reverting) {
  3468. return false;
  3469. }
  3470. if(this.options.disabled || this.options.type === "static") {
  3471. return false;
  3472. }
  3473. //We have to refresh the items data once first
  3474. this._refreshItems(event);
  3475. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  3476. $(event.target).parents().each(function() {
  3477. if($.data(this, that.widgetName + "-item") === that) {
  3478. currentItem = $(this);
  3479. return false;
  3480. }
  3481. });
  3482. if($.data(event.target, that.widgetName + "-item") === that) {
  3483. currentItem = $(event.target);
  3484. }
  3485. if(!currentItem) {
  3486. return false;
  3487. }
  3488. if(this.options.handle && !overrideHandle) {
  3489. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  3490. if(this === event.target) {
  3491. validHandle = true;
  3492. }
  3493. });
  3494. if(!validHandle) {
  3495. return false;
  3496. }
  3497. }
  3498. this.currentItem = currentItem;
  3499. this._removeCurrentsFromItems();
  3500. return true;
  3501. },
  3502. _mouseStart: function(event, overrideHandle, noActivation) {
  3503. var i, body,
  3504. o = this.options;
  3505. this.currentContainer = this;
  3506. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3507. this.refreshPositions();
  3508. //Create and append the visible helper
  3509. this.helper = this._createHelper(event);
  3510. //Cache the helper size
  3511. this._cacheHelperProportions();
  3512. /*
  3513. * - Position generation -
  3514. * This block generates everything position related - it's the core of draggables.
  3515. */
  3516. //Cache the margins of the original element
  3517. this._cacheMargins();
  3518. //Get the next scrolling parent
  3519. this.scrollParent = this.helper.scrollParent();
  3520. //The element's absolute position on the page minus margins
  3521. this.offset = this.currentItem.offset();
  3522. this.offset = {
  3523. top: this.offset.top - this.margins.top,
  3524. left: this.offset.left - this.margins.left
  3525. };
  3526. $.extend(this.offset, {
  3527. click: { //Where the click happened, relative to the element
  3528. left: event.pageX - this.offset.left,
  3529. top: event.pageY - this.offset.top
  3530. },
  3531. parent: this._getParentOffset(),
  3532. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3533. });
  3534. // Only after we got the offset, we can change the helper's position to absolute
  3535. // TODO: Still need to figure out a way to make relative sorting possible
  3536. this.helper.css("position", "absolute");
  3537. this.cssPosition = this.helper.css("position");
  3538. //Generate the original position
  3539. this.originalPosition = this._generatePosition(event);
  3540. this.originalPageX = event.pageX;
  3541. this.originalPageY = event.pageY;
  3542. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3543. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3544. //Cache the former DOM position
  3545. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3546. //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
  3547. if(this.helper[0] !== this.currentItem[0]) {
  3548. this.currentItem.hide();
  3549. }
  3550. //Create the placeholder
  3551. this._createPlaceholder();
  3552. //Set a containment if given in the options
  3553. if(o.containment) {
  3554. this._setContainment();
  3555. }
  3556. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  3557. body = this.document.find( "body" );
  3558. // support: IE
  3559. this.storedCursor = body.css( "cursor" );
  3560. body.css( "cursor", o.cursor );
  3561. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  3562. }
  3563. if(o.opacity) { // opacity option
  3564. if (this.helper.css("opacity")) {
  3565. this._storedOpacity = this.helper.css("opacity");
  3566. }
  3567. this.helper.css("opacity", o.opacity);
  3568. }
  3569. if(o.zIndex) { // zIndex option
  3570. if (this.helper.css("zIndex")) {
  3571. this._storedZIndex = this.helper.css("zIndex");
  3572. }
  3573. this.helper.css("zIndex", o.zIndex);
  3574. }
  3575. //Prepare scrolling
  3576. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3577. this.overflowOffset = this.scrollParent.offset();
  3578. }
  3579. //Call callbacks
  3580. this._trigger("start", event, this._uiHash());
  3581. //Recache the helper size
  3582. if(!this._preserveHelperProportions) {
  3583. this._cacheHelperProportions();
  3584. }
  3585. //Post "activate" events to possible containers
  3586. if( !noActivation ) {
  3587. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  3588. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  3589. }
  3590. }
  3591. //Prepare possible droppables
  3592. if($.ui.ddmanager) {
  3593. $.ui.ddmanager.current = this;
  3594. }
  3595. if ($.ui.ddmanager && !o.dropBehaviour) {
  3596. $.ui.ddmanager.prepareOffsets(this, event);
  3597. }
  3598. this.dragging = true;
  3599. this.helper.addClass("ui-sortable-helper");
  3600. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  3601. return true;
  3602. },
  3603. _mouseDrag: function(event) {
  3604. var i, item, itemElement, intersection,
  3605. o = this.options,
  3606. scrolled = false;
  3607. //Compute the helpers position
  3608. this.position = this._generatePosition(event);
  3609. this.positionAbs = this._convertPositionTo("absolute");
  3610. if (!this.lastPositionAbs) {
  3611. this.lastPositionAbs = this.positionAbs;
  3612. }
  3613. //Do scrolling
  3614. if(this.options.scroll) {
  3615. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3616. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  3617. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  3618. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  3619. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  3620. }
  3621. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  3622. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  3623. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  3624. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  3625. }
  3626. } else {
  3627. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  3628. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  3629. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  3630. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  3631. }
  3632. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  3633. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  3634. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  3635. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  3636. }
  3637. }
  3638. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  3639. $.ui.ddmanager.prepareOffsets(this, event);
  3640. }
  3641. }
  3642. //Regenerate the absolute position used for position checks
  3643. this.positionAbs = this._convertPositionTo("absolute");
  3644. //Set the helper position
  3645. if(!this.options.axis || this.options.axis !== "y") {
  3646. this.helper[0].style.left = this.position.left+"px";
  3647. }
  3648. if(!this.options.axis || this.options.axis !== "x") {
  3649. this.helper[0].style.top = this.position.top+"px";
  3650. }
  3651. //Rearrange
  3652. for (i = this.items.length - 1; i >= 0; i--) {
  3653. //Cache variables and intersection, continue if no intersection
  3654. item = this.items[i];
  3655. itemElement = item.item[0];
  3656. intersection = this._intersectsWithPointer(item);
  3657. if (!intersection) {
  3658. continue;
  3659. }
  3660. // Only put the placeholder inside the current Container, skip all
  3661. // items from other containers. This works because when moving
  3662. // an item from one container to another the
  3663. // currentContainer is switched before the placeholder is moved.
  3664. //
  3665. // Without this, moving items in "sub-sortables" can cause
  3666. // the placeholder to jitter beetween the outer and inner container.
  3667. if (item.instance !== this.currentContainer) {
  3668. continue;
  3669. }
  3670. // cannot intersect with itself
  3671. // no useless actions that have been done before
  3672. // no action if the item moved is the parent of the item checked
  3673. if (itemElement !== this.currentItem[0] &&
  3674. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  3675. !$.contains(this.placeholder[0], itemElement) &&
  3676. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  3677. ) {
  3678. this.direction = intersection === 1 ? "down" : "up";
  3679. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  3680. this._rearrange(event, item);
  3681. } else {
  3682. break;
  3683. }
  3684. this._trigger("change", event, this._uiHash());
  3685. break;
  3686. }
  3687. }
  3688. //Post events to containers
  3689. this._contactContainers(event);
  3690. //Interconnect with droppables
  3691. if($.ui.ddmanager) {
  3692. $.ui.ddmanager.drag(this, event);
  3693. }
  3694. //Call callbacks
  3695. this._trigger("sort", event, this._uiHash());
  3696. this.lastPositionAbs = this.positionAbs;
  3697. return false;
  3698. },
  3699. _mouseStop: function(event, noPropagation) {
  3700. if(!event) {
  3701. return;
  3702. }
  3703. //If we are using droppables, inform the manager about the drop
  3704. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  3705. $.ui.ddmanager.drop(this, event);
  3706. }
  3707. if(this.options.revert) {
  3708. var that = this,
  3709. cur = this.placeholder.offset(),
  3710. axis = this.options.axis,
  3711. animation = {};
  3712. if ( !axis || axis === "x" ) {
  3713. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  3714. }
  3715. if ( !axis || axis === "y" ) {
  3716. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  3717. }
  3718. this.reverting = true;
  3719. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  3720. that._clear(event);
  3721. });
  3722. } else {
  3723. this._clear(event, noPropagation);
  3724. }
  3725. return false;
  3726. },
  3727. cancel: function() {
  3728. if(this.dragging) {
  3729. this._mouseUp({ target: null });
  3730. if(this.options.helper === "original") {
  3731. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3732. } else {
  3733. this.currentItem.show();
  3734. }
  3735. //Post deactivating events to containers
  3736. for (var i = this.containers.length - 1; i >= 0; i--){
  3737. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  3738. if(this.containers[i].containerCache.over) {
  3739. this.containers[i]._trigger("out", null, this._uiHash(this));
  3740. this.containers[i].containerCache.over = 0;
  3741. }
  3742. }
  3743. }
  3744. if (this.placeholder) {
  3745. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3746. if(this.placeholder[0].parentNode) {
  3747. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3748. }
  3749. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  3750. this.helper.remove();
  3751. }
  3752. $.extend(this, {
  3753. helper: null,
  3754. dragging: false,
  3755. reverting: false,
  3756. _noFinalSort: null
  3757. });
  3758. if(this.domPosition.prev) {
  3759. $(this.domPosition.prev).after(this.currentItem);
  3760. } else {
  3761. $(this.domPosition.parent).prepend(this.currentItem);
  3762. }
  3763. }
  3764. return this;
  3765. },
  3766. serialize: function(o) {
  3767. var items = this._getItemsAsjQuery(o && o.connected),
  3768. str = [];
  3769. o = o || {};
  3770. $(items).each(function() {
  3771. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  3772. if (res) {
  3773. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  3774. }
  3775. });
  3776. if(!str.length && o.key) {
  3777. str.push(o.key + "=");
  3778. }
  3779. return str.join("&");
  3780. },
  3781. toArray: function(o) {
  3782. var items = this._getItemsAsjQuery(o && o.connected),
  3783. ret = [];
  3784. o = o || {};
  3785. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  3786. return ret;
  3787. },
  3788. /* Be careful with the following core functions */
  3789. _intersectsWith: function(item) {
  3790. var x1 = this.positionAbs.left,
  3791. x2 = x1 + this.helperProportions.width,
  3792. y1 = this.positionAbs.top,
  3793. y2 = y1 + this.helperProportions.height,
  3794. l = item.left,
  3795. r = l + item.width,
  3796. t = item.top,
  3797. b = t + item.height,
  3798. dyClick = this.offset.click.top,
  3799. dxClick = this.offset.click.left,
  3800. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  3801. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  3802. isOverElement = isOverElementHeight && isOverElementWidth;
  3803. if ( this.options.tolerance === "pointer" ||
  3804. this.options.forcePointerForContainers ||
  3805. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  3806. ) {
  3807. return isOverElement;
  3808. } else {
  3809. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  3810. x2 - (this.helperProportions.width / 2) < r && // Left Half
  3811. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  3812. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  3813. }
  3814. },
  3815. _intersectsWithPointer: function(item) {
  3816. var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  3817. isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  3818. isOverElement = isOverElementHeight && isOverElementWidth,
  3819. verticalDirection = this._getDragVerticalDirection(),
  3820. horizontalDirection = this._getDragHorizontalDirection();
  3821. if (!isOverElement) {
  3822. return false;
  3823. }
  3824. return this.floating ?
  3825. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  3826. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  3827. },
  3828. _intersectsWithSides: function(item) {
  3829. var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  3830. isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  3831. verticalDirection = this._getDragVerticalDirection(),
  3832. horizontalDirection = this._getDragHorizontalDirection();
  3833. if (this.floating && horizontalDirection) {
  3834. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  3835. } else {
  3836. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  3837. }
  3838. },
  3839. _getDragVerticalDirection: function() {
  3840. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  3841. return delta !== 0 && (delta > 0 ? "down" : "up");
  3842. },
  3843. _getDragHorizontalDirection: function() {
  3844. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  3845. return delta !== 0 && (delta > 0 ? "right" : "left");
  3846. },
  3847. refresh: function(event) {
  3848. this._refreshItems(event);
  3849. this.refreshPositions();
  3850. return this;
  3851. },
  3852. _connectWith: function() {
  3853. var options = this.options;
  3854. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  3855. },
  3856. _getItemsAsjQuery: function(connected) {
  3857. var i, j, cur, inst,
  3858. items = [],
  3859. queries = [],
  3860. connectWith = this._connectWith();
  3861. if(connectWith && connected) {
  3862. for (i = connectWith.length - 1; i >= 0; i--){
  3863. cur = $(connectWith[i]);
  3864. for ( j = cur.length - 1; j >= 0; j--){
  3865. inst = $.data(cur[j], this.widgetFullName);
  3866. if(inst && inst !== this && !inst.options.disabled) {
  3867. 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]);
  3868. }
  3869. }
  3870. }
  3871. }
  3872. 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]);
  3873. function addItems() {
  3874. items.push( this );
  3875. }
  3876. for (i = queries.length - 1; i >= 0; i--){
  3877. queries[i][0].each( addItems );
  3878. }
  3879. return $(items);
  3880. },
  3881. _removeCurrentsFromItems: function() {
  3882. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  3883. this.items = $.grep(this.items, function (item) {
  3884. for (var j=0; j < list.length; j++) {
  3885. if(list[j] === item.item[0]) {
  3886. return false;
  3887. }
  3888. }
  3889. return true;
  3890. });
  3891. },
  3892. _refreshItems: function(event) {
  3893. this.items = [];
  3894. this.containers = [this];
  3895. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  3896. items = this.items,
  3897. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  3898. connectWith = this._connectWith();
  3899. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  3900. for (i = connectWith.length - 1; i >= 0; i--){
  3901. cur = $(connectWith[i]);
  3902. for (j = cur.length - 1; j >= 0; j--){
  3903. inst = $.data(cur[j], this.widgetFullName);
  3904. if(inst && inst !== this && !inst.options.disabled) {
  3905. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  3906. this.containers.push(inst);
  3907. }
  3908. }
  3909. }
  3910. }
  3911. for (i = queries.length - 1; i >= 0; i--) {
  3912. targetData = queries[i][1];
  3913. _queries = queries[i][0];
  3914. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  3915. item = $(_queries[j]);
  3916. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  3917. items.push({
  3918. item: item,
  3919. instance: targetData,
  3920. width: 0, height: 0,
  3921. left: 0, top: 0
  3922. });
  3923. }
  3924. }
  3925. },
  3926. refreshPositions: function(fast) {
  3927. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  3928. if(this.offsetParent && this.helper) {
  3929. this.offset.parent = this._getParentOffset();
  3930. }
  3931. var i, item, t, p;
  3932. for (i = this.items.length - 1; i >= 0; i--){
  3933. item = this.items[i];
  3934. //We ignore calculating positions of all connected containers when we're not over them
  3935. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  3936. continue;
  3937. }
  3938. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  3939. if (!fast) {
  3940. item.width = t.outerWidth();
  3941. item.height = t.outerHeight();
  3942. }
  3943. p = t.offset();
  3944. item.left = p.left;
  3945. item.top = p.top;
  3946. }
  3947. if(this.options.custom && this.options.custom.refreshContainers) {
  3948. this.options.custom.refreshContainers.call(this);
  3949. } else {
  3950. for (i = this.containers.length - 1; i >= 0; i--){
  3951. p = this.containers[i].element.offset();
  3952. this.containers[i].containerCache.left = p.left;
  3953. this.containers[i].containerCache.top = p.top;
  3954. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  3955. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  3956. }
  3957. }
  3958. return this;
  3959. },
  3960. _createPlaceholder: function(that) {
  3961. that = that || this;
  3962. var className,
  3963. o = that.options;
  3964. if(!o.placeholder || o.placeholder.constructor === String) {
  3965. className = o.placeholder;
  3966. o.placeholder = {
  3967. element: function() {
  3968. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  3969. element = $( "<" + nodeName + ">", that.document[0] )
  3970. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  3971. .removeClass("ui-sortable-helper");
  3972. if ( nodeName === "tr" ) {
  3973. that.currentItem.children().each(function() {
  3974. $( "<td>&#160;</td>", that.document[0] )
  3975. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  3976. .appendTo( element );
  3977. });
  3978. } else if ( nodeName === "img" ) {
  3979. element.attr( "src", that.currentItem.attr( "src" ) );
  3980. }
  3981. if ( !className ) {
  3982. element.css( "visibility", "hidden" );
  3983. }
  3984. return element;
  3985. },
  3986. update: function(container, p) {
  3987. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  3988. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  3989. if(className && !o.forcePlaceholderSize) {
  3990. return;
  3991. }
  3992. //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
  3993. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  3994. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  3995. }
  3996. };
  3997. }
  3998. //Create the placeholder
  3999. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  4000. //Append it after the actual current item
  4001. that.currentItem.after(that.placeholder);
  4002. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  4003. o.placeholder.update(that, that.placeholder);
  4004. },
  4005. _contactContainers: function(event) {
  4006. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
  4007. innermostContainer = null,
  4008. innermostIndex = null;
  4009. // get innermost container that intersects with item
  4010. for (i = this.containers.length - 1; i >= 0; i--) {
  4011. // never consider a container that's located within the item itself
  4012. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  4013. continue;
  4014. }
  4015. if(this._intersectsWith(this.containers[i].containerCache)) {
  4016. // if we've already found a container and it's more "inner" than this, then continue
  4017. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  4018. continue;
  4019. }
  4020. innermostContainer = this.containers[i];
  4021. innermostIndex = i;
  4022. } else {
  4023. // container doesn't intersect. trigger "out" event if necessary
  4024. if(this.containers[i].containerCache.over) {
  4025. this.containers[i]._trigger("out", event, this._uiHash(this));
  4026. this.containers[i].containerCache.over = 0;
  4027. }
  4028. }
  4029. }
  4030. // if no intersecting containers found, return
  4031. if(!innermostContainer) {
  4032. return;
  4033. }
  4034. // move the item into the container if it's not there already
  4035. if(this.containers.length === 1) {
  4036. if (!this.containers[innermostIndex].containerCache.over) {
  4037. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4038. this.containers[innermostIndex].containerCache.over = 1;
  4039. }
  4040. } else {
  4041. //When entering a new container, we will find the item with the least distance and append our item near it
  4042. dist = 10000;
  4043. itemWithLeastDistance = null;
  4044. floating = innermostContainer.floating || isFloating(this.currentItem);
  4045. posProperty = floating ? "left" : "top";
  4046. sizeProperty = floating ? "width" : "height";
  4047. base = this.positionAbs[posProperty] + this.offset.click[posProperty];
  4048. for (j = this.items.length - 1; j >= 0; j--) {
  4049. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  4050. continue;
  4051. }
  4052. if(this.items[j].item[0] === this.currentItem[0]) {
  4053. continue;
  4054. }
  4055. if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
  4056. continue;
  4057. }
  4058. cur = this.items[j].item.offset()[posProperty];
  4059. nearBottom = false;
  4060. if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
  4061. nearBottom = true;
  4062. cur += this.items[j][sizeProperty];
  4063. }
  4064. if(Math.abs(cur - base) < dist) {
  4065. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  4066. this.direction = nearBottom ? "up": "down";
  4067. }
  4068. }
  4069. //Check if dropOnEmpty is enabled
  4070. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  4071. return;
  4072. }
  4073. if(this.currentContainer === this.containers[innermostIndex]) {
  4074. return;
  4075. }
  4076. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  4077. this._trigger("change", event, this._uiHash());
  4078. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  4079. this.currentContainer = this.containers[innermostIndex];
  4080. //Update the placeholder
  4081. this.options.placeholder.update(this.currentContainer, this.placeholder);
  4082. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4083. this.containers[innermostIndex].containerCache.over = 1;
  4084. }
  4085. },
  4086. _createHelper: function(event) {
  4087. var o = this.options,
  4088. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  4089. //Add the helper to the DOM if that didn't happen already
  4090. if(!helper.parents("body").length) {
  4091. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  4092. }
  4093. if(helper[0] === this.currentItem[0]) {
  4094. 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") };
  4095. }
  4096. if(!helper[0].style.width || o.forceHelperSize) {
  4097. helper.width(this.currentItem.width());
  4098. }
  4099. if(!helper[0].style.height || o.forceHelperSize) {
  4100. helper.height(this.currentItem.height());
  4101. }
  4102. return helper;
  4103. },
  4104. _adjustOffsetFromHelper: function(obj) {
  4105. if (typeof obj === "string") {
  4106. obj = obj.split(" ");
  4107. }
  4108. if ($.isArray(obj)) {
  4109. obj = {left: +obj[0], top: +obj[1] || 0};
  4110. }
  4111. if ("left" in obj) {
  4112. this.offset.click.left = obj.left + this.margins.left;
  4113. }
  4114. if ("right" in obj) {
  4115. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  4116. }
  4117. if ("top" in obj) {
  4118. this.offset.click.top = obj.top + this.margins.top;
  4119. }
  4120. if ("bottom" in obj) {
  4121. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  4122. }
  4123. },
  4124. _getParentOffset: function() {
  4125. //Get the offsetParent and cache its position
  4126. this.offsetParent = this.helper.offsetParent();
  4127. var po = this.offsetParent.offset();
  4128. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  4129. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  4130. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  4131. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  4132. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  4133. po.left += this.scrollParent.scrollLeft();
  4134. po.top += this.scrollParent.scrollTop();
  4135. }
  4136. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  4137. // with an ugly IE fix
  4138. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  4139. po = { top: 0, left: 0 };
  4140. }
  4141. return {
  4142. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  4143. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  4144. };
  4145. },
  4146. _getRelativeOffset: function() {
  4147. if(this.cssPosition === "relative") {
  4148. var p = this.currentItem.position();
  4149. return {
  4150. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  4151. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  4152. };
  4153. } else {
  4154. return { top: 0, left: 0 };
  4155. }
  4156. },
  4157. _cacheMargins: function() {
  4158. this.margins = {
  4159. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  4160. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  4161. };
  4162. },
  4163. _cacheHelperProportions: function() {
  4164. this.helperProportions = {
  4165. width: this.helper.outerWidth(),
  4166. height: this.helper.outerHeight()
  4167. };
  4168. },
  4169. _setContainment: function() {
  4170. var ce, co, over,
  4171. o = this.options;
  4172. if(o.containment === "parent") {
  4173. o.containment = this.helper[0].parentNode;
  4174. }
  4175. if(o.containment === "document" || o.containment === "window") {
  4176. this.containment = [
  4177. 0 - this.offset.relative.left - this.offset.parent.left,
  4178. 0 - this.offset.relative.top - this.offset.parent.top,
  4179. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  4180. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  4181. ];
  4182. }
  4183. if(!(/^(document|window|parent)$/).test(o.containment)) {
  4184. ce = $(o.containment)[0];
  4185. co = $(o.containment).offset();
  4186. over = ($(ce).css("overflow") !== "hidden");
  4187. this.containment = [
  4188. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  4189. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  4190. 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,
  4191. 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
  4192. ];
  4193. }
  4194. },
  4195. _convertPositionTo: function(d, pos) {
  4196. if(!pos) {
  4197. pos = this.position;
  4198. }
  4199. var mod = d === "absolute" ? 1 : -1,
  4200. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  4201. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  4202. return {
  4203. top: (
  4204. pos.top + // The absolute mouse position
  4205. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4206. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  4207. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  4208. ),
  4209. left: (
  4210. pos.left + // The absolute mouse position
  4211. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4212. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  4213. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  4214. )
  4215. };
  4216. },
  4217. _generatePosition: function(event) {
  4218. var top, left,
  4219. o = this.options,
  4220. pageX = event.pageX,
  4221. pageY = event.pageY,
  4222. 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);
  4223. // This is another very weird special case that only happens for relative elements:
  4224. // 1. If the css position is relative
  4225. // 2. and the scroll parent is the document or similar to the offset parent
  4226. // we have to refresh the relative offset during the scroll so there are no jumps
  4227. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  4228. this.offset.relative = this._getRelativeOffset();
  4229. }
  4230. /*
  4231. * - Position constraining -
  4232. * Constrain the position to a mix of grid, containment.
  4233. */
  4234. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  4235. if(this.containment) {
  4236. if(event.pageX - this.offset.click.left < this.containment[0]) {
  4237. pageX = this.containment[0] + this.offset.click.left;
  4238. }
  4239. if(event.pageY - this.offset.click.top < this.containment[1]) {
  4240. pageY = this.containment[1] + this.offset.click.top;
  4241. }
  4242. if(event.pageX - this.offset.click.left > this.containment[2]) {
  4243. pageX = this.containment[2] + this.offset.click.left;
  4244. }
  4245. if(event.pageY - this.offset.click.top > this.containment[3]) {
  4246. pageY = this.containment[3] + this.offset.click.top;
  4247. }
  4248. }
  4249. if(o.grid) {
  4250. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  4251. 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;
  4252. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  4253. 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;
  4254. }
  4255. }
  4256. return {
  4257. top: (
  4258. pageY - // The absolute mouse position
  4259. this.offset.click.top - // Click offset (relative to the element)
  4260. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  4261. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  4262. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  4263. ),
  4264. left: (
  4265. pageX - // The absolute mouse position
  4266. this.offset.click.left - // Click offset (relative to the element)
  4267. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  4268. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  4269. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  4270. )
  4271. };
  4272. },
  4273. _rearrange: function(event, i, a, hardRefresh) {
  4274. 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));
  4275. //Various things done here to improve the performance:
  4276. // 1. we create a setTimeout, that calls refreshPositions
  4277. // 2. on the instance, we have a counter variable, that get's higher after every append
  4278. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  4279. // 4. this lets only the last addition to the timeout stack through
  4280. this.counter = this.counter ? ++this.counter : 1;
  4281. var counter = this.counter;
  4282. this._delay(function() {
  4283. if(counter === this.counter) {
  4284. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  4285. }
  4286. });
  4287. },
  4288. _clear: function(event, noPropagation) {
  4289. this.reverting = false;
  4290. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  4291. // everything else normalized again
  4292. var i,
  4293. delayedTriggers = [];
  4294. // We first have to update the dom position of the actual currentItem
  4295. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  4296. if(!this._noFinalSort && this.currentItem.parent().length) {
  4297. this.placeholder.before(this.currentItem);
  4298. }
  4299. this._noFinalSort = null;
  4300. if(this.helper[0] === this.currentItem[0]) {
  4301. for(i in this._storedCSS) {
  4302. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  4303. this._storedCSS[i] = "";
  4304. }
  4305. }
  4306. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  4307. } else {
  4308. this.currentItem.show();
  4309. }
  4310. if(this.fromOutside && !noPropagation) {
  4311. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  4312. }
  4313. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  4314. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  4315. }
  4316. // Check if the items Container has Changed and trigger appropriate
  4317. // events.
  4318. if (this !== this.currentContainer) {
  4319. if(!noPropagation) {
  4320. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  4321. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4322. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4323. }
  4324. }
  4325. //Post events to containers
  4326. function delayEvent( type, instance, container ) {
  4327. return function( event ) {
  4328. container._trigger( type, event, instance._uiHash( instance ) );
  4329. };
  4330. }
  4331. for (i = this.containers.length - 1; i >= 0; i--){
  4332. if (!noPropagation) {
  4333. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  4334. }
  4335. if(this.containers[i].containerCache.over) {
  4336. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  4337. this.containers[i].containerCache.over = 0;
  4338. }
  4339. }
  4340. //Do what was originally in plugins
  4341. if ( this.storedCursor ) {
  4342. this.document.find( "body" ).css( "cursor", this.storedCursor );
  4343. this.storedStylesheet.remove();
  4344. }
  4345. if(this._storedOpacity) {
  4346. this.helper.css("opacity", this._storedOpacity);
  4347. }
  4348. if(this._storedZIndex) {
  4349. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  4350. }
  4351. this.dragging = false;
  4352. if(this.cancelHelperRemoval) {
  4353. if(!noPropagation) {
  4354. this._trigger("beforeStop", event, this._uiHash());
  4355. for (i=0; i < delayedTriggers.length; i++) {
  4356. delayedTriggers[i].call(this, event);
  4357. } //Trigger all delayed events
  4358. this._trigger("stop", event, this._uiHash());
  4359. }
  4360. this.fromOutside = false;
  4361. return false;
  4362. }
  4363. if(!noPropagation) {
  4364. this._trigger("beforeStop", event, this._uiHash());
  4365. }
  4366. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  4367. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  4368. if(this.helper[0] !== this.currentItem[0]) {
  4369. this.helper.remove();
  4370. }
  4371. this.helper = null;
  4372. if(!noPropagation) {
  4373. for (i=0; i < delayedTriggers.length; i++) {
  4374. delayedTriggers[i].call(this, event);
  4375. } //Trigger all delayed events
  4376. this._trigger("stop", event, this._uiHash());
  4377. }
  4378. this.fromOutside = false;
  4379. return true;
  4380. },
  4381. _trigger: function() {
  4382. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  4383. this.cancel();
  4384. }
  4385. },
  4386. _uiHash: function(_inst) {
  4387. var inst = _inst || this;
  4388. return {
  4389. helper: inst.helper,
  4390. placeholder: inst.placeholder || $([]),
  4391. position: inst.position,
  4392. originalPosition: inst.originalPosition,
  4393. offset: inst.positionAbs,
  4394. item: inst.currentItem,
  4395. sender: _inst ? _inst.element : null
  4396. };
  4397. }
  4398. });
  4399. })(jQuery);
  4400. (function( $, undefined ) {
  4401. var uid = 0,
  4402. hideProps = {},
  4403. showProps = {};
  4404. hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
  4405. hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
  4406. showProps.height = showProps.paddingTop = showProps.paddingBottom =
  4407. showProps.borderTopWidth = showProps.borderBottomWidth = "show";
  4408. $.widget( "ui.accordion", {
  4409. version: "1.10.4",
  4410. options: {
  4411. active: 0,
  4412. animate: {},
  4413. collapsible: false,
  4414. event: "click",
  4415. header: "> li > :first-child,> :not(li):even",
  4416. heightStyle: "auto",
  4417. icons: {
  4418. activeHeader: "ui-icon-triangle-1-s",
  4419. header: "ui-icon-triangle-1-e"
  4420. },
  4421. // callbacks
  4422. activate: null,
  4423. beforeActivate: null
  4424. },
  4425. _create: function() {
  4426. var options = this.options;
  4427. this.prevShow = this.prevHide = $();
  4428. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  4429. // ARIA
  4430. .attr( "role", "tablist" );
  4431. // don't allow collapsible: false and active: false / null
  4432. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  4433. options.active = 0;
  4434. }
  4435. this._processPanels();
  4436. // handle negative values
  4437. if ( options.active < 0 ) {
  4438. options.active += this.headers.length;
  4439. }
  4440. this._refresh();
  4441. },
  4442. _getCreateEventData: function() {
  4443. return {
  4444. header: this.active,
  4445. panel: !this.active.length ? $() : this.active.next(),
  4446. content: !this.active.length ? $() : this.active.next()
  4447. };
  4448. },
  4449. _createIcons: function() {
  4450. var icons = this.options.icons;
  4451. if ( icons ) {
  4452. $( "<span>" )
  4453. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  4454. .prependTo( this.headers );
  4455. this.active.children( ".ui-accordion-header-icon" )
  4456. .removeClass( icons.header )
  4457. .addClass( icons.activeHeader );
  4458. this.headers.addClass( "ui-accordion-icons" );
  4459. }
  4460. },
  4461. _destroyIcons: function() {
  4462. this.headers
  4463. .removeClass( "ui-accordion-icons" )
  4464. .children( ".ui-accordion-header-icon" )
  4465. .remove();
  4466. },
  4467. _destroy: function() {
  4468. var contents;
  4469. // clean up main element
  4470. this.element
  4471. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  4472. .removeAttr( "role" );
  4473. // clean up headers
  4474. this.headers
  4475. .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" )
  4476. .removeAttr( "role" )
  4477. .removeAttr( "aria-expanded" )
  4478. .removeAttr( "aria-selected" )
  4479. .removeAttr( "aria-controls" )
  4480. .removeAttr( "tabIndex" )
  4481. .each(function() {
  4482. if ( /^ui-accordion/.test( this.id ) ) {
  4483. this.removeAttribute( "id" );
  4484. }
  4485. });
  4486. this._destroyIcons();
  4487. // clean up content panels
  4488. contents = this.headers.next()
  4489. .css( "display", "" )
  4490. .removeAttr( "role" )
  4491. .removeAttr( "aria-hidden" )
  4492. .removeAttr( "aria-labelledby" )
  4493. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  4494. .each(function() {
  4495. if ( /^ui-accordion/.test( this.id ) ) {
  4496. this.removeAttribute( "id" );
  4497. }
  4498. });
  4499. if ( this.options.heightStyle !== "content" ) {
  4500. contents.css( "height", "" );
  4501. }
  4502. },
  4503. _setOption: function( key, value ) {
  4504. if ( key === "active" ) {
  4505. // _activate() will handle invalid values and update this.options
  4506. this._activate( value );
  4507. return;
  4508. }
  4509. if ( key === "event" ) {
  4510. if ( this.options.event ) {
  4511. this._off( this.headers, this.options.event );
  4512. }
  4513. this._setupEvents( value );
  4514. }
  4515. this._super( key, value );
  4516. // setting collapsible: false while collapsed; open first panel
  4517. if ( key === "collapsible" && !value && this.options.active === false ) {
  4518. this._activate( 0 );
  4519. }
  4520. if ( key === "icons" ) {
  4521. this._destroyIcons();
  4522. if ( value ) {
  4523. this._createIcons();
  4524. }
  4525. }
  4526. // #5332 - opacity doesn't cascade to positioned elements in IE
  4527. // so we need to add the disabled class to the headers and panels
  4528. if ( key === "disabled" ) {
  4529. this.headers.add( this.headers.next() )
  4530. .toggleClass( "ui-state-disabled", !!value );
  4531. }
  4532. },
  4533. _keydown: function( event ) {
  4534. if ( event.altKey || event.ctrlKey ) {
  4535. return;
  4536. }
  4537. var keyCode = $.ui.keyCode,
  4538. length = this.headers.length,
  4539. currentIndex = this.headers.index( event.target ),
  4540. toFocus = false;
  4541. switch ( event.keyCode ) {
  4542. case keyCode.RIGHT:
  4543. case keyCode.DOWN:
  4544. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  4545. break;
  4546. case keyCode.LEFT:
  4547. case keyCode.UP:
  4548. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  4549. break;
  4550. case keyCode.SPACE:
  4551. case keyCode.ENTER:
  4552. this._eventHandler( event );
  4553. break;
  4554. case keyCode.HOME:
  4555. toFocus = this.headers[ 0 ];
  4556. break;
  4557. case keyCode.END:
  4558. toFocus = this.headers[ length - 1 ];
  4559. break;
  4560. }
  4561. if ( toFocus ) {
  4562. $( event.target ).attr( "tabIndex", -1 );
  4563. $( toFocus ).attr( "tabIndex", 0 );
  4564. toFocus.focus();
  4565. event.preventDefault();
  4566. }
  4567. },
  4568. _panelKeyDown : function( event ) {
  4569. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  4570. $( event.currentTarget ).prev().focus();
  4571. }
  4572. },
  4573. refresh: function() {
  4574. var options = this.options;
  4575. this._processPanels();
  4576. // was collapsed or no panel
  4577. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  4578. options.active = false;
  4579. this.active = $();
  4580. // active false only when collapsible is true
  4581. } else if ( options.active === false ) {
  4582. this._activate( 0 );
  4583. // was active, but active panel is gone
  4584. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  4585. // all remaining panel are disabled
  4586. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  4587. options.active = false;
  4588. this.active = $();
  4589. // activate previous panel
  4590. } else {
  4591. this._activate( Math.max( 0, options.active - 1 ) );
  4592. }
  4593. // was active, active panel still exists
  4594. } else {
  4595. // make sure active index is correct
  4596. options.active = this.headers.index( this.active );
  4597. }
  4598. this._destroyIcons();
  4599. this._refresh();
  4600. },
  4601. _processPanels: function() {
  4602. this.headers = this.element.find( this.options.header )
  4603. .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
  4604. this.headers.next()
  4605. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  4606. .filter(":not(.ui-accordion-content-active)")
  4607. .hide();
  4608. },
  4609. _refresh: function() {
  4610. var maxHeight,
  4611. options = this.options,
  4612. heightStyle = options.heightStyle,
  4613. parent = this.element.parent(),
  4614. accordionId = this.accordionId = "ui-accordion-" +
  4615. (this.element.attr( "id" ) || ++uid);
  4616. this.active = this._findActive( options.active )
  4617. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  4618. .removeClass( "ui-corner-all" );
  4619. this.active.next()
  4620. .addClass( "ui-accordion-content-active" )
  4621. .show();
  4622. this.headers
  4623. .attr( "role", "tab" )
  4624. .each(function( i ) {
  4625. var header = $( this ),
  4626. headerId = header.attr( "id" ),
  4627. panel = header.next(),
  4628. panelId = panel.attr( "id" );
  4629. if ( !headerId ) {
  4630. headerId = accordionId + "-header-" + i;
  4631. header.attr( "id", headerId );
  4632. }
  4633. if ( !panelId ) {
  4634. panelId = accordionId + "-panel-" + i;
  4635. panel.attr( "id", panelId );
  4636. }
  4637. header.attr( "aria-controls", panelId );
  4638. panel.attr( "aria-labelledby", headerId );
  4639. })
  4640. .next()
  4641. .attr( "role", "tabpanel" );
  4642. this.headers
  4643. .not( this.active )
  4644. .attr({
  4645. "aria-selected": "false",
  4646. "aria-expanded": "false",
  4647. tabIndex: -1
  4648. })
  4649. .next()
  4650. .attr({
  4651. "aria-hidden": "true"
  4652. })
  4653. .hide();
  4654. // make sure at least one header is in the tab order
  4655. if ( !this.active.length ) {
  4656. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  4657. } else {
  4658. this.active.attr({
  4659. "aria-selected": "true",
  4660. "aria-expanded": "true",
  4661. tabIndex: 0
  4662. })
  4663. .next()
  4664. .attr({
  4665. "aria-hidden": "false"
  4666. });
  4667. }
  4668. this._createIcons();
  4669. this._setupEvents( options.event );
  4670. if ( heightStyle === "fill" ) {
  4671. maxHeight = parent.height();
  4672. this.element.siblings( ":visible" ).each(function() {
  4673. var elem = $( this ),
  4674. position = elem.css( "position" );
  4675. if ( position === "absolute" || position === "fixed" ) {
  4676. return;
  4677. }
  4678. maxHeight -= elem.outerHeight( true );
  4679. });
  4680. this.headers.each(function() {
  4681. maxHeight -= $( this ).outerHeight( true );
  4682. });
  4683. this.headers.next()
  4684. .each(function() {
  4685. $( this ).height( Math.max( 0, maxHeight -
  4686. $( this ).innerHeight() + $( this ).height() ) );
  4687. })
  4688. .css( "overflow", "auto" );
  4689. } else if ( heightStyle === "auto" ) {
  4690. maxHeight = 0;
  4691. this.headers.next()
  4692. .each(function() {
  4693. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  4694. })
  4695. .height( maxHeight );
  4696. }
  4697. },
  4698. _activate: function( index ) {
  4699. var active = this._findActive( index )[ 0 ];
  4700. // trying to activate the already active panel
  4701. if ( active === this.active[ 0 ] ) {
  4702. return;
  4703. }
  4704. // trying to collapse, simulate a click on the currently active header
  4705. active = active || this.active[ 0 ];
  4706. this._eventHandler({
  4707. target: active,
  4708. currentTarget: active,
  4709. preventDefault: $.noop
  4710. });
  4711. },
  4712. _findActive: function( selector ) {
  4713. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  4714. },
  4715. _setupEvents: function( event ) {
  4716. var events = {
  4717. keydown: "_keydown"
  4718. };
  4719. if ( event ) {
  4720. $.each( event.split(" "), function( index, eventName ) {
  4721. events[ eventName ] = "_eventHandler";
  4722. });
  4723. }
  4724. this._off( this.headers.add( this.headers.next() ) );
  4725. this._on( this.headers, events );
  4726. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  4727. this._hoverable( this.headers );
  4728. this._focusable( this.headers );
  4729. },
  4730. _eventHandler: function( event ) {
  4731. var options = this.options,
  4732. active = this.active,
  4733. clicked = $( event.currentTarget ),
  4734. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  4735. collapsing = clickedIsActive && options.collapsible,
  4736. toShow = collapsing ? $() : clicked.next(),
  4737. toHide = active.next(),
  4738. eventData = {
  4739. oldHeader: active,
  4740. oldPanel: toHide,
  4741. newHeader: collapsing ? $() : clicked,
  4742. newPanel: toShow
  4743. };
  4744. event.preventDefault();
  4745. if (
  4746. // click on active header, but not collapsible
  4747. ( clickedIsActive && !options.collapsible ) ||
  4748. // allow canceling activation
  4749. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  4750. return;
  4751. }
  4752. options.active = collapsing ? false : this.headers.index( clicked );
  4753. // when the call to ._toggle() comes after the class changes
  4754. // it causes a very odd bug in IE 8 (see #6720)
  4755. this.active = clickedIsActive ? $() : clicked;
  4756. this._toggle( eventData );
  4757. // switch classes
  4758. // corner classes on the previously active header stay after the animation
  4759. active.removeClass( "ui-accordion-header-active ui-state-active" );
  4760. if ( options.icons ) {
  4761. active.children( ".ui-accordion-header-icon" )
  4762. .removeClass( options.icons.activeHeader )
  4763. .addClass( options.icons.header );
  4764. }
  4765. if ( !clickedIsActive ) {
  4766. clicked
  4767. .removeClass( "ui-corner-all" )
  4768. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  4769. if ( options.icons ) {
  4770. clicked.children( ".ui-accordion-header-icon" )
  4771. .removeClass( options.icons.header )
  4772. .addClass( options.icons.activeHeader );
  4773. }
  4774. clicked
  4775. .next()
  4776. .addClass( "ui-accordion-content-active" );
  4777. }
  4778. },
  4779. _toggle: function( data ) {
  4780. var toShow = data.newPanel,
  4781. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  4782. // handle activating a panel during the animation for another activation
  4783. this.prevShow.add( this.prevHide ).stop( true, true );
  4784. this.prevShow = toShow;
  4785. this.prevHide = toHide;
  4786. if ( this.options.animate ) {
  4787. this._animate( toShow, toHide, data );
  4788. } else {
  4789. toHide.hide();
  4790. toShow.show();
  4791. this._toggleComplete( data );
  4792. }
  4793. toHide.attr({
  4794. "aria-hidden": "true"
  4795. });
  4796. toHide.prev().attr( "aria-selected", "false" );
  4797. // if we're switching panels, remove the old header from the tab order
  4798. // if we're opening from collapsed state, remove the previous header from the tab order
  4799. // if we're collapsing, then keep the collapsing header in the tab order
  4800. if ( toShow.length && toHide.length ) {
  4801. toHide.prev().attr({
  4802. "tabIndex": -1,
  4803. "aria-expanded": "false"
  4804. });
  4805. } else if ( toShow.length ) {
  4806. this.headers.filter(function() {
  4807. return $( this ).attr( "tabIndex" ) === 0;
  4808. })
  4809. .attr( "tabIndex", -1 );
  4810. }
  4811. toShow
  4812. .attr( "aria-hidden", "false" )
  4813. .prev()
  4814. .attr({
  4815. "aria-selected": "true",
  4816. tabIndex: 0,
  4817. "aria-expanded": "true"
  4818. });
  4819. },
  4820. _animate: function( toShow, toHide, data ) {
  4821. var total, easing, duration,
  4822. that = this,
  4823. adjust = 0,
  4824. down = toShow.length &&
  4825. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  4826. animate = this.options.animate || {},
  4827. options = down && animate.down || animate,
  4828. complete = function() {
  4829. that._toggleComplete( data );
  4830. };
  4831. if ( typeof options === "number" ) {
  4832. duration = options;
  4833. }
  4834. if ( typeof options === "string" ) {
  4835. easing = options;
  4836. }
  4837. // fall back from options to animation in case of partial down settings
  4838. easing = easing || options.easing || animate.easing;
  4839. duration = duration || options.duration || animate.duration;
  4840. if ( !toHide.length ) {
  4841. return toShow.animate( showProps, duration, easing, complete );
  4842. }
  4843. if ( !toShow.length ) {
  4844. return toHide.animate( hideProps, duration, easing, complete );
  4845. }
  4846. total = toShow.show().outerHeight();
  4847. toHide.animate( hideProps, {
  4848. duration: duration,
  4849. easing: easing,
  4850. step: function( now, fx ) {
  4851. fx.now = Math.round( now );
  4852. }
  4853. });
  4854. toShow
  4855. .hide()
  4856. .animate( showProps, {
  4857. duration: duration,
  4858. easing: easing,
  4859. complete: complete,
  4860. step: function( now, fx ) {
  4861. fx.now = Math.round( now );
  4862. if ( fx.prop !== "height" ) {
  4863. adjust += fx.now;
  4864. } else if ( that.options.heightStyle !== "content" ) {
  4865. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  4866. adjust = 0;
  4867. }
  4868. }
  4869. });
  4870. },
  4871. _toggleComplete: function( data ) {
  4872. var toHide = data.oldPanel;
  4873. toHide
  4874. .removeClass( "ui-accordion-content-active" )
  4875. .prev()
  4876. .removeClass( "ui-corner-top" )
  4877. .addClass( "ui-corner-all" );
  4878. // Work around for rendering bug in IE (#5421)
  4879. if ( toHide.length ) {
  4880. toHide.parent()[0].className = toHide.parent()[0].className;
  4881. }
  4882. this._trigger( "activate", null, data );
  4883. }
  4884. });
  4885. })( jQuery );
  4886. (function( $, undefined ) {
  4887. $.widget( "ui.autocomplete", {
  4888. version: "1.10.4",
  4889. defaultElement: "<input>",
  4890. options: {
  4891. appendTo: null,
  4892. autoFocus: false,
  4893. delay: 300,
  4894. minLength: 1,
  4895. position: {
  4896. my: "left top",
  4897. at: "left bottom",
  4898. collision: "none"
  4899. },
  4900. source: null,
  4901. // callbacks
  4902. change: null,
  4903. close: null,
  4904. focus: null,
  4905. open: null,
  4906. response: null,
  4907. search: null,
  4908. select: null
  4909. },
  4910. requestIndex: 0,
  4911. pending: 0,
  4912. _create: function() {
  4913. // Some browsers only repeat keydown events, not keypress events,
  4914. // so we use the suppressKeyPress flag to determine if we've already
  4915. // handled the keydown event. #7269
  4916. // Unfortunately the code for & in keypress is the same as the up arrow,
  4917. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  4918. // events when we know the keydown event was used to modify the
  4919. // search term. #7799
  4920. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  4921. nodeName = this.element[0].nodeName.toLowerCase(),
  4922. isTextarea = nodeName === "textarea",
  4923. isInput = nodeName === "input";
  4924. this.isMultiLine =
  4925. // Textareas are always multi-line
  4926. isTextarea ? true :
  4927. // Inputs are always single-line, even if inside a contentEditable element
  4928. // IE also treats inputs as contentEditable
  4929. isInput ? false :
  4930. // All other element types are determined by whether or not they're contentEditable
  4931. this.element.prop( "isContentEditable" );
  4932. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  4933. this.isNewMenu = true;
  4934. this.element
  4935. .addClass( "ui-autocomplete-input" )
  4936. .attr( "autocomplete", "off" );
  4937. this._on( this.element, {
  4938. keydown: function( event ) {
  4939. if ( this.element.prop( "readOnly" ) ) {
  4940. suppressKeyPress = true;
  4941. suppressInput = true;
  4942. suppressKeyPressRepeat = true;
  4943. return;
  4944. }
  4945. suppressKeyPress = false;
  4946. suppressInput = false;
  4947. suppressKeyPressRepeat = false;
  4948. var keyCode = $.ui.keyCode;
  4949. switch( event.keyCode ) {
  4950. case keyCode.PAGE_UP:
  4951. suppressKeyPress = true;
  4952. this._move( "previousPage", event );
  4953. break;
  4954. case keyCode.PAGE_DOWN:
  4955. suppressKeyPress = true;
  4956. this._move( "nextPage", event );
  4957. break;
  4958. case keyCode.UP:
  4959. suppressKeyPress = true;
  4960. this._keyEvent( "previous", event );
  4961. break;
  4962. case keyCode.DOWN:
  4963. suppressKeyPress = true;
  4964. this._keyEvent( "next", event );
  4965. break;
  4966. case keyCode.ENTER:
  4967. case keyCode.NUMPAD_ENTER:
  4968. // when menu is open and has focus
  4969. if ( this.menu.active ) {
  4970. // #6055 - Opera still allows the keypress to occur
  4971. // which causes forms to submit
  4972. suppressKeyPress = true;
  4973. event.preventDefault();
  4974. this.menu.select( event );
  4975. }
  4976. break;
  4977. case keyCode.TAB:
  4978. if ( this.menu.active ) {
  4979. this.menu.select( event );
  4980. }
  4981. break;
  4982. case keyCode.ESCAPE:
  4983. if ( this.menu.element.is( ":visible" ) ) {
  4984. this._value( this.term );
  4985. this.close( event );
  4986. // Different browsers have different default behavior for escape
  4987. // Single press can mean undo or clear
  4988. // Double press in IE means clear the whole form
  4989. event.preventDefault();
  4990. }
  4991. break;
  4992. default:
  4993. suppressKeyPressRepeat = true;
  4994. // search timeout should be triggered before the input value is changed
  4995. this._searchTimeout( event );
  4996. break;
  4997. }
  4998. },
  4999. keypress: function( event ) {
  5000. if ( suppressKeyPress ) {
  5001. suppressKeyPress = false;
  5002. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5003. event.preventDefault();
  5004. }
  5005. return;
  5006. }
  5007. if ( suppressKeyPressRepeat ) {
  5008. return;
  5009. }
  5010. // replicate some key handlers to allow them to repeat in Firefox and Opera
  5011. var keyCode = $.ui.keyCode;
  5012. switch( event.keyCode ) {
  5013. case keyCode.PAGE_UP:
  5014. this._move( "previousPage", event );
  5015. break;
  5016. case keyCode.PAGE_DOWN:
  5017. this._move( "nextPage", event );
  5018. break;
  5019. case keyCode.UP:
  5020. this._keyEvent( "previous", event );
  5021. break;
  5022. case keyCode.DOWN:
  5023. this._keyEvent( "next", event );
  5024. break;
  5025. }
  5026. },
  5027. input: function( event ) {
  5028. if ( suppressInput ) {
  5029. suppressInput = false;
  5030. event.preventDefault();
  5031. return;
  5032. }
  5033. this._searchTimeout( event );
  5034. },
  5035. focus: function() {
  5036. this.selectedItem = null;
  5037. this.previous = this._value();
  5038. },
  5039. blur: function( event ) {
  5040. if ( this.cancelBlur ) {
  5041. delete this.cancelBlur;
  5042. return;
  5043. }
  5044. clearTimeout( this.searching );
  5045. this.close( event );
  5046. this._change( event );
  5047. }
  5048. });
  5049. this._initSource();
  5050. this.menu = $( "<ul>" )
  5051. .addClass( "ui-autocomplete ui-front" )
  5052. .appendTo( this._appendTo() )
  5053. .menu({
  5054. // disable ARIA support, the live region takes care of that
  5055. role: null
  5056. })
  5057. .hide()
  5058. .data( "ui-menu" );
  5059. this._on( this.menu.element, {
  5060. mousedown: function( event ) {
  5061. // prevent moving focus out of the text field
  5062. event.preventDefault();
  5063. // IE doesn't prevent moving focus even with event.preventDefault()
  5064. // so we set a flag to know when we should ignore the blur event
  5065. this.cancelBlur = true;
  5066. this._delay(function() {
  5067. delete this.cancelBlur;
  5068. });
  5069. // clicking on the scrollbar causes focus to shift to the body
  5070. // but we can't detect a mouseup or a click immediately afterward
  5071. // so we have to track the next mousedown and close the menu if
  5072. // the user clicks somewhere outside of the autocomplete
  5073. var menuElement = this.menu.element[ 0 ];
  5074. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  5075. this._delay(function() {
  5076. var that = this;
  5077. this.document.one( "mousedown", function( event ) {
  5078. if ( event.target !== that.element[ 0 ] &&
  5079. event.target !== menuElement &&
  5080. !$.contains( menuElement, event.target ) ) {
  5081. that.close();
  5082. }
  5083. });
  5084. });
  5085. }
  5086. },
  5087. menufocus: function( event, ui ) {
  5088. // support: Firefox
  5089. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  5090. if ( this.isNewMenu ) {
  5091. this.isNewMenu = false;
  5092. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  5093. this.menu.blur();
  5094. this.document.one( "mousemove", function() {
  5095. $( event.target ).trigger( event.originalEvent );
  5096. });
  5097. return;
  5098. }
  5099. }
  5100. var item = ui.item.data( "ui-autocomplete-item" );
  5101. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  5102. // use value to match what will end up in the input, if it was a key event
  5103. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  5104. this._value( item.value );
  5105. }
  5106. } else {
  5107. // Normally the input is populated with the item's value as the
  5108. // menu is navigated, causing screen readers to notice a change and
  5109. // announce the item. Since the focus event was canceled, this doesn't
  5110. // happen, so we update the live region so that screen readers can
  5111. // still notice the change and announce it.
  5112. this.liveRegion.text( item.value );
  5113. }
  5114. },
  5115. menuselect: function( event, ui ) {
  5116. var item = ui.item.data( "ui-autocomplete-item" ),
  5117. previous = this.previous;
  5118. // only trigger when focus was lost (click on menu)
  5119. if ( this.element[0] !== this.document[0].activeElement ) {
  5120. this.element.focus();
  5121. this.previous = previous;
  5122. // #6109 - IE triggers two focus events and the second
  5123. // is asynchronous, so we need to reset the previous
  5124. // term synchronously and asynchronously :-(
  5125. this._delay(function() {
  5126. this.previous = previous;
  5127. this.selectedItem = item;
  5128. });
  5129. }
  5130. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  5131. this._value( item.value );
  5132. }
  5133. // reset the term after the select event
  5134. // this allows custom select handling to work properly
  5135. this.term = this._value();
  5136. this.close( event );
  5137. this.selectedItem = item;
  5138. }
  5139. });
  5140. this.liveRegion = $( "<span>", {
  5141. role: "status",
  5142. "aria-live": "polite"
  5143. })
  5144. .addClass( "ui-helper-hidden-accessible" )
  5145. .insertBefore( this.element );
  5146. // turning off autocomplete prevents the browser from remembering the
  5147. // value when navigating through history, so we re-enable autocomplete
  5148. // if the page is unloaded before the widget is destroyed. #7790
  5149. this._on( this.window, {
  5150. beforeunload: function() {
  5151. this.element.removeAttr( "autocomplete" );
  5152. }
  5153. });
  5154. },
  5155. _destroy: function() {
  5156. clearTimeout( this.searching );
  5157. this.element
  5158. .removeClass( "ui-autocomplete-input" )
  5159. .removeAttr( "autocomplete" );
  5160. this.menu.element.remove();
  5161. this.liveRegion.remove();
  5162. },
  5163. _setOption: function( key, value ) {
  5164. this._super( key, value );
  5165. if ( key === "source" ) {
  5166. this._initSource();
  5167. }
  5168. if ( key === "appendTo" ) {
  5169. this.menu.element.appendTo( this._appendTo() );
  5170. }
  5171. if ( key === "disabled" && value && this.xhr ) {
  5172. this.xhr.abort();
  5173. }
  5174. },
  5175. _appendTo: function() {
  5176. var element = this.options.appendTo;
  5177. if ( element ) {
  5178. element = element.jquery || element.nodeType ?
  5179. $( element ) :
  5180. this.document.find( element ).eq( 0 );
  5181. }
  5182. if ( !element ) {
  5183. element = this.element.closest( ".ui-front" );
  5184. }
  5185. if ( !element.length ) {
  5186. element = this.document[0].body;
  5187. }
  5188. return element;
  5189. },
  5190. _initSource: function() {
  5191. var array, url,
  5192. that = this;
  5193. if ( $.isArray(this.options.source) ) {
  5194. array = this.options.source;
  5195. this.source = function( request, response ) {
  5196. response( $.ui.autocomplete.filter( array, request.term ) );
  5197. };
  5198. } else if ( typeof this.options.source === "string" ) {
  5199. url = this.options.source;
  5200. this.source = function( request, response ) {
  5201. if ( that.xhr ) {
  5202. that.xhr.abort();
  5203. }
  5204. that.xhr = $.ajax({
  5205. url: url,
  5206. data: request,
  5207. dataType: "json",
  5208. success: function( data ) {
  5209. response( data );
  5210. },
  5211. error: function() {
  5212. response( [] );
  5213. }
  5214. });
  5215. };
  5216. } else {
  5217. this.source = this.options.source;
  5218. }
  5219. },
  5220. _searchTimeout: function( event ) {
  5221. clearTimeout( this.searching );
  5222. this.searching = this._delay(function() {
  5223. // only search if the value has changed
  5224. if ( this.term !== this._value() ) {
  5225. this.selectedItem = null;
  5226. this.search( null, event );
  5227. }
  5228. }, this.options.delay );
  5229. },
  5230. search: function( value, event ) {
  5231. value = value != null ? value : this._value();
  5232. // always save the actual value, not the one passed as an argument
  5233. this.term = this._value();
  5234. if ( value.length < this.options.minLength ) {
  5235. return this.close( event );
  5236. }
  5237. if ( this._trigger( "search", event ) === false ) {
  5238. return;
  5239. }
  5240. return this._search( value );
  5241. },
  5242. _search: function( value ) {
  5243. this.pending++;
  5244. this.element.addClass( "ui-autocomplete-loading" );
  5245. this.cancelSearch = false;
  5246. this.source( { term: value }, this._response() );
  5247. },
  5248. _response: function() {
  5249. var index = ++this.requestIndex;
  5250. return $.proxy(function( content ) {
  5251. if ( index === this.requestIndex ) {
  5252. this.__response( content );
  5253. }
  5254. this.pending--;
  5255. if ( !this.pending ) {
  5256. this.element.removeClass( "ui-autocomplete-loading" );
  5257. }
  5258. }, this );
  5259. },
  5260. __response: function( content ) {
  5261. if ( content ) {
  5262. content = this._normalize( content );
  5263. }
  5264. this._trigger( "response", null, { content: content } );
  5265. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  5266. this._suggest( content );
  5267. this._trigger( "open" );
  5268. } else {
  5269. // use ._close() instead of .close() so we don't cancel future searches
  5270. this._close();
  5271. }
  5272. },
  5273. close: function( event ) {
  5274. this.cancelSearch = true;
  5275. this._close( event );
  5276. },
  5277. _close: function( event ) {
  5278. if ( this.menu.element.is( ":visible" ) ) {
  5279. this.menu.element.hide();
  5280. this.menu.blur();
  5281. this.isNewMenu = true;
  5282. this._trigger( "close", event );
  5283. }
  5284. },
  5285. _change: function( event ) {
  5286. if ( this.previous !== this._value() ) {
  5287. this._trigger( "change", event, { item: this.selectedItem } );
  5288. }
  5289. },
  5290. _normalize: function( items ) {
  5291. // assume all items have the right format when the first item is complete
  5292. if ( items.length && items[0].label && items[0].value ) {
  5293. return items;
  5294. }
  5295. return $.map( items, function( item ) {
  5296. if ( typeof item === "string" ) {
  5297. return {
  5298. label: item,
  5299. value: item
  5300. };
  5301. }
  5302. return $.extend({
  5303. label: item.label || item.value,
  5304. value: item.value || item.label
  5305. }, item );
  5306. });
  5307. },
  5308. _suggest: function( items ) {
  5309. var ul = this.menu.element.empty();
  5310. this._renderMenu( ul, items );
  5311. this.isNewMenu = true;
  5312. this.menu.refresh();
  5313. // size and position menu
  5314. ul.show();
  5315. this._resizeMenu();
  5316. ul.position( $.extend({
  5317. of: this.element
  5318. }, this.options.position ));
  5319. if ( this.options.autoFocus ) {
  5320. this.menu.next();
  5321. }
  5322. },
  5323. _resizeMenu: function() {
  5324. var ul = this.menu.element;
  5325. ul.outerWidth( Math.max(
  5326. // Firefox wraps long text (possibly a rounding bug)
  5327. // so we add 1px to avoid the wrapping (#7513)
  5328. ul.width( "" ).outerWidth() + 1,
  5329. this.element.outerWidth()
  5330. ) );
  5331. },
  5332. _renderMenu: function( ul, items ) {
  5333. var that = this;
  5334. $.each( items, function( index, item ) {
  5335. that._renderItemData( ul, item );
  5336. });
  5337. },
  5338. _renderItemData: function( ul, item ) {
  5339. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  5340. },
  5341. _renderItem: function( ul, item ) {
  5342. return $( "<li>" )
  5343. .append( $( "<a>" ).text( item.label ) )
  5344. .appendTo( ul );
  5345. },
  5346. _move: function( direction, event ) {
  5347. if ( !this.menu.element.is( ":visible" ) ) {
  5348. this.search( null, event );
  5349. return;
  5350. }
  5351. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  5352. this.menu.isLastItem() && /^next/.test( direction ) ) {
  5353. this._value( this.term );
  5354. this.menu.blur();
  5355. return;
  5356. }
  5357. this.menu[ direction ]( event );
  5358. },
  5359. widget: function() {
  5360. return this.menu.element;
  5361. },
  5362. _value: function() {
  5363. return this.valueMethod.apply( this.element, arguments );
  5364. },
  5365. _keyEvent: function( keyEvent, event ) {
  5366. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5367. this._move( keyEvent, event );
  5368. // prevents moving cursor to beginning/end of the text field in some browsers
  5369. event.preventDefault();
  5370. }
  5371. }
  5372. });
  5373. $.extend( $.ui.autocomplete, {
  5374. escapeRegex: function( value ) {
  5375. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  5376. },
  5377. filter: function(array, term) {
  5378. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  5379. return $.grep( array, function(value) {
  5380. return matcher.test( value.label || value.value || value );
  5381. });
  5382. }
  5383. });
  5384. // live region extension, adding a `messages` option
  5385. // NOTE: This is an experimental API. We are still investigating
  5386. // a full solution for string manipulation and internationalization.
  5387. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  5388. options: {
  5389. messages: {
  5390. noResults: "No search results.",
  5391. results: function( amount ) {
  5392. return amount + ( amount > 1 ? " results are" : " result is" ) +
  5393. " available, use up and down arrow keys to navigate.";
  5394. }
  5395. }
  5396. },
  5397. __response: function( content ) {
  5398. var message;
  5399. this._superApply( arguments );
  5400. if ( this.options.disabled || this.cancelSearch ) {
  5401. return;
  5402. }
  5403. if ( content && content.length ) {
  5404. message = this.options.messages.results( content.length );
  5405. } else {
  5406. message = this.options.messages.noResults;
  5407. }
  5408. this.liveRegion.text( message );
  5409. }
  5410. });
  5411. }( jQuery ));
  5412. (function( $, undefined ) {
  5413. var lastActive,
  5414. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  5415. 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",
  5416. formResetHandler = function() {
  5417. var form = $( this );
  5418. setTimeout(function() {
  5419. form.find( ":ui-button" ).button( "refresh" );
  5420. }, 1 );
  5421. },
  5422. radioGroup = function( radio ) {
  5423. var name = radio.name,
  5424. form = radio.form,
  5425. radios = $( [] );
  5426. if ( name ) {
  5427. name = name.replace( /'/g, "\\'" );
  5428. if ( form ) {
  5429. radios = $( form ).find( "[name='" + name + "']" );
  5430. } else {
  5431. radios = $( "[name='" + name + "']", radio.ownerDocument )
  5432. .filter(function() {
  5433. return !this.form;
  5434. });
  5435. }
  5436. }
  5437. return radios;
  5438. };
  5439. $.widget( "ui.button", {
  5440. version: "1.10.4",
  5441. defaultElement: "<button>",
  5442. options: {
  5443. disabled: null,
  5444. text: true,
  5445. label: null,
  5446. icons: {
  5447. primary: null,
  5448. secondary: null
  5449. }
  5450. },
  5451. _create: function() {
  5452. this.element.closest( "form" )
  5453. .unbind( "reset" + this.eventNamespace )
  5454. .bind( "reset" + this.eventNamespace, formResetHandler );
  5455. if ( typeof this.options.disabled !== "boolean" ) {
  5456. this.options.disabled = !!this.element.prop( "disabled" );
  5457. } else {
  5458. this.element.prop( "disabled", this.options.disabled );
  5459. }
  5460. this._determineButtonType();
  5461. this.hasTitle = !!this.buttonElement.attr( "title" );
  5462. var that = this,
  5463. options = this.options,
  5464. toggleButton = this.type === "checkbox" || this.type === "radio",
  5465. activeClass = !toggleButton ? "ui-state-active" : "";
  5466. if ( options.label === null ) {
  5467. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  5468. }
  5469. this._hoverable( this.buttonElement );
  5470. this.buttonElement
  5471. .addClass( baseClasses )
  5472. .attr( "role", "button" )
  5473. .bind( "mouseenter" + this.eventNamespace, function() {
  5474. if ( options.disabled ) {
  5475. return;
  5476. }
  5477. if ( this === lastActive ) {
  5478. $( this ).addClass( "ui-state-active" );
  5479. }
  5480. })
  5481. .bind( "mouseleave" + this.eventNamespace, function() {
  5482. if ( options.disabled ) {
  5483. return;
  5484. }
  5485. $( this ).removeClass( activeClass );
  5486. })
  5487. .bind( "click" + this.eventNamespace, function( event ) {
  5488. if ( options.disabled ) {
  5489. event.preventDefault();
  5490. event.stopImmediatePropagation();
  5491. }
  5492. });
  5493. // Can't use _focusable() because the element that receives focus
  5494. // and the element that gets the ui-state-focus class are different
  5495. this._on({
  5496. focus: function() {
  5497. this.buttonElement.addClass( "ui-state-focus" );
  5498. },
  5499. blur: function() {
  5500. this.buttonElement.removeClass( "ui-state-focus" );
  5501. }
  5502. });
  5503. if ( toggleButton ) {
  5504. this.element.bind( "change" + this.eventNamespace, function() {
  5505. that.refresh();
  5506. });
  5507. }
  5508. if ( this.type === "checkbox" ) {
  5509. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  5510. if ( options.disabled ) {
  5511. return false;
  5512. }
  5513. });
  5514. } else if ( this.type === "radio" ) {
  5515. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  5516. if ( options.disabled ) {
  5517. return false;
  5518. }
  5519. $( this ).addClass( "ui-state-active" );
  5520. that.buttonElement.attr( "aria-pressed", "true" );
  5521. var radio = that.element[ 0 ];
  5522. radioGroup( radio )
  5523. .not( radio )
  5524. .map(function() {
  5525. return $( this ).button( "widget" )[ 0 ];
  5526. })
  5527. .removeClass( "ui-state-active" )
  5528. .attr( "aria-pressed", "false" );
  5529. });
  5530. } else {
  5531. this.buttonElement
  5532. .bind( "mousedown" + this.eventNamespace, function() {
  5533. if ( options.disabled ) {
  5534. return false;
  5535. }
  5536. $( this ).addClass( "ui-state-active" );
  5537. lastActive = this;
  5538. that.document.one( "mouseup", function() {
  5539. lastActive = null;
  5540. });
  5541. })
  5542. .bind( "mouseup" + this.eventNamespace, function() {
  5543. if ( options.disabled ) {
  5544. return false;
  5545. }
  5546. $( this ).removeClass( "ui-state-active" );
  5547. })
  5548. .bind( "keydown" + this.eventNamespace, function(event) {
  5549. if ( options.disabled ) {
  5550. return false;
  5551. }
  5552. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  5553. $( this ).addClass( "ui-state-active" );
  5554. }
  5555. })
  5556. // see #8559, we bind to blur here in case the button element loses
  5557. // focus between keydown and keyup, it would be left in an "active" state
  5558. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  5559. $( this ).removeClass( "ui-state-active" );
  5560. });
  5561. if ( this.buttonElement.is("a") ) {
  5562. this.buttonElement.keyup(function(event) {
  5563. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  5564. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  5565. $( this ).click();
  5566. }
  5567. });
  5568. }
  5569. }
  5570. // TODO: pull out $.Widget's handling for the disabled option into
  5571. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  5572. // be overridden by individual plugins
  5573. this._setOption( "disabled", options.disabled );
  5574. this._resetButton();
  5575. },
  5576. _determineButtonType: function() {
  5577. var ancestor, labelSelector, checked;
  5578. if ( this.element.is("[type=checkbox]") ) {
  5579. this.type = "checkbox";
  5580. } else if ( this.element.is("[type=radio]") ) {
  5581. this.type = "radio";
  5582. } else if ( this.element.is("input") ) {
  5583. this.type = "input";
  5584. } else {
  5585. this.type = "button";
  5586. }
  5587. if ( this.type === "checkbox" || this.type === "radio" ) {
  5588. // we don't search against the document in case the element
  5589. // is disconnected from the DOM
  5590. ancestor = this.element.parents().last();
  5591. labelSelector = "label[for='" + this.element.attr("id") + "']";
  5592. this.buttonElement = ancestor.find( labelSelector );
  5593. if ( !this.buttonElement.length ) {
  5594. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  5595. this.buttonElement = ancestor.filter( labelSelector );
  5596. if ( !this.buttonElement.length ) {
  5597. this.buttonElement = ancestor.find( labelSelector );
  5598. }
  5599. }
  5600. this.element.addClass( "ui-helper-hidden-accessible" );
  5601. checked = this.element.is( ":checked" );
  5602. if ( checked ) {
  5603. this.buttonElement.addClass( "ui-state-active" );
  5604. }
  5605. this.buttonElement.prop( "aria-pressed", checked );
  5606. } else {
  5607. this.buttonElement = this.element;
  5608. }
  5609. },
  5610. widget: function() {
  5611. return this.buttonElement;
  5612. },
  5613. _destroy: function() {
  5614. this.element
  5615. .removeClass( "ui-helper-hidden-accessible" );
  5616. this.buttonElement
  5617. .removeClass( baseClasses + " ui-state-active " + typeClasses )
  5618. .removeAttr( "role" )
  5619. .removeAttr( "aria-pressed" )
  5620. .html( this.buttonElement.find(".ui-button-text").html() );
  5621. if ( !this.hasTitle ) {
  5622. this.buttonElement.removeAttr( "title" );
  5623. }
  5624. },
  5625. _setOption: function( key, value ) {
  5626. this._super( key, value );
  5627. if ( key === "disabled" ) {
  5628. this.element.prop( "disabled", !!value );
  5629. if ( value ) {
  5630. this.buttonElement.removeClass( "ui-state-focus" );
  5631. }
  5632. return;
  5633. }
  5634. this._resetButton();
  5635. },
  5636. refresh: function() {
  5637. //See #8237 & #8828
  5638. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  5639. if ( isDisabled !== this.options.disabled ) {
  5640. this._setOption( "disabled", isDisabled );
  5641. }
  5642. if ( this.type === "radio" ) {
  5643. radioGroup( this.element[0] ).each(function() {
  5644. if ( $( this ).is( ":checked" ) ) {
  5645. $( this ).button( "widget" )
  5646. .addClass( "ui-state-active" )
  5647. .attr( "aria-pressed", "true" );
  5648. } else {
  5649. $( this ).button( "widget" )
  5650. .removeClass( "ui-state-active" )
  5651. .attr( "aria-pressed", "false" );
  5652. }
  5653. });
  5654. } else if ( this.type === "checkbox" ) {
  5655. if ( this.element.is( ":checked" ) ) {
  5656. this.buttonElement
  5657. .addClass( "ui-state-active" )
  5658. .attr( "aria-pressed", "true" );
  5659. } else {
  5660. this.buttonElement
  5661. .removeClass( "ui-state-active" )
  5662. .attr( "aria-pressed", "false" );
  5663. }
  5664. }
  5665. },
  5666. _resetButton: function() {
  5667. if ( this.type === "input" ) {
  5668. if ( this.options.label ) {
  5669. this.element.val( this.options.label );
  5670. }
  5671. return;
  5672. }
  5673. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  5674. buttonText = $( "<span></span>", this.document[0] )
  5675. .addClass( "ui-button-text" )
  5676. .html( this.options.label )
  5677. .appendTo( buttonElement.empty() )
  5678. .text(),
  5679. icons = this.options.icons,
  5680. multipleIcons = icons.primary && icons.secondary,
  5681. buttonClasses = [];
  5682. if ( icons.primary || icons.secondary ) {
  5683. if ( this.options.text ) {
  5684. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  5685. }
  5686. if ( icons.primary ) {
  5687. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  5688. }
  5689. if ( icons.secondary ) {
  5690. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  5691. }
  5692. if ( !this.options.text ) {
  5693. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  5694. if ( !this.hasTitle ) {
  5695. buttonElement.attr( "title", $.trim( buttonText ) );
  5696. }
  5697. }
  5698. } else {
  5699. buttonClasses.push( "ui-button-text-only" );
  5700. }
  5701. buttonElement.addClass( buttonClasses.join( " " ) );
  5702. }
  5703. });
  5704. $.widget( "ui.buttonset", {
  5705. version: "1.10.4",
  5706. options: {
  5707. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  5708. },
  5709. _create: function() {
  5710. this.element.addClass( "ui-buttonset" );
  5711. },
  5712. _init: function() {
  5713. this.refresh();
  5714. },
  5715. _setOption: function( key, value ) {
  5716. if ( key === "disabled" ) {
  5717. this.buttons.button( "option", key, value );
  5718. }
  5719. this._super( key, value );
  5720. },
  5721. refresh: function() {
  5722. var rtl = this.element.css( "direction" ) === "rtl";
  5723. this.buttons = this.element.find( this.options.items )
  5724. .filter( ":ui-button" )
  5725. .button( "refresh" )
  5726. .end()
  5727. .not( ":ui-button" )
  5728. .button()
  5729. .end()
  5730. .map(function() {
  5731. return $( this ).button( "widget" )[ 0 ];
  5732. })
  5733. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  5734. .filter( ":first" )
  5735. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  5736. .end()
  5737. .filter( ":last" )
  5738. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  5739. .end()
  5740. .end();
  5741. },
  5742. _destroy: function() {
  5743. this.element.removeClass( "ui-buttonset" );
  5744. this.buttons
  5745. .map(function() {
  5746. return $( this ).button( "widget" )[ 0 ];
  5747. })
  5748. .removeClass( "ui-corner-left ui-corner-right" )
  5749. .end()
  5750. .button( "destroy" );
  5751. }
  5752. });
  5753. }( jQuery ) );
  5754. (function( $, undefined ) {
  5755. $.extend($.ui, { datepicker: { version: "1.10.4" } });
  5756. var PROP_NAME = "datepicker",
  5757. instActive;
  5758. /* Date picker manager.
  5759. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  5760. Settings for (groups of) date pickers are maintained in an instance object,
  5761. allowing multiple different settings on the same page. */
  5762. function Datepicker() {
  5763. this._curInst = null; // The current instance in use
  5764. this._keyEvent = false; // If the last event was a key event
  5765. this._disabledInputs = []; // List of date picker inputs that have been disabled
  5766. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  5767. this._inDialog = false; // True if showing within a "dialog", false if not
  5768. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  5769. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  5770. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  5771. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  5772. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  5773. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  5774. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  5775. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  5776. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  5777. this.regional = []; // Available regional settings, indexed by language code
  5778. this.regional[""] = { // Default regional settings
  5779. closeText: "Done", // Display text for close link
  5780. prevText: "Prev", // Display text for previous month link
  5781. nextText: "Next", // Display text for next month link
  5782. currentText: "Today", // Display text for current month link
  5783. monthNames: ["January","February","March","April","May","June",
  5784. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  5785. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  5786. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  5787. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  5788. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  5789. weekHeader: "Wk", // Column header for week of the year
  5790. dateFormat: "mm/dd/yy", // See format options on parseDate
  5791. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  5792. isRTL: false, // True if right-to-left language, false if left-to-right
  5793. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  5794. yearSuffix: "" // Additional text to append to the year in the month headers
  5795. };
  5796. this._defaults = { // Global defaults for all the date picker instances
  5797. showOn: "focus", // "focus" for popup on focus,
  5798. // "button" for trigger button, or "both" for either
  5799. showAnim: "fadeIn", // Name of jQuery animation for popup
  5800. showOptions: {}, // Options for enhanced animations
  5801. defaultDate: null, // Used when field is blank: actual date,
  5802. // +/-number for offset from today, null for today
  5803. appendText: "", // Display text following the input box, e.g. showing the format
  5804. buttonText: "...", // Text for trigger button
  5805. buttonImage: "", // URL for trigger button image
  5806. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  5807. hideIfNoPrevNext: false, // True to hide next/previous month links
  5808. // if not applicable, false to just disable them
  5809. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  5810. gotoCurrent: false, // True if today link goes back to current selection instead
  5811. changeMonth: false, // True if month can be selected directly, false if only prev/next
  5812. changeYear: false, // True if year can be selected directly, false if only prev/next
  5813. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  5814. // either relative to today's year (-nn:+nn), relative to currently displayed year
  5815. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  5816. showOtherMonths: false, // True to show dates in other months, false to leave blank
  5817. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  5818. showWeek: false, // True to show week of the year, false to not show it
  5819. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  5820. // takes a Date and returns the number of the week for it
  5821. shortYearCutoff: "+10", // Short year values < this are in the current century,
  5822. // > this are in the previous century,
  5823. // string value starting with "+" for current year + value
  5824. minDate: null, // The earliest selectable date, or null for no limit
  5825. maxDate: null, // The latest selectable date, or null for no limit
  5826. duration: "fast", // Duration of display/closure
  5827. beforeShowDay: null, // Function that takes a date and returns an array with
  5828. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  5829. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  5830. beforeShow: null, // Function that takes an input field and
  5831. // returns a set of custom settings for the date picker
  5832. onSelect: null, // Define a callback function when a date is selected
  5833. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  5834. onClose: null, // Define a callback function when the datepicker is closed
  5835. numberOfMonths: 1, // Number of months to show at a time
  5836. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  5837. stepMonths: 1, // Number of months to step back/forward
  5838. stepBigMonths: 12, // Number of months to step back/forward for the big links
  5839. altField: "", // Selector for an alternate field to store selected dates into
  5840. altFormat: "", // The date format to use for the alternate field
  5841. constrainInput: true, // The input is constrained by the current date format
  5842. showButtonPanel: false, // True to show button panel, false to not show it
  5843. autoSize: false, // True to size the input for the date format, false to leave as is
  5844. disabled: false // The initial disabled state
  5845. };
  5846. $.extend(this._defaults, this.regional[""]);
  5847. this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  5848. }
  5849. $.extend(Datepicker.prototype, {
  5850. /* Class name added to elements to indicate already configured with a date picker. */
  5851. markerClassName: "hasDatepicker",
  5852. //Keep track of the maximum number of rows displayed (see #7043)
  5853. maxRows: 4,
  5854. // TODO rename to "widget" when switching to widget factory
  5855. _widgetDatepicker: function() {
  5856. return this.dpDiv;
  5857. },
  5858. /* Override the default settings for all instances of the date picker.
  5859. * @param settings object - the new settings to use as defaults (anonymous object)
  5860. * @return the manager object
  5861. */
  5862. setDefaults: function(settings) {
  5863. extendRemove(this._defaults, settings || {});
  5864. return this;
  5865. },
  5866. /* Attach the date picker to a jQuery selection.
  5867. * @param target element - the target input field or division or span
  5868. * @param settings object - the new settings to use for this date picker instance (anonymous)
  5869. */
  5870. _attachDatepicker: function(target, settings) {
  5871. var nodeName, inline, inst;
  5872. nodeName = target.nodeName.toLowerCase();
  5873. inline = (nodeName === "div" || nodeName === "span");
  5874. if (!target.id) {
  5875. this.uuid += 1;
  5876. target.id = "dp" + this.uuid;
  5877. }
  5878. inst = this._newInst($(target), inline);
  5879. inst.settings = $.extend({}, settings || {});
  5880. if (nodeName === "input") {
  5881. this._connectDatepicker(target, inst);
  5882. } else if (inline) {
  5883. this._inlineDatepicker(target, inst);
  5884. }
  5885. },
  5886. /* Create a new instance object. */
  5887. _newInst: function(target, inline) {
  5888. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  5889. return {id: id, input: target, // associated target
  5890. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  5891. drawMonth: 0, drawYear: 0, // month being drawn
  5892. inline: inline, // is datepicker inline or not
  5893. dpDiv: (!inline ? this.dpDiv : // presentation div
  5894. bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  5895. },
  5896. /* Attach the date picker to an input field. */
  5897. _connectDatepicker: function(target, inst) {
  5898. var input = $(target);
  5899. inst.append = $([]);
  5900. inst.trigger = $([]);
  5901. if (input.hasClass(this.markerClassName)) {
  5902. return;
  5903. }
  5904. this._attachments(input, inst);
  5905. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  5906. keypress(this._doKeyPress).keyup(this._doKeyUp);
  5907. this._autoSize(inst);
  5908. $.data(target, PROP_NAME, inst);
  5909. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  5910. if( inst.settings.disabled ) {
  5911. this._disableDatepicker( target );
  5912. }
  5913. },
  5914. /* Make attachments based on settings. */
  5915. _attachments: function(input, inst) {
  5916. var showOn, buttonText, buttonImage,
  5917. appendText = this._get(inst, "appendText"),
  5918. isRTL = this._get(inst, "isRTL");
  5919. if (inst.append) {
  5920. inst.append.remove();
  5921. }
  5922. if (appendText) {
  5923. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  5924. input[isRTL ? "before" : "after"](inst.append);
  5925. }
  5926. input.unbind("focus", this._showDatepicker);
  5927. if (inst.trigger) {
  5928. inst.trigger.remove();
  5929. }
  5930. showOn = this._get(inst, "showOn");
  5931. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  5932. input.focus(this._showDatepicker);
  5933. }
  5934. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  5935. buttonText = this._get(inst, "buttonText");
  5936. buttonImage = this._get(inst, "buttonImage");
  5937. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  5938. $("<img/>").addClass(this._triggerClass).
  5939. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  5940. $("<button type='button'></button>").addClass(this._triggerClass).
  5941. html(!buttonImage ? buttonText : $("<img/>").attr(
  5942. { src:buttonImage, alt:buttonText, title:buttonText })));
  5943. input[isRTL ? "before" : "after"](inst.trigger);
  5944. inst.trigger.click(function() {
  5945. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  5946. $.datepicker._hideDatepicker();
  5947. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  5948. $.datepicker._hideDatepicker();
  5949. $.datepicker._showDatepicker(input[0]);
  5950. } else {
  5951. $.datepicker._showDatepicker(input[0]);
  5952. }
  5953. return false;
  5954. });
  5955. }
  5956. },
  5957. /* Apply the maximum length for the date format. */
  5958. _autoSize: function(inst) {
  5959. if (this._get(inst, "autoSize") && !inst.inline) {
  5960. var findMax, max, maxI, i,
  5961. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  5962. dateFormat = this._get(inst, "dateFormat");
  5963. if (dateFormat.match(/[DM]/)) {
  5964. findMax = function(names) {
  5965. max = 0;
  5966. maxI = 0;
  5967. for (i = 0; i < names.length; i++) {
  5968. if (names[i].length > max) {
  5969. max = names[i].length;
  5970. maxI = i;
  5971. }
  5972. }
  5973. return maxI;
  5974. };
  5975. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  5976. "monthNames" : "monthNamesShort"))));
  5977. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  5978. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  5979. }
  5980. inst.input.attr("size", this._formatDate(inst, date).length);
  5981. }
  5982. },
  5983. /* Attach an inline date picker to a div. */
  5984. _inlineDatepicker: function(target, inst) {
  5985. var divSpan = $(target);
  5986. if (divSpan.hasClass(this.markerClassName)) {
  5987. return;
  5988. }
  5989. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  5990. $.data(target, PROP_NAME, inst);
  5991. this._setDate(inst, this._getDefaultDate(inst), true);
  5992. this._updateDatepicker(inst);
  5993. this._updateAlternate(inst);
  5994. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  5995. if( inst.settings.disabled ) {
  5996. this._disableDatepicker( target );
  5997. }
  5998. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  5999. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  6000. inst.dpDiv.css( "display", "block" );
  6001. },
  6002. /* Pop-up the date picker in a "dialog" box.
  6003. * @param input element - ignored
  6004. * @param date string or Date - the initial date to display
  6005. * @param onSelect function - the function to call when a date is selected
  6006. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  6007. * @param pos int[2] - coordinates for the dialog's position within the screen or
  6008. * event - with x/y coordinates or
  6009. * leave empty for default (screen centre)
  6010. * @return the manager object
  6011. */
  6012. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  6013. var id, browserWidth, browserHeight, scrollX, scrollY,
  6014. inst = this._dialogInst; // internal instance
  6015. if (!inst) {
  6016. this.uuid += 1;
  6017. id = "dp" + this.uuid;
  6018. this._dialogInput = $("<input type='text' id='" + id +
  6019. "' style='position: absolute; top: -100px; width: 0px;'/>");
  6020. this._dialogInput.keydown(this._doKeyDown);
  6021. $("body").append(this._dialogInput);
  6022. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  6023. inst.settings = {};
  6024. $.data(this._dialogInput[0], PROP_NAME, inst);
  6025. }
  6026. extendRemove(inst.settings, settings || {});
  6027. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  6028. this._dialogInput.val(date);
  6029. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  6030. if (!this._pos) {
  6031. browserWidth = document.documentElement.clientWidth;
  6032. browserHeight = document.documentElement.clientHeight;
  6033. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  6034. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  6035. this._pos = // should use actual width/height below
  6036. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  6037. }
  6038. // move input on screen for focus, but hidden behind dialog
  6039. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  6040. inst.settings.onSelect = onSelect;
  6041. this._inDialog = true;
  6042. this.dpDiv.addClass(this._dialogClass);
  6043. this._showDatepicker(this._dialogInput[0]);
  6044. if ($.blockUI) {
  6045. $.blockUI(this.dpDiv);
  6046. }
  6047. $.data(this._dialogInput[0], PROP_NAME, inst);
  6048. return this;
  6049. },
  6050. /* Detach a datepicker from its control.
  6051. * @param target element - the target input field or division or span
  6052. */
  6053. _destroyDatepicker: function(target) {
  6054. var nodeName,
  6055. $target = $(target),
  6056. inst = $.data(target, PROP_NAME);
  6057. if (!$target.hasClass(this.markerClassName)) {
  6058. return;
  6059. }
  6060. nodeName = target.nodeName.toLowerCase();
  6061. $.removeData(target, PROP_NAME);
  6062. if (nodeName === "input") {
  6063. inst.append.remove();
  6064. inst.trigger.remove();
  6065. $target.removeClass(this.markerClassName).
  6066. unbind("focus", this._showDatepicker).
  6067. unbind("keydown", this._doKeyDown).
  6068. unbind("keypress", this._doKeyPress).
  6069. unbind("keyup", this._doKeyUp);
  6070. } else if (nodeName === "div" || nodeName === "span") {
  6071. $target.removeClass(this.markerClassName).empty();
  6072. }
  6073. },
  6074. /* Enable the date picker to a jQuery selection.
  6075. * @param target element - the target input field or division or span
  6076. */
  6077. _enableDatepicker: function(target) {
  6078. var nodeName, inline,
  6079. $target = $(target),
  6080. inst = $.data(target, PROP_NAME);
  6081. if (!$target.hasClass(this.markerClassName)) {
  6082. return;
  6083. }
  6084. nodeName = target.nodeName.toLowerCase();
  6085. if (nodeName === "input") {
  6086. target.disabled = false;
  6087. inst.trigger.filter("button").
  6088. each(function() { this.disabled = false; }).end().
  6089. filter("img").css({opacity: "1.0", cursor: ""});
  6090. } else if (nodeName === "div" || nodeName === "span") {
  6091. inline = $target.children("." + this._inlineClass);
  6092. inline.children().removeClass("ui-state-disabled");
  6093. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6094. prop("disabled", false);
  6095. }
  6096. this._disabledInputs = $.map(this._disabledInputs,
  6097. function(value) { return (value === target ? null : value); }); // delete entry
  6098. },
  6099. /* Disable the date picker to a jQuery selection.
  6100. * @param target element - the target input field or division or span
  6101. */
  6102. _disableDatepicker: function(target) {
  6103. var nodeName, inline,
  6104. $target = $(target),
  6105. inst = $.data(target, PROP_NAME);
  6106. if (!$target.hasClass(this.markerClassName)) {
  6107. return;
  6108. }
  6109. nodeName = target.nodeName.toLowerCase();
  6110. if (nodeName === "input") {
  6111. target.disabled = true;
  6112. inst.trigger.filter("button").
  6113. each(function() { this.disabled = true; }).end().
  6114. filter("img").css({opacity: "0.5", cursor: "default"});
  6115. } else if (nodeName === "div" || nodeName === "span") {
  6116. inline = $target.children("." + this._inlineClass);
  6117. inline.children().addClass("ui-state-disabled");
  6118. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6119. prop("disabled", true);
  6120. }
  6121. this._disabledInputs = $.map(this._disabledInputs,
  6122. function(value) { return (value === target ? null : value); }); // delete entry
  6123. this._disabledInputs[this._disabledInputs.length] = target;
  6124. },
  6125. /* Is the first field in a jQuery collection disabled as a datepicker?
  6126. * @param target element - the target input field or division or span
  6127. * @return boolean - true if disabled, false if enabled
  6128. */
  6129. _isDisabledDatepicker: function(target) {
  6130. if (!target) {
  6131. return false;
  6132. }
  6133. for (var i = 0; i < this._disabledInputs.length; i++) {
  6134. if (this._disabledInputs[i] === target) {
  6135. return true;
  6136. }
  6137. }
  6138. return false;
  6139. },
  6140. /* Retrieve the instance data for the target control.
  6141. * @param target element - the target input field or division or span
  6142. * @return object - the associated instance data
  6143. * @throws error if a jQuery problem getting data
  6144. */
  6145. _getInst: function(target) {
  6146. try {
  6147. return $.data(target, PROP_NAME);
  6148. }
  6149. catch (err) {
  6150. throw "Missing instance data for this datepicker";
  6151. }
  6152. },
  6153. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6154. * @param target element - the target input field or division or span
  6155. * @param name object - the new settings to update or
  6156. * string - the name of the setting to change or retrieve,
  6157. * when retrieving also "all" for all instance settings or
  6158. * "defaults" for all global defaults
  6159. * @param value any - the new value for the setting
  6160. * (omit if above is an object or to retrieve a value)
  6161. */
  6162. _optionDatepicker: function(target, name, value) {
  6163. var settings, date, minDate, maxDate,
  6164. inst = this._getInst(target);
  6165. if (arguments.length === 2 && typeof name === "string") {
  6166. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  6167. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  6168. this._get(inst, name)) : null));
  6169. }
  6170. settings = name || {};
  6171. if (typeof name === "string") {
  6172. settings = {};
  6173. settings[name] = value;
  6174. }
  6175. if (inst) {
  6176. if (this._curInst === inst) {
  6177. this._hideDatepicker();
  6178. }
  6179. date = this._getDateDatepicker(target, true);
  6180. minDate = this._getMinMaxDate(inst, "min");
  6181. maxDate = this._getMinMaxDate(inst, "max");
  6182. extendRemove(inst.settings, settings);
  6183. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6184. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  6185. inst.settings.minDate = this._formatDate(inst, minDate);
  6186. }
  6187. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  6188. inst.settings.maxDate = this._formatDate(inst, maxDate);
  6189. }
  6190. if ( "disabled" in settings ) {
  6191. if ( settings.disabled ) {
  6192. this._disableDatepicker(target);
  6193. } else {
  6194. this._enableDatepicker(target);
  6195. }
  6196. }
  6197. this._attachments($(target), inst);
  6198. this._autoSize(inst);
  6199. this._setDate(inst, date);
  6200. this._updateAlternate(inst);
  6201. this._updateDatepicker(inst);
  6202. }
  6203. },
  6204. // change method deprecated
  6205. _changeDatepicker: function(target, name, value) {
  6206. this._optionDatepicker(target, name, value);
  6207. },
  6208. /* Redraw the date picker attached to an input field or division.
  6209. * @param target element - the target input field or division or span
  6210. */
  6211. _refreshDatepicker: function(target) {
  6212. var inst = this._getInst(target);
  6213. if (inst) {
  6214. this._updateDatepicker(inst);
  6215. }
  6216. },
  6217. /* Set the dates for a jQuery selection.
  6218. * @param target element - the target input field or division or span
  6219. * @param date Date - the new date
  6220. */
  6221. _setDateDatepicker: function(target, date) {
  6222. var inst = this._getInst(target);
  6223. if (inst) {
  6224. this._setDate(inst, date);
  6225. this._updateDatepicker(inst);
  6226. this._updateAlternate(inst);
  6227. }
  6228. },
  6229. /* Get the date(s) for the first entry in a jQuery selection.
  6230. * @param target element - the target input field or division or span
  6231. * @param noDefault boolean - true if no default date is to be used
  6232. * @return Date - the current date
  6233. */
  6234. _getDateDatepicker: function(target, noDefault) {
  6235. var inst = this._getInst(target);
  6236. if (inst && !inst.inline) {
  6237. this._setDateFromField(inst, noDefault);
  6238. }
  6239. return (inst ? this._getDate(inst) : null);
  6240. },
  6241. /* Handle keystrokes. */
  6242. _doKeyDown: function(event) {
  6243. var onSelect, dateStr, sel,
  6244. inst = $.datepicker._getInst(event.target),
  6245. handled = true,
  6246. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  6247. inst._keyEvent = true;
  6248. if ($.datepicker._datepickerShowing) {
  6249. switch (event.keyCode) {
  6250. case 9: $.datepicker._hideDatepicker();
  6251. handled = false;
  6252. break; // hide on tab out
  6253. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  6254. $.datepicker._currentClass + ")", inst.dpDiv);
  6255. if (sel[0]) {
  6256. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  6257. }
  6258. onSelect = $.datepicker._get(inst, "onSelect");
  6259. if (onSelect) {
  6260. dateStr = $.datepicker._formatDate(inst);
  6261. // trigger custom callback
  6262. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  6263. } else {
  6264. $.datepicker._hideDatepicker();
  6265. }
  6266. return false; // don't submit the form
  6267. case 27: $.datepicker._hideDatepicker();
  6268. break; // hide on escape
  6269. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6270. -$.datepicker._get(inst, "stepBigMonths") :
  6271. -$.datepicker._get(inst, "stepMonths")), "M");
  6272. break; // previous month/year on page up/+ ctrl
  6273. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6274. +$.datepicker._get(inst, "stepBigMonths") :
  6275. +$.datepicker._get(inst, "stepMonths")), "M");
  6276. break; // next month/year on page down/+ ctrl
  6277. case 35: if (event.ctrlKey || event.metaKey) {
  6278. $.datepicker._clearDate(event.target);
  6279. }
  6280. handled = event.ctrlKey || event.metaKey;
  6281. break; // clear on ctrl or command +end
  6282. case 36: if (event.ctrlKey || event.metaKey) {
  6283. $.datepicker._gotoToday(event.target);
  6284. }
  6285. handled = event.ctrlKey || event.metaKey;
  6286. break; // current on ctrl or command +home
  6287. case 37: if (event.ctrlKey || event.metaKey) {
  6288. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  6289. }
  6290. handled = event.ctrlKey || event.metaKey;
  6291. // -1 day on ctrl or command +left
  6292. if (event.originalEvent.altKey) {
  6293. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6294. -$.datepicker._get(inst, "stepBigMonths") :
  6295. -$.datepicker._get(inst, "stepMonths")), "M");
  6296. }
  6297. // next month/year on alt +left on Mac
  6298. break;
  6299. case 38: if (event.ctrlKey || event.metaKey) {
  6300. $.datepicker._adjustDate(event.target, -7, "D");
  6301. }
  6302. handled = event.ctrlKey || event.metaKey;
  6303. break; // -1 week on ctrl or command +up
  6304. case 39: if (event.ctrlKey || event.metaKey) {
  6305. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  6306. }
  6307. handled = event.ctrlKey || event.metaKey;
  6308. // +1 day on ctrl or command +right
  6309. if (event.originalEvent.altKey) {
  6310. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6311. +$.datepicker._get(inst, "stepBigMonths") :
  6312. +$.datepicker._get(inst, "stepMonths")), "M");
  6313. }
  6314. // next month/year on alt +right
  6315. break;
  6316. case 40: if (event.ctrlKey || event.metaKey) {
  6317. $.datepicker._adjustDate(event.target, +7, "D");
  6318. }
  6319. handled = event.ctrlKey || event.metaKey;
  6320. break; // +1 week on ctrl or command +down
  6321. default: handled = false;
  6322. }
  6323. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  6324. $.datepicker._showDatepicker(this);
  6325. } else {
  6326. handled = false;
  6327. }
  6328. if (handled) {
  6329. event.preventDefault();
  6330. event.stopPropagation();
  6331. }
  6332. },
  6333. /* Filter entered characters - based on date format. */
  6334. _doKeyPress: function(event) {
  6335. var chars, chr,
  6336. inst = $.datepicker._getInst(event.target);
  6337. if ($.datepicker._get(inst, "constrainInput")) {
  6338. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  6339. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  6340. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  6341. }
  6342. },
  6343. /* Synchronise manual entry and field/alternate field. */
  6344. _doKeyUp: function(event) {
  6345. var date,
  6346. inst = $.datepicker._getInst(event.target);
  6347. if (inst.input.val() !== inst.lastVal) {
  6348. try {
  6349. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  6350. (inst.input ? inst.input.val() : null),
  6351. $.datepicker._getFormatConfig(inst));
  6352. if (date) { // only if valid
  6353. $.datepicker._setDateFromField(inst);
  6354. $.datepicker._updateAlternate(inst);
  6355. $.datepicker._updateDatepicker(inst);
  6356. }
  6357. }
  6358. catch (err) {
  6359. }
  6360. }
  6361. return true;
  6362. },
  6363. /* Pop-up the date picker for a given input field.
  6364. * If false returned from beforeShow event handler do not show.
  6365. * @param input element - the input field attached to the date picker or
  6366. * event - if triggered by focus
  6367. */
  6368. _showDatepicker: function(input) {
  6369. input = input.target || input;
  6370. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  6371. input = $("input", input.parentNode)[0];
  6372. }
  6373. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  6374. return;
  6375. }
  6376. var inst, beforeShow, beforeShowSettings, isFixed,
  6377. offset, showAnim, duration;
  6378. inst = $.datepicker._getInst(input);
  6379. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  6380. $.datepicker._curInst.dpDiv.stop(true, true);
  6381. if ( inst && $.datepicker._datepickerShowing ) {
  6382. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  6383. }
  6384. }
  6385. beforeShow = $.datepicker._get(inst, "beforeShow");
  6386. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  6387. if(beforeShowSettings === false){
  6388. return;
  6389. }
  6390. extendRemove(inst.settings, beforeShowSettings);
  6391. inst.lastVal = null;
  6392. $.datepicker._lastInput = input;
  6393. $.datepicker._setDateFromField(inst);
  6394. if ($.datepicker._inDialog) { // hide cursor
  6395. input.value = "";
  6396. }
  6397. if (!$.datepicker._pos) { // position below input
  6398. $.datepicker._pos = $.datepicker._findPos(input);
  6399. $.datepicker._pos[1] += input.offsetHeight; // add the height
  6400. }
  6401. isFixed = false;
  6402. $(input).parents().each(function() {
  6403. isFixed |= $(this).css("position") === "fixed";
  6404. return !isFixed;
  6405. });
  6406. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  6407. $.datepicker._pos = null;
  6408. //to avoid flashes on Firefox
  6409. inst.dpDiv.empty();
  6410. // determine sizing offscreen
  6411. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  6412. $.datepicker._updateDatepicker(inst);
  6413. // fix width for dynamic number of date pickers
  6414. // and adjust position before showing
  6415. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  6416. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  6417. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  6418. left: offset.left + "px", top: offset.top + "px"});
  6419. if (!inst.inline) {
  6420. showAnim = $.datepicker._get(inst, "showAnim");
  6421. duration = $.datepicker._get(inst, "duration");
  6422. inst.dpDiv.zIndex($(input).zIndex()+1);
  6423. $.datepicker._datepickerShowing = true;
  6424. if ( $.effects && $.effects.effect[ showAnim ] ) {
  6425. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  6426. } else {
  6427. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  6428. }
  6429. if ( $.datepicker._shouldFocusInput( inst ) ) {
  6430. inst.input.focus();
  6431. }
  6432. $.datepicker._curInst = inst;
  6433. }
  6434. },
  6435. /* Generate the date picker content. */
  6436. _updateDatepicker: function(inst) {
  6437. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  6438. instActive = inst; // for delegate hover events
  6439. inst.dpDiv.empty().append(this._generateHTML(inst));
  6440. this._attachHandlers(inst);
  6441. inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
  6442. var origyearshtml,
  6443. numMonths = this._getNumberOfMonths(inst),
  6444. cols = numMonths[1],
  6445. width = 17;
  6446. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  6447. if (cols > 1) {
  6448. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  6449. }
  6450. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  6451. "Class"]("ui-datepicker-multi");
  6452. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  6453. "Class"]("ui-datepicker-rtl");
  6454. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  6455. inst.input.focus();
  6456. }
  6457. // deffered render of the years select (to avoid flashes on Firefox)
  6458. if( inst.yearshtml ){
  6459. origyearshtml = inst.yearshtml;
  6460. setTimeout(function(){
  6461. //assure that inst.yearshtml didn't change.
  6462. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  6463. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  6464. }
  6465. origyearshtml = inst.yearshtml = null;
  6466. }, 0);
  6467. }
  6468. },
  6469. // #6694 - don't focus the input if it's already focused
  6470. // this breaks the change event in IE
  6471. // Support: IE and jQuery <1.9
  6472. _shouldFocusInput: function( inst ) {
  6473. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  6474. },
  6475. /* Check positioning to remain on screen. */
  6476. _checkOffset: function(inst, offset, isFixed) {
  6477. var dpWidth = inst.dpDiv.outerWidth(),
  6478. dpHeight = inst.dpDiv.outerHeight(),
  6479. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  6480. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  6481. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  6482. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  6483. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  6484. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  6485. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  6486. // now check if datepicker is showing outside window viewport - move to a better place if so.
  6487. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  6488. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  6489. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  6490. Math.abs(dpHeight + inputHeight) : 0);
  6491. return offset;
  6492. },
  6493. /* Find an object's position on the screen. */
  6494. _findPos: function(obj) {
  6495. var position,
  6496. inst = this._getInst(obj),
  6497. isRTL = this._get(inst, "isRTL");
  6498. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  6499. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  6500. }
  6501. position = $(obj).offset();
  6502. return [position.left, position.top];
  6503. },
  6504. /* Hide the date picker from view.
  6505. * @param input element - the input field attached to the date picker
  6506. */
  6507. _hideDatepicker: function(input) {
  6508. var showAnim, duration, postProcess, onClose,
  6509. inst = this._curInst;
  6510. if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
  6511. return;
  6512. }
  6513. if (this._datepickerShowing) {
  6514. showAnim = this._get(inst, "showAnim");
  6515. duration = this._get(inst, "duration");
  6516. postProcess = function() {
  6517. $.datepicker._tidyDialog(inst);
  6518. };
  6519. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  6520. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  6521. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  6522. } else {
  6523. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  6524. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  6525. }
  6526. if (!showAnim) {
  6527. postProcess();
  6528. }
  6529. this._datepickerShowing = false;
  6530. onClose = this._get(inst, "onClose");
  6531. if (onClose) {
  6532. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  6533. }
  6534. this._lastInput = null;
  6535. if (this._inDialog) {
  6536. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  6537. if ($.blockUI) {
  6538. $.unblockUI();
  6539. $("body").append(this.dpDiv);
  6540. }
  6541. }
  6542. this._inDialog = false;
  6543. }
  6544. },
  6545. /* Tidy up after a dialog display. */
  6546. _tidyDialog: function(inst) {
  6547. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  6548. },
  6549. /* Close date picker if clicked elsewhere. */
  6550. _checkExternalClick: function(event) {
  6551. if (!$.datepicker._curInst) {
  6552. return;
  6553. }
  6554. var $target = $(event.target),
  6555. inst = $.datepicker._getInst($target[0]);
  6556. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  6557. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  6558. !$target.hasClass($.datepicker.markerClassName) &&
  6559. !$target.closest("." + $.datepicker._triggerClass).length &&
  6560. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  6561. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  6562. $.datepicker._hideDatepicker();
  6563. }
  6564. },
  6565. /* Adjust one of the date sub-fields. */
  6566. _adjustDate: function(id, offset, period) {
  6567. var target = $(id),
  6568. inst = this._getInst(target[0]);
  6569. if (this._isDisabledDatepicker(target[0])) {
  6570. return;
  6571. }
  6572. this._adjustInstDate(inst, offset +
  6573. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  6574. period);
  6575. this._updateDatepicker(inst);
  6576. },
  6577. /* Action for current link. */
  6578. _gotoToday: function(id) {
  6579. var date,
  6580. target = $(id),
  6581. inst = this._getInst(target[0]);
  6582. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  6583. inst.selectedDay = inst.currentDay;
  6584. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  6585. inst.drawYear = inst.selectedYear = inst.currentYear;
  6586. } else {
  6587. date = new Date();
  6588. inst.selectedDay = date.getDate();
  6589. inst.drawMonth = inst.selectedMonth = date.getMonth();
  6590. inst.drawYear = inst.selectedYear = date.getFullYear();
  6591. }
  6592. this._notifyChange(inst);
  6593. this._adjustDate(target);
  6594. },
  6595. /* Action for selecting a new month/year. */
  6596. _selectMonthYear: function(id, select, period) {
  6597. var target = $(id),
  6598. inst = this._getInst(target[0]);
  6599. inst["selected" + (period === "M" ? "Month" : "Year")] =
  6600. inst["draw" + (period === "M" ? "Month" : "Year")] =
  6601. parseInt(select.options[select.selectedIndex].value,10);
  6602. this._notifyChange(inst);
  6603. this._adjustDate(target);
  6604. },
  6605. /* Action for selecting a day. */
  6606. _selectDay: function(id, month, year, td) {
  6607. var inst,
  6608. target = $(id);
  6609. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  6610. return;
  6611. }
  6612. inst = this._getInst(target[0]);
  6613. inst.selectedDay = inst.currentDay = $("a", td).html();
  6614. inst.selectedMonth = inst.currentMonth = month;
  6615. inst.selectedYear = inst.currentYear = year;
  6616. this._selectDate(id, this._formatDate(inst,
  6617. inst.currentDay, inst.currentMonth, inst.currentYear));
  6618. },
  6619. /* Erase the input field and hide the date picker. */
  6620. _clearDate: function(id) {
  6621. var target = $(id);
  6622. this._selectDate(target, "");
  6623. },
  6624. /* Update the input field with the selected date. */
  6625. _selectDate: function(id, dateStr) {
  6626. var onSelect,
  6627. target = $(id),
  6628. inst = this._getInst(target[0]);
  6629. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  6630. if (inst.input) {
  6631. inst.input.val(dateStr);
  6632. }
  6633. this._updateAlternate(inst);
  6634. onSelect = this._get(inst, "onSelect");
  6635. if (onSelect) {
  6636. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  6637. } else if (inst.input) {
  6638. inst.input.trigger("change"); // fire the change event
  6639. }
  6640. if (inst.inline){
  6641. this._updateDatepicker(inst);
  6642. } else {
  6643. this._hideDatepicker();
  6644. this._lastInput = inst.input[0];
  6645. if (typeof(inst.input[0]) !== "object") {
  6646. inst.input.focus(); // restore focus
  6647. }
  6648. this._lastInput = null;
  6649. }
  6650. },
  6651. /* Update any alternate field to synchronise with the main field. */
  6652. _updateAlternate: function(inst) {
  6653. var altFormat, date, dateStr,
  6654. altField = this._get(inst, "altField");
  6655. if (altField) { // update alternate field too
  6656. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  6657. date = this._getDate(inst);
  6658. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  6659. $(altField).each(function() { $(this).val(dateStr); });
  6660. }
  6661. },
  6662. /* Set as beforeShowDay function to prevent selection of weekends.
  6663. * @param date Date - the date to customise
  6664. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  6665. */
  6666. noWeekends: function(date) {
  6667. var day = date.getDay();
  6668. return [(day > 0 && day < 6), ""];
  6669. },
  6670. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  6671. * @param date Date - the date to get the week for
  6672. * @return number - the number of the week within the year that contains this date
  6673. */
  6674. iso8601Week: function(date) {
  6675. var time,
  6676. checkDate = new Date(date.getTime());
  6677. // Find Thursday of this week starting on Monday
  6678. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  6679. time = checkDate.getTime();
  6680. checkDate.setMonth(0); // Compare with Jan 1
  6681. checkDate.setDate(1);
  6682. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  6683. },
  6684. /* Parse a string value into a date object.
  6685. * See formatDate below for the possible formats.
  6686. *
  6687. * @param format string - the expected format of the date
  6688. * @param value string - the date in the above format
  6689. * @param settings Object - attributes include:
  6690. * shortYearCutoff number - the cutoff year for determining the century (optional)
  6691. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  6692. * dayNames string[7] - names of the days from Sunday (optional)
  6693. * monthNamesShort string[12] - abbreviated names of the months (optional)
  6694. * monthNames string[12] - names of the months (optional)
  6695. * @return Date - the extracted date value or null if value is blank
  6696. */
  6697. parseDate: function (format, value, settings) {
  6698. if (format == null || value == null) {
  6699. throw "Invalid arguments";
  6700. }
  6701. value = (typeof value === "object" ? value.toString() : value + "");
  6702. if (value === "") {
  6703. return null;
  6704. }
  6705. var iFormat, dim, extra,
  6706. iValue = 0,
  6707. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  6708. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  6709. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  6710. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  6711. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  6712. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  6713. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  6714. year = -1,
  6715. month = -1,
  6716. day = -1,
  6717. doy = -1,
  6718. literal = false,
  6719. date,
  6720. // Check whether a format character is doubled
  6721. lookAhead = function(match) {
  6722. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  6723. if (matches) {
  6724. iFormat++;
  6725. }
  6726. return matches;
  6727. },
  6728. // Extract a number from the string value
  6729. getNumber = function(match) {
  6730. var isDoubled = lookAhead(match),
  6731. size = (match === "@" ? 14 : (match === "!" ? 20 :
  6732. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  6733. digits = new RegExp("^\\d{1," + size + "}"),
  6734. num = value.substring(iValue).match(digits);
  6735. if (!num) {
  6736. throw "Missing number at position " + iValue;
  6737. }
  6738. iValue += num[0].length;
  6739. return parseInt(num[0], 10);
  6740. },
  6741. // Extract a name from the string value and convert to an index
  6742. getName = function(match, shortNames, longNames) {
  6743. var index = -1,
  6744. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  6745. return [ [k, v] ];
  6746. }).sort(function (a, b) {
  6747. return -(a[1].length - b[1].length);
  6748. });
  6749. $.each(names, function (i, pair) {
  6750. var name = pair[1];
  6751. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  6752. index = pair[0];
  6753. iValue += name.length;
  6754. return false;
  6755. }
  6756. });
  6757. if (index !== -1) {
  6758. return index + 1;
  6759. } else {
  6760. throw "Unknown name at position " + iValue;
  6761. }
  6762. },
  6763. // Confirm that a literal character matches the string value
  6764. checkLiteral = function() {
  6765. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  6766. throw "Unexpected literal at position " + iValue;
  6767. }
  6768. iValue++;
  6769. };
  6770. for (iFormat = 0; iFormat < format.length; iFormat++) {
  6771. if (literal) {
  6772. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  6773. literal = false;
  6774. } else {
  6775. checkLiteral();
  6776. }
  6777. } else {
  6778. switch (format.charAt(iFormat)) {
  6779. case "d":
  6780. day = getNumber("d");
  6781. break;
  6782. case "D":
  6783. getName("D", dayNamesShort, dayNames);
  6784. break;
  6785. case "o":
  6786. doy = getNumber("o");
  6787. break;
  6788. case "m":
  6789. month = getNumber("m");
  6790. break;
  6791. case "M":
  6792. month = getName("M", monthNamesShort, monthNames);
  6793. break;
  6794. case "y":
  6795. year = getNumber("y");
  6796. break;
  6797. case "@":
  6798. date = new Date(getNumber("@"));
  6799. year = date.getFullYear();
  6800. month = date.getMonth() + 1;
  6801. day = date.getDate();
  6802. break;
  6803. case "!":
  6804. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  6805. year = date.getFullYear();
  6806. month = date.getMonth() + 1;
  6807. day = date.getDate();
  6808. break;
  6809. case "'":
  6810. if (lookAhead("'")){
  6811. checkLiteral();
  6812. } else {
  6813. literal = true;
  6814. }
  6815. break;
  6816. default:
  6817. checkLiteral();
  6818. }
  6819. }
  6820. }
  6821. if (iValue < value.length){
  6822. extra = value.substr(iValue);
  6823. if (!/^\s+/.test(extra)) {
  6824. throw "Extra/unparsed characters found in date: " + extra;
  6825. }
  6826. }
  6827. if (year === -1) {
  6828. year = new Date().getFullYear();
  6829. } else if (year < 100) {
  6830. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  6831. (year <= shortYearCutoff ? 0 : -100);
  6832. }
  6833. if (doy > -1) {
  6834. month = 1;
  6835. day = doy;
  6836. do {
  6837. dim = this._getDaysInMonth(year, month - 1);
  6838. if (day <= dim) {
  6839. break;
  6840. }
  6841. month++;
  6842. day -= dim;
  6843. } while (true);
  6844. }
  6845. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  6846. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  6847. throw "Invalid date"; // E.g. 31/02/00
  6848. }
  6849. return date;
  6850. },
  6851. /* Standard date formats. */
  6852. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  6853. COOKIE: "D, dd M yy",
  6854. ISO_8601: "yy-mm-dd",
  6855. RFC_822: "D, d M y",
  6856. RFC_850: "DD, dd-M-y",
  6857. RFC_1036: "D, d M y",
  6858. RFC_1123: "D, d M yy",
  6859. RFC_2822: "D, d M yy",
  6860. RSS: "D, d M y", // RFC 822
  6861. TICKS: "!",
  6862. TIMESTAMP: "@",
  6863. W3C: "yy-mm-dd", // ISO 8601
  6864. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  6865. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  6866. /* Format a date object into a string value.
  6867. * The format can be combinations of the following:
  6868. * d - day of month (no leading zero)
  6869. * dd - day of month (two digit)
  6870. * o - day of year (no leading zeros)
  6871. * oo - day of year (three digit)
  6872. * D - day name short
  6873. * DD - day name long
  6874. * m - month of year (no leading zero)
  6875. * mm - month of year (two digit)
  6876. * M - month name short
  6877. * MM - month name long
  6878. * y - year (two digit)
  6879. * yy - year (four digit)
  6880. * @ - Unix timestamp (ms since 01/01/1970)
  6881. * ! - Windows ticks (100ns since 01/01/0001)
  6882. * "..." - literal text
  6883. * '' - single quote
  6884. *
  6885. * @param format string - the desired format of the date
  6886. * @param date Date - the date value to format
  6887. * @param settings Object - attributes include:
  6888. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  6889. * dayNames string[7] - names of the days from Sunday (optional)
  6890. * monthNamesShort string[12] - abbreviated names of the months (optional)
  6891. * monthNames string[12] - names of the months (optional)
  6892. * @return string - the date in the above format
  6893. */
  6894. formatDate: function (format, date, settings) {
  6895. if (!date) {
  6896. return "";
  6897. }
  6898. var iFormat,
  6899. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  6900. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  6901. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  6902. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  6903. // Check whether a format character is doubled
  6904. lookAhead = function(match) {
  6905. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  6906. if (matches) {
  6907. iFormat++;
  6908. }
  6909. return matches;
  6910. },
  6911. // Format a number, with leading zero if necessary
  6912. formatNumber = function(match, value, len) {
  6913. var num = "" + value;
  6914. if (lookAhead(match)) {
  6915. while (num.length < len) {
  6916. num = "0" + num;
  6917. }
  6918. }
  6919. return num;
  6920. },
  6921. // Format a name, short or long as requested
  6922. formatName = function(match, value, shortNames, longNames) {
  6923. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  6924. },
  6925. output = "",
  6926. literal = false;
  6927. if (date) {
  6928. for (iFormat = 0; iFormat < format.length; iFormat++) {
  6929. if (literal) {
  6930. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  6931. literal = false;
  6932. } else {
  6933. output += format.charAt(iFormat);
  6934. }
  6935. } else {
  6936. switch (format.charAt(iFormat)) {
  6937. case "d":
  6938. output += formatNumber("d", date.getDate(), 2);
  6939. break;
  6940. case "D":
  6941. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  6942. break;
  6943. case "o":
  6944. output += formatNumber("o",
  6945. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  6946. break;
  6947. case "m":
  6948. output += formatNumber("m", date.getMonth() + 1, 2);
  6949. break;
  6950. case "M":
  6951. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  6952. break;
  6953. case "y":
  6954. output += (lookAhead("y") ? date.getFullYear() :
  6955. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  6956. break;
  6957. case "@":
  6958. output += date.getTime();
  6959. break;
  6960. case "!":
  6961. output += date.getTime() * 10000 + this._ticksTo1970;
  6962. break;
  6963. case "'":
  6964. if (lookAhead("'")) {
  6965. output += "'";
  6966. } else {
  6967. literal = true;
  6968. }
  6969. break;
  6970. default:
  6971. output += format.charAt(iFormat);
  6972. }
  6973. }
  6974. }
  6975. }
  6976. return output;
  6977. },
  6978. /* Extract all possible characters from the date format. */
  6979. _possibleChars: function (format) {
  6980. var iFormat,
  6981. chars = "",
  6982. literal = false,
  6983. // Check whether a format character is doubled
  6984. lookAhead = function(match) {
  6985. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  6986. if (matches) {
  6987. iFormat++;
  6988. }
  6989. return matches;
  6990. };
  6991. for (iFormat = 0; iFormat < format.length; iFormat++) {
  6992. if (literal) {
  6993. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  6994. literal = false;
  6995. } else {
  6996. chars += format.charAt(iFormat);
  6997. }
  6998. } else {
  6999. switch (format.charAt(iFormat)) {
  7000. case "d": case "m": case "y": case "@":
  7001. chars += "0123456789";
  7002. break;
  7003. case "D": case "M":
  7004. return null; // Accept anything
  7005. case "'":
  7006. if (lookAhead("'")) {
  7007. chars += "'";
  7008. } else {
  7009. literal = true;
  7010. }
  7011. break;
  7012. default:
  7013. chars += format.charAt(iFormat);
  7014. }
  7015. }
  7016. }
  7017. return chars;
  7018. },
  7019. /* Get a setting value, defaulting if necessary. */
  7020. _get: function(inst, name) {
  7021. return inst.settings[name] !== undefined ?
  7022. inst.settings[name] : this._defaults[name];
  7023. },
  7024. /* Parse existing date and initialise date picker. */
  7025. _setDateFromField: function(inst, noDefault) {
  7026. if (inst.input.val() === inst.lastVal) {
  7027. return;
  7028. }
  7029. var dateFormat = this._get(inst, "dateFormat"),
  7030. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  7031. defaultDate = this._getDefaultDate(inst),
  7032. date = defaultDate,
  7033. settings = this._getFormatConfig(inst);
  7034. try {
  7035. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  7036. } catch (event) {
  7037. dates = (noDefault ? "" : dates);
  7038. }
  7039. inst.selectedDay = date.getDate();
  7040. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7041. inst.drawYear = inst.selectedYear = date.getFullYear();
  7042. inst.currentDay = (dates ? date.getDate() : 0);
  7043. inst.currentMonth = (dates ? date.getMonth() : 0);
  7044. inst.currentYear = (dates ? date.getFullYear() : 0);
  7045. this._adjustInstDate(inst);
  7046. },
  7047. /* Retrieve the default date shown on opening. */
  7048. _getDefaultDate: function(inst) {
  7049. return this._restrictMinMax(inst,
  7050. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  7051. },
  7052. /* A date may be specified as an exact value or a relative one. */
  7053. _determineDate: function(inst, date, defaultDate) {
  7054. var offsetNumeric = function(offset) {
  7055. var date = new Date();
  7056. date.setDate(date.getDate() + offset);
  7057. return date;
  7058. },
  7059. offsetString = function(offset) {
  7060. try {
  7061. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7062. offset, $.datepicker._getFormatConfig(inst));
  7063. }
  7064. catch (e) {
  7065. // Ignore
  7066. }
  7067. var date = (offset.toLowerCase().match(/^c/) ?
  7068. $.datepicker._getDate(inst) : null) || new Date(),
  7069. year = date.getFullYear(),
  7070. month = date.getMonth(),
  7071. day = date.getDate(),
  7072. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  7073. matches = pattern.exec(offset);
  7074. while (matches) {
  7075. switch (matches[2] || "d") {
  7076. case "d" : case "D" :
  7077. day += parseInt(matches[1],10); break;
  7078. case "w" : case "W" :
  7079. day += parseInt(matches[1],10) * 7; break;
  7080. case "m" : case "M" :
  7081. month += parseInt(matches[1],10);
  7082. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7083. break;
  7084. case "y": case "Y" :
  7085. year += parseInt(matches[1],10);
  7086. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7087. break;
  7088. }
  7089. matches = pattern.exec(offset);
  7090. }
  7091. return new Date(year, month, day);
  7092. },
  7093. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  7094. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  7095. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  7096. if (newDate) {
  7097. newDate.setHours(0);
  7098. newDate.setMinutes(0);
  7099. newDate.setSeconds(0);
  7100. newDate.setMilliseconds(0);
  7101. }
  7102. return this._daylightSavingAdjust(newDate);
  7103. },
  7104. /* Handle switch to/from daylight saving.
  7105. * Hours may be non-zero on daylight saving cut-over:
  7106. * > 12 when midnight changeover, but then cannot generate
  7107. * midnight datetime, so jump to 1AM, otherwise reset.
  7108. * @param date (Date) the date to check
  7109. * @return (Date) the corrected date
  7110. */
  7111. _daylightSavingAdjust: function(date) {
  7112. if (!date) {
  7113. return null;
  7114. }
  7115. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  7116. return date;
  7117. },
  7118. /* Set the date(s) directly. */
  7119. _setDate: function(inst, date, noChange) {
  7120. var clear = !date,
  7121. origMonth = inst.selectedMonth,
  7122. origYear = inst.selectedYear,
  7123. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  7124. inst.selectedDay = inst.currentDay = newDate.getDate();
  7125. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  7126. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  7127. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  7128. this._notifyChange(inst);
  7129. }
  7130. this._adjustInstDate(inst);
  7131. if (inst.input) {
  7132. inst.input.val(clear ? "" : this._formatDate(inst));
  7133. }
  7134. },
  7135. /* Retrieve the date(s) directly. */
  7136. _getDate: function(inst) {
  7137. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  7138. this._daylightSavingAdjust(new Date(
  7139. inst.currentYear, inst.currentMonth, inst.currentDay)));
  7140. return startDate;
  7141. },
  7142. /* Attach the onxxx handlers. These are declared statically so
  7143. * they work with static code transformers like Caja.
  7144. */
  7145. _attachHandlers: function(inst) {
  7146. var stepMonths = this._get(inst, "stepMonths"),
  7147. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  7148. inst.dpDiv.find("[data-handler]").map(function () {
  7149. var handler = {
  7150. prev: function () {
  7151. $.datepicker._adjustDate(id, -stepMonths, "M");
  7152. },
  7153. next: function () {
  7154. $.datepicker._adjustDate(id, +stepMonths, "M");
  7155. },
  7156. hide: function () {
  7157. $.datepicker._hideDatepicker();
  7158. },
  7159. today: function () {
  7160. $.datepicker._gotoToday(id);
  7161. },
  7162. selectDay: function () {
  7163. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  7164. return false;
  7165. },
  7166. selectMonth: function () {
  7167. $.datepicker._selectMonthYear(id, this, "M");
  7168. return false;
  7169. },
  7170. selectYear: function () {
  7171. $.datepicker._selectMonthYear(id, this, "Y");
  7172. return false;
  7173. }
  7174. };
  7175. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  7176. });
  7177. },
  7178. /* Generate the HTML for the current state of the date picker. */
  7179. _generateHTML: function(inst) {
  7180. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  7181. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  7182. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  7183. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  7184. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  7185. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  7186. tempDate = new Date(),
  7187. today = this._daylightSavingAdjust(
  7188. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  7189. isRTL = this._get(inst, "isRTL"),
  7190. showButtonPanel = this._get(inst, "showButtonPanel"),
  7191. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  7192. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  7193. numMonths = this._getNumberOfMonths(inst),
  7194. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  7195. stepMonths = this._get(inst, "stepMonths"),
  7196. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  7197. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  7198. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  7199. minDate = this._getMinMaxDate(inst, "min"),
  7200. maxDate = this._getMinMaxDate(inst, "max"),
  7201. drawMonth = inst.drawMonth - showCurrentAtPos,
  7202. drawYear = inst.drawYear;
  7203. if (drawMonth < 0) {
  7204. drawMonth += 12;
  7205. drawYear--;
  7206. }
  7207. if (maxDate) {
  7208. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  7209. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  7210. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  7211. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  7212. drawMonth--;
  7213. if (drawMonth < 0) {
  7214. drawMonth = 11;
  7215. drawYear--;
  7216. }
  7217. }
  7218. }
  7219. inst.drawMonth = drawMonth;
  7220. inst.drawYear = drawYear;
  7221. prevText = this._get(inst, "prevText");
  7222. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  7223. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  7224. this._getFormatConfig(inst)));
  7225. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  7226. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  7227. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  7228. (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>"));
  7229. nextText = this._get(inst, "nextText");
  7230. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  7231. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  7232. this._getFormatConfig(inst)));
  7233. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  7234. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  7235. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  7236. (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>"));
  7237. currentText = this._get(inst, "currentText");
  7238. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  7239. currentText = (!navigationAsDateFormat ? currentText :
  7240. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  7241. 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'>" +
  7242. this._get(inst, "closeText") + "</button>" : "");
  7243. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  7244. (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'" +
  7245. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  7246. firstDay = parseInt(this._get(inst, "firstDay"),10);
  7247. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  7248. showWeek = this._get(inst, "showWeek");
  7249. dayNames = this._get(inst, "dayNames");
  7250. dayNamesMin = this._get(inst, "dayNamesMin");
  7251. monthNames = this._get(inst, "monthNames");
  7252. monthNamesShort = this._get(inst, "monthNamesShort");
  7253. beforeShowDay = this._get(inst, "beforeShowDay");
  7254. showOtherMonths = this._get(inst, "showOtherMonths");
  7255. selectOtherMonths = this._get(inst, "selectOtherMonths");
  7256. defaultDate = this._getDefaultDate(inst);
  7257. html = "";
  7258. dow;
  7259. for (row = 0; row < numMonths[0]; row++) {
  7260. group = "";
  7261. this.maxRows = 4;
  7262. for (col = 0; col < numMonths[1]; col++) {
  7263. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  7264. cornerClass = " ui-corner-all";
  7265. calender = "";
  7266. if (isMultiMonth) {
  7267. calender += "<div class='ui-datepicker-group";
  7268. if (numMonths[1] > 1) {
  7269. switch (col) {
  7270. case 0: calender += " ui-datepicker-group-first";
  7271. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  7272. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  7273. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  7274. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  7275. }
  7276. }
  7277. calender += "'>";
  7278. }
  7279. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  7280. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  7281. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  7282. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  7283. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  7284. "</div><table class='ui-datepicker-calendar'><thead>" +
  7285. "<tr>";
  7286. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  7287. for (dow = 0; dow < 7; dow++) { // days of the week
  7288. day = (dow + firstDay) % 7;
  7289. thead += "<th" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  7290. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  7291. }
  7292. calender += thead + "</tr></thead><tbody>";
  7293. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  7294. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  7295. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  7296. }
  7297. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  7298. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  7299. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  7300. this.maxRows = numRows;
  7301. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  7302. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  7303. calender += "<tr>";
  7304. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  7305. this._get(inst, "calculateWeek")(printDate) + "</td>");
  7306. for (dow = 0; dow < 7; dow++) { // create date picker days
  7307. daySettings = (beforeShowDay ?
  7308. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  7309. otherMonth = (printDate.getMonth() !== drawMonth);
  7310. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  7311. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  7312. tbody += "<td class='" +
  7313. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  7314. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  7315. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  7316. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  7317. // or defaultDate is current printedDate and defaultDate is selectedDate
  7318. " " + this._dayOverClass : "") + // highlight selected day
  7319. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  7320. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  7321. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  7322. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  7323. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  7324. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  7325. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  7326. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  7327. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  7328. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  7329. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  7330. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  7331. printDate.setDate(printDate.getDate() + 1);
  7332. printDate = this._daylightSavingAdjust(printDate);
  7333. }
  7334. calender += tbody + "</tr>";
  7335. }
  7336. drawMonth++;
  7337. if (drawMonth > 11) {
  7338. drawMonth = 0;
  7339. drawYear++;
  7340. }
  7341. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  7342. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  7343. group += calender;
  7344. }
  7345. html += group;
  7346. }
  7347. html += buttonPanel;
  7348. inst._keyEvent = false;
  7349. return html;
  7350. },
  7351. /* Generate the month and year header. */
  7352. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  7353. secondary, monthNames, monthNamesShort) {
  7354. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  7355. changeMonth = this._get(inst, "changeMonth"),
  7356. changeYear = this._get(inst, "changeYear"),
  7357. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  7358. html = "<div class='ui-datepicker-title'>",
  7359. monthHtml = "";
  7360. // month selection
  7361. if (secondary || !changeMonth) {
  7362. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  7363. } else {
  7364. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  7365. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  7366. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  7367. for ( month = 0; month < 12; month++) {
  7368. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  7369. monthHtml += "<option value='" + month + "'" +
  7370. (month === drawMonth ? " selected='selected'" : "") +
  7371. ">" + monthNamesShort[month] + "</option>";
  7372. }
  7373. }
  7374. monthHtml += "</select>";
  7375. }
  7376. if (!showMonthAfterYear) {
  7377. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  7378. }
  7379. // year selection
  7380. if ( !inst.yearshtml ) {
  7381. inst.yearshtml = "";
  7382. if (secondary || !changeYear) {
  7383. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  7384. } else {
  7385. // determine range of years to display
  7386. years = this._get(inst, "yearRange").split(":");
  7387. thisYear = new Date().getFullYear();
  7388. determineYear = function(value) {
  7389. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  7390. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  7391. parseInt(value, 10)));
  7392. return (isNaN(year) ? thisYear : year);
  7393. };
  7394. year = determineYear(years[0]);
  7395. endYear = Math.max(year, determineYear(years[1] || ""));
  7396. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  7397. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  7398. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  7399. for (; year <= endYear; year++) {
  7400. inst.yearshtml += "<option value='" + year + "'" +
  7401. (year === drawYear ? " selected='selected'" : "") +
  7402. ">" + year + "</option>";
  7403. }
  7404. inst.yearshtml += "</select>";
  7405. html += inst.yearshtml;
  7406. inst.yearshtml = null;
  7407. }
  7408. }
  7409. html += this._get(inst, "yearSuffix");
  7410. if (showMonthAfterYear) {
  7411. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  7412. }
  7413. html += "</div>"; // Close datepicker_header
  7414. return html;
  7415. },
  7416. /* Adjust one of the date sub-fields. */
  7417. _adjustInstDate: function(inst, offset, period) {
  7418. var year = inst.drawYear + (period === "Y" ? offset : 0),
  7419. month = inst.drawMonth + (period === "M" ? offset : 0),
  7420. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  7421. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  7422. inst.selectedDay = date.getDate();
  7423. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7424. inst.drawYear = inst.selectedYear = date.getFullYear();
  7425. if (period === "M" || period === "Y") {
  7426. this._notifyChange(inst);
  7427. }
  7428. },
  7429. /* Ensure a date is within any min/max bounds. */
  7430. _restrictMinMax: function(inst, date) {
  7431. var minDate = this._getMinMaxDate(inst, "min"),
  7432. maxDate = this._getMinMaxDate(inst, "max"),
  7433. newDate = (minDate && date < minDate ? minDate : date);
  7434. return (maxDate && newDate > maxDate ? maxDate : newDate);
  7435. },
  7436. /* Notify change of month/year. */
  7437. _notifyChange: function(inst) {
  7438. var onChange = this._get(inst, "onChangeMonthYear");
  7439. if (onChange) {
  7440. onChange.apply((inst.input ? inst.input[0] : null),
  7441. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  7442. }
  7443. },
  7444. /* Determine the number of months to show. */
  7445. _getNumberOfMonths: function(inst) {
  7446. var numMonths = this._get(inst, "numberOfMonths");
  7447. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  7448. },
  7449. /* Determine the current maximum date - ensure no time components are set. */
  7450. _getMinMaxDate: function(inst, minMax) {
  7451. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  7452. },
  7453. /* Find the number of days in a given month. */
  7454. _getDaysInMonth: function(year, month) {
  7455. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  7456. },
  7457. /* Find the day of the week of the first of a month. */
  7458. _getFirstDayOfMonth: function(year, month) {
  7459. return new Date(year, month, 1).getDay();
  7460. },
  7461. /* Determines if we should allow a "next/prev" month display change. */
  7462. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  7463. var numMonths = this._getNumberOfMonths(inst),
  7464. date = this._daylightSavingAdjust(new Date(curYear,
  7465. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  7466. if (offset < 0) {
  7467. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  7468. }
  7469. return this._isInRange(inst, date);
  7470. },
  7471. /* Is the given date in the accepted range? */
  7472. _isInRange: function(inst, date) {
  7473. var yearSplit, currentYear,
  7474. minDate = this._getMinMaxDate(inst, "min"),
  7475. maxDate = this._getMinMaxDate(inst, "max"),
  7476. minYear = null,
  7477. maxYear = null,
  7478. years = this._get(inst, "yearRange");
  7479. if (years){
  7480. yearSplit = years.split(":");
  7481. currentYear = new Date().getFullYear();
  7482. minYear = parseInt(yearSplit[0], 10);
  7483. maxYear = parseInt(yearSplit[1], 10);
  7484. if ( yearSplit[0].match(/[+\-].*/) ) {
  7485. minYear += currentYear;
  7486. }
  7487. if ( yearSplit[1].match(/[+\-].*/) ) {
  7488. maxYear += currentYear;
  7489. }
  7490. }
  7491. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  7492. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  7493. (!minYear || date.getFullYear() >= minYear) &&
  7494. (!maxYear || date.getFullYear() <= maxYear));
  7495. },
  7496. /* Provide the configuration settings for formatting/parsing. */
  7497. _getFormatConfig: function(inst) {
  7498. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  7499. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  7500. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  7501. return {shortYearCutoff: shortYearCutoff,
  7502. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  7503. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  7504. },
  7505. /* Format the given date for display. */
  7506. _formatDate: function(inst, day, month, year) {
  7507. if (!day) {
  7508. inst.currentDay = inst.selectedDay;
  7509. inst.currentMonth = inst.selectedMonth;
  7510. inst.currentYear = inst.selectedYear;
  7511. }
  7512. var date = (day ? (typeof day === "object" ? day :
  7513. this._daylightSavingAdjust(new Date(year, month, day))) :
  7514. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  7515. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  7516. }
  7517. });
  7518. /*
  7519. * Bind hover events for datepicker elements.
  7520. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  7521. * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  7522. */
  7523. function bindHover(dpDiv) {
  7524. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  7525. return dpDiv.delegate(selector, "mouseout", function() {
  7526. $(this).removeClass("ui-state-hover");
  7527. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  7528. $(this).removeClass("ui-datepicker-prev-hover");
  7529. }
  7530. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  7531. $(this).removeClass("ui-datepicker-next-hover");
  7532. }
  7533. })
  7534. .delegate(selector, "mouseover", function(){
  7535. if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
  7536. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  7537. $(this).addClass("ui-state-hover");
  7538. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  7539. $(this).addClass("ui-datepicker-prev-hover");
  7540. }
  7541. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  7542. $(this).addClass("ui-datepicker-next-hover");
  7543. }
  7544. }
  7545. });
  7546. }
  7547. /* jQuery extend now ignores nulls! */
  7548. function extendRemove(target, props) {
  7549. $.extend(target, props);
  7550. for (var name in props) {
  7551. if (props[name] == null) {
  7552. target[name] = props[name];
  7553. }
  7554. }
  7555. return target;
  7556. }
  7557. /* Invoke the datepicker functionality.
  7558. @param options string - a command, optionally followed by additional parameters or
  7559. Object - settings for attaching new datepicker functionality
  7560. @return jQuery object */
  7561. $.fn.datepicker = function(options){
  7562. /* Verify an empty collection wasn't passed - Fixes #6976 */
  7563. if ( !this.length ) {
  7564. return this;
  7565. }
  7566. /* Initialise the date picker. */
  7567. if (!$.datepicker.initialized) {
  7568. $(document).mousedown($.datepicker._checkExternalClick);
  7569. $.datepicker.initialized = true;
  7570. }
  7571. /* Append datepicker main container to body if not exist. */
  7572. if ($("#"+$.datepicker._mainDivId).length === 0) {
  7573. $("body").append($.datepicker.dpDiv);
  7574. }
  7575. var otherArgs = Array.prototype.slice.call(arguments, 1);
  7576. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  7577. return $.datepicker["_" + options + "Datepicker"].
  7578. apply($.datepicker, [this[0]].concat(otherArgs));
  7579. }
  7580. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  7581. return $.datepicker["_" + options + "Datepicker"].
  7582. apply($.datepicker, [this[0]].concat(otherArgs));
  7583. }
  7584. return this.each(function() {
  7585. typeof options === "string" ?
  7586. $.datepicker["_" + options + "Datepicker"].
  7587. apply($.datepicker, [this].concat(otherArgs)) :
  7588. $.datepicker._attachDatepicker(this, options);
  7589. });
  7590. };
  7591. $.datepicker = new Datepicker(); // singleton instance
  7592. $.datepicker.initialized = false;
  7593. $.datepicker.uuid = new Date().getTime();
  7594. $.datepicker.version = "1.10.4";
  7595. })(jQuery);
  7596. (function( $, undefined ) {
  7597. var sizeRelatedOptions = {
  7598. buttons: true,
  7599. height: true,
  7600. maxHeight: true,
  7601. maxWidth: true,
  7602. minHeight: true,
  7603. minWidth: true,
  7604. width: true
  7605. },
  7606. resizableRelatedOptions = {
  7607. maxHeight: true,
  7608. maxWidth: true,
  7609. minHeight: true,
  7610. minWidth: true
  7611. };
  7612. $.widget( "ui.dialog", {
  7613. version: "1.10.4",
  7614. options: {
  7615. appendTo: "body",
  7616. autoOpen: true,
  7617. buttons: [],
  7618. closeOnEscape: true,
  7619. closeText: "close",
  7620. dialogClass: "",
  7621. draggable: true,
  7622. hide: null,
  7623. height: "auto",
  7624. maxHeight: null,
  7625. maxWidth: null,
  7626. minHeight: 150,
  7627. minWidth: 150,
  7628. modal: false,
  7629. position: {
  7630. my: "center",
  7631. at: "center",
  7632. of: window,
  7633. collision: "fit",
  7634. // Ensure the titlebar is always visible
  7635. using: function( pos ) {
  7636. var topOffset = $( this ).css( pos ).offset().top;
  7637. if ( topOffset < 0 ) {
  7638. $( this ).css( "top", pos.top - topOffset );
  7639. }
  7640. }
  7641. },
  7642. resizable: true,
  7643. show: null,
  7644. title: null,
  7645. width: 300,
  7646. // callbacks
  7647. beforeClose: null,
  7648. close: null,
  7649. drag: null,
  7650. dragStart: null,
  7651. dragStop: null,
  7652. focus: null,
  7653. open: null,
  7654. resize: null,
  7655. resizeStart: null,
  7656. resizeStop: null
  7657. },
  7658. _create: function() {
  7659. this.originalCss = {
  7660. display: this.element[0].style.display,
  7661. width: this.element[0].style.width,
  7662. minHeight: this.element[0].style.minHeight,
  7663. maxHeight: this.element[0].style.maxHeight,
  7664. height: this.element[0].style.height
  7665. };
  7666. this.originalPosition = {
  7667. parent: this.element.parent(),
  7668. index: this.element.parent().children().index( this.element )
  7669. };
  7670. this.originalTitle = this.element.attr("title");
  7671. this.options.title = this.options.title || this.originalTitle;
  7672. this._createWrapper();
  7673. this.element
  7674. .show()
  7675. .removeAttr("title")
  7676. .addClass("ui-dialog-content ui-widget-content")
  7677. .appendTo( this.uiDialog );
  7678. this._createTitlebar();
  7679. this._createButtonPane();
  7680. if ( this.options.draggable && $.fn.draggable ) {
  7681. this._makeDraggable();
  7682. }
  7683. if ( this.options.resizable && $.fn.resizable ) {
  7684. this._makeResizable();
  7685. }
  7686. this._isOpen = false;
  7687. },
  7688. _init: function() {
  7689. if ( this.options.autoOpen ) {
  7690. this.open();
  7691. }
  7692. },
  7693. _appendTo: function() {
  7694. var element = this.options.appendTo;
  7695. if ( element && (element.jquery || element.nodeType) ) {
  7696. return $( element );
  7697. }
  7698. return this.document.find( element || "body" ).eq( 0 );
  7699. },
  7700. _destroy: function() {
  7701. var next,
  7702. originalPosition = this.originalPosition;
  7703. this._destroyOverlay();
  7704. this.element
  7705. .removeUniqueId()
  7706. .removeClass("ui-dialog-content ui-widget-content")
  7707. .css( this.originalCss )
  7708. // Without detaching first, the following becomes really slow
  7709. .detach();
  7710. this.uiDialog.stop( true, true ).remove();
  7711. if ( this.originalTitle ) {
  7712. this.element.attr( "title", this.originalTitle );
  7713. }
  7714. next = originalPosition.parent.children().eq( originalPosition.index );
  7715. // Don't try to place the dialog next to itself (#8613)
  7716. if ( next.length && next[0] !== this.element[0] ) {
  7717. next.before( this.element );
  7718. } else {
  7719. originalPosition.parent.append( this.element );
  7720. }
  7721. },
  7722. widget: function() {
  7723. return this.uiDialog;
  7724. },
  7725. disable: $.noop,
  7726. enable: $.noop,
  7727. close: function( event ) {
  7728. var activeElement,
  7729. that = this;
  7730. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  7731. return;
  7732. }
  7733. this._isOpen = false;
  7734. this._destroyOverlay();
  7735. if ( !this.opener.filter(":focusable").focus().length ) {
  7736. // support: IE9
  7737. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  7738. try {
  7739. activeElement = this.document[ 0 ].activeElement;
  7740. // Support: IE9, IE10
  7741. // If the <body> is blurred, IE will switch windows, see #4520
  7742. if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {
  7743. // Hiding a focused element doesn't trigger blur in WebKit
  7744. // so in case we have nothing to focus on, explicitly blur the active element
  7745. // https://bugs.webkit.org/show_bug.cgi?id=47182
  7746. $( activeElement ).blur();
  7747. }
  7748. } catch ( error ) {}
  7749. }
  7750. this._hide( this.uiDialog, this.options.hide, function() {
  7751. that._trigger( "close", event );
  7752. });
  7753. },
  7754. isOpen: function() {
  7755. return this._isOpen;
  7756. },
  7757. moveToTop: function() {
  7758. this._moveToTop();
  7759. },
  7760. _moveToTop: function( event, silent ) {
  7761. var moved = !!this.uiDialog.nextAll(":visible").insertBefore( this.uiDialog ).length;
  7762. if ( moved && !silent ) {
  7763. this._trigger( "focus", event );
  7764. }
  7765. return moved;
  7766. },
  7767. open: function() {
  7768. var that = this;
  7769. if ( this._isOpen ) {
  7770. if ( this._moveToTop() ) {
  7771. this._focusTabbable();
  7772. }
  7773. return;
  7774. }
  7775. this._isOpen = true;
  7776. this.opener = $( this.document[0].activeElement );
  7777. this._size();
  7778. this._position();
  7779. this._createOverlay();
  7780. this._moveToTop( null, true );
  7781. this._show( this.uiDialog, this.options.show, function() {
  7782. that._focusTabbable();
  7783. that._trigger("focus");
  7784. });
  7785. this._trigger("open");
  7786. },
  7787. _focusTabbable: function() {
  7788. // Set focus to the first match:
  7789. // 1. First element inside the dialog matching [autofocus]
  7790. // 2. Tabbable element inside the content element
  7791. // 3. Tabbable element inside the buttonpane
  7792. // 4. The close button
  7793. // 5. The dialog itself
  7794. var hasFocus = this.element.find("[autofocus]");
  7795. if ( !hasFocus.length ) {
  7796. hasFocus = this.element.find(":tabbable");
  7797. }
  7798. if ( !hasFocus.length ) {
  7799. hasFocus = this.uiDialogButtonPane.find(":tabbable");
  7800. }
  7801. if ( !hasFocus.length ) {
  7802. hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
  7803. }
  7804. if ( !hasFocus.length ) {
  7805. hasFocus = this.uiDialog;
  7806. }
  7807. hasFocus.eq( 0 ).focus();
  7808. },
  7809. _keepFocus: function( event ) {
  7810. function checkFocus() {
  7811. var activeElement = this.document[0].activeElement,
  7812. isActive = this.uiDialog[0] === activeElement ||
  7813. $.contains( this.uiDialog[0], activeElement );
  7814. if ( !isActive ) {
  7815. this._focusTabbable();
  7816. }
  7817. }
  7818. event.preventDefault();
  7819. checkFocus.call( this );
  7820. // support: IE
  7821. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  7822. // so we check again later
  7823. this._delay( checkFocus );
  7824. },
  7825. _createWrapper: function() {
  7826. this.uiDialog = $("<div>")
  7827. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  7828. this.options.dialogClass )
  7829. .hide()
  7830. .attr({
  7831. // Setting tabIndex makes the div focusable
  7832. tabIndex: -1,
  7833. role: "dialog"
  7834. })
  7835. .appendTo( this._appendTo() );
  7836. this._on( this.uiDialog, {
  7837. keydown: function( event ) {
  7838. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  7839. event.keyCode === $.ui.keyCode.ESCAPE ) {
  7840. event.preventDefault();
  7841. this.close( event );
  7842. return;
  7843. }
  7844. // prevent tabbing out of dialogs
  7845. if ( event.keyCode !== $.ui.keyCode.TAB ) {
  7846. return;
  7847. }
  7848. var tabbables = this.uiDialog.find(":tabbable"),
  7849. first = tabbables.filter(":first"),
  7850. last = tabbables.filter(":last");
  7851. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  7852. first.focus( 1 );
  7853. event.preventDefault();
  7854. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  7855. last.focus( 1 );
  7856. event.preventDefault();
  7857. }
  7858. },
  7859. mousedown: function( event ) {
  7860. if ( this._moveToTop( event ) ) {
  7861. this._focusTabbable();
  7862. }
  7863. }
  7864. });
  7865. // We assume that any existing aria-describedby attribute means
  7866. // that the dialog content is marked up properly
  7867. // otherwise we brute force the content as the description
  7868. if ( !this.element.find("[aria-describedby]").length ) {
  7869. this.uiDialog.attr({
  7870. "aria-describedby": this.element.uniqueId().attr("id")
  7871. });
  7872. }
  7873. },
  7874. _createTitlebar: function() {
  7875. var uiDialogTitle;
  7876. this.uiDialogTitlebar = $("<div>")
  7877. .addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix")
  7878. .prependTo( this.uiDialog );
  7879. this._on( this.uiDialogTitlebar, {
  7880. mousedown: function( event ) {
  7881. // Don't prevent click on close button (#8838)
  7882. // Focusing a dialog that is partially scrolled out of view
  7883. // causes the browser to scroll it into view, preventing the click event
  7884. if ( !$( event.target ).closest(".ui-dialog-titlebar-close") ) {
  7885. // Dialog isn't getting focus when dragging (#8063)
  7886. this.uiDialog.focus();
  7887. }
  7888. }
  7889. });
  7890. // support: IE
  7891. // Use type="button" to prevent enter keypresses in textboxes from closing the
  7892. // dialog in IE (#9312)
  7893. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  7894. .button({
  7895. label: this.options.closeText,
  7896. icons: {
  7897. primary: "ui-icon-closethick"
  7898. },
  7899. text: false
  7900. })
  7901. .addClass("ui-dialog-titlebar-close")
  7902. .appendTo( this.uiDialogTitlebar );
  7903. this._on( this.uiDialogTitlebarClose, {
  7904. click: function( event ) {
  7905. event.preventDefault();
  7906. this.close( event );
  7907. }
  7908. });
  7909. uiDialogTitle = $("<span>")
  7910. .uniqueId()
  7911. .addClass("ui-dialog-title")
  7912. .prependTo( this.uiDialogTitlebar );
  7913. this._title( uiDialogTitle );
  7914. this.uiDialog.attr({
  7915. "aria-labelledby": uiDialogTitle.attr("id")
  7916. });
  7917. },
  7918. _title: function( title ) {
  7919. if ( !this.options.title ) {
  7920. title.html("&#160;");
  7921. }
  7922. title.text( this.options.title );
  7923. },
  7924. _createButtonPane: function() {
  7925. this.uiDialogButtonPane = $("<div>")
  7926. .addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");
  7927. this.uiButtonSet = $("<div>")
  7928. .addClass("ui-dialog-buttonset")
  7929. .appendTo( this.uiDialogButtonPane );
  7930. this._createButtons();
  7931. },
  7932. _createButtons: function() {
  7933. var that = this,
  7934. buttons = this.options.buttons;
  7935. // if we already have a button pane, remove it
  7936. this.uiDialogButtonPane.remove();
  7937. this.uiButtonSet.empty();
  7938. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  7939. this.uiDialog.removeClass("ui-dialog-buttons");
  7940. return;
  7941. }
  7942. $.each( buttons, function( name, props ) {
  7943. var click, buttonOptions;
  7944. props = $.isFunction( props ) ?
  7945. { click: props, text: name } :
  7946. props;
  7947. // Default to a non-submitting button
  7948. props = $.extend( { type: "button" }, props );
  7949. // Change the context for the click callback to be the main element
  7950. click = props.click;
  7951. props.click = function() {
  7952. click.apply( that.element[0], arguments );
  7953. };
  7954. buttonOptions = {
  7955. icons: props.icons,
  7956. text: props.showText
  7957. };
  7958. delete props.icons;
  7959. delete props.showText;
  7960. $( "<button></button>", props )
  7961. .button( buttonOptions )
  7962. .appendTo( that.uiButtonSet );
  7963. });
  7964. this.uiDialog.addClass("ui-dialog-buttons");
  7965. this.uiDialogButtonPane.appendTo( this.uiDialog );
  7966. },
  7967. _makeDraggable: function() {
  7968. var that = this,
  7969. options = this.options;
  7970. function filteredUi( ui ) {
  7971. return {
  7972. position: ui.position,
  7973. offset: ui.offset
  7974. };
  7975. }
  7976. this.uiDialog.draggable({
  7977. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  7978. handle: ".ui-dialog-titlebar",
  7979. containment: "document",
  7980. start: function( event, ui ) {
  7981. $( this ).addClass("ui-dialog-dragging");
  7982. that._blockFrames();
  7983. that._trigger( "dragStart", event, filteredUi( ui ) );
  7984. },
  7985. drag: function( event, ui ) {
  7986. that._trigger( "drag", event, filteredUi( ui ) );
  7987. },
  7988. stop: function( event, ui ) {
  7989. options.position = [
  7990. ui.position.left - that.document.scrollLeft(),
  7991. ui.position.top - that.document.scrollTop()
  7992. ];
  7993. $( this ).removeClass("ui-dialog-dragging");
  7994. that._unblockFrames();
  7995. that._trigger( "dragStop", event, filteredUi( ui ) );
  7996. }
  7997. });
  7998. },
  7999. _makeResizable: function() {
  8000. var that = this,
  8001. options = this.options,
  8002. handles = options.resizable,
  8003. // .ui-resizable has position: relative defined in the stylesheet
  8004. // but dialogs have to use absolute or fixed positioning
  8005. position = this.uiDialog.css("position"),
  8006. resizeHandles = typeof handles === "string" ?
  8007. handles :
  8008. "n,e,s,w,se,sw,ne,nw";
  8009. function filteredUi( ui ) {
  8010. return {
  8011. originalPosition: ui.originalPosition,
  8012. originalSize: ui.originalSize,
  8013. position: ui.position,
  8014. size: ui.size
  8015. };
  8016. }
  8017. this.uiDialog.resizable({
  8018. cancel: ".ui-dialog-content",
  8019. containment: "document",
  8020. alsoResize: this.element,
  8021. maxWidth: options.maxWidth,
  8022. maxHeight: options.maxHeight,
  8023. minWidth: options.minWidth,
  8024. minHeight: this._minHeight(),
  8025. handles: resizeHandles,
  8026. start: function( event, ui ) {
  8027. $( this ).addClass("ui-dialog-resizing");
  8028. that._blockFrames();
  8029. that._trigger( "resizeStart", event, filteredUi( ui ) );
  8030. },
  8031. resize: function( event, ui ) {
  8032. that._trigger( "resize", event, filteredUi( ui ) );
  8033. },
  8034. stop: function( event, ui ) {
  8035. options.height = $( this ).height();
  8036. options.width = $( this ).width();
  8037. $( this ).removeClass("ui-dialog-resizing");
  8038. that._unblockFrames();
  8039. that._trigger( "resizeStop", event, filteredUi( ui ) );
  8040. }
  8041. })
  8042. .css( "position", position );
  8043. },
  8044. _minHeight: function() {
  8045. var options = this.options;
  8046. return options.height === "auto" ?
  8047. options.minHeight :
  8048. Math.min( options.minHeight, options.height );
  8049. },
  8050. _position: function() {
  8051. // Need to show the dialog to get the actual offset in the position plugin
  8052. var isVisible = this.uiDialog.is(":visible");
  8053. if ( !isVisible ) {
  8054. this.uiDialog.show();
  8055. }
  8056. this.uiDialog.position( this.options.position );
  8057. if ( !isVisible ) {
  8058. this.uiDialog.hide();
  8059. }
  8060. },
  8061. _setOptions: function( options ) {
  8062. var that = this,
  8063. resize = false,
  8064. resizableOptions = {};
  8065. $.each( options, function( key, value ) {
  8066. that._setOption( key, value );
  8067. if ( key in sizeRelatedOptions ) {
  8068. resize = true;
  8069. }
  8070. if ( key in resizableRelatedOptions ) {
  8071. resizableOptions[ key ] = value;
  8072. }
  8073. });
  8074. if ( resize ) {
  8075. this._size();
  8076. this._position();
  8077. }
  8078. if ( this.uiDialog.is(":data(ui-resizable)") ) {
  8079. this.uiDialog.resizable( "option", resizableOptions );
  8080. }
  8081. },
  8082. _setOption: function( key, value ) {
  8083. var isDraggable, isResizable,
  8084. uiDialog = this.uiDialog;
  8085. if ( key === "dialogClass" ) {
  8086. uiDialog
  8087. .removeClass( this.options.dialogClass )
  8088. .addClass( value );
  8089. }
  8090. if ( key === "disabled" ) {
  8091. return;
  8092. }
  8093. this._super( key, value );
  8094. if ( key === "appendTo" ) {
  8095. this.uiDialog.appendTo( this._appendTo() );
  8096. }
  8097. if ( key === "buttons" ) {
  8098. this._createButtons();
  8099. }
  8100. if ( key === "closeText" ) {
  8101. this.uiDialogTitlebarClose.button({
  8102. // Ensure that we always pass a string
  8103. label: "" + value
  8104. });
  8105. }
  8106. if ( key === "draggable" ) {
  8107. isDraggable = uiDialog.is(":data(ui-draggable)");
  8108. if ( isDraggable && !value ) {
  8109. uiDialog.draggable("destroy");
  8110. }
  8111. if ( !isDraggable && value ) {
  8112. this._makeDraggable();
  8113. }
  8114. }
  8115. if ( key === "position" ) {
  8116. this._position();
  8117. }
  8118. if ( key === "resizable" ) {
  8119. // currently resizable, becoming non-resizable
  8120. isResizable = uiDialog.is(":data(ui-resizable)");
  8121. if ( isResizable && !value ) {
  8122. uiDialog.resizable("destroy");
  8123. }
  8124. // currently resizable, changing handles
  8125. if ( isResizable && typeof value === "string" ) {
  8126. uiDialog.resizable( "option", "handles", value );
  8127. }
  8128. // currently non-resizable, becoming resizable
  8129. if ( !isResizable && value !== false ) {
  8130. this._makeResizable();
  8131. }
  8132. }
  8133. if ( key === "title" ) {
  8134. this._title( this.uiDialogTitlebar.find(".ui-dialog-title") );
  8135. }
  8136. },
  8137. _size: function() {
  8138. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  8139. // divs will both have width and height set, so we need to reset them
  8140. var nonContentHeight, minContentHeight, maxContentHeight,
  8141. options = this.options;
  8142. // Reset content sizing
  8143. this.element.show().css({
  8144. width: "auto",
  8145. minHeight: 0,
  8146. maxHeight: "none",
  8147. height: 0
  8148. });
  8149. if ( options.minWidth > options.width ) {
  8150. options.width = options.minWidth;
  8151. }
  8152. // reset wrapper sizing
  8153. // determine the height of all the non-content elements
  8154. nonContentHeight = this.uiDialog.css({
  8155. height: "auto",
  8156. width: options.width
  8157. })
  8158. .outerHeight();
  8159. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  8160. maxContentHeight = typeof options.maxHeight === "number" ?
  8161. Math.max( 0, options.maxHeight - nonContentHeight ) :
  8162. "none";
  8163. if ( options.height === "auto" ) {
  8164. this.element.css({
  8165. minHeight: minContentHeight,
  8166. maxHeight: maxContentHeight,
  8167. height: "auto"
  8168. });
  8169. } else {
  8170. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  8171. }
  8172. if (this.uiDialog.is(":data(ui-resizable)") ) {
  8173. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  8174. }
  8175. },
  8176. _blockFrames: function() {
  8177. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  8178. var iframe = $( this );
  8179. return $( "<div>" )
  8180. .css({
  8181. position: "absolute",
  8182. width: iframe.outerWidth(),
  8183. height: iframe.outerHeight()
  8184. })
  8185. .appendTo( iframe.parent() )
  8186. .offset( iframe.offset() )[0];
  8187. });
  8188. },
  8189. _unblockFrames: function() {
  8190. if ( this.iframeBlocks ) {
  8191. this.iframeBlocks.remove();
  8192. delete this.iframeBlocks;
  8193. }
  8194. },
  8195. _allowInteraction: function( event ) {
  8196. if ( $( event.target ).closest(".ui-dialog").length ) {
  8197. return true;
  8198. }
  8199. // TODO: Remove hack when datepicker implements
  8200. // the .ui-front logic (#8989)
  8201. return !!$( event.target ).closest(".ui-datepicker").length;
  8202. },
  8203. _createOverlay: function() {
  8204. if ( !this.options.modal ) {
  8205. return;
  8206. }
  8207. var that = this,
  8208. widgetFullName = this.widgetFullName;
  8209. if ( !$.ui.dialog.overlayInstances ) {
  8210. // Prevent use of anchors and inputs.
  8211. // We use a delay in case the overlay is created from an
  8212. // event that we're going to be cancelling. (#2804)
  8213. this._delay(function() {
  8214. // Handle .dialog().dialog("close") (#4065)
  8215. if ( $.ui.dialog.overlayInstances ) {
  8216. this.document.bind( "focusin.dialog", function( event ) {
  8217. if ( !that._allowInteraction( event ) ) {
  8218. event.preventDefault();
  8219. $(".ui-dialog:visible:last .ui-dialog-content")
  8220. .data( widgetFullName )._focusTabbable();
  8221. }
  8222. });
  8223. }
  8224. });
  8225. }
  8226. this.overlay = $("<div>")
  8227. .addClass("ui-widget-overlay ui-front")
  8228. .appendTo( this._appendTo() );
  8229. this._on( this.overlay, {
  8230. mousedown: "_keepFocus"
  8231. });
  8232. $.ui.dialog.overlayInstances++;
  8233. },
  8234. _destroyOverlay: function() {
  8235. if ( !this.options.modal ) {
  8236. return;
  8237. }
  8238. if ( this.overlay ) {
  8239. $.ui.dialog.overlayInstances--;
  8240. if ( !$.ui.dialog.overlayInstances ) {
  8241. this.document.unbind( "focusin.dialog" );
  8242. }
  8243. this.overlay.remove();
  8244. this.overlay = null;
  8245. }
  8246. }
  8247. });
  8248. $.ui.dialog.overlayInstances = 0;
  8249. // DEPRECATED
  8250. if ( $.uiBackCompat !== false ) {
  8251. // position option with array notation
  8252. // just override with old implementation
  8253. $.widget( "ui.dialog", $.ui.dialog, {
  8254. _position: function() {
  8255. var position = this.options.position,
  8256. myAt = [],
  8257. offset = [ 0, 0 ],
  8258. isVisible;
  8259. if ( position ) {
  8260. if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
  8261. myAt = position.split ? position.split(" ") : [ position[0], position[1] ];
  8262. if ( myAt.length === 1 ) {
  8263. myAt[1] = myAt[0];
  8264. }
  8265. $.each( [ "left", "top" ], function( i, offsetPosition ) {
  8266. if ( +myAt[ i ] === myAt[ i ] ) {
  8267. offset[ i ] = myAt[ i ];
  8268. myAt[ i ] = offsetPosition;
  8269. }
  8270. });
  8271. position = {
  8272. my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
  8273. myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
  8274. at: myAt.join(" ")
  8275. };
  8276. }
  8277. position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
  8278. } else {
  8279. position = $.ui.dialog.prototype.options.position;
  8280. }
  8281. // need to show the dialog to get the actual offset in the position plugin
  8282. isVisible = this.uiDialog.is(":visible");
  8283. if ( !isVisible ) {
  8284. this.uiDialog.show();
  8285. }
  8286. this.uiDialog.position( position );
  8287. if ( !isVisible ) {
  8288. this.uiDialog.hide();
  8289. }
  8290. }
  8291. });
  8292. }
  8293. }( jQuery ) );
  8294. (function( $, undefined ) {
  8295. $.widget( "ui.menu", {
  8296. version: "1.10.4",
  8297. defaultElement: "<ul>",
  8298. delay: 300,
  8299. options: {
  8300. icons: {
  8301. submenu: "ui-icon-carat-1-e"
  8302. },
  8303. menus: "ul",
  8304. position: {
  8305. my: "left top",
  8306. at: "right top"
  8307. },
  8308. role: "menu",
  8309. // callbacks
  8310. blur: null,
  8311. focus: null,
  8312. select: null
  8313. },
  8314. _create: function() {
  8315. this.activeMenu = this.element;
  8316. // flag used to prevent firing of the click handler
  8317. // as the event bubbles up through nested menus
  8318. this.mouseHandled = false;
  8319. this.element
  8320. .uniqueId()
  8321. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  8322. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  8323. .attr({
  8324. role: this.options.role,
  8325. tabIndex: 0
  8326. })
  8327. // need to catch all clicks on disabled menu
  8328. // not possible through _on
  8329. .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
  8330. if ( this.options.disabled ) {
  8331. event.preventDefault();
  8332. }
  8333. }, this ));
  8334. if ( this.options.disabled ) {
  8335. this.element
  8336. .addClass( "ui-state-disabled" )
  8337. .attr( "aria-disabled", "true" );
  8338. }
  8339. this._on({
  8340. // Prevent focus from sticking to links inside menu after clicking
  8341. // them (focus should always stay on UL during navigation).
  8342. "mousedown .ui-menu-item > a": function( event ) {
  8343. event.preventDefault();
  8344. },
  8345. "click .ui-state-disabled > a": function( event ) {
  8346. event.preventDefault();
  8347. },
  8348. "click .ui-menu-item:has(a)": function( event ) {
  8349. var target = $( event.target ).closest( ".ui-menu-item" );
  8350. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  8351. this.select( event );
  8352. // Only set the mouseHandled flag if the event will bubble, see #9469.
  8353. if ( !event.isPropagationStopped() ) {
  8354. this.mouseHandled = true;
  8355. }
  8356. // Open submenu on click
  8357. if ( target.has( ".ui-menu" ).length ) {
  8358. this.expand( event );
  8359. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  8360. // Redirect focus to the menu
  8361. this.element.trigger( "focus", [ true ] );
  8362. // If the active item is on the top level, let it stay active.
  8363. // Otherwise, blur the active item since it is no longer visible.
  8364. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  8365. clearTimeout( this.timer );
  8366. }
  8367. }
  8368. }
  8369. },
  8370. "mouseenter .ui-menu-item": function( event ) {
  8371. var target = $( event.currentTarget );
  8372. // Remove ui-state-active class from siblings of the newly focused menu item
  8373. // to avoid a jump caused by adjacent elements both having a class with a border
  8374. target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
  8375. this.focus( event, target );
  8376. },
  8377. mouseleave: "collapseAll",
  8378. "mouseleave .ui-menu": "collapseAll",
  8379. focus: function( event, keepActiveItem ) {
  8380. // If there's already an active item, keep it active
  8381. // If not, activate the first item
  8382. var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
  8383. if ( !keepActiveItem ) {
  8384. this.focus( event, item );
  8385. }
  8386. },
  8387. blur: function( event ) {
  8388. this._delay(function() {
  8389. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  8390. this.collapseAll( event );
  8391. }
  8392. });
  8393. },
  8394. keydown: "_keydown"
  8395. });
  8396. this.refresh();
  8397. // Clicks outside of a menu collapse any open menus
  8398. this._on( this.document, {
  8399. click: function( event ) {
  8400. if ( !$( event.target ).closest( ".ui-menu" ).length ) {
  8401. this.collapseAll( event );
  8402. }
  8403. // Reset the mouseHandled flag
  8404. this.mouseHandled = false;
  8405. }
  8406. });
  8407. },
  8408. _destroy: function() {
  8409. // Destroy (sub)menus
  8410. this.element
  8411. .removeAttr( "aria-activedescendant" )
  8412. .find( ".ui-menu" ).addBack()
  8413. .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
  8414. .removeAttr( "role" )
  8415. .removeAttr( "tabIndex" )
  8416. .removeAttr( "aria-labelledby" )
  8417. .removeAttr( "aria-expanded" )
  8418. .removeAttr( "aria-hidden" )
  8419. .removeAttr( "aria-disabled" )
  8420. .removeUniqueId()
  8421. .show();
  8422. // Destroy menu items
  8423. this.element.find( ".ui-menu-item" )
  8424. .removeClass( "ui-menu-item" )
  8425. .removeAttr( "role" )
  8426. .removeAttr( "aria-disabled" )
  8427. .children( "a" )
  8428. .removeUniqueId()
  8429. .removeClass( "ui-corner-all ui-state-hover" )
  8430. .removeAttr( "tabIndex" )
  8431. .removeAttr( "role" )
  8432. .removeAttr( "aria-haspopup" )
  8433. .children().each( function() {
  8434. var elem = $( this );
  8435. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  8436. elem.remove();
  8437. }
  8438. });
  8439. // Destroy menu dividers
  8440. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  8441. },
  8442. _keydown: function( event ) {
  8443. var match, prev, character, skip, regex,
  8444. preventDefault = true;
  8445. function escape( value ) {
  8446. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  8447. }
  8448. switch ( event.keyCode ) {
  8449. case $.ui.keyCode.PAGE_UP:
  8450. this.previousPage( event );
  8451. break;
  8452. case $.ui.keyCode.PAGE_DOWN:
  8453. this.nextPage( event );
  8454. break;
  8455. case $.ui.keyCode.HOME:
  8456. this._move( "first", "first", event );
  8457. break;
  8458. case $.ui.keyCode.END:
  8459. this._move( "last", "last", event );
  8460. break;
  8461. case $.ui.keyCode.UP:
  8462. this.previous( event );
  8463. break;
  8464. case $.ui.keyCode.DOWN:
  8465. this.next( event );
  8466. break;
  8467. case $.ui.keyCode.LEFT:
  8468. this.collapse( event );
  8469. break;
  8470. case $.ui.keyCode.RIGHT:
  8471. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  8472. this.expand( event );
  8473. }
  8474. break;
  8475. case $.ui.keyCode.ENTER:
  8476. case $.ui.keyCode.SPACE:
  8477. this._activate( event );
  8478. break;
  8479. case $.ui.keyCode.ESCAPE:
  8480. this.collapse( event );
  8481. break;
  8482. default:
  8483. preventDefault = false;
  8484. prev = this.previousFilter || "";
  8485. character = String.fromCharCode( event.keyCode );
  8486. skip = false;
  8487. clearTimeout( this.filterTimer );
  8488. if ( character === prev ) {
  8489. skip = true;
  8490. } else {
  8491. character = prev + character;
  8492. }
  8493. regex = new RegExp( "^" + escape( character ), "i" );
  8494. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  8495. return regex.test( $( this ).children( "a" ).text() );
  8496. });
  8497. match = skip && match.index( this.active.next() ) !== -1 ?
  8498. this.active.nextAll( ".ui-menu-item" ) :
  8499. match;
  8500. // If no matches on the current filter, reset to the last character pressed
  8501. // to move down the menu to the first item that starts with that character
  8502. if ( !match.length ) {
  8503. character = String.fromCharCode( event.keyCode );
  8504. regex = new RegExp( "^" + escape( character ), "i" );
  8505. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  8506. return regex.test( $( this ).children( "a" ).text() );
  8507. });
  8508. }
  8509. if ( match.length ) {
  8510. this.focus( event, match );
  8511. if ( match.length > 1 ) {
  8512. this.previousFilter = character;
  8513. this.filterTimer = this._delay(function() {
  8514. delete this.previousFilter;
  8515. }, 1000 );
  8516. } else {
  8517. delete this.previousFilter;
  8518. }
  8519. } else {
  8520. delete this.previousFilter;
  8521. }
  8522. }
  8523. if ( preventDefault ) {
  8524. event.preventDefault();
  8525. }
  8526. },
  8527. _activate: function( event ) {
  8528. if ( !this.active.is( ".ui-state-disabled" ) ) {
  8529. if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
  8530. this.expand( event );
  8531. } else {
  8532. this.select( event );
  8533. }
  8534. }
  8535. },
  8536. refresh: function() {
  8537. var menus,
  8538. icon = this.options.icons.submenu,
  8539. submenus = this.element.find( this.options.menus );
  8540. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  8541. // Initialize nested menus
  8542. submenus.filter( ":not(.ui-menu)" )
  8543. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  8544. .hide()
  8545. .attr({
  8546. role: this.options.role,
  8547. "aria-hidden": "true",
  8548. "aria-expanded": "false"
  8549. })
  8550. .each(function() {
  8551. var menu = $( this ),
  8552. item = menu.prev( "a" ),
  8553. submenuCarat = $( "<span>" )
  8554. .addClass( "ui-menu-icon ui-icon " + icon )
  8555. .data( "ui-menu-submenu-carat", true );
  8556. item
  8557. .attr( "aria-haspopup", "true" )
  8558. .prepend( submenuCarat );
  8559. menu.attr( "aria-labelledby", item.attr( "id" ) );
  8560. });
  8561. menus = submenus.add( this.element );
  8562. // Don't refresh list items that are already adapted
  8563. menus.children( ":not(.ui-menu-item):has(a)" )
  8564. .addClass( "ui-menu-item" )
  8565. .attr( "role", "presentation" )
  8566. .children( "a" )
  8567. .uniqueId()
  8568. .addClass( "ui-corner-all" )
  8569. .attr({
  8570. tabIndex: -1,
  8571. role: this._itemRole()
  8572. });
  8573. // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
  8574. menus.children( ":not(.ui-menu-item)" ).each(function() {
  8575. var item = $( this );
  8576. // hyphen, em dash, en dash
  8577. if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
  8578. item.addClass( "ui-widget-content ui-menu-divider" );
  8579. }
  8580. });
  8581. // Add aria-disabled attribute to any disabled menu item
  8582. menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  8583. // If the active item has been removed, blur the menu
  8584. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  8585. this.blur();
  8586. }
  8587. },
  8588. _itemRole: function() {
  8589. return {
  8590. menu: "menuitem",
  8591. listbox: "option"
  8592. }[ this.options.role ];
  8593. },
  8594. _setOption: function( key, value ) {
  8595. if ( key === "icons" ) {
  8596. this.element.find( ".ui-menu-icon" )
  8597. .removeClass( this.options.icons.submenu )
  8598. .addClass( value.submenu );
  8599. }
  8600. this._super( key, value );
  8601. },
  8602. focus: function( event, item ) {
  8603. var nested, focused;
  8604. this.blur( event, event && event.type === "focus" );
  8605. this._scrollIntoView( item );
  8606. this.active = item.first();
  8607. focused = this.active.children( "a" ).addClass( "ui-state-focus" );
  8608. // Only update aria-activedescendant if there's a role
  8609. // otherwise we assume focus is managed elsewhere
  8610. if ( this.options.role ) {
  8611. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  8612. }
  8613. // Highlight active parent menu item, if any
  8614. this.active
  8615. .parent()
  8616. .closest( ".ui-menu-item" )
  8617. .children( "a:first" )
  8618. .addClass( "ui-state-active" );
  8619. if ( event && event.type === "keydown" ) {
  8620. this._close();
  8621. } else {
  8622. this.timer = this._delay(function() {
  8623. this._close();
  8624. }, this.delay );
  8625. }
  8626. nested = item.children( ".ui-menu" );
  8627. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  8628. this._startOpening(nested);
  8629. }
  8630. this.activeMenu = item.parent();
  8631. this._trigger( "focus", event, { item: item } );
  8632. },
  8633. _scrollIntoView: function( item ) {
  8634. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  8635. if ( this._hasScroll() ) {
  8636. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  8637. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  8638. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  8639. scroll = this.activeMenu.scrollTop();
  8640. elementHeight = this.activeMenu.height();
  8641. itemHeight = item.height();
  8642. if ( offset < 0 ) {
  8643. this.activeMenu.scrollTop( scroll + offset );
  8644. } else if ( offset + itemHeight > elementHeight ) {
  8645. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  8646. }
  8647. }
  8648. },
  8649. blur: function( event, fromFocus ) {
  8650. if ( !fromFocus ) {
  8651. clearTimeout( this.timer );
  8652. }
  8653. if ( !this.active ) {
  8654. return;
  8655. }
  8656. this.active.children( "a" ).removeClass( "ui-state-focus" );
  8657. this.active = null;
  8658. this._trigger( "blur", event, { item: this.active } );
  8659. },
  8660. _startOpening: function( submenu ) {
  8661. clearTimeout( this.timer );
  8662. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  8663. // shift in the submenu position when mousing over the carat icon
  8664. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  8665. return;
  8666. }
  8667. this.timer = this._delay(function() {
  8668. this._close();
  8669. this._open( submenu );
  8670. }, this.delay );
  8671. },
  8672. _open: function( submenu ) {
  8673. var position = $.extend({
  8674. of: this.active
  8675. }, this.options.position );
  8676. clearTimeout( this.timer );
  8677. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  8678. .hide()
  8679. .attr( "aria-hidden", "true" );
  8680. submenu
  8681. .show()
  8682. .removeAttr( "aria-hidden" )
  8683. .attr( "aria-expanded", "true" )
  8684. .position( position );
  8685. },
  8686. collapseAll: function( event, all ) {
  8687. clearTimeout( this.timer );
  8688. this.timer = this._delay(function() {
  8689. // If we were passed an event, look for the submenu that contains the event
  8690. var currentMenu = all ? this.element :
  8691. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  8692. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  8693. if ( !currentMenu.length ) {
  8694. currentMenu = this.element;
  8695. }
  8696. this._close( currentMenu );
  8697. this.blur( event );
  8698. this.activeMenu = currentMenu;
  8699. }, this.delay );
  8700. },
  8701. // With no arguments, closes the currently active menu - if nothing is active
  8702. // it closes all menus. If passed an argument, it will search for menus BELOW
  8703. _close: function( startMenu ) {
  8704. if ( !startMenu ) {
  8705. startMenu = this.active ? this.active.parent() : this.element;
  8706. }
  8707. startMenu
  8708. .find( ".ui-menu" )
  8709. .hide()
  8710. .attr( "aria-hidden", "true" )
  8711. .attr( "aria-expanded", "false" )
  8712. .end()
  8713. .find( "a.ui-state-active" )
  8714. .removeClass( "ui-state-active" );
  8715. },
  8716. collapse: function( event ) {
  8717. var newItem = this.active &&
  8718. this.active.parent().closest( ".ui-menu-item", this.element );
  8719. if ( newItem && newItem.length ) {
  8720. this._close();
  8721. this.focus( event, newItem );
  8722. }
  8723. },
  8724. expand: function( event ) {
  8725. var newItem = this.active &&
  8726. this.active
  8727. .children( ".ui-menu " )
  8728. .children( ".ui-menu-item" )
  8729. .first();
  8730. if ( newItem && newItem.length ) {
  8731. this._open( newItem.parent() );
  8732. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  8733. this._delay(function() {
  8734. this.focus( event, newItem );
  8735. });
  8736. }
  8737. },
  8738. next: function( event ) {
  8739. this._move( "next", "first", event );
  8740. },
  8741. previous: function( event ) {
  8742. this._move( "prev", "last", event );
  8743. },
  8744. isFirstItem: function() {
  8745. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  8746. },
  8747. isLastItem: function() {
  8748. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  8749. },
  8750. _move: function( direction, filter, event ) {
  8751. var next;
  8752. if ( this.active ) {
  8753. if ( direction === "first" || direction === "last" ) {
  8754. next = this.active
  8755. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  8756. .eq( -1 );
  8757. } else {
  8758. next = this.active
  8759. [ direction + "All" ]( ".ui-menu-item" )
  8760. .eq( 0 );
  8761. }
  8762. }
  8763. if ( !next || !next.length || !this.active ) {
  8764. next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
  8765. }
  8766. this.focus( event, next );
  8767. },
  8768. nextPage: function( event ) {
  8769. var item, base, height;
  8770. if ( !this.active ) {
  8771. this.next( event );
  8772. return;
  8773. }
  8774. if ( this.isLastItem() ) {
  8775. return;
  8776. }
  8777. if ( this._hasScroll() ) {
  8778. base = this.active.offset().top;
  8779. height = this.element.height();
  8780. this.active.nextAll( ".ui-menu-item" ).each(function() {
  8781. item = $( this );
  8782. return item.offset().top - base - height < 0;
  8783. });
  8784. this.focus( event, item );
  8785. } else {
  8786. this.focus( event, this.activeMenu.children( ".ui-menu-item" )
  8787. [ !this.active ? "first" : "last" ]() );
  8788. }
  8789. },
  8790. previousPage: function( event ) {
  8791. var item, base, height;
  8792. if ( !this.active ) {
  8793. this.next( event );
  8794. return;
  8795. }
  8796. if ( this.isFirstItem() ) {
  8797. return;
  8798. }
  8799. if ( this._hasScroll() ) {
  8800. base = this.active.offset().top;
  8801. height = this.element.height();
  8802. this.active.prevAll( ".ui-menu-item" ).each(function() {
  8803. item = $( this );
  8804. return item.offset().top - base + height > 0;
  8805. });
  8806. this.focus( event, item );
  8807. } else {
  8808. this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
  8809. }
  8810. },
  8811. _hasScroll: function() {
  8812. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  8813. },
  8814. select: function( event ) {
  8815. // TODO: It should never be possible to not have an active item at this
  8816. // point, but the tests don't trigger mouseenter before click.
  8817. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  8818. var ui = { item: this.active };
  8819. if ( !this.active.has( ".ui-menu" ).length ) {
  8820. this.collapseAll( event, true );
  8821. }
  8822. this._trigger( "select", event, ui );
  8823. }
  8824. });
  8825. }( jQuery ));
  8826. (function( $, undefined ) {
  8827. $.widget( "ui.progressbar", {
  8828. version: "1.10.4",
  8829. options: {
  8830. max: 100,
  8831. value: 0,
  8832. change: null,
  8833. complete: null
  8834. },
  8835. min: 0,
  8836. _create: function() {
  8837. // Constrain initial value
  8838. this.oldValue = this.options.value = this._constrainedValue();
  8839. this.element
  8840. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8841. .attr({
  8842. // Only set static values, aria-valuenow and aria-valuemax are
  8843. // set inside _refreshValue()
  8844. role: "progressbar",
  8845. "aria-valuemin": this.min
  8846. });
  8847. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  8848. .appendTo( this.element );
  8849. this._refreshValue();
  8850. },
  8851. _destroy: function() {
  8852. this.element
  8853. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8854. .removeAttr( "role" )
  8855. .removeAttr( "aria-valuemin" )
  8856. .removeAttr( "aria-valuemax" )
  8857. .removeAttr( "aria-valuenow" );
  8858. this.valueDiv.remove();
  8859. },
  8860. value: function( newValue ) {
  8861. if ( newValue === undefined ) {
  8862. return this.options.value;
  8863. }
  8864. this.options.value = this._constrainedValue( newValue );
  8865. this._refreshValue();
  8866. },
  8867. _constrainedValue: function( newValue ) {
  8868. if ( newValue === undefined ) {
  8869. newValue = this.options.value;
  8870. }
  8871. this.indeterminate = newValue === false;
  8872. // sanitize value
  8873. if ( typeof newValue !== "number" ) {
  8874. newValue = 0;
  8875. }
  8876. return this.indeterminate ? false :
  8877. Math.min( this.options.max, Math.max( this.min, newValue ) );
  8878. },
  8879. _setOptions: function( options ) {
  8880. // Ensure "value" option is set after other values (like max)
  8881. var value = options.value;
  8882. delete options.value;
  8883. this._super( options );
  8884. this.options.value = this._constrainedValue( value );
  8885. this._refreshValue();
  8886. },
  8887. _setOption: function( key, value ) {
  8888. if ( key === "max" ) {
  8889. // Don't allow a max less than min
  8890. value = Math.max( this.min, value );
  8891. }
  8892. this._super( key, value );
  8893. },
  8894. _percentage: function() {
  8895. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  8896. },
  8897. _refreshValue: function() {
  8898. var value = this.options.value,
  8899. percentage = this._percentage();
  8900. this.valueDiv
  8901. .toggle( this.indeterminate || value > this.min )
  8902. .toggleClass( "ui-corner-right", value === this.options.max )
  8903. .width( percentage.toFixed(0) + "%" );
  8904. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  8905. if ( this.indeterminate ) {
  8906. this.element.removeAttr( "aria-valuenow" );
  8907. if ( !this.overlayDiv ) {
  8908. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  8909. }
  8910. } else {
  8911. this.element.attr({
  8912. "aria-valuemax": this.options.max,
  8913. "aria-valuenow": value
  8914. });
  8915. if ( this.overlayDiv ) {
  8916. this.overlayDiv.remove();
  8917. this.overlayDiv = null;
  8918. }
  8919. }
  8920. if ( this.oldValue !== value ) {
  8921. this.oldValue = value;
  8922. this._trigger( "change" );
  8923. }
  8924. if ( value === this.options.max ) {
  8925. this._trigger( "complete" );
  8926. }
  8927. }
  8928. });
  8929. })( jQuery );
  8930. (function( $, undefined ) {
  8931. // number of pages in a slider
  8932. // (how many times can you page up/down to go through the whole range)
  8933. var numPages = 5;
  8934. $.widget( "ui.slider", $.ui.mouse, {
  8935. version: "1.10.4",
  8936. widgetEventPrefix: "slide",
  8937. options: {
  8938. animate: false,
  8939. distance: 0,
  8940. max: 100,
  8941. min: 0,
  8942. orientation: "horizontal",
  8943. range: false,
  8944. step: 1,
  8945. value: 0,
  8946. values: null,
  8947. // callbacks
  8948. change: null,
  8949. slide: null,
  8950. start: null,
  8951. stop: null
  8952. },
  8953. _create: function() {
  8954. this._keySliding = false;
  8955. this._mouseSliding = false;
  8956. this._animateOff = true;
  8957. this._handleIndex = null;
  8958. this._detectOrientation();
  8959. this._mouseInit();
  8960. this.element
  8961. .addClass( "ui-slider" +
  8962. " ui-slider-" + this.orientation +
  8963. " ui-widget" +
  8964. " ui-widget-content" +
  8965. " ui-corner-all");
  8966. this._refresh();
  8967. this._setOption( "disabled", this.options.disabled );
  8968. this._animateOff = false;
  8969. },
  8970. _refresh: function() {
  8971. this._createRange();
  8972. this._createHandles();
  8973. this._setupEvents();
  8974. this._refreshValue();
  8975. },
  8976. _createHandles: function() {
  8977. var i, handleCount,
  8978. options = this.options,
  8979. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  8980. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  8981. handles = [];
  8982. handleCount = ( options.values && options.values.length ) || 1;
  8983. if ( existingHandles.length > handleCount ) {
  8984. existingHandles.slice( handleCount ).remove();
  8985. existingHandles = existingHandles.slice( 0, handleCount );
  8986. }
  8987. for ( i = existingHandles.length; i < handleCount; i++ ) {
  8988. handles.push( handle );
  8989. }
  8990. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  8991. this.handle = this.handles.eq( 0 );
  8992. this.handles.each(function( i ) {
  8993. $( this ).data( "ui-slider-handle-index", i );
  8994. });
  8995. },
  8996. _createRange: function() {
  8997. var options = this.options,
  8998. classes = "";
  8999. if ( options.range ) {
  9000. if ( options.range === true ) {
  9001. if ( !options.values ) {
  9002. options.values = [ this._valueMin(), this._valueMin() ];
  9003. } else if ( options.values.length && options.values.length !== 2 ) {
  9004. options.values = [ options.values[0], options.values[0] ];
  9005. } else if ( $.isArray( options.values ) ) {
  9006. options.values = options.values.slice(0);
  9007. }
  9008. }
  9009. if ( !this.range || !this.range.length ) {
  9010. this.range = $( "<div></div>" )
  9011. .appendTo( this.element );
  9012. classes = "ui-slider-range" +
  9013. // note: this isn't the most fittingly semantic framework class for this element,
  9014. // but worked best visually with a variety of themes
  9015. " ui-widget-header ui-corner-all";
  9016. } else {
  9017. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  9018. // Handle range switching from true to min/max
  9019. .css({
  9020. "left": "",
  9021. "bottom": ""
  9022. });
  9023. }
  9024. this.range.addClass( classes +
  9025. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  9026. } else {
  9027. if ( this.range ) {
  9028. this.range.remove();
  9029. }
  9030. this.range = null;
  9031. }
  9032. },
  9033. _setupEvents: function() {
  9034. var elements = this.handles.add( this.range ).filter( "a" );
  9035. this._off( elements );
  9036. this._on( elements, this._handleEvents );
  9037. this._hoverable( elements );
  9038. this._focusable( elements );
  9039. },
  9040. _destroy: function() {
  9041. this.handles.remove();
  9042. if ( this.range ) {
  9043. this.range.remove();
  9044. }
  9045. this.element
  9046. .removeClass( "ui-slider" +
  9047. " ui-slider-horizontal" +
  9048. " ui-slider-vertical" +
  9049. " ui-widget" +
  9050. " ui-widget-content" +
  9051. " ui-corner-all" );
  9052. this._mouseDestroy();
  9053. },
  9054. _mouseCapture: function( event ) {
  9055. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  9056. that = this,
  9057. o = this.options;
  9058. if ( o.disabled ) {
  9059. return false;
  9060. }
  9061. this.elementSize = {
  9062. width: this.element.outerWidth(),
  9063. height: this.element.outerHeight()
  9064. };
  9065. this.elementOffset = this.element.offset();
  9066. position = { x: event.pageX, y: event.pageY };
  9067. normValue = this._normValueFromMouse( position );
  9068. distance = this._valueMax() - this._valueMin() + 1;
  9069. this.handles.each(function( i ) {
  9070. var thisDistance = Math.abs( normValue - that.values(i) );
  9071. if (( distance > thisDistance ) ||
  9072. ( distance === thisDistance &&
  9073. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  9074. distance = thisDistance;
  9075. closestHandle = $( this );
  9076. index = i;
  9077. }
  9078. });
  9079. allowed = this._start( event, index );
  9080. if ( allowed === false ) {
  9081. return false;
  9082. }
  9083. this._mouseSliding = true;
  9084. this._handleIndex = index;
  9085. closestHandle
  9086. .addClass( "ui-state-active" )
  9087. .focus();
  9088. offset = closestHandle.offset();
  9089. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  9090. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  9091. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  9092. top: event.pageY - offset.top -
  9093. ( closestHandle.height() / 2 ) -
  9094. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  9095. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  9096. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  9097. };
  9098. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  9099. this._slide( event, index, normValue );
  9100. }
  9101. this._animateOff = true;
  9102. return true;
  9103. },
  9104. _mouseStart: function() {
  9105. return true;
  9106. },
  9107. _mouseDrag: function( event ) {
  9108. var position = { x: event.pageX, y: event.pageY },
  9109. normValue = this._normValueFromMouse( position );
  9110. this._slide( event, this._handleIndex, normValue );
  9111. return false;
  9112. },
  9113. _mouseStop: function( event ) {
  9114. this.handles.removeClass( "ui-state-active" );
  9115. this._mouseSliding = false;
  9116. this._stop( event, this._handleIndex );
  9117. this._change( event, this._handleIndex );
  9118. this._handleIndex = null;
  9119. this._clickOffset = null;
  9120. this._animateOff = false;
  9121. return false;
  9122. },
  9123. _detectOrientation: function() {
  9124. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  9125. },
  9126. _normValueFromMouse: function( position ) {
  9127. var pixelTotal,
  9128. pixelMouse,
  9129. percentMouse,
  9130. valueTotal,
  9131. valueMouse;
  9132. if ( this.orientation === "horizontal" ) {
  9133. pixelTotal = this.elementSize.width;
  9134. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  9135. } else {
  9136. pixelTotal = this.elementSize.height;
  9137. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  9138. }
  9139. percentMouse = ( pixelMouse / pixelTotal );
  9140. if ( percentMouse > 1 ) {
  9141. percentMouse = 1;
  9142. }
  9143. if ( percentMouse < 0 ) {
  9144. percentMouse = 0;
  9145. }
  9146. if ( this.orientation === "vertical" ) {
  9147. percentMouse = 1 - percentMouse;
  9148. }
  9149. valueTotal = this._valueMax() - this._valueMin();
  9150. valueMouse = this._valueMin() + percentMouse * valueTotal;
  9151. return this._trimAlignValue( valueMouse );
  9152. },
  9153. _start: function( event, index ) {
  9154. var uiHash = {
  9155. handle: this.handles[ index ],
  9156. value: this.value()
  9157. };
  9158. if ( this.options.values && this.options.values.length ) {
  9159. uiHash.value = this.values( index );
  9160. uiHash.values = this.values();
  9161. }
  9162. return this._trigger( "start", event, uiHash );
  9163. },
  9164. _slide: function( event, index, newVal ) {
  9165. var otherVal,
  9166. newValues,
  9167. allowed;
  9168. if ( this.options.values && this.options.values.length ) {
  9169. otherVal = this.values( index ? 0 : 1 );
  9170. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  9171. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  9172. ) {
  9173. newVal = otherVal;
  9174. }
  9175. if ( newVal !== this.values( index ) ) {
  9176. newValues = this.values();
  9177. newValues[ index ] = newVal;
  9178. // A slide can be canceled by returning false from the slide callback
  9179. allowed = this._trigger( "slide", event, {
  9180. handle: this.handles[ index ],
  9181. value: newVal,
  9182. values: newValues
  9183. } );
  9184. otherVal = this.values( index ? 0 : 1 );
  9185. if ( allowed !== false ) {
  9186. this.values( index, newVal );
  9187. }
  9188. }
  9189. } else {
  9190. if ( newVal !== this.value() ) {
  9191. // A slide can be canceled by returning false from the slide callback
  9192. allowed = this._trigger( "slide", event, {
  9193. handle: this.handles[ index ],
  9194. value: newVal
  9195. } );
  9196. if ( allowed !== false ) {
  9197. this.value( newVal );
  9198. }
  9199. }
  9200. }
  9201. },
  9202. _stop: function( event, index ) {
  9203. var uiHash = {
  9204. handle: this.handles[ index ],
  9205. value: this.value()
  9206. };
  9207. if ( this.options.values && this.options.values.length ) {
  9208. uiHash.value = this.values( index );
  9209. uiHash.values = this.values();
  9210. }
  9211. this._trigger( "stop", event, uiHash );
  9212. },
  9213. _change: function( event, index ) {
  9214. if ( !this._keySliding && !this._mouseSliding ) {
  9215. var uiHash = {
  9216. handle: this.handles[ index ],
  9217. value: this.value()
  9218. };
  9219. if ( this.options.values && this.options.values.length ) {
  9220. uiHash.value = this.values( index );
  9221. uiHash.values = this.values();
  9222. }
  9223. //store the last changed value index for reference when handles overlap
  9224. this._lastChangedValue = index;
  9225. this._trigger( "change", event, uiHash );
  9226. }
  9227. },
  9228. value: function( newValue ) {
  9229. if ( arguments.length ) {
  9230. this.options.value = this._trimAlignValue( newValue );
  9231. this._refreshValue();
  9232. this._change( null, 0 );
  9233. return;
  9234. }
  9235. return this._value();
  9236. },
  9237. values: function( index, newValue ) {
  9238. var vals,
  9239. newValues,
  9240. i;
  9241. if ( arguments.length > 1 ) {
  9242. this.options.values[ index ] = this._trimAlignValue( newValue );
  9243. this._refreshValue();
  9244. this._change( null, index );
  9245. return;
  9246. }
  9247. if ( arguments.length ) {
  9248. if ( $.isArray( arguments[ 0 ] ) ) {
  9249. vals = this.options.values;
  9250. newValues = arguments[ 0 ];
  9251. for ( i = 0; i < vals.length; i += 1 ) {
  9252. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  9253. this._change( null, i );
  9254. }
  9255. this._refreshValue();
  9256. } else {
  9257. if ( this.options.values && this.options.values.length ) {
  9258. return this._values( index );
  9259. } else {
  9260. return this.value();
  9261. }
  9262. }
  9263. } else {
  9264. return this._values();
  9265. }
  9266. },
  9267. _setOption: function( key, value ) {
  9268. var i,
  9269. valsLength = 0;
  9270. if ( key === "range" && this.options.range === true ) {
  9271. if ( value === "min" ) {
  9272. this.options.value = this._values( 0 );
  9273. this.options.values = null;
  9274. } else if ( value === "max" ) {
  9275. this.options.value = this._values( this.options.values.length-1 );
  9276. this.options.values = null;
  9277. }
  9278. }
  9279. if ( $.isArray( this.options.values ) ) {
  9280. valsLength = this.options.values.length;
  9281. }
  9282. $.Widget.prototype._setOption.apply( this, arguments );
  9283. switch ( key ) {
  9284. case "orientation":
  9285. this._detectOrientation();
  9286. this.element
  9287. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  9288. .addClass( "ui-slider-" + this.orientation );
  9289. this._refreshValue();
  9290. break;
  9291. case "value":
  9292. this._animateOff = true;
  9293. this._refreshValue();
  9294. this._change( null, 0 );
  9295. this._animateOff = false;
  9296. break;
  9297. case "values":
  9298. this._animateOff = true;
  9299. this._refreshValue();
  9300. for ( i = 0; i < valsLength; i += 1 ) {
  9301. this._change( null, i );
  9302. }
  9303. this._animateOff = false;
  9304. break;
  9305. case "min":
  9306. case "max":
  9307. this._animateOff = true;
  9308. this._refreshValue();
  9309. this._animateOff = false;
  9310. break;
  9311. case "range":
  9312. this._animateOff = true;
  9313. this._refresh();
  9314. this._animateOff = false;
  9315. break;
  9316. }
  9317. },
  9318. //internal value getter
  9319. // _value() returns value trimmed by min and max, aligned by step
  9320. _value: function() {
  9321. var val = this.options.value;
  9322. val = this._trimAlignValue( val );
  9323. return val;
  9324. },
  9325. //internal values getter
  9326. // _values() returns array of values trimmed by min and max, aligned by step
  9327. // _values( index ) returns single value trimmed by min and max, aligned by step
  9328. _values: function( index ) {
  9329. var val,
  9330. vals,
  9331. i;
  9332. if ( arguments.length ) {
  9333. val = this.options.values[ index ];
  9334. val = this._trimAlignValue( val );
  9335. return val;
  9336. } else if ( this.options.values && this.options.values.length ) {
  9337. // .slice() creates a copy of the array
  9338. // this copy gets trimmed by min and max and then returned
  9339. vals = this.options.values.slice();
  9340. for ( i = 0; i < vals.length; i+= 1) {
  9341. vals[ i ] = this._trimAlignValue( vals[ i ] );
  9342. }
  9343. return vals;
  9344. } else {
  9345. return [];
  9346. }
  9347. },
  9348. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  9349. _trimAlignValue: function( val ) {
  9350. if ( val <= this._valueMin() ) {
  9351. return this._valueMin();
  9352. }
  9353. if ( val >= this._valueMax() ) {
  9354. return this._valueMax();
  9355. }
  9356. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  9357. valModStep = (val - this._valueMin()) % step,
  9358. alignValue = val - valModStep;
  9359. if ( Math.abs(valModStep) * 2 >= step ) {
  9360. alignValue += ( valModStep > 0 ) ? step : ( -step );
  9361. }
  9362. // Since JavaScript has problems with large floats, round
  9363. // the final value to 5 digits after the decimal point (see #4124)
  9364. return parseFloat( alignValue.toFixed(5) );
  9365. },
  9366. _valueMin: function() {
  9367. return this.options.min;
  9368. },
  9369. _valueMax: function() {
  9370. return this.options.max;
  9371. },
  9372. _refreshValue: function() {
  9373. var lastValPercent, valPercent, value, valueMin, valueMax,
  9374. oRange = this.options.range,
  9375. o = this.options,
  9376. that = this,
  9377. animate = ( !this._animateOff ) ? o.animate : false,
  9378. _set = {};
  9379. if ( this.options.values && this.options.values.length ) {
  9380. this.handles.each(function( i ) {
  9381. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  9382. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  9383. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  9384. if ( that.options.range === true ) {
  9385. if ( that.orientation === "horizontal" ) {
  9386. if ( i === 0 ) {
  9387. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  9388. }
  9389. if ( i === 1 ) {
  9390. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  9391. }
  9392. } else {
  9393. if ( i === 0 ) {
  9394. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  9395. }
  9396. if ( i === 1 ) {
  9397. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  9398. }
  9399. }
  9400. }
  9401. lastValPercent = valPercent;
  9402. });
  9403. } else {
  9404. value = this.value();
  9405. valueMin = this._valueMin();
  9406. valueMax = this._valueMax();
  9407. valPercent = ( valueMax !== valueMin ) ?
  9408. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  9409. 0;
  9410. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  9411. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  9412. if ( oRange === "min" && this.orientation === "horizontal" ) {
  9413. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  9414. }
  9415. if ( oRange === "max" && this.orientation === "horizontal" ) {
  9416. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  9417. }
  9418. if ( oRange === "min" && this.orientation === "vertical" ) {
  9419. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  9420. }
  9421. if ( oRange === "max" && this.orientation === "vertical" ) {
  9422. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  9423. }
  9424. }
  9425. },
  9426. _handleEvents: {
  9427. keydown: function( event ) {
  9428. var allowed, curVal, newVal, step,
  9429. index = $( event.target ).data( "ui-slider-handle-index" );
  9430. switch ( event.keyCode ) {
  9431. case $.ui.keyCode.HOME:
  9432. case $.ui.keyCode.END:
  9433. case $.ui.keyCode.PAGE_UP:
  9434. case $.ui.keyCode.PAGE_DOWN:
  9435. case $.ui.keyCode.UP:
  9436. case $.ui.keyCode.RIGHT:
  9437. case $.ui.keyCode.DOWN:
  9438. case $.ui.keyCode.LEFT:
  9439. event.preventDefault();
  9440. if ( !this._keySliding ) {
  9441. this._keySliding = true;
  9442. $( event.target ).addClass( "ui-state-active" );
  9443. allowed = this._start( event, index );
  9444. if ( allowed === false ) {
  9445. return;
  9446. }
  9447. }
  9448. break;
  9449. }
  9450. step = this.options.step;
  9451. if ( this.options.values && this.options.values.length ) {
  9452. curVal = newVal = this.values( index );
  9453. } else {
  9454. curVal = newVal = this.value();
  9455. }
  9456. switch ( event.keyCode ) {
  9457. case $.ui.keyCode.HOME:
  9458. newVal = this._valueMin();
  9459. break;
  9460. case $.ui.keyCode.END:
  9461. newVal = this._valueMax();
  9462. break;
  9463. case $.ui.keyCode.PAGE_UP:
  9464. newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
  9465. break;
  9466. case $.ui.keyCode.PAGE_DOWN:
  9467. newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
  9468. break;
  9469. case $.ui.keyCode.UP:
  9470. case $.ui.keyCode.RIGHT:
  9471. if ( curVal === this._valueMax() ) {
  9472. return;
  9473. }
  9474. newVal = this._trimAlignValue( curVal + step );
  9475. break;
  9476. case $.ui.keyCode.DOWN:
  9477. case $.ui.keyCode.LEFT:
  9478. if ( curVal === this._valueMin() ) {
  9479. return;
  9480. }
  9481. newVal = this._trimAlignValue( curVal - step );
  9482. break;
  9483. }
  9484. this._slide( event, index, newVal );
  9485. },
  9486. click: function( event ) {
  9487. event.preventDefault();
  9488. },
  9489. keyup: function( event ) {
  9490. var index = $( event.target ).data( "ui-slider-handle-index" );
  9491. if ( this._keySliding ) {
  9492. this._keySliding = false;
  9493. this._stop( event, index );
  9494. this._change( event, index );
  9495. $( event.target ).removeClass( "ui-state-active" );
  9496. }
  9497. }
  9498. }
  9499. });
  9500. }(jQuery));
  9501. (function( $ ) {
  9502. function modifier( fn ) {
  9503. return function() {
  9504. var previous = this.element.val();
  9505. fn.apply( this, arguments );
  9506. this._refresh();
  9507. if ( previous !== this.element.val() ) {
  9508. this._trigger( "change" );
  9509. }
  9510. };
  9511. }
  9512. $.widget( "ui.spinner", {
  9513. version: "1.10.4",
  9514. defaultElement: "<input>",
  9515. widgetEventPrefix: "spin",
  9516. options: {
  9517. culture: null,
  9518. icons: {
  9519. down: "ui-icon-triangle-1-s",
  9520. up: "ui-icon-triangle-1-n"
  9521. },
  9522. incremental: true,
  9523. max: null,
  9524. min: null,
  9525. numberFormat: null,
  9526. page: 10,
  9527. step: 1,
  9528. change: null,
  9529. spin: null,
  9530. start: null,
  9531. stop: null
  9532. },
  9533. _create: function() {
  9534. // handle string values that need to be parsed
  9535. this._setOption( "max", this.options.max );
  9536. this._setOption( "min", this.options.min );
  9537. this._setOption( "step", this.options.step );
  9538. // Only format if there is a value, prevents the field from being marked
  9539. // as invalid in Firefox, see #9573.
  9540. if ( this.value() !== "" ) {
  9541. // Format the value, but don't constrain.
  9542. this._value( this.element.val(), true );
  9543. }
  9544. this._draw();
  9545. this._on( this._events );
  9546. this._refresh();
  9547. // turning off autocomplete prevents the browser from remembering the
  9548. // value when navigating through history, so we re-enable autocomplete
  9549. // if the page is unloaded before the widget is destroyed. #7790
  9550. this._on( this.window, {
  9551. beforeunload: function() {
  9552. this.element.removeAttr( "autocomplete" );
  9553. }
  9554. });
  9555. },
  9556. _getCreateOptions: function() {
  9557. var options = {},
  9558. element = this.element;
  9559. $.each( [ "min", "max", "step" ], function( i, option ) {
  9560. var value = element.attr( option );
  9561. if ( value !== undefined && value.length ) {
  9562. options[ option ] = value;
  9563. }
  9564. });
  9565. return options;
  9566. },
  9567. _events: {
  9568. keydown: function( event ) {
  9569. if ( this._start( event ) && this._keydown( event ) ) {
  9570. event.preventDefault();
  9571. }
  9572. },
  9573. keyup: "_stop",
  9574. focus: function() {
  9575. this.previous = this.element.val();
  9576. },
  9577. blur: function( event ) {
  9578. if ( this.cancelBlur ) {
  9579. delete this.cancelBlur;
  9580. return;
  9581. }
  9582. this._stop();
  9583. this._refresh();
  9584. if ( this.previous !== this.element.val() ) {
  9585. this._trigger( "change", event );
  9586. }
  9587. },
  9588. mousewheel: function( event, delta ) {
  9589. if ( !delta ) {
  9590. return;
  9591. }
  9592. if ( !this.spinning && !this._start( event ) ) {
  9593. return false;
  9594. }
  9595. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  9596. clearTimeout( this.mousewheelTimer );
  9597. this.mousewheelTimer = this._delay(function() {
  9598. if ( this.spinning ) {
  9599. this._stop( event );
  9600. }
  9601. }, 100 );
  9602. event.preventDefault();
  9603. },
  9604. "mousedown .ui-spinner-button": function( event ) {
  9605. var previous;
  9606. // We never want the buttons to have focus; whenever the user is
  9607. // interacting with the spinner, the focus should be on the input.
  9608. // If the input is focused then this.previous is properly set from
  9609. // when the input first received focus. If the input is not focused
  9610. // then we need to set this.previous based on the value before spinning.
  9611. previous = this.element[0] === this.document[0].activeElement ?
  9612. this.previous : this.element.val();
  9613. function checkFocus() {
  9614. var isActive = this.element[0] === this.document[0].activeElement;
  9615. if ( !isActive ) {
  9616. this.element.focus();
  9617. this.previous = previous;
  9618. // support: IE
  9619. // IE sets focus asynchronously, so we need to check if focus
  9620. // moved off of the input because the user clicked on the button.
  9621. this._delay(function() {
  9622. this.previous = previous;
  9623. });
  9624. }
  9625. }
  9626. // ensure focus is on (or stays on) the text field
  9627. event.preventDefault();
  9628. checkFocus.call( this );
  9629. // support: IE
  9630. // IE doesn't prevent moving focus even with event.preventDefault()
  9631. // so we set a flag to know when we should ignore the blur event
  9632. // and check (again) if focus moved off of the input.
  9633. this.cancelBlur = true;
  9634. this._delay(function() {
  9635. delete this.cancelBlur;
  9636. checkFocus.call( this );
  9637. });
  9638. if ( this._start( event ) === false ) {
  9639. return;
  9640. }
  9641. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  9642. },
  9643. "mouseup .ui-spinner-button": "_stop",
  9644. "mouseenter .ui-spinner-button": function( event ) {
  9645. // button will add ui-state-active if mouse was down while mouseleave and kept down
  9646. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  9647. return;
  9648. }
  9649. if ( this._start( event ) === false ) {
  9650. return false;
  9651. }
  9652. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  9653. },
  9654. // TODO: do we really want to consider this a stop?
  9655. // shouldn't we just stop the repeater and wait until mouseup before
  9656. // we trigger the stop event?
  9657. "mouseleave .ui-spinner-button": "_stop"
  9658. },
  9659. _draw: function() {
  9660. var uiSpinner = this.uiSpinner = this.element
  9661. .addClass( "ui-spinner-input" )
  9662. .attr( "autocomplete", "off" )
  9663. .wrap( this._uiSpinnerHtml() )
  9664. .parent()
  9665. // add buttons
  9666. .append( this._buttonHtml() );
  9667. this.element.attr( "role", "spinbutton" );
  9668. // button bindings
  9669. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  9670. .attr( "tabIndex", -1 )
  9671. .button()
  9672. .removeClass( "ui-corner-all" );
  9673. // IE 6 doesn't understand height: 50% for the buttons
  9674. // unless the wrapper has an explicit height
  9675. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  9676. uiSpinner.height() > 0 ) {
  9677. uiSpinner.height( uiSpinner.height() );
  9678. }
  9679. // disable spinner if element was already disabled
  9680. if ( this.options.disabled ) {
  9681. this.disable();
  9682. }
  9683. },
  9684. _keydown: function( event ) {
  9685. var options = this.options,
  9686. keyCode = $.ui.keyCode;
  9687. switch ( event.keyCode ) {
  9688. case keyCode.UP:
  9689. this._repeat( null, 1, event );
  9690. return true;
  9691. case keyCode.DOWN:
  9692. this._repeat( null, -1, event );
  9693. return true;
  9694. case keyCode.PAGE_UP:
  9695. this._repeat( null, options.page, event );
  9696. return true;
  9697. case keyCode.PAGE_DOWN:
  9698. this._repeat( null, -options.page, event );
  9699. return true;
  9700. }
  9701. return false;
  9702. },
  9703. _uiSpinnerHtml: function() {
  9704. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  9705. },
  9706. _buttonHtml: function() {
  9707. return "" +
  9708. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  9709. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  9710. "</a>" +
  9711. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  9712. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  9713. "</a>";
  9714. },
  9715. _start: function( event ) {
  9716. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  9717. return false;
  9718. }
  9719. if ( !this.counter ) {
  9720. this.counter = 1;
  9721. }
  9722. this.spinning = true;
  9723. return true;
  9724. },
  9725. _repeat: function( i, steps, event ) {
  9726. i = i || 500;
  9727. clearTimeout( this.timer );
  9728. this.timer = this._delay(function() {
  9729. this._repeat( 40, steps, event );
  9730. }, i );
  9731. this._spin( steps * this.options.step, event );
  9732. },
  9733. _spin: function( step, event ) {
  9734. var value = this.value() || 0;
  9735. if ( !this.counter ) {
  9736. this.counter = 1;
  9737. }
  9738. value = this._adjustValue( value + step * this._increment( this.counter ) );
  9739. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  9740. this._value( value );
  9741. this.counter++;
  9742. }
  9743. },
  9744. _increment: function( i ) {
  9745. var incremental = this.options.incremental;
  9746. if ( incremental ) {
  9747. return $.isFunction( incremental ) ?
  9748. incremental( i ) :
  9749. Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
  9750. }
  9751. return 1;
  9752. },
  9753. _precision: function() {
  9754. var precision = this._precisionOf( this.options.step );
  9755. if ( this.options.min !== null ) {
  9756. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  9757. }
  9758. return precision;
  9759. },
  9760. _precisionOf: function( num ) {
  9761. var str = num.toString(),
  9762. decimal = str.indexOf( "." );
  9763. return decimal === -1 ? 0 : str.length - decimal - 1;
  9764. },
  9765. _adjustValue: function( value ) {
  9766. var base, aboveMin,
  9767. options = this.options;
  9768. // make sure we're at a valid step
  9769. // - find out where we are relative to the base (min or 0)
  9770. base = options.min !== null ? options.min : 0;
  9771. aboveMin = value - base;
  9772. // - round to the nearest step
  9773. aboveMin = Math.round(aboveMin / options.step) * options.step;
  9774. // - rounding is based on 0, so adjust back to our base
  9775. value = base + aboveMin;
  9776. // fix precision from bad JS floating point math
  9777. value = parseFloat( value.toFixed( this._precision() ) );
  9778. // clamp the value
  9779. if ( options.max !== null && value > options.max) {
  9780. return options.max;
  9781. }
  9782. if ( options.min !== null && value < options.min ) {
  9783. return options.min;
  9784. }
  9785. return value;
  9786. },
  9787. _stop: function( event ) {
  9788. if ( !this.spinning ) {
  9789. return;
  9790. }
  9791. clearTimeout( this.timer );
  9792. clearTimeout( this.mousewheelTimer );
  9793. this.counter = 0;
  9794. this.spinning = false;
  9795. this._trigger( "stop", event );
  9796. },
  9797. _setOption: function( key, value ) {
  9798. if ( key === "culture" || key === "numberFormat" ) {
  9799. var prevValue = this._parse( this.element.val() );
  9800. this.options[ key ] = value;
  9801. this.element.val( this._format( prevValue ) );
  9802. return;
  9803. }
  9804. if ( key === "max" || key === "min" || key === "step" ) {
  9805. if ( typeof value === "string" ) {
  9806. value = this._parse( value );
  9807. }
  9808. }
  9809. if ( key === "icons" ) {
  9810. this.buttons.first().find( ".ui-icon" )
  9811. .removeClass( this.options.icons.up )
  9812. .addClass( value.up );
  9813. this.buttons.last().find( ".ui-icon" )
  9814. .removeClass( this.options.icons.down )
  9815. .addClass( value.down );
  9816. }
  9817. this._super( key, value );
  9818. if ( key === "disabled" ) {
  9819. if ( value ) {
  9820. this.element.prop( "disabled", true );
  9821. this.buttons.button( "disable" );
  9822. } else {
  9823. this.element.prop( "disabled", false );
  9824. this.buttons.button( "enable" );
  9825. }
  9826. }
  9827. },
  9828. _setOptions: modifier(function( options ) {
  9829. this._super( options );
  9830. this._value( this.element.val() );
  9831. }),
  9832. _parse: function( val ) {
  9833. if ( typeof val === "string" && val !== "" ) {
  9834. val = window.Globalize && this.options.numberFormat ?
  9835. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  9836. }
  9837. return val === "" || isNaN( val ) ? null : val;
  9838. },
  9839. _format: function( value ) {
  9840. if ( value === "" ) {
  9841. return "";
  9842. }
  9843. return window.Globalize && this.options.numberFormat ?
  9844. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  9845. value;
  9846. },
  9847. _refresh: function() {
  9848. this.element.attr({
  9849. "aria-valuemin": this.options.min,
  9850. "aria-valuemax": this.options.max,
  9851. // TODO: what should we do with values that can't be parsed?
  9852. "aria-valuenow": this._parse( this.element.val() )
  9853. });
  9854. },
  9855. // update the value without triggering change
  9856. _value: function( value, allowAny ) {
  9857. var parsed;
  9858. if ( value !== "" ) {
  9859. parsed = this._parse( value );
  9860. if ( parsed !== null ) {
  9861. if ( !allowAny ) {
  9862. parsed = this._adjustValue( parsed );
  9863. }
  9864. value = this._format( parsed );
  9865. }
  9866. }
  9867. this.element.val( value );
  9868. this._refresh();
  9869. },
  9870. _destroy: function() {
  9871. this.element
  9872. .removeClass( "ui-spinner-input" )
  9873. .prop( "disabled", false )
  9874. .removeAttr( "autocomplete" )
  9875. .removeAttr( "role" )
  9876. .removeAttr( "aria-valuemin" )
  9877. .removeAttr( "aria-valuemax" )
  9878. .removeAttr( "aria-valuenow" );
  9879. this.uiSpinner.replaceWith( this.element );
  9880. },
  9881. stepUp: modifier(function( steps ) {
  9882. this._stepUp( steps );
  9883. }),
  9884. _stepUp: function( steps ) {
  9885. if ( this._start() ) {
  9886. this._spin( (steps || 1) * this.options.step );
  9887. this._stop();
  9888. }
  9889. },
  9890. stepDown: modifier(function( steps ) {
  9891. this._stepDown( steps );
  9892. }),
  9893. _stepDown: function( steps ) {
  9894. if ( this._start() ) {
  9895. this._spin( (steps || 1) * -this.options.step );
  9896. this._stop();
  9897. }
  9898. },
  9899. pageUp: modifier(function( pages ) {
  9900. this._stepUp( (pages || 1) * this.options.page );
  9901. }),
  9902. pageDown: modifier(function( pages ) {
  9903. this._stepDown( (pages || 1) * this.options.page );
  9904. }),
  9905. value: function( newVal ) {
  9906. if ( !arguments.length ) {
  9907. return this._parse( this.element.val() );
  9908. }
  9909. modifier( this._value ).call( this, newVal );
  9910. },
  9911. widget: function() {
  9912. return this.uiSpinner;
  9913. }
  9914. });
  9915. }( jQuery ) );
  9916. (function( $, undefined ) {
  9917. var tabId = 0,
  9918. rhash = /#.*$/;
  9919. function getNextTabId() {
  9920. return ++tabId;
  9921. }
  9922. function isLocal( anchor ) {
  9923. // support: IE7
  9924. // IE7 doesn't normalize the href property when set via script (#9317)
  9925. anchor = anchor.cloneNode( false );
  9926. return anchor.hash.length > 1 &&
  9927. decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
  9928. decodeURIComponent( location.href.replace( rhash, "" ) );
  9929. }
  9930. $.widget( "ui.tabs", {
  9931. version: "1.10.4",
  9932. delay: 300,
  9933. options: {
  9934. active: null,
  9935. collapsible: false,
  9936. event: "click",
  9937. heightStyle: "content",
  9938. hide: null,
  9939. show: null,
  9940. // callbacks
  9941. activate: null,
  9942. beforeActivate: null,
  9943. beforeLoad: null,
  9944. load: null
  9945. },
  9946. _create: function() {
  9947. var that = this,
  9948. options = this.options;
  9949. this.running = false;
  9950. this.element
  9951. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  9952. .toggleClass( "ui-tabs-collapsible", options.collapsible )
  9953. // Prevent users from focusing disabled tabs via click
  9954. .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
  9955. if ( $( this ).is( ".ui-state-disabled" ) ) {
  9956. event.preventDefault();
  9957. }
  9958. })
  9959. // support: IE <9
  9960. // Preventing the default action in mousedown doesn't prevent IE
  9961. // from focusing the element, so if the anchor gets focused, blur.
  9962. // We don't have to worry about focusing the previously focused
  9963. // element since clicking on a non-focusable element should focus
  9964. // the body anyway.
  9965. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  9966. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  9967. this.blur();
  9968. }
  9969. });
  9970. this._processTabs();
  9971. options.active = this._initialActive();
  9972. // Take disabling tabs via class attribute from HTML
  9973. // into account and update option properly.
  9974. if ( $.isArray( options.disabled ) ) {
  9975. options.disabled = $.unique( options.disabled.concat(
  9976. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  9977. return that.tabs.index( li );
  9978. })
  9979. ) ).sort();
  9980. }
  9981. // check for length avoids error when initializing empty list
  9982. if ( this.options.active !== false && this.anchors.length ) {
  9983. this.active = this._findActive( options.active );
  9984. } else {
  9985. this.active = $();
  9986. }
  9987. this._refresh();
  9988. if ( this.active.length ) {
  9989. this.load( options.active );
  9990. }
  9991. },
  9992. _initialActive: function() {
  9993. var active = this.options.active,
  9994. collapsible = this.options.collapsible,
  9995. locationHash = location.hash.substring( 1 );
  9996. if ( active === null ) {
  9997. // check the fragment identifier in the URL
  9998. if ( locationHash ) {
  9999. this.tabs.each(function( i, tab ) {
  10000. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  10001. active = i;
  10002. return false;
  10003. }
  10004. });
  10005. }
  10006. // check for a tab marked active via a class
  10007. if ( active === null ) {
  10008. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  10009. }
  10010. // no active tab, set to false
  10011. if ( active === null || active === -1 ) {
  10012. active = this.tabs.length ? 0 : false;
  10013. }
  10014. }
  10015. // handle numbers: negative, out of range
  10016. if ( active !== false ) {
  10017. active = this.tabs.index( this.tabs.eq( active ) );
  10018. if ( active === -1 ) {
  10019. active = collapsible ? false : 0;
  10020. }
  10021. }
  10022. // don't allow collapsible: false and active: false
  10023. if ( !collapsible && active === false && this.anchors.length ) {
  10024. active = 0;
  10025. }
  10026. return active;
  10027. },
  10028. _getCreateEventData: function() {
  10029. return {
  10030. tab: this.active,
  10031. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  10032. };
  10033. },
  10034. _tabKeydown: function( event ) {
  10035. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  10036. selectedIndex = this.tabs.index( focusedTab ),
  10037. goingForward = true;
  10038. if ( this._handlePageNav( event ) ) {
  10039. return;
  10040. }
  10041. switch ( event.keyCode ) {
  10042. case $.ui.keyCode.RIGHT:
  10043. case $.ui.keyCode.DOWN:
  10044. selectedIndex++;
  10045. break;
  10046. case $.ui.keyCode.UP:
  10047. case $.ui.keyCode.LEFT:
  10048. goingForward = false;
  10049. selectedIndex--;
  10050. break;
  10051. case $.ui.keyCode.END:
  10052. selectedIndex = this.anchors.length - 1;
  10053. break;
  10054. case $.ui.keyCode.HOME:
  10055. selectedIndex = 0;
  10056. break;
  10057. case $.ui.keyCode.SPACE:
  10058. // Activate only, no collapsing
  10059. event.preventDefault();
  10060. clearTimeout( this.activating );
  10061. this._activate( selectedIndex );
  10062. return;
  10063. case $.ui.keyCode.ENTER:
  10064. // Toggle (cancel delayed activation, allow collapsing)
  10065. event.preventDefault();
  10066. clearTimeout( this.activating );
  10067. // Determine if we should collapse or activate
  10068. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  10069. return;
  10070. default:
  10071. return;
  10072. }
  10073. // Focus the appropriate tab, based on which key was pressed
  10074. event.preventDefault();
  10075. clearTimeout( this.activating );
  10076. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  10077. // Navigating with control key will prevent automatic activation
  10078. if ( !event.ctrlKey ) {
  10079. // Update aria-selected immediately so that AT think the tab is already selected.
  10080. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  10081. // but the tab will already be activated by the time the announcement finishes.
  10082. focusedTab.attr( "aria-selected", "false" );
  10083. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  10084. this.activating = this._delay(function() {
  10085. this.option( "active", selectedIndex );
  10086. }, this.delay );
  10087. }
  10088. },
  10089. _panelKeydown: function( event ) {
  10090. if ( this._handlePageNav( event ) ) {
  10091. return;
  10092. }
  10093. // Ctrl+up moves focus to the current tab
  10094. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  10095. event.preventDefault();
  10096. this.active.focus();
  10097. }
  10098. },
  10099. // Alt+page up/down moves focus to the previous/next tab (and activates)
  10100. _handlePageNav: function( event ) {
  10101. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  10102. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  10103. return true;
  10104. }
  10105. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  10106. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  10107. return true;
  10108. }
  10109. },
  10110. _findNextTab: function( index, goingForward ) {
  10111. var lastTabIndex = this.tabs.length - 1;
  10112. function constrain() {
  10113. if ( index > lastTabIndex ) {
  10114. index = 0;
  10115. }
  10116. if ( index < 0 ) {
  10117. index = lastTabIndex;
  10118. }
  10119. return index;
  10120. }
  10121. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  10122. index = goingForward ? index + 1 : index - 1;
  10123. }
  10124. return index;
  10125. },
  10126. _focusNextTab: function( index, goingForward ) {
  10127. index = this._findNextTab( index, goingForward );
  10128. this.tabs.eq( index ).focus();
  10129. return index;
  10130. },
  10131. _setOption: function( key, value ) {
  10132. if ( key === "active" ) {
  10133. // _activate() will handle invalid values and update this.options
  10134. this._activate( value );
  10135. return;
  10136. }
  10137. if ( key === "disabled" ) {
  10138. // don't use the widget factory's disabled handling
  10139. this._setupDisabled( value );
  10140. return;
  10141. }
  10142. this._super( key, value);
  10143. if ( key === "collapsible" ) {
  10144. this.element.toggleClass( "ui-tabs-collapsible", value );
  10145. // Setting collapsible: false while collapsed; open first panel
  10146. if ( !value && this.options.active === false ) {
  10147. this._activate( 0 );
  10148. }
  10149. }
  10150. if ( key === "event" ) {
  10151. this._setupEvents( value );
  10152. }
  10153. if ( key === "heightStyle" ) {
  10154. this._setupHeightStyle( value );
  10155. }
  10156. },
  10157. _tabId: function( tab ) {
  10158. return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
  10159. },
  10160. _sanitizeSelector: function( hash ) {
  10161. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  10162. },
  10163. refresh: function() {
  10164. var options = this.options,
  10165. lis = this.tablist.children( ":has(a[href])" );
  10166. // get disabled tabs from class attribute from HTML
  10167. // this will get converted to a boolean if needed in _refresh()
  10168. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  10169. return lis.index( tab );
  10170. });
  10171. this._processTabs();
  10172. // was collapsed or no tabs
  10173. if ( options.active === false || !this.anchors.length ) {
  10174. options.active = false;
  10175. this.active = $();
  10176. // was active, but active tab is gone
  10177. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  10178. // all remaining tabs are disabled
  10179. if ( this.tabs.length === options.disabled.length ) {
  10180. options.active = false;
  10181. this.active = $();
  10182. // activate previous tab
  10183. } else {
  10184. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  10185. }
  10186. // was active, active tab still exists
  10187. } else {
  10188. // make sure active index is correct
  10189. options.active = this.tabs.index( this.active );
  10190. }
  10191. this._refresh();
  10192. },
  10193. _refresh: function() {
  10194. this._setupDisabled( this.options.disabled );
  10195. this._setupEvents( this.options.event );
  10196. this._setupHeightStyle( this.options.heightStyle );
  10197. this.tabs.not( this.active ).attr({
  10198. "aria-selected": "false",
  10199. tabIndex: -1
  10200. });
  10201. this.panels.not( this._getPanelForTab( this.active ) )
  10202. .hide()
  10203. .attr({
  10204. "aria-expanded": "false",
  10205. "aria-hidden": "true"
  10206. });
  10207. // Make sure one tab is in the tab order
  10208. if ( !this.active.length ) {
  10209. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  10210. } else {
  10211. this.active
  10212. .addClass( "ui-tabs-active ui-state-active" )
  10213. .attr({
  10214. "aria-selected": "true",
  10215. tabIndex: 0
  10216. });
  10217. this._getPanelForTab( this.active )
  10218. .show()
  10219. .attr({
  10220. "aria-expanded": "true",
  10221. "aria-hidden": "false"
  10222. });
  10223. }
  10224. },
  10225. _processTabs: function() {
  10226. var that = this;
  10227. this.tablist = this._getList()
  10228. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  10229. .attr( "role", "tablist" );
  10230. this.tabs = this.tablist.find( "> li:has(a[href])" )
  10231. .addClass( "ui-state-default ui-corner-top" )
  10232. .attr({
  10233. role: "tab",
  10234. tabIndex: -1
  10235. });
  10236. this.anchors = this.tabs.map(function() {
  10237. return $( "a", this )[ 0 ];
  10238. })
  10239. .addClass( "ui-tabs-anchor" )
  10240. .attr({
  10241. role: "presentation",
  10242. tabIndex: -1
  10243. });
  10244. this.panels = $();
  10245. this.anchors.each(function( i, anchor ) {
  10246. var selector, panel, panelId,
  10247. anchorId = $( anchor ).uniqueId().attr( "id" ),
  10248. tab = $( anchor ).closest( "li" ),
  10249. originalAriaControls = tab.attr( "aria-controls" );
  10250. // inline tab
  10251. if ( isLocal( anchor ) ) {
  10252. selector = anchor.hash;
  10253. panel = that.element.find( that._sanitizeSelector( selector ) );
  10254. // remote tab
  10255. } else {
  10256. panelId = that._tabId( tab );
  10257. selector = "#" + panelId;
  10258. panel = that.element.find( selector );
  10259. if ( !panel.length ) {
  10260. panel = that._createPanel( panelId );
  10261. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  10262. }
  10263. panel.attr( "aria-live", "polite" );
  10264. }
  10265. if ( panel.length) {
  10266. that.panels = that.panels.add( panel );
  10267. }
  10268. if ( originalAriaControls ) {
  10269. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  10270. }
  10271. tab.attr({
  10272. "aria-controls": selector.substring( 1 ),
  10273. "aria-labelledby": anchorId
  10274. });
  10275. panel.attr( "aria-labelledby", anchorId );
  10276. });
  10277. this.panels
  10278. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  10279. .attr( "role", "tabpanel" );
  10280. },
  10281. // allow overriding how to find the list for rare usage scenarios (#7715)
  10282. _getList: function() {
  10283. return this.tablist || this.element.find( "ol,ul" ).eq( 0 );
  10284. },
  10285. _createPanel: function( id ) {
  10286. return $( "<div>" )
  10287. .attr( "id", id )
  10288. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  10289. .data( "ui-tabs-destroy", true );
  10290. },
  10291. _setupDisabled: function( disabled ) {
  10292. if ( $.isArray( disabled ) ) {
  10293. if ( !disabled.length ) {
  10294. disabled = false;
  10295. } else if ( disabled.length === this.anchors.length ) {
  10296. disabled = true;
  10297. }
  10298. }
  10299. // disable tabs
  10300. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  10301. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  10302. $( li )
  10303. .addClass( "ui-state-disabled" )
  10304. .attr( "aria-disabled", "true" );
  10305. } else {
  10306. $( li )
  10307. .removeClass( "ui-state-disabled" )
  10308. .removeAttr( "aria-disabled" );
  10309. }
  10310. }
  10311. this.options.disabled = disabled;
  10312. },
  10313. _setupEvents: function( event ) {
  10314. var events = {
  10315. click: function( event ) {
  10316. event.preventDefault();
  10317. }
  10318. };
  10319. if ( event ) {
  10320. $.each( event.split(" "), function( index, eventName ) {
  10321. events[ eventName ] = "_eventHandler";
  10322. });
  10323. }
  10324. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  10325. this._on( this.anchors, events );
  10326. this._on( this.tabs, { keydown: "_tabKeydown" } );
  10327. this._on( this.panels, { keydown: "_panelKeydown" } );
  10328. this._focusable( this.tabs );
  10329. this._hoverable( this.tabs );
  10330. },
  10331. _setupHeightStyle: function( heightStyle ) {
  10332. var maxHeight,
  10333. parent = this.element.parent();
  10334. if ( heightStyle === "fill" ) {
  10335. maxHeight = parent.height();
  10336. maxHeight -= this.element.outerHeight() - this.element.height();
  10337. this.element.siblings( ":visible" ).each(function() {
  10338. var elem = $( this ),
  10339. position = elem.css( "position" );
  10340. if ( position === "absolute" || position === "fixed" ) {
  10341. return;
  10342. }
  10343. maxHeight -= elem.outerHeight( true );
  10344. });
  10345. this.element.children().not( this.panels ).each(function() {
  10346. maxHeight -= $( this ).outerHeight( true );
  10347. });
  10348. this.panels.each(function() {
  10349. $( this ).height( Math.max( 0, maxHeight -
  10350. $( this ).innerHeight() + $( this ).height() ) );
  10351. })
  10352. .css( "overflow", "auto" );
  10353. } else if ( heightStyle === "auto" ) {
  10354. maxHeight = 0;
  10355. this.panels.each(function() {
  10356. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  10357. }).height( maxHeight );
  10358. }
  10359. },
  10360. _eventHandler: function( event ) {
  10361. var options = this.options,
  10362. active = this.active,
  10363. anchor = $( event.currentTarget ),
  10364. tab = anchor.closest( "li" ),
  10365. clickedIsActive = tab[ 0 ] === active[ 0 ],
  10366. collapsing = clickedIsActive && options.collapsible,
  10367. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  10368. toHide = !active.length ? $() : this._getPanelForTab( active ),
  10369. eventData = {
  10370. oldTab: active,
  10371. oldPanel: toHide,
  10372. newTab: collapsing ? $() : tab,
  10373. newPanel: toShow
  10374. };
  10375. event.preventDefault();
  10376. if ( tab.hasClass( "ui-state-disabled" ) ||
  10377. // tab is already loading
  10378. tab.hasClass( "ui-tabs-loading" ) ||
  10379. // can't switch durning an animation
  10380. this.running ||
  10381. // click on active header, but not collapsible
  10382. ( clickedIsActive && !options.collapsible ) ||
  10383. // allow canceling activation
  10384. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  10385. return;
  10386. }
  10387. options.active = collapsing ? false : this.tabs.index( tab );
  10388. this.active = clickedIsActive ? $() : tab;
  10389. if ( this.xhr ) {
  10390. this.xhr.abort();
  10391. }
  10392. if ( !toHide.length && !toShow.length ) {
  10393. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  10394. }
  10395. if ( toShow.length ) {
  10396. this.load( this.tabs.index( tab ), event );
  10397. }
  10398. this._toggle( event, eventData );
  10399. },
  10400. // handles show/hide for selecting tabs
  10401. _toggle: function( event, eventData ) {
  10402. var that = this,
  10403. toShow = eventData.newPanel,
  10404. toHide = eventData.oldPanel;
  10405. this.running = true;
  10406. function complete() {
  10407. that.running = false;
  10408. that._trigger( "activate", event, eventData );
  10409. }
  10410. function show() {
  10411. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  10412. if ( toShow.length && that.options.show ) {
  10413. that._show( toShow, that.options.show, complete );
  10414. } else {
  10415. toShow.show();
  10416. complete();
  10417. }
  10418. }
  10419. // start out by hiding, then showing, then completing
  10420. if ( toHide.length && this.options.hide ) {
  10421. this._hide( toHide, this.options.hide, function() {
  10422. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  10423. show();
  10424. });
  10425. } else {
  10426. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  10427. toHide.hide();
  10428. show();
  10429. }
  10430. toHide.attr({
  10431. "aria-expanded": "false",
  10432. "aria-hidden": "true"
  10433. });
  10434. eventData.oldTab.attr( "aria-selected", "false" );
  10435. // If we're switching tabs, remove the old tab from the tab order.
  10436. // If we're opening from collapsed state, remove the previous tab from the tab order.
  10437. // If we're collapsing, then keep the collapsing tab in the tab order.
  10438. if ( toShow.length && toHide.length ) {
  10439. eventData.oldTab.attr( "tabIndex", -1 );
  10440. } else if ( toShow.length ) {
  10441. this.tabs.filter(function() {
  10442. return $( this ).attr( "tabIndex" ) === 0;
  10443. })
  10444. .attr( "tabIndex", -1 );
  10445. }
  10446. toShow.attr({
  10447. "aria-expanded": "true",
  10448. "aria-hidden": "false"
  10449. });
  10450. eventData.newTab.attr({
  10451. "aria-selected": "true",
  10452. tabIndex: 0
  10453. });
  10454. },
  10455. _activate: function( index ) {
  10456. var anchor,
  10457. active = this._findActive( index );
  10458. // trying to activate the already active panel
  10459. if ( active[ 0 ] === this.active[ 0 ] ) {
  10460. return;
  10461. }
  10462. // trying to collapse, simulate a click on the current active header
  10463. if ( !active.length ) {
  10464. active = this.active;
  10465. }
  10466. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  10467. this._eventHandler({
  10468. target: anchor,
  10469. currentTarget: anchor,
  10470. preventDefault: $.noop
  10471. });
  10472. },
  10473. _findActive: function( index ) {
  10474. return index === false ? $() : this.tabs.eq( index );
  10475. },
  10476. _getIndex: function( index ) {
  10477. // meta-function to give users option to provide a href string instead of a numerical index.
  10478. if ( typeof index === "string" ) {
  10479. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  10480. }
  10481. return index;
  10482. },
  10483. _destroy: function() {
  10484. if ( this.xhr ) {
  10485. this.xhr.abort();
  10486. }
  10487. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  10488. this.tablist
  10489. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  10490. .removeAttr( "role" );
  10491. this.anchors
  10492. .removeClass( "ui-tabs-anchor" )
  10493. .removeAttr( "role" )
  10494. .removeAttr( "tabIndex" )
  10495. .removeUniqueId();
  10496. this.tabs.add( this.panels ).each(function() {
  10497. if ( $.data( this, "ui-tabs-destroy" ) ) {
  10498. $( this ).remove();
  10499. } else {
  10500. $( this )
  10501. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  10502. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  10503. .removeAttr( "tabIndex" )
  10504. .removeAttr( "aria-live" )
  10505. .removeAttr( "aria-busy" )
  10506. .removeAttr( "aria-selected" )
  10507. .removeAttr( "aria-labelledby" )
  10508. .removeAttr( "aria-hidden" )
  10509. .removeAttr( "aria-expanded" )
  10510. .removeAttr( "role" );
  10511. }
  10512. });
  10513. this.tabs.each(function() {
  10514. var li = $( this ),
  10515. prev = li.data( "ui-tabs-aria-controls" );
  10516. if ( prev ) {
  10517. li
  10518. .attr( "aria-controls", prev )
  10519. .removeData( "ui-tabs-aria-controls" );
  10520. } else {
  10521. li.removeAttr( "aria-controls" );
  10522. }
  10523. });
  10524. this.panels.show();
  10525. if ( this.options.heightStyle !== "content" ) {
  10526. this.panels.css( "height", "" );
  10527. }
  10528. },
  10529. enable: function( index ) {
  10530. var disabled = this.options.disabled;
  10531. if ( disabled === false ) {
  10532. return;
  10533. }
  10534. if ( index === undefined ) {
  10535. disabled = false;
  10536. } else {
  10537. index = this._getIndex( index );
  10538. if ( $.isArray( disabled ) ) {
  10539. disabled = $.map( disabled, function( num ) {
  10540. return num !== index ? num : null;
  10541. });
  10542. } else {
  10543. disabled = $.map( this.tabs, function( li, num ) {
  10544. return num !== index ? num : null;
  10545. });
  10546. }
  10547. }
  10548. this._setupDisabled( disabled );
  10549. },
  10550. disable: function( index ) {
  10551. var disabled = this.options.disabled;
  10552. if ( disabled === true ) {
  10553. return;
  10554. }
  10555. if ( index === undefined ) {
  10556. disabled = true;
  10557. } else {
  10558. index = this._getIndex( index );
  10559. if ( $.inArray( index, disabled ) !== -1 ) {
  10560. return;
  10561. }
  10562. if ( $.isArray( disabled ) ) {
  10563. disabled = $.merge( [ index ], disabled ).sort();
  10564. } else {
  10565. disabled = [ index ];
  10566. }
  10567. }
  10568. this._setupDisabled( disabled );
  10569. },
  10570. load: function( index, event ) {
  10571. index = this._getIndex( index );
  10572. var that = this,
  10573. tab = this.tabs.eq( index ),
  10574. anchor = tab.find( ".ui-tabs-anchor" ),
  10575. panel = this._getPanelForTab( tab ),
  10576. eventData = {
  10577. tab: tab,
  10578. panel: panel
  10579. };
  10580. // not remote
  10581. if ( isLocal( anchor[ 0 ] ) ) {
  10582. return;
  10583. }
  10584. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  10585. // support: jQuery <1.8
  10586. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  10587. // but as of 1.8, $.ajax() always returns a jqXHR object.
  10588. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  10589. tab.addClass( "ui-tabs-loading" );
  10590. panel.attr( "aria-busy", "true" );
  10591. this.xhr
  10592. .success(function( response ) {
  10593. // support: jQuery <1.8
  10594. // http://bugs.jquery.com/ticket/11778
  10595. setTimeout(function() {
  10596. panel.html( response );
  10597. that._trigger( "load", event, eventData );
  10598. }, 1 );
  10599. })
  10600. .complete(function( jqXHR, status ) {
  10601. // support: jQuery <1.8
  10602. // http://bugs.jquery.com/ticket/11778
  10603. setTimeout(function() {
  10604. if ( status === "abort" ) {
  10605. that.panels.stop( false, true );
  10606. }
  10607. tab.removeClass( "ui-tabs-loading" );
  10608. panel.removeAttr( "aria-busy" );
  10609. if ( jqXHR === that.xhr ) {
  10610. delete that.xhr;
  10611. }
  10612. }, 1 );
  10613. });
  10614. }
  10615. },
  10616. _ajaxSettings: function( anchor, event, eventData ) {
  10617. var that = this;
  10618. return {
  10619. url: anchor.attr( "href" ),
  10620. beforeSend: function( jqXHR, settings ) {
  10621. return that._trigger( "beforeLoad", event,
  10622. $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
  10623. }
  10624. };
  10625. },
  10626. _getPanelForTab: function( tab ) {
  10627. var id = $( tab ).attr( "aria-controls" );
  10628. return this.element.find( this._sanitizeSelector( "#" + id ) );
  10629. }
  10630. });
  10631. })( jQuery );
  10632. (function( $ ) {
  10633. var increments = 0;
  10634. function addDescribedBy( elem, id ) {
  10635. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  10636. describedby.push( id );
  10637. elem
  10638. .data( "ui-tooltip-id", id )
  10639. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  10640. }
  10641. function removeDescribedBy( elem ) {
  10642. var id = elem.data( "ui-tooltip-id" ),
  10643. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  10644. index = $.inArray( id, describedby );
  10645. if ( index !== -1 ) {
  10646. describedby.splice( index, 1 );
  10647. }
  10648. elem.removeData( "ui-tooltip-id" );
  10649. describedby = $.trim( describedby.join( " " ) );
  10650. if ( describedby ) {
  10651. elem.attr( "aria-describedby", describedby );
  10652. } else {
  10653. elem.removeAttr( "aria-describedby" );
  10654. }
  10655. }
  10656. $.widget( "ui.tooltip", {
  10657. version: "1.10.4",
  10658. options: {
  10659. content: function() {
  10660. // support: IE<9, Opera in jQuery <1.7
  10661. // .text() can't accept undefined, so coerce to a string
  10662. var title = $( this ).attr( "title" ) || "";
  10663. // Escape title, since we're going from an attribute to raw HTML
  10664. return $( "<a>" ).text( title ).html();
  10665. },
  10666. hide: true,
  10667. // Disabled elements have inconsistent behavior across browsers (#8661)
  10668. items: "[title]:not([disabled])",
  10669. position: {
  10670. my: "left top+15",
  10671. at: "left bottom",
  10672. collision: "flipfit flip"
  10673. },
  10674. show: true,
  10675. tooltipClass: null,
  10676. track: false,
  10677. // callbacks
  10678. close: null,
  10679. open: null
  10680. },
  10681. _create: function() {
  10682. this._on({
  10683. mouseover: "open",
  10684. focusin: "open"
  10685. });
  10686. // IDs of generated tooltips, needed for destroy
  10687. this.tooltips = {};
  10688. // IDs of parent tooltips where we removed the title attribute
  10689. this.parents = {};
  10690. if ( this.options.disabled ) {
  10691. this._disable();
  10692. }
  10693. },
  10694. _setOption: function( key, value ) {
  10695. var that = this;
  10696. if ( key === "disabled" ) {
  10697. this[ value ? "_disable" : "_enable" ]();
  10698. this.options[ key ] = value;
  10699. // disable element style changes
  10700. return;
  10701. }
  10702. this._super( key, value );
  10703. if ( key === "content" ) {
  10704. $.each( this.tooltips, function( id, element ) {
  10705. that._updateContent( element );
  10706. });
  10707. }
  10708. },
  10709. _disable: function() {
  10710. var that = this;
  10711. // close open tooltips
  10712. $.each( this.tooltips, function( id, element ) {
  10713. var event = $.Event( "blur" );
  10714. event.target = event.currentTarget = element[0];
  10715. that.close( event, true );
  10716. });
  10717. // remove title attributes to prevent native tooltips
  10718. this.element.find( this.options.items ).addBack().each(function() {
  10719. var element = $( this );
  10720. if ( element.is( "[title]" ) ) {
  10721. element
  10722. .data( "ui-tooltip-title", element.attr( "title" ) )
  10723. .attr( "title", "" );
  10724. }
  10725. });
  10726. },
  10727. _enable: function() {
  10728. // restore title attributes
  10729. this.element.find( this.options.items ).addBack().each(function() {
  10730. var element = $( this );
  10731. if ( element.data( "ui-tooltip-title" ) ) {
  10732. element.attr( "title", element.data( "ui-tooltip-title" ) );
  10733. }
  10734. });
  10735. },
  10736. open: function( event ) {
  10737. var that = this,
  10738. target = $( event ? event.target : this.element )
  10739. // we need closest here due to mouseover bubbling,
  10740. // but always pointing at the same event target
  10741. .closest( this.options.items );
  10742. // No element to show a tooltip for or the tooltip is already open
  10743. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  10744. return;
  10745. }
  10746. if ( target.attr( "title" ) ) {
  10747. target.data( "ui-tooltip-title", target.attr( "title" ) );
  10748. }
  10749. target.data( "ui-tooltip-open", true );
  10750. // kill parent tooltips, custom or native, for hover
  10751. if ( event && event.type === "mouseover" ) {
  10752. target.parents().each(function() {
  10753. var parent = $( this ),
  10754. blurEvent;
  10755. if ( parent.data( "ui-tooltip-open" ) ) {
  10756. blurEvent = $.Event( "blur" );
  10757. blurEvent.target = blurEvent.currentTarget = this;
  10758. that.close( blurEvent, true );
  10759. }
  10760. if ( parent.attr( "title" ) ) {
  10761. parent.uniqueId();
  10762. that.parents[ this.id ] = {
  10763. element: this,
  10764. title: parent.attr( "title" )
  10765. };
  10766. parent.attr( "title", "" );
  10767. }
  10768. });
  10769. }
  10770. this._updateContent( target, event );
  10771. },
  10772. _updateContent: function( target, event ) {
  10773. var content,
  10774. contentOption = this.options.content,
  10775. that = this,
  10776. eventType = event ? event.type : null;
  10777. if ( typeof contentOption === "string" ) {
  10778. return this._open( event, target, contentOption );
  10779. }
  10780. content = contentOption.call( target[0], function( response ) {
  10781. // ignore async response if tooltip was closed already
  10782. if ( !target.data( "ui-tooltip-open" ) ) {
  10783. return;
  10784. }
  10785. // IE may instantly serve a cached response for ajax requests
  10786. // delay this call to _open so the other call to _open runs first
  10787. that._delay(function() {
  10788. // jQuery creates a special event for focusin when it doesn't
  10789. // exist natively. To improve performance, the native event
  10790. // object is reused and the type is changed. Therefore, we can't
  10791. // rely on the type being correct after the event finished
  10792. // bubbling, so we set it back to the previous value. (#8740)
  10793. if ( event ) {
  10794. event.type = eventType;
  10795. }
  10796. this._open( event, target, response );
  10797. });
  10798. });
  10799. if ( content ) {
  10800. this._open( event, target, content );
  10801. }
  10802. },
  10803. _open: function( event, target, content ) {
  10804. var tooltip, events, delayedShow,
  10805. positionOption = $.extend( {}, this.options.position );
  10806. if ( !content ) {
  10807. return;
  10808. }
  10809. // Content can be updated multiple times. If the tooltip already
  10810. // exists, then just update the content and bail.
  10811. tooltip = this._find( target );
  10812. if ( tooltip.length ) {
  10813. tooltip.find( ".ui-tooltip-content" ).html( content );
  10814. return;
  10815. }
  10816. // if we have a title, clear it to prevent the native tooltip
  10817. // we have to check first to avoid defining a title if none exists
  10818. // (we don't want to cause an element to start matching [title])
  10819. //
  10820. // We use removeAttr only for key events, to allow IE to export the correct
  10821. // accessible attributes. For mouse events, set to empty string to avoid
  10822. // native tooltip showing up (happens only when removing inside mouseover).
  10823. if ( target.is( "[title]" ) ) {
  10824. if ( event && event.type === "mouseover" ) {
  10825. target.attr( "title", "" );
  10826. } else {
  10827. target.removeAttr( "title" );
  10828. }
  10829. }
  10830. tooltip = this._tooltip( target );
  10831. addDescribedBy( target, tooltip.attr( "id" ) );
  10832. tooltip.find( ".ui-tooltip-content" ).html( content );
  10833. function position( event ) {
  10834. positionOption.of = event;
  10835. if ( tooltip.is( ":hidden" ) ) {
  10836. return;
  10837. }
  10838. tooltip.position( positionOption );
  10839. }
  10840. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  10841. this._on( this.document, {
  10842. mousemove: position
  10843. });
  10844. // trigger once to override element-relative positioning
  10845. position( event );
  10846. } else {
  10847. tooltip.position( $.extend({
  10848. of: target
  10849. }, this.options.position ) );
  10850. }
  10851. tooltip.hide();
  10852. this._show( tooltip, this.options.show );
  10853. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  10854. // as the tooltip is visible, position the tooltip using the most recent
  10855. // event.
  10856. if ( this.options.show && this.options.show.delay ) {
  10857. delayedShow = this.delayedShow = setInterval(function() {
  10858. if ( tooltip.is( ":visible" ) ) {
  10859. position( positionOption.of );
  10860. clearInterval( delayedShow );
  10861. }
  10862. }, $.fx.interval );
  10863. }
  10864. this._trigger( "open", event, { tooltip: tooltip } );
  10865. events = {
  10866. keyup: function( event ) {
  10867. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  10868. var fakeEvent = $.Event(event);
  10869. fakeEvent.currentTarget = target[0];
  10870. this.close( fakeEvent, true );
  10871. }
  10872. },
  10873. remove: function() {
  10874. this._removeTooltip( tooltip );
  10875. }
  10876. };
  10877. if ( !event || event.type === "mouseover" ) {
  10878. events.mouseleave = "close";
  10879. }
  10880. if ( !event || event.type === "focusin" ) {
  10881. events.focusout = "close";
  10882. }
  10883. this._on( true, target, events );
  10884. },
  10885. close: function( event ) {
  10886. var that = this,
  10887. target = $( event ? event.currentTarget : this.element ),
  10888. tooltip = this._find( target );
  10889. // disabling closes the tooltip, so we need to track when we're closing
  10890. // to avoid an infinite loop in case the tooltip becomes disabled on close
  10891. if ( this.closing ) {
  10892. return;
  10893. }
  10894. // Clear the interval for delayed tracking tooltips
  10895. clearInterval( this.delayedShow );
  10896. // only set title if we had one before (see comment in _open())
  10897. if ( target.data( "ui-tooltip-title" ) ) {
  10898. target.attr( "title", target.data( "ui-tooltip-title" ) );
  10899. }
  10900. removeDescribedBy( target );
  10901. tooltip.stop( true );
  10902. this._hide( tooltip, this.options.hide, function() {
  10903. that._removeTooltip( $( this ) );
  10904. });
  10905. target.removeData( "ui-tooltip-open" );
  10906. this._off( target, "mouseleave focusout keyup" );
  10907. // Remove 'remove' binding only on delegated targets
  10908. if ( target[0] !== this.element[0] ) {
  10909. this._off( target, "remove" );
  10910. }
  10911. this._off( this.document, "mousemove" );
  10912. if ( event && event.type === "mouseleave" ) {
  10913. $.each( this.parents, function( id, parent ) {
  10914. $( parent.element ).attr( "title", parent.title );
  10915. delete that.parents[ id ];
  10916. });
  10917. }
  10918. this.closing = true;
  10919. this._trigger( "close", event, { tooltip: tooltip } );
  10920. this.closing = false;
  10921. },
  10922. _tooltip: function( element ) {
  10923. var id = "ui-tooltip-" + increments++,
  10924. tooltip = $( "<div>" )
  10925. .attr({
  10926. id: id,
  10927. role: "tooltip"
  10928. })
  10929. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  10930. ( this.options.tooltipClass || "" ) );
  10931. $( "<div>" )
  10932. .addClass( "ui-tooltip-content" )
  10933. .appendTo( tooltip );
  10934. tooltip.appendTo( this.document[0].body );
  10935. this.tooltips[ id ] = element;
  10936. return tooltip;
  10937. },
  10938. _find: function( target ) {
  10939. var id = target.data( "ui-tooltip-id" );
  10940. return id ? $( "#" + id ) : $();
  10941. },
  10942. _removeTooltip: function( tooltip ) {
  10943. tooltip.remove();
  10944. delete this.tooltips[ tooltip.attr( "id" ) ];
  10945. },
  10946. _destroy: function() {
  10947. var that = this;
  10948. // close open tooltips
  10949. $.each( this.tooltips, function( id, element ) {
  10950. // Delegate to close method to handle common cleanup
  10951. var event = $.Event( "blur" );
  10952. event.target = event.currentTarget = element[0];
  10953. that.close( event, true );
  10954. // Remove immediately; destroying an open tooltip doesn't use the
  10955. // hide animation
  10956. $( "#" + id ).remove();
  10957. // Restore the title
  10958. if ( element.data( "ui-tooltip-title" ) ) {
  10959. element.attr( "title", element.data( "ui-tooltip-title" ) );
  10960. element.removeData( "ui-tooltip-title" );
  10961. }
  10962. });
  10963. }
  10964. });
  10965. }( jQuery ) );
  10966. (function($, undefined) {
  10967. var dataSpace = "ui-effects-";
  10968. $.effects = {
  10969. effect: {}
  10970. };
  10971. /*!
  10972. * jQuery Color Animations v2.1.2
  10973. * https://github.com/jquery/jquery-color
  10974. *
  10975. * Copyright 2013 jQuery Foundation and other contributors
  10976. * Released under the MIT license.
  10977. * http://jquery.org/license
  10978. *
  10979. * Date: Wed Jan 16 08:47:09 2013 -0600
  10980. */
  10981. (function( jQuery, undefined ) {
  10982. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  10983. // plusequals test for += 100 -= 100
  10984. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  10985. // a set of RE's that can match strings and generate color tuples.
  10986. stringParsers = [{
  10987. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  10988. parse: function( execResult ) {
  10989. return [
  10990. execResult[ 1 ],
  10991. execResult[ 2 ],
  10992. execResult[ 3 ],
  10993. execResult[ 4 ]
  10994. ];
  10995. }
  10996. }, {
  10997. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  10998. parse: function( execResult ) {
  10999. return [
  11000. execResult[ 1 ] * 2.55,
  11001. execResult[ 2 ] * 2.55,
  11002. execResult[ 3 ] * 2.55,
  11003. execResult[ 4 ]
  11004. ];
  11005. }
  11006. }, {
  11007. // this regex ignores A-F because it's compared against an already lowercased string
  11008. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  11009. parse: function( execResult ) {
  11010. return [
  11011. parseInt( execResult[ 1 ], 16 ),
  11012. parseInt( execResult[ 2 ], 16 ),
  11013. parseInt( execResult[ 3 ], 16 )
  11014. ];
  11015. }
  11016. }, {
  11017. // this regex ignores A-F because it's compared against an already lowercased string
  11018. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  11019. parse: function( execResult ) {
  11020. return [
  11021. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  11022. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  11023. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  11024. ];
  11025. }
  11026. }, {
  11027. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  11028. space: "hsla",
  11029. parse: function( execResult ) {
  11030. return [
  11031. execResult[ 1 ],
  11032. execResult[ 2 ] / 100,
  11033. execResult[ 3 ] / 100,
  11034. execResult[ 4 ]
  11035. ];
  11036. }
  11037. }],
  11038. // jQuery.Color( )
  11039. color = jQuery.Color = function( color, green, blue, alpha ) {
  11040. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  11041. },
  11042. spaces = {
  11043. rgba: {
  11044. props: {
  11045. red: {
  11046. idx: 0,
  11047. type: "byte"
  11048. },
  11049. green: {
  11050. idx: 1,
  11051. type: "byte"
  11052. },
  11053. blue: {
  11054. idx: 2,
  11055. type: "byte"
  11056. }
  11057. }
  11058. },
  11059. hsla: {
  11060. props: {
  11061. hue: {
  11062. idx: 0,
  11063. type: "degrees"
  11064. },
  11065. saturation: {
  11066. idx: 1,
  11067. type: "percent"
  11068. },
  11069. lightness: {
  11070. idx: 2,
  11071. type: "percent"
  11072. }
  11073. }
  11074. }
  11075. },
  11076. propTypes = {
  11077. "byte": {
  11078. floor: true,
  11079. max: 255
  11080. },
  11081. "percent": {
  11082. max: 1
  11083. },
  11084. "degrees": {
  11085. mod: 360,
  11086. floor: true
  11087. }
  11088. },
  11089. support = color.support = {},
  11090. // element for support tests
  11091. supportElem = jQuery( "<p>" )[ 0 ],
  11092. // colors = jQuery.Color.names
  11093. colors,
  11094. // local aliases of functions called often
  11095. each = jQuery.each;
  11096. // determine rgba support immediately
  11097. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  11098. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  11099. // define cache name and alpha properties
  11100. // for rgba and hsla spaces
  11101. each( spaces, function( spaceName, space ) {
  11102. space.cache = "_" + spaceName;
  11103. space.props.alpha = {
  11104. idx: 3,
  11105. type: "percent",
  11106. def: 1
  11107. };
  11108. });
  11109. function clamp( value, prop, allowEmpty ) {
  11110. var type = propTypes[ prop.type ] || {};
  11111. if ( value == null ) {
  11112. return (allowEmpty || !prop.def) ? null : prop.def;
  11113. }
  11114. // ~~ is an short way of doing floor for positive numbers
  11115. value = type.floor ? ~~value : parseFloat( value );
  11116. // IE will pass in empty strings as value for alpha,
  11117. // which will hit this case
  11118. if ( isNaN( value ) ) {
  11119. return prop.def;
  11120. }
  11121. if ( type.mod ) {
  11122. // we add mod before modding to make sure that negatives values
  11123. // get converted properly: -10 -> 350
  11124. return (value + type.mod) % type.mod;
  11125. }
  11126. // for now all property types without mod have min and max
  11127. return 0 > value ? 0 : type.max < value ? type.max : value;
  11128. }
  11129. function stringParse( string ) {
  11130. var inst = color(),
  11131. rgba = inst._rgba = [];
  11132. string = string.toLowerCase();
  11133. each( stringParsers, function( i, parser ) {
  11134. var parsed,
  11135. match = parser.re.exec( string ),
  11136. values = match && parser.parse( match ),
  11137. spaceName = parser.space || "rgba";
  11138. if ( values ) {
  11139. parsed = inst[ spaceName ]( values );
  11140. // if this was an rgba parse the assignment might happen twice
  11141. // oh well....
  11142. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  11143. rgba = inst._rgba = parsed._rgba;
  11144. // exit each( stringParsers ) here because we matched
  11145. return false;
  11146. }
  11147. });
  11148. // Found a stringParser that handled it
  11149. if ( rgba.length ) {
  11150. // if this came from a parsed string, force "transparent" when alpha is 0
  11151. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  11152. if ( rgba.join() === "0,0,0,0" ) {
  11153. jQuery.extend( rgba, colors.transparent );
  11154. }
  11155. return inst;
  11156. }
  11157. // named colors
  11158. return colors[ string ];
  11159. }
  11160. color.fn = jQuery.extend( color.prototype, {
  11161. parse: function( red, green, blue, alpha ) {
  11162. if ( red === undefined ) {
  11163. this._rgba = [ null, null, null, null ];
  11164. return this;
  11165. }
  11166. if ( red.jquery || red.nodeType ) {
  11167. red = jQuery( red ).css( green );
  11168. green = undefined;
  11169. }
  11170. var inst = this,
  11171. type = jQuery.type( red ),
  11172. rgba = this._rgba = [];
  11173. // more than 1 argument specified - assume ( red, green, blue, alpha )
  11174. if ( green !== undefined ) {
  11175. red = [ red, green, blue, alpha ];
  11176. type = "array";
  11177. }
  11178. if ( type === "string" ) {
  11179. return this.parse( stringParse( red ) || colors._default );
  11180. }
  11181. if ( type === "array" ) {
  11182. each( spaces.rgba.props, function( key, prop ) {
  11183. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  11184. });
  11185. return this;
  11186. }
  11187. if ( type === "object" ) {
  11188. if ( red instanceof color ) {
  11189. each( spaces, function( spaceName, space ) {
  11190. if ( red[ space.cache ] ) {
  11191. inst[ space.cache ] = red[ space.cache ].slice();
  11192. }
  11193. });
  11194. } else {
  11195. each( spaces, function( spaceName, space ) {
  11196. var cache = space.cache;
  11197. each( space.props, function( key, prop ) {
  11198. // if the cache doesn't exist, and we know how to convert
  11199. if ( !inst[ cache ] && space.to ) {
  11200. // if the value was null, we don't need to copy it
  11201. // if the key was alpha, we don't need to copy it either
  11202. if ( key === "alpha" || red[ key ] == null ) {
  11203. return;
  11204. }
  11205. inst[ cache ] = space.to( inst._rgba );
  11206. }
  11207. // this is the only case where we allow nulls for ALL properties.
  11208. // call clamp with alwaysAllowEmpty
  11209. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  11210. });
  11211. // everything defined but alpha?
  11212. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  11213. // use the default of 1
  11214. inst[ cache ][ 3 ] = 1;
  11215. if ( space.from ) {
  11216. inst._rgba = space.from( inst[ cache ] );
  11217. }
  11218. }
  11219. });
  11220. }
  11221. return this;
  11222. }
  11223. },
  11224. is: function( compare ) {
  11225. var is = color( compare ),
  11226. same = true,
  11227. inst = this;
  11228. each( spaces, function( _, space ) {
  11229. var localCache,
  11230. isCache = is[ space.cache ];
  11231. if (isCache) {
  11232. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  11233. each( space.props, function( _, prop ) {
  11234. if ( isCache[ prop.idx ] != null ) {
  11235. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  11236. return same;
  11237. }
  11238. });
  11239. }
  11240. return same;
  11241. });
  11242. return same;
  11243. },
  11244. _space: function() {
  11245. var used = [],
  11246. inst = this;
  11247. each( spaces, function( spaceName, space ) {
  11248. if ( inst[ space.cache ] ) {
  11249. used.push( spaceName );
  11250. }
  11251. });
  11252. return used.pop();
  11253. },
  11254. transition: function( other, distance ) {
  11255. var end = color( other ),
  11256. spaceName = end._space(),
  11257. space = spaces[ spaceName ],
  11258. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  11259. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  11260. result = start.slice();
  11261. end = end[ space.cache ];
  11262. each( space.props, function( key, prop ) {
  11263. var index = prop.idx,
  11264. startValue = start[ index ],
  11265. endValue = end[ index ],
  11266. type = propTypes[ prop.type ] || {};
  11267. // if null, don't override start value
  11268. if ( endValue === null ) {
  11269. return;
  11270. }
  11271. // if null - use end
  11272. if ( startValue === null ) {
  11273. result[ index ] = endValue;
  11274. } else {
  11275. if ( type.mod ) {
  11276. if ( endValue - startValue > type.mod / 2 ) {
  11277. startValue += type.mod;
  11278. } else if ( startValue - endValue > type.mod / 2 ) {
  11279. startValue -= type.mod;
  11280. }
  11281. }
  11282. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  11283. }
  11284. });
  11285. return this[ spaceName ]( result );
  11286. },
  11287. blend: function( opaque ) {
  11288. // if we are already opaque - return ourself
  11289. if ( this._rgba[ 3 ] === 1 ) {
  11290. return this;
  11291. }
  11292. var rgb = this._rgba.slice(),
  11293. a = rgb.pop(),
  11294. blend = color( opaque )._rgba;
  11295. return color( jQuery.map( rgb, function( v, i ) {
  11296. return ( 1 - a ) * blend[ i ] + a * v;
  11297. }));
  11298. },
  11299. toRgbaString: function() {
  11300. var prefix = "rgba(",
  11301. rgba = jQuery.map( this._rgba, function( v, i ) {
  11302. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  11303. });
  11304. if ( rgba[ 3 ] === 1 ) {
  11305. rgba.pop();
  11306. prefix = "rgb(";
  11307. }
  11308. return prefix + rgba.join() + ")";
  11309. },
  11310. toHslaString: function() {
  11311. var prefix = "hsla(",
  11312. hsla = jQuery.map( this.hsla(), function( v, i ) {
  11313. if ( v == null ) {
  11314. v = i > 2 ? 1 : 0;
  11315. }
  11316. // catch 1 and 2
  11317. if ( i && i < 3 ) {
  11318. v = Math.round( v * 100 ) + "%";
  11319. }
  11320. return v;
  11321. });
  11322. if ( hsla[ 3 ] === 1 ) {
  11323. hsla.pop();
  11324. prefix = "hsl(";
  11325. }
  11326. return prefix + hsla.join() + ")";
  11327. },
  11328. toHexString: function( includeAlpha ) {
  11329. var rgba = this._rgba.slice(),
  11330. alpha = rgba.pop();
  11331. if ( includeAlpha ) {
  11332. rgba.push( ~~( alpha * 255 ) );
  11333. }
  11334. return "#" + jQuery.map( rgba, function( v ) {
  11335. // default to 0 when nulls exist
  11336. v = ( v || 0 ).toString( 16 );
  11337. return v.length === 1 ? "0" + v : v;
  11338. }).join("");
  11339. },
  11340. toString: function() {
  11341. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  11342. }
  11343. });
  11344. color.fn.parse.prototype = color.fn;
  11345. // hsla conversions adapted from:
  11346. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  11347. function hue2rgb( p, q, h ) {
  11348. h = ( h + 1 ) % 1;
  11349. if ( h * 6 < 1 ) {
  11350. return p + (q - p) * h * 6;
  11351. }
  11352. if ( h * 2 < 1) {
  11353. return q;
  11354. }
  11355. if ( h * 3 < 2 ) {
  11356. return p + (q - p) * ((2/3) - h) * 6;
  11357. }
  11358. return p;
  11359. }
  11360. spaces.hsla.to = function ( rgba ) {
  11361. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  11362. return [ null, null, null, rgba[ 3 ] ];
  11363. }
  11364. var r = rgba[ 0 ] / 255,
  11365. g = rgba[ 1 ] / 255,
  11366. b = rgba[ 2 ] / 255,
  11367. a = rgba[ 3 ],
  11368. max = Math.max( r, g, b ),
  11369. min = Math.min( r, g, b ),
  11370. diff = max - min,
  11371. add = max + min,
  11372. l = add * 0.5,
  11373. h, s;
  11374. if ( min === max ) {
  11375. h = 0;
  11376. } else if ( r === max ) {
  11377. h = ( 60 * ( g - b ) / diff ) + 360;
  11378. } else if ( g === max ) {
  11379. h = ( 60 * ( b - r ) / diff ) + 120;
  11380. } else {
  11381. h = ( 60 * ( r - g ) / diff ) + 240;
  11382. }
  11383. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  11384. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  11385. if ( diff === 0 ) {
  11386. s = 0;
  11387. } else if ( l <= 0.5 ) {
  11388. s = diff / add;
  11389. } else {
  11390. s = diff / ( 2 - add );
  11391. }
  11392. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  11393. };
  11394. spaces.hsla.from = function ( hsla ) {
  11395. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  11396. return [ null, null, null, hsla[ 3 ] ];
  11397. }
  11398. var h = hsla[ 0 ] / 360,
  11399. s = hsla[ 1 ],
  11400. l = hsla[ 2 ],
  11401. a = hsla[ 3 ],
  11402. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  11403. p = 2 * l - q;
  11404. return [
  11405. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  11406. Math.round( hue2rgb( p, q, h ) * 255 ),
  11407. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  11408. a
  11409. ];
  11410. };
  11411. each( spaces, function( spaceName, space ) {
  11412. var props = space.props,
  11413. cache = space.cache,
  11414. to = space.to,
  11415. from = space.from;
  11416. // makes rgba() and hsla()
  11417. color.fn[ spaceName ] = function( value ) {
  11418. // generate a cache for this space if it doesn't exist
  11419. if ( to && !this[ cache ] ) {
  11420. this[ cache ] = to( this._rgba );
  11421. }
  11422. if ( value === undefined ) {
  11423. return this[ cache ].slice();
  11424. }
  11425. var ret,
  11426. type = jQuery.type( value ),
  11427. arr = ( type === "array" || type === "object" ) ? value : arguments,
  11428. local = this[ cache ].slice();
  11429. each( props, function( key, prop ) {
  11430. var val = arr[ type === "object" ? key : prop.idx ];
  11431. if ( val == null ) {
  11432. val = local[ prop.idx ];
  11433. }
  11434. local[ prop.idx ] = clamp( val, prop );
  11435. });
  11436. if ( from ) {
  11437. ret = color( from( local ) );
  11438. ret[ cache ] = local;
  11439. return ret;
  11440. } else {
  11441. return color( local );
  11442. }
  11443. };
  11444. // makes red() green() blue() alpha() hue() saturation() lightness()
  11445. each( props, function( key, prop ) {
  11446. // alpha is included in more than one space
  11447. if ( color.fn[ key ] ) {
  11448. return;
  11449. }
  11450. color.fn[ key ] = function( value ) {
  11451. var vtype = jQuery.type( value ),
  11452. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  11453. local = this[ fn ](),
  11454. cur = local[ prop.idx ],
  11455. match;
  11456. if ( vtype === "undefined" ) {
  11457. return cur;
  11458. }
  11459. if ( vtype === "function" ) {
  11460. value = value.call( this, cur );
  11461. vtype = jQuery.type( value );
  11462. }
  11463. if ( value == null && prop.empty ) {
  11464. return this;
  11465. }
  11466. if ( vtype === "string" ) {
  11467. match = rplusequals.exec( value );
  11468. if ( match ) {
  11469. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  11470. }
  11471. }
  11472. local[ prop.idx ] = value;
  11473. return this[ fn ]( local );
  11474. };
  11475. });
  11476. });
  11477. // add cssHook and .fx.step function for each named hook.
  11478. // accept a space separated string of properties
  11479. color.hook = function( hook ) {
  11480. var hooks = hook.split( " " );
  11481. each( hooks, function( i, hook ) {
  11482. jQuery.cssHooks[ hook ] = {
  11483. set: function( elem, value ) {
  11484. var parsed, curElem,
  11485. backgroundColor = "";
  11486. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  11487. value = color( parsed || value );
  11488. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  11489. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  11490. while (
  11491. (backgroundColor === "" || backgroundColor === "transparent") &&
  11492. curElem && curElem.style
  11493. ) {
  11494. try {
  11495. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  11496. curElem = curElem.parentNode;
  11497. } catch ( e ) {
  11498. }
  11499. }
  11500. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  11501. backgroundColor :
  11502. "_default" );
  11503. }
  11504. value = value.toRgbaString();
  11505. }
  11506. try {
  11507. elem.style[ hook ] = value;
  11508. } catch( e ) {
  11509. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  11510. }
  11511. }
  11512. };
  11513. jQuery.fx.step[ hook ] = function( fx ) {
  11514. if ( !fx.colorInit ) {
  11515. fx.start = color( fx.elem, hook );
  11516. fx.end = color( fx.end );
  11517. fx.colorInit = true;
  11518. }
  11519. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  11520. };
  11521. });
  11522. };
  11523. color.hook( stepHooks );
  11524. jQuery.cssHooks.borderColor = {
  11525. expand: function( value ) {
  11526. var expanded = {};
  11527. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  11528. expanded[ "border" + part + "Color" ] = value;
  11529. });
  11530. return expanded;
  11531. }
  11532. };
  11533. // Basic color names only.
  11534. // Usage of any of the other color names requires adding yourself or including
  11535. // jquery.color.svg-names.js.
  11536. colors = jQuery.Color.names = {
  11537. // 4.1. Basic color keywords
  11538. aqua: "#00ffff",
  11539. black: "#000000",
  11540. blue: "#0000ff",
  11541. fuchsia: "#ff00ff",
  11542. gray: "#808080",
  11543. green: "#008000",
  11544. lime: "#00ff00",
  11545. maroon: "#800000",
  11546. navy: "#000080",
  11547. olive: "#808000",
  11548. purple: "#800080",
  11549. red: "#ff0000",
  11550. silver: "#c0c0c0",
  11551. teal: "#008080",
  11552. white: "#ffffff",
  11553. yellow: "#ffff00",
  11554. // 4.2.3. "transparent" color keyword
  11555. transparent: [ null, null, null, 0 ],
  11556. _default: "#ffffff"
  11557. };
  11558. })( jQuery );
  11559. /******************************************************************************/
  11560. /****************************** CLASS ANIMATIONS ******************************/
  11561. /******************************************************************************/
  11562. (function() {
  11563. var classAnimationActions = [ "add", "remove", "toggle" ],
  11564. shorthandStyles = {
  11565. border: 1,
  11566. borderBottom: 1,
  11567. borderColor: 1,
  11568. borderLeft: 1,
  11569. borderRight: 1,
  11570. borderTop: 1,
  11571. borderWidth: 1,
  11572. margin: 1,
  11573. padding: 1
  11574. };
  11575. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  11576. $.fx.step[ prop ] = function( fx ) {
  11577. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  11578. jQuery.style( fx.elem, prop, fx.end );
  11579. fx.setAttr = true;
  11580. }
  11581. };
  11582. });
  11583. function getElementStyles( elem ) {
  11584. var key, len,
  11585. style = elem.ownerDocument.defaultView ?
  11586. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  11587. elem.currentStyle,
  11588. styles = {};
  11589. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  11590. len = style.length;
  11591. while ( len-- ) {
  11592. key = style[ len ];
  11593. if ( typeof style[ key ] === "string" ) {
  11594. styles[ $.camelCase( key ) ] = style[ key ];
  11595. }
  11596. }
  11597. // support: Opera, IE <9
  11598. } else {
  11599. for ( key in style ) {
  11600. if ( typeof style[ key ] === "string" ) {
  11601. styles[ key ] = style[ key ];
  11602. }
  11603. }
  11604. }
  11605. return styles;
  11606. }
  11607. function styleDifference( oldStyle, newStyle ) {
  11608. var diff = {},
  11609. name, value;
  11610. for ( name in newStyle ) {
  11611. value = newStyle[ name ];
  11612. if ( oldStyle[ name ] !== value ) {
  11613. if ( !shorthandStyles[ name ] ) {
  11614. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  11615. diff[ name ] = value;
  11616. }
  11617. }
  11618. }
  11619. }
  11620. return diff;
  11621. }
  11622. // support: jQuery <1.8
  11623. if ( !$.fn.addBack ) {
  11624. $.fn.addBack = function( selector ) {
  11625. return this.add( selector == null ?
  11626. this.prevObject : this.prevObject.filter( selector )
  11627. );
  11628. };
  11629. }
  11630. $.effects.animateClass = function( value, duration, easing, callback ) {
  11631. var o = $.speed( duration, easing, callback );
  11632. return this.queue( function() {
  11633. var animated = $( this ),
  11634. baseClass = animated.attr( "class" ) || "",
  11635. applyClassChange,
  11636. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  11637. // map the animated objects to store the original styles.
  11638. allAnimations = allAnimations.map(function() {
  11639. var el = $( this );
  11640. return {
  11641. el: el,
  11642. start: getElementStyles( this )
  11643. };
  11644. });
  11645. // apply class change
  11646. applyClassChange = function() {
  11647. $.each( classAnimationActions, function(i, action) {
  11648. if ( value[ action ] ) {
  11649. animated[ action + "Class" ]( value[ action ] );
  11650. }
  11651. });
  11652. };
  11653. applyClassChange();
  11654. // map all animated objects again - calculate new styles and diff
  11655. allAnimations = allAnimations.map(function() {
  11656. this.end = getElementStyles( this.el[ 0 ] );
  11657. this.diff = styleDifference( this.start, this.end );
  11658. return this;
  11659. });
  11660. // apply original class
  11661. animated.attr( "class", baseClass );
  11662. // map all animated objects again - this time collecting a promise
  11663. allAnimations = allAnimations.map(function() {
  11664. var styleInfo = this,
  11665. dfd = $.Deferred(),
  11666. opts = $.extend({}, o, {
  11667. queue: false,
  11668. complete: function() {
  11669. dfd.resolve( styleInfo );
  11670. }
  11671. });
  11672. this.el.animate( this.diff, opts );
  11673. return dfd.promise();
  11674. });
  11675. // once all animations have completed:
  11676. $.when.apply( $, allAnimations.get() ).done(function() {
  11677. // set the final class
  11678. applyClassChange();
  11679. // for each animated element,
  11680. // clear all css properties that were animated
  11681. $.each( arguments, function() {
  11682. var el = this.el;
  11683. $.each( this.diff, function(key) {
  11684. el.css( key, "" );
  11685. });
  11686. });
  11687. // this is guarnteed to be there if you use jQuery.speed()
  11688. // it also handles dequeuing the next anim...
  11689. o.complete.call( animated[ 0 ] );
  11690. });
  11691. });
  11692. };
  11693. $.fn.extend({
  11694. addClass: (function( orig ) {
  11695. return function( classNames, speed, easing, callback ) {
  11696. return speed ?
  11697. $.effects.animateClass.call( this,
  11698. { add: classNames }, speed, easing, callback ) :
  11699. orig.apply( this, arguments );
  11700. };
  11701. })( $.fn.addClass ),
  11702. removeClass: (function( orig ) {
  11703. return function( classNames, speed, easing, callback ) {
  11704. return arguments.length > 1 ?
  11705. $.effects.animateClass.call( this,
  11706. { remove: classNames }, speed, easing, callback ) :
  11707. orig.apply( this, arguments );
  11708. };
  11709. })( $.fn.removeClass ),
  11710. toggleClass: (function( orig ) {
  11711. return function( classNames, force, speed, easing, callback ) {
  11712. if ( typeof force === "boolean" || force === undefined ) {
  11713. if ( !speed ) {
  11714. // without speed parameter
  11715. return orig.apply( this, arguments );
  11716. } else {
  11717. return $.effects.animateClass.call( this,
  11718. (force ? { add: classNames } : { remove: classNames }),
  11719. speed, easing, callback );
  11720. }
  11721. } else {
  11722. // without force parameter
  11723. return $.effects.animateClass.call( this,
  11724. { toggle: classNames }, force, speed, easing );
  11725. }
  11726. };
  11727. })( $.fn.toggleClass ),
  11728. switchClass: function( remove, add, speed, easing, callback) {
  11729. return $.effects.animateClass.call( this, {
  11730. add: add,
  11731. remove: remove
  11732. }, speed, easing, callback );
  11733. }
  11734. });
  11735. })();
  11736. /******************************************************************************/
  11737. /*********************************** EFFECTS **********************************/
  11738. /******************************************************************************/
  11739. (function() {
  11740. $.extend( $.effects, {
  11741. version: "1.10.4",
  11742. // Saves a set of properties in a data storage
  11743. save: function( element, set ) {
  11744. for( var i=0; i < set.length; i++ ) {
  11745. if ( set[ i ] !== null ) {
  11746. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  11747. }
  11748. }
  11749. },
  11750. // Restores a set of previously saved properties from a data storage
  11751. restore: function( element, set ) {
  11752. var val, i;
  11753. for( i=0; i < set.length; i++ ) {
  11754. if ( set[ i ] !== null ) {
  11755. val = element.data( dataSpace + set[ i ] );
  11756. // support: jQuery 1.6.2
  11757. // http://bugs.jquery.com/ticket/9917
  11758. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  11759. // We can't differentiate between "" and 0 here, so we just assume
  11760. // empty string since it's likely to be a more common value...
  11761. if ( val === undefined ) {
  11762. val = "";
  11763. }
  11764. element.css( set[ i ], val );
  11765. }
  11766. }
  11767. },
  11768. setMode: function( el, mode ) {
  11769. if (mode === "toggle") {
  11770. mode = el.is( ":hidden" ) ? "show" : "hide";
  11771. }
  11772. return mode;
  11773. },
  11774. // Translates a [top,left] array into a baseline value
  11775. // this should be a little more flexible in the future to handle a string & hash
  11776. getBaseline: function( origin, original ) {
  11777. var y, x;
  11778. switch ( origin[ 0 ] ) {
  11779. case "top": y = 0; break;
  11780. case "middle": y = 0.5; break;
  11781. case "bottom": y = 1; break;
  11782. default: y = origin[ 0 ] / original.height;
  11783. }
  11784. switch ( origin[ 1 ] ) {
  11785. case "left": x = 0; break;
  11786. case "center": x = 0.5; break;
  11787. case "right": x = 1; break;
  11788. default: x = origin[ 1 ] / original.width;
  11789. }
  11790. return {
  11791. x: x,
  11792. y: y
  11793. };
  11794. },
  11795. // Wraps the element around a wrapper that copies position properties
  11796. createWrapper: function( element ) {
  11797. // if the element is already wrapped, return it
  11798. if ( element.parent().is( ".ui-effects-wrapper" )) {
  11799. return element.parent();
  11800. }
  11801. // wrap the element
  11802. var props = {
  11803. width: element.outerWidth(true),
  11804. height: element.outerHeight(true),
  11805. "float": element.css( "float" )
  11806. },
  11807. wrapper = $( "<div></div>" )
  11808. .addClass( "ui-effects-wrapper" )
  11809. .css({
  11810. fontSize: "100%",
  11811. background: "transparent",
  11812. border: "none",
  11813. margin: 0,
  11814. padding: 0
  11815. }),
  11816. // Store the size in case width/height are defined in % - Fixes #5245
  11817. size = {
  11818. width: element.width(),
  11819. height: element.height()
  11820. },
  11821. active = document.activeElement;
  11822. // support: Firefox
  11823. // Firefox incorrectly exposes anonymous content
  11824. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  11825. try {
  11826. active.id;
  11827. } catch( e ) {
  11828. active = document.body;
  11829. }
  11830. element.wrap( wrapper );
  11831. // Fixes #7595 - Elements lose focus when wrapped.
  11832. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  11833. $( active ).focus();
  11834. }
  11835. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  11836. // transfer positioning properties to the wrapper
  11837. if ( element.css( "position" ) === "static" ) {
  11838. wrapper.css({ position: "relative" });
  11839. element.css({ position: "relative" });
  11840. } else {
  11841. $.extend( props, {
  11842. position: element.css( "position" ),
  11843. zIndex: element.css( "z-index" )
  11844. });
  11845. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  11846. props[ pos ] = element.css( pos );
  11847. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  11848. props[ pos ] = "auto";
  11849. }
  11850. });
  11851. element.css({
  11852. position: "relative",
  11853. top: 0,
  11854. left: 0,
  11855. right: "auto",
  11856. bottom: "auto"
  11857. });
  11858. }
  11859. element.css(size);
  11860. return wrapper.css( props ).show();
  11861. },
  11862. removeWrapper: function( element ) {
  11863. var active = document.activeElement;
  11864. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  11865. element.parent().replaceWith( element );
  11866. // Fixes #7595 - Elements lose focus when wrapped.
  11867. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  11868. $( active ).focus();
  11869. }
  11870. }
  11871. return element;
  11872. },
  11873. setTransition: function( element, list, factor, value ) {
  11874. value = value || {};
  11875. $.each( list, function( i, x ) {
  11876. var unit = element.cssUnit( x );
  11877. if ( unit[ 0 ] > 0 ) {
  11878. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  11879. }
  11880. });
  11881. return value;
  11882. }
  11883. });
  11884. // return an effect options object for the given parameters:
  11885. function _normalizeArguments( effect, options, speed, callback ) {
  11886. // allow passing all options as the first parameter
  11887. if ( $.isPlainObject( effect ) ) {
  11888. options = effect;
  11889. effect = effect.effect;
  11890. }
  11891. // convert to an object
  11892. effect = { effect: effect };
  11893. // catch (effect, null, ...)
  11894. if ( options == null ) {
  11895. options = {};
  11896. }
  11897. // catch (effect, callback)
  11898. if ( $.isFunction( options ) ) {
  11899. callback = options;
  11900. speed = null;
  11901. options = {};
  11902. }
  11903. // catch (effect, speed, ?)
  11904. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  11905. callback = speed;
  11906. speed = options;
  11907. options = {};
  11908. }
  11909. // catch (effect, options, callback)
  11910. if ( $.isFunction( speed ) ) {
  11911. callback = speed;
  11912. speed = null;
  11913. }
  11914. // add options to effect
  11915. if ( options ) {
  11916. $.extend( effect, options );
  11917. }
  11918. speed = speed || options.duration;
  11919. effect.duration = $.fx.off ? 0 :
  11920. typeof speed === "number" ? speed :
  11921. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  11922. $.fx.speeds._default;
  11923. effect.complete = callback || options.complete;
  11924. return effect;
  11925. }
  11926. function standardAnimationOption( option ) {
  11927. // Valid standard speeds (nothing, number, named speed)
  11928. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  11929. return true;
  11930. }
  11931. // Invalid strings - treat as "normal" speed
  11932. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  11933. return true;
  11934. }
  11935. // Complete callback
  11936. if ( $.isFunction( option ) ) {
  11937. return true;
  11938. }
  11939. // Options hash (but not naming an effect)
  11940. if ( typeof option === "object" && !option.effect ) {
  11941. return true;
  11942. }
  11943. // Didn't match any standard API
  11944. return false;
  11945. }
  11946. $.fn.extend({
  11947. effect: function( /* effect, options, speed, callback */ ) {
  11948. var args = _normalizeArguments.apply( this, arguments ),
  11949. mode = args.mode,
  11950. queue = args.queue,
  11951. effectMethod = $.effects.effect[ args.effect ];
  11952. if ( $.fx.off || !effectMethod ) {
  11953. // delegate to the original method (e.g., .show()) if possible
  11954. if ( mode ) {
  11955. return this[ mode ]( args.duration, args.complete );
  11956. } else {
  11957. return this.each( function() {
  11958. if ( args.complete ) {
  11959. args.complete.call( this );
  11960. }
  11961. });
  11962. }
  11963. }
  11964. function run( next ) {
  11965. var elem = $( this ),
  11966. complete = args.complete,
  11967. mode = args.mode;
  11968. function done() {
  11969. if ( $.isFunction( complete ) ) {
  11970. complete.call( elem[0] );
  11971. }
  11972. if ( $.isFunction( next ) ) {
  11973. next();
  11974. }
  11975. }
  11976. // If the element already has the correct final state, delegate to
  11977. // the core methods so the internal tracking of "olddisplay" works.
  11978. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  11979. elem[ mode ]();
  11980. done();
  11981. } else {
  11982. effectMethod.call( elem[0], args, done );
  11983. }
  11984. }
  11985. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  11986. },
  11987. show: (function( orig ) {
  11988. return function( option ) {
  11989. if ( standardAnimationOption( option ) ) {
  11990. return orig.apply( this, arguments );
  11991. } else {
  11992. var args = _normalizeArguments.apply( this, arguments );
  11993. args.mode = "show";
  11994. return this.effect.call( this, args );
  11995. }
  11996. };
  11997. })( $.fn.show ),
  11998. hide: (function( orig ) {
  11999. return function( option ) {
  12000. if ( standardAnimationOption( option ) ) {
  12001. return orig.apply( this, arguments );
  12002. } else {
  12003. var args = _normalizeArguments.apply( this, arguments );
  12004. args.mode = "hide";
  12005. return this.effect.call( this, args );
  12006. }
  12007. };
  12008. })( $.fn.hide ),
  12009. toggle: (function( orig ) {
  12010. return function( option ) {
  12011. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  12012. return orig.apply( this, arguments );
  12013. } else {
  12014. var args = _normalizeArguments.apply( this, arguments );
  12015. args.mode = "toggle";
  12016. return this.effect.call( this, args );
  12017. }
  12018. };
  12019. })( $.fn.toggle ),
  12020. // helper functions
  12021. cssUnit: function(key) {
  12022. var style = this.css( key ),
  12023. val = [];
  12024. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  12025. if ( style.indexOf( unit ) > 0 ) {
  12026. val = [ parseFloat( style ), unit ];
  12027. }
  12028. });
  12029. return val;
  12030. }
  12031. });
  12032. })();
  12033. /******************************************************************************/
  12034. /*********************************** EASING ***********************************/
  12035. /******************************************************************************/
  12036. (function() {
  12037. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  12038. var baseEasings = {};
  12039. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  12040. baseEasings[ name ] = function( p ) {
  12041. return Math.pow( p, i + 2 );
  12042. };
  12043. });
  12044. $.extend( baseEasings, {
  12045. Sine: function ( p ) {
  12046. return 1 - Math.cos( p * Math.PI / 2 );
  12047. },
  12048. Circ: function ( p ) {
  12049. return 1 - Math.sqrt( 1 - p * p );
  12050. },
  12051. Elastic: function( p ) {
  12052. return p === 0 || p === 1 ? p :
  12053. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  12054. },
  12055. Back: function( p ) {
  12056. return p * p * ( 3 * p - 2 );
  12057. },
  12058. Bounce: function ( p ) {
  12059. var pow2,
  12060. bounce = 4;
  12061. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  12062. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  12063. }
  12064. });
  12065. $.each( baseEasings, function( name, easeIn ) {
  12066. $.easing[ "easeIn" + name ] = easeIn;
  12067. $.easing[ "easeOut" + name ] = function( p ) {
  12068. return 1 - easeIn( 1 - p );
  12069. };
  12070. $.easing[ "easeInOut" + name ] = function( p ) {
  12071. return p < 0.5 ?
  12072. easeIn( p * 2 ) / 2 :
  12073. 1 - easeIn( p * -2 + 2 ) / 2;
  12074. };
  12075. });
  12076. })();
  12077. })(jQuery);
  12078. (function( $, undefined ) {
  12079. var rvertical = /up|down|vertical/,
  12080. rpositivemotion = /up|left|vertical|horizontal/;
  12081. $.effects.effect.blind = function( o, done ) {
  12082. // Create element
  12083. var el = $( this ),
  12084. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12085. mode = $.effects.setMode( el, o.mode || "hide" ),
  12086. direction = o.direction || "up",
  12087. vertical = rvertical.test( direction ),
  12088. ref = vertical ? "height" : "width",
  12089. ref2 = vertical ? "top" : "left",
  12090. motion = rpositivemotion.test( direction ),
  12091. animation = {},
  12092. show = mode === "show",
  12093. wrapper, distance, margin;
  12094. // if already wrapped, the wrapper's properties are my property. #6245
  12095. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  12096. $.effects.save( el.parent(), props );
  12097. } else {
  12098. $.effects.save( el, props );
  12099. }
  12100. el.show();
  12101. wrapper = $.effects.createWrapper( el ).css({
  12102. overflow: "hidden"
  12103. });
  12104. distance = wrapper[ ref ]();
  12105. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  12106. animation[ ref ] = show ? distance : 0;
  12107. if ( !motion ) {
  12108. el
  12109. .css( vertical ? "bottom" : "right", 0 )
  12110. .css( vertical ? "top" : "left", "auto" )
  12111. .css({ position: "absolute" });
  12112. animation[ ref2 ] = show ? margin : distance + margin;
  12113. }
  12114. // start at 0 if we are showing
  12115. if ( show ) {
  12116. wrapper.css( ref, 0 );
  12117. if ( ! motion ) {
  12118. wrapper.css( ref2, margin + distance );
  12119. }
  12120. }
  12121. // Animate
  12122. wrapper.animate( animation, {
  12123. duration: o.duration,
  12124. easing: o.easing,
  12125. queue: false,
  12126. complete: function() {
  12127. if ( mode === "hide" ) {
  12128. el.hide();
  12129. }
  12130. $.effects.restore( el, props );
  12131. $.effects.removeWrapper( el );
  12132. done();
  12133. }
  12134. });
  12135. };
  12136. })(jQuery);
  12137. (function( $, undefined ) {
  12138. $.effects.effect.bounce = function( o, done ) {
  12139. var el = $( this ),
  12140. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12141. // defaults:
  12142. mode = $.effects.setMode( el, o.mode || "effect" ),
  12143. hide = mode === "hide",
  12144. show = mode === "show",
  12145. direction = o.direction || "up",
  12146. distance = o.distance,
  12147. times = o.times || 5,
  12148. // number of internal animations
  12149. anims = times * 2 + ( show || hide ? 1 : 0 ),
  12150. speed = o.duration / anims,
  12151. easing = o.easing,
  12152. // utility:
  12153. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  12154. motion = ( direction === "up" || direction === "left" ),
  12155. i,
  12156. upAnim,
  12157. downAnim,
  12158. // we will need to re-assemble the queue to stack our animations in place
  12159. queue = el.queue(),
  12160. queuelen = queue.length;
  12161. // Avoid touching opacity to prevent clearType and PNG issues in IE
  12162. if ( show || hide ) {
  12163. props.push( "opacity" );
  12164. }
  12165. $.effects.save( el, props );
  12166. el.show();
  12167. $.effects.createWrapper( el ); // Create Wrapper
  12168. // default distance for the BIGGEST bounce is the outer Distance / 3
  12169. if ( !distance ) {
  12170. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  12171. }
  12172. if ( show ) {
  12173. downAnim = { opacity: 1 };
  12174. downAnim[ ref ] = 0;
  12175. // if we are showing, force opacity 0 and set the initial position
  12176. // then do the "first" animation
  12177. el.css( "opacity", 0 )
  12178. .css( ref, motion ? -distance * 2 : distance * 2 )
  12179. .animate( downAnim, speed, easing );
  12180. }
  12181. // start at the smallest distance if we are hiding
  12182. if ( hide ) {
  12183. distance = distance / Math.pow( 2, times - 1 );
  12184. }
  12185. downAnim = {};
  12186. downAnim[ ref ] = 0;
  12187. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  12188. for ( i = 0; i < times; i++ ) {
  12189. upAnim = {};
  12190. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  12191. el.animate( upAnim, speed, easing )
  12192. .animate( downAnim, speed, easing );
  12193. distance = hide ? distance * 2 : distance / 2;
  12194. }
  12195. // Last Bounce when Hiding
  12196. if ( hide ) {
  12197. upAnim = { opacity: 0 };
  12198. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  12199. el.animate( upAnim, speed, easing );
  12200. }
  12201. el.queue(function() {
  12202. if ( hide ) {
  12203. el.hide();
  12204. }
  12205. $.effects.restore( el, props );
  12206. $.effects.removeWrapper( el );
  12207. done();
  12208. });
  12209. // inject all the animations we just queued to be first in line (after "inprogress")
  12210. if ( queuelen > 1) {
  12211. queue.splice.apply( queue,
  12212. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  12213. }
  12214. el.dequeue();
  12215. };
  12216. })(jQuery);
  12217. (function( $, undefined ) {
  12218. $.effects.effect.clip = function( o, done ) {
  12219. // Create element
  12220. var el = $( this ),
  12221. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12222. mode = $.effects.setMode( el, o.mode || "hide" ),
  12223. show = mode === "show",
  12224. direction = o.direction || "vertical",
  12225. vert = direction === "vertical",
  12226. size = vert ? "height" : "width",
  12227. position = vert ? "top" : "left",
  12228. animation = {},
  12229. wrapper, animate, distance;
  12230. // Save & Show
  12231. $.effects.save( el, props );
  12232. el.show();
  12233. // Create Wrapper
  12234. wrapper = $.effects.createWrapper( el ).css({
  12235. overflow: "hidden"
  12236. });
  12237. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  12238. distance = animate[ size ]();
  12239. // Shift
  12240. if ( show ) {
  12241. animate.css( size, 0 );
  12242. animate.css( position, distance / 2 );
  12243. }
  12244. // Create Animation Object:
  12245. animation[ size ] = show ? distance : 0;
  12246. animation[ position ] = show ? 0 : distance / 2;
  12247. // Animate
  12248. animate.animate( animation, {
  12249. queue: false,
  12250. duration: o.duration,
  12251. easing: o.easing,
  12252. complete: function() {
  12253. if ( !show ) {
  12254. el.hide();
  12255. }
  12256. $.effects.restore( el, props );
  12257. $.effects.removeWrapper( el );
  12258. done();
  12259. }
  12260. });
  12261. };
  12262. })(jQuery);
  12263. (function( $, undefined ) {
  12264. $.effects.effect.drop = function( o, done ) {
  12265. var el = $( this ),
  12266. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  12267. mode = $.effects.setMode( el, o.mode || "hide" ),
  12268. show = mode === "show",
  12269. direction = o.direction || "left",
  12270. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  12271. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  12272. animation = {
  12273. opacity: show ? 1 : 0
  12274. },
  12275. distance;
  12276. // Adjust
  12277. $.effects.save( el, props );
  12278. el.show();
  12279. $.effects.createWrapper( el );
  12280. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  12281. if ( show ) {
  12282. el
  12283. .css( "opacity", 0 )
  12284. .css( ref, motion === "pos" ? -distance : distance );
  12285. }
  12286. // Animation
  12287. animation[ ref ] = ( show ?
  12288. ( motion === "pos" ? "+=" : "-=" ) :
  12289. ( motion === "pos" ? "-=" : "+=" ) ) +
  12290. distance;
  12291. // Animate
  12292. el.animate( animation, {
  12293. queue: false,
  12294. duration: o.duration,
  12295. easing: o.easing,
  12296. complete: function() {
  12297. if ( mode === "hide" ) {
  12298. el.hide();
  12299. }
  12300. $.effects.restore( el, props );
  12301. $.effects.removeWrapper( el );
  12302. done();
  12303. }
  12304. });
  12305. };
  12306. })(jQuery);
  12307. (function( $, undefined ) {
  12308. $.effects.effect.explode = function( o, done ) {
  12309. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  12310. cells = rows,
  12311. el = $( this ),
  12312. mode = $.effects.setMode( el, o.mode || "hide" ),
  12313. show = mode === "show",
  12314. // show and then visibility:hidden the element before calculating offset
  12315. offset = el.show().css( "visibility", "hidden" ).offset(),
  12316. // width and height of a piece
  12317. width = Math.ceil( el.outerWidth() / cells ),
  12318. height = Math.ceil( el.outerHeight() / rows ),
  12319. pieces = [],
  12320. // loop
  12321. i, j, left, top, mx, my;
  12322. // children animate complete:
  12323. function childComplete() {
  12324. pieces.push( this );
  12325. if ( pieces.length === rows * cells ) {
  12326. animComplete();
  12327. }
  12328. }
  12329. // clone the element for each row and cell.
  12330. for( i = 0; i < rows ; i++ ) { // ===>
  12331. top = offset.top + i * height;
  12332. my = i - ( rows - 1 ) / 2 ;
  12333. for( j = 0; j < cells ; j++ ) { // |||
  12334. left = offset.left + j * width;
  12335. mx = j - ( cells - 1 ) / 2 ;
  12336. // Create a clone of the now hidden main element that will be absolute positioned
  12337. // within a wrapper div off the -left and -top equal to size of our pieces
  12338. el
  12339. .clone()
  12340. .appendTo( "body" )
  12341. .wrap( "<div></div>" )
  12342. .css({
  12343. position: "absolute",
  12344. visibility: "visible",
  12345. left: -j * width,
  12346. top: -i * height
  12347. })
  12348. // select the wrapper - make it overflow: hidden and absolute positioned based on
  12349. // where the original was located +left and +top equal to the size of pieces
  12350. .parent()
  12351. .addClass( "ui-effects-explode" )
  12352. .css({
  12353. position: "absolute",
  12354. overflow: "hidden",
  12355. width: width,
  12356. height: height,
  12357. left: left + ( show ? mx * width : 0 ),
  12358. top: top + ( show ? my * height : 0 ),
  12359. opacity: show ? 0 : 1
  12360. }).animate({
  12361. left: left + ( show ? 0 : mx * width ),
  12362. top: top + ( show ? 0 : my * height ),
  12363. opacity: show ? 1 : 0
  12364. }, o.duration || 500, o.easing, childComplete );
  12365. }
  12366. }
  12367. function animComplete() {
  12368. el.css({
  12369. visibility: "visible"
  12370. });
  12371. $( pieces ).remove();
  12372. if ( !show ) {
  12373. el.hide();
  12374. }
  12375. done();
  12376. }
  12377. };
  12378. })(jQuery);
  12379. (function( $, undefined ) {
  12380. $.effects.effect.fade = function( o, done ) {
  12381. var el = $( this ),
  12382. mode = $.effects.setMode( el, o.mode || "toggle" );
  12383. el.animate({
  12384. opacity: mode
  12385. }, {
  12386. queue: false,
  12387. duration: o.duration,
  12388. easing: o.easing,
  12389. complete: done
  12390. });
  12391. };
  12392. })( jQuery );
  12393. (function( $, undefined ) {
  12394. $.effects.effect.fold = function( o, done ) {
  12395. // Create element
  12396. var el = $( this ),
  12397. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12398. mode = $.effects.setMode( el, o.mode || "hide" ),
  12399. show = mode === "show",
  12400. hide = mode === "hide",
  12401. size = o.size || 15,
  12402. percent = /([0-9]+)%/.exec( size ),
  12403. horizFirst = !!o.horizFirst,
  12404. widthFirst = show !== horizFirst,
  12405. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  12406. duration = o.duration / 2,
  12407. wrapper, distance,
  12408. animation1 = {},
  12409. animation2 = {};
  12410. $.effects.save( el, props );
  12411. el.show();
  12412. // Create Wrapper
  12413. wrapper = $.effects.createWrapper( el ).css({
  12414. overflow: "hidden"
  12415. });
  12416. distance = widthFirst ?
  12417. [ wrapper.width(), wrapper.height() ] :
  12418. [ wrapper.height(), wrapper.width() ];
  12419. if ( percent ) {
  12420. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  12421. }
  12422. if ( show ) {
  12423. wrapper.css( horizFirst ? {
  12424. height: 0,
  12425. width: size
  12426. } : {
  12427. height: size,
  12428. width: 0
  12429. });
  12430. }
  12431. // Animation
  12432. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  12433. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  12434. // Animate
  12435. wrapper
  12436. .animate( animation1, duration, o.easing )
  12437. .animate( animation2, duration, o.easing, function() {
  12438. if ( hide ) {
  12439. el.hide();
  12440. }
  12441. $.effects.restore( el, props );
  12442. $.effects.removeWrapper( el );
  12443. done();
  12444. });
  12445. };
  12446. })(jQuery);
  12447. (function( $, undefined ) {
  12448. $.effects.effect.highlight = function( o, done ) {
  12449. var elem = $( this ),
  12450. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  12451. mode = $.effects.setMode( elem, o.mode || "show" ),
  12452. animation = {
  12453. backgroundColor: elem.css( "backgroundColor" )
  12454. };
  12455. if (mode === "hide") {
  12456. animation.opacity = 0;
  12457. }
  12458. $.effects.save( elem, props );
  12459. elem
  12460. .show()
  12461. .css({
  12462. backgroundImage: "none",
  12463. backgroundColor: o.color || "#ffff99"
  12464. })
  12465. .animate( animation, {
  12466. queue: false,
  12467. duration: o.duration,
  12468. easing: o.easing,
  12469. complete: function() {
  12470. if ( mode === "hide" ) {
  12471. elem.hide();
  12472. }
  12473. $.effects.restore( elem, props );
  12474. done();
  12475. }
  12476. });
  12477. };
  12478. })(jQuery);
  12479. (function( $, undefined ) {
  12480. $.effects.effect.pulsate = function( o, done ) {
  12481. var elem = $( this ),
  12482. mode = $.effects.setMode( elem, o.mode || "show" ),
  12483. show = mode === "show",
  12484. hide = mode === "hide",
  12485. showhide = ( show || mode === "hide" ),
  12486. // showing or hiding leaves of the "last" animation
  12487. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  12488. duration = o.duration / anims,
  12489. animateTo = 0,
  12490. queue = elem.queue(),
  12491. queuelen = queue.length,
  12492. i;
  12493. if ( show || !elem.is(":visible")) {
  12494. elem.css( "opacity", 0 ).show();
  12495. animateTo = 1;
  12496. }
  12497. // anims - 1 opacity "toggles"
  12498. for ( i = 1; i < anims; i++ ) {
  12499. elem.animate({
  12500. opacity: animateTo
  12501. }, duration, o.easing );
  12502. animateTo = 1 - animateTo;
  12503. }
  12504. elem.animate({
  12505. opacity: animateTo
  12506. }, duration, o.easing);
  12507. elem.queue(function() {
  12508. if ( hide ) {
  12509. elem.hide();
  12510. }
  12511. done();
  12512. });
  12513. // We just queued up "anims" animations, we need to put them next in the queue
  12514. if ( queuelen > 1 ) {
  12515. queue.splice.apply( queue,
  12516. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  12517. }
  12518. elem.dequeue();
  12519. };
  12520. })(jQuery);
  12521. (function( $, undefined ) {
  12522. $.effects.effect.puff = function( o, done ) {
  12523. var elem = $( this ),
  12524. mode = $.effects.setMode( elem, o.mode || "hide" ),
  12525. hide = mode === "hide",
  12526. percent = parseInt( o.percent, 10 ) || 150,
  12527. factor = percent / 100,
  12528. original = {
  12529. height: elem.height(),
  12530. width: elem.width(),
  12531. outerHeight: elem.outerHeight(),
  12532. outerWidth: elem.outerWidth()
  12533. };
  12534. $.extend( o, {
  12535. effect: "scale",
  12536. queue: false,
  12537. fade: true,
  12538. mode: mode,
  12539. complete: done,
  12540. percent: hide ? percent : 100,
  12541. from: hide ?
  12542. original :
  12543. {
  12544. height: original.height * factor,
  12545. width: original.width * factor,
  12546. outerHeight: original.outerHeight * factor,
  12547. outerWidth: original.outerWidth * factor
  12548. }
  12549. });
  12550. elem.effect( o );
  12551. };
  12552. $.effects.effect.scale = function( o, done ) {
  12553. // Create element
  12554. var el = $( this ),
  12555. options = $.extend( true, {}, o ),
  12556. mode = $.effects.setMode( el, o.mode || "effect" ),
  12557. percent = parseInt( o.percent, 10 ) ||
  12558. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  12559. direction = o.direction || "both",
  12560. origin = o.origin,
  12561. original = {
  12562. height: el.height(),
  12563. width: el.width(),
  12564. outerHeight: el.outerHeight(),
  12565. outerWidth: el.outerWidth()
  12566. },
  12567. factor = {
  12568. y: direction !== "horizontal" ? (percent / 100) : 1,
  12569. x: direction !== "vertical" ? (percent / 100) : 1
  12570. };
  12571. // We are going to pass this effect to the size effect:
  12572. options.effect = "size";
  12573. options.queue = false;
  12574. options.complete = done;
  12575. // Set default origin and restore for show/hide
  12576. if ( mode !== "effect" ) {
  12577. options.origin = origin || ["middle","center"];
  12578. options.restore = true;
  12579. }
  12580. options.from = o.from || ( mode === "show" ? {
  12581. height: 0,
  12582. width: 0,
  12583. outerHeight: 0,
  12584. outerWidth: 0
  12585. } : original );
  12586. options.to = {
  12587. height: original.height * factor.y,
  12588. width: original.width * factor.x,
  12589. outerHeight: original.outerHeight * factor.y,
  12590. outerWidth: original.outerWidth * factor.x
  12591. };
  12592. // Fade option to support puff
  12593. if ( options.fade ) {
  12594. if ( mode === "show" ) {
  12595. options.from.opacity = 0;
  12596. options.to.opacity = 1;
  12597. }
  12598. if ( mode === "hide" ) {
  12599. options.from.opacity = 1;
  12600. options.to.opacity = 0;
  12601. }
  12602. }
  12603. // Animate
  12604. el.effect( options );
  12605. };
  12606. $.effects.effect.size = function( o, done ) {
  12607. // Create element
  12608. var original, baseline, factor,
  12609. el = $( this ),
  12610. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  12611. // Always restore
  12612. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  12613. // Copy for children
  12614. props2 = [ "width", "height", "overflow" ],
  12615. cProps = [ "fontSize" ],
  12616. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  12617. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  12618. // Set options
  12619. mode = $.effects.setMode( el, o.mode || "effect" ),
  12620. restore = o.restore || mode !== "effect",
  12621. scale = o.scale || "both",
  12622. origin = o.origin || [ "middle", "center" ],
  12623. position = el.css( "position" ),
  12624. props = restore ? props0 : props1,
  12625. zero = {
  12626. height: 0,
  12627. width: 0,
  12628. outerHeight: 0,
  12629. outerWidth: 0
  12630. };
  12631. if ( mode === "show" ) {
  12632. el.show();
  12633. }
  12634. original = {
  12635. height: el.height(),
  12636. width: el.width(),
  12637. outerHeight: el.outerHeight(),
  12638. outerWidth: el.outerWidth()
  12639. };
  12640. if ( o.mode === "toggle" && mode === "show" ) {
  12641. el.from = o.to || zero;
  12642. el.to = o.from || original;
  12643. } else {
  12644. el.from = o.from || ( mode === "show" ? zero : original );
  12645. el.to = o.to || ( mode === "hide" ? zero : original );
  12646. }
  12647. // Set scaling factor
  12648. factor = {
  12649. from: {
  12650. y: el.from.height / original.height,
  12651. x: el.from.width / original.width
  12652. },
  12653. to: {
  12654. y: el.to.height / original.height,
  12655. x: el.to.width / original.width
  12656. }
  12657. };
  12658. // Scale the css box
  12659. if ( scale === "box" || scale === "both" ) {
  12660. // Vertical props scaling
  12661. if ( factor.from.y !== factor.to.y ) {
  12662. props = props.concat( vProps );
  12663. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  12664. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  12665. }
  12666. // Horizontal props scaling
  12667. if ( factor.from.x !== factor.to.x ) {
  12668. props = props.concat( hProps );
  12669. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  12670. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  12671. }
  12672. }
  12673. // Scale the content
  12674. if ( scale === "content" || scale === "both" ) {
  12675. // Vertical props scaling
  12676. if ( factor.from.y !== factor.to.y ) {
  12677. props = props.concat( cProps ).concat( props2 );
  12678. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  12679. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  12680. }
  12681. }
  12682. $.effects.save( el, props );
  12683. el.show();
  12684. $.effects.createWrapper( el );
  12685. el.css( "overflow", "hidden" ).css( el.from );
  12686. // Adjust
  12687. if (origin) { // Calculate baseline shifts
  12688. baseline = $.effects.getBaseline( origin, original );
  12689. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  12690. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  12691. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  12692. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  12693. }
  12694. el.css( el.from ); // set top & left
  12695. // Animate
  12696. if ( scale === "content" || scale === "both" ) { // Scale the children
  12697. // Add margins/font-size
  12698. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  12699. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  12700. props2 = props0.concat(vProps).concat(hProps);
  12701. el.find( "*[width]" ).each( function(){
  12702. var child = $( this ),
  12703. c_original = {
  12704. height: child.height(),
  12705. width: child.width(),
  12706. outerHeight: child.outerHeight(),
  12707. outerWidth: child.outerWidth()
  12708. };
  12709. if (restore) {
  12710. $.effects.save(child, props2);
  12711. }
  12712. child.from = {
  12713. height: c_original.height * factor.from.y,
  12714. width: c_original.width * factor.from.x,
  12715. outerHeight: c_original.outerHeight * factor.from.y,
  12716. outerWidth: c_original.outerWidth * factor.from.x
  12717. };
  12718. child.to = {
  12719. height: c_original.height * factor.to.y,
  12720. width: c_original.width * factor.to.x,
  12721. outerHeight: c_original.height * factor.to.y,
  12722. outerWidth: c_original.width * factor.to.x
  12723. };
  12724. // Vertical props scaling
  12725. if ( factor.from.y !== factor.to.y ) {
  12726. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  12727. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  12728. }
  12729. // Horizontal props scaling
  12730. if ( factor.from.x !== factor.to.x ) {
  12731. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  12732. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  12733. }
  12734. // Animate children
  12735. child.css( child.from );
  12736. child.animate( child.to, o.duration, o.easing, function() {
  12737. // Restore children
  12738. if ( restore ) {
  12739. $.effects.restore( child, props2 );
  12740. }
  12741. });
  12742. });
  12743. }
  12744. // Animate
  12745. el.animate( el.to, {
  12746. queue: false,
  12747. duration: o.duration,
  12748. easing: o.easing,
  12749. complete: function() {
  12750. if ( el.to.opacity === 0 ) {
  12751. el.css( "opacity", el.from.opacity );
  12752. }
  12753. if( mode === "hide" ) {
  12754. el.hide();
  12755. }
  12756. $.effects.restore( el, props );
  12757. if ( !restore ) {
  12758. // we need to calculate our new positioning based on the scaling
  12759. if ( position === "static" ) {
  12760. el.css({
  12761. position: "relative",
  12762. top: el.to.top,
  12763. left: el.to.left
  12764. });
  12765. } else {
  12766. $.each([ "top", "left" ], function( idx, pos ) {
  12767. el.css( pos, function( _, str ) {
  12768. var val = parseInt( str, 10 ),
  12769. toRef = idx ? el.to.left : el.to.top;
  12770. // if original was "auto", recalculate the new value from wrapper
  12771. if ( str === "auto" ) {
  12772. return toRef + "px";
  12773. }
  12774. return val + toRef + "px";
  12775. });
  12776. });
  12777. }
  12778. }
  12779. $.effects.removeWrapper( el );
  12780. done();
  12781. }
  12782. });
  12783. };
  12784. })(jQuery);
  12785. (function( $, undefined ) {
  12786. $.effects.effect.shake = function( o, done ) {
  12787. var el = $( this ),
  12788. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12789. mode = $.effects.setMode( el, o.mode || "effect" ),
  12790. direction = o.direction || "left",
  12791. distance = o.distance || 20,
  12792. times = o.times || 3,
  12793. anims = times * 2 + 1,
  12794. speed = Math.round(o.duration/anims),
  12795. ref = (direction === "up" || direction === "down") ? "top" : "left",
  12796. positiveMotion = (direction === "up" || direction === "left"),
  12797. animation = {},
  12798. animation1 = {},
  12799. animation2 = {},
  12800. i,
  12801. // we will need to re-assemble the queue to stack our animations in place
  12802. queue = el.queue(),
  12803. queuelen = queue.length;
  12804. $.effects.save( el, props );
  12805. el.show();
  12806. $.effects.createWrapper( el );
  12807. // Animation
  12808. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  12809. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  12810. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  12811. // Animate
  12812. el.animate( animation, speed, o.easing );
  12813. // Shakes
  12814. for ( i = 1; i < times; i++ ) {
  12815. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  12816. }
  12817. el
  12818. .animate( animation1, speed, o.easing )
  12819. .animate( animation, speed / 2, o.easing )
  12820. .queue(function() {
  12821. if ( mode === "hide" ) {
  12822. el.hide();
  12823. }
  12824. $.effects.restore( el, props );
  12825. $.effects.removeWrapper( el );
  12826. done();
  12827. });
  12828. // inject all the animations we just queued to be first in line (after "inprogress")
  12829. if ( queuelen > 1) {
  12830. queue.splice.apply( queue,
  12831. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  12832. }
  12833. el.dequeue();
  12834. };
  12835. })(jQuery);
  12836. (function( $, undefined ) {
  12837. $.effects.effect.slide = function( o, done ) {
  12838. // Create element
  12839. var el = $( this ),
  12840. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  12841. mode = $.effects.setMode( el, o.mode || "show" ),
  12842. show = mode === "show",
  12843. direction = o.direction || "left",
  12844. ref = (direction === "up" || direction === "down") ? "top" : "left",
  12845. positiveMotion = (direction === "up" || direction === "left"),
  12846. distance,
  12847. animation = {};
  12848. // Adjust
  12849. $.effects.save( el, props );
  12850. el.show();
  12851. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  12852. $.effects.createWrapper( el ).css({
  12853. overflow: "hidden"
  12854. });
  12855. if ( show ) {
  12856. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  12857. }
  12858. // Animation
  12859. animation[ ref ] = ( show ?
  12860. ( positiveMotion ? "+=" : "-=") :
  12861. ( positiveMotion ? "-=" : "+=")) +
  12862. distance;
  12863. // Animate
  12864. el.animate( animation, {
  12865. queue: false,
  12866. duration: o.duration,
  12867. easing: o.easing,
  12868. complete: function() {
  12869. if ( mode === "hide" ) {
  12870. el.hide();
  12871. }
  12872. $.effects.restore( el, props );
  12873. $.effects.removeWrapper( el );
  12874. done();
  12875. }
  12876. });
  12877. };
  12878. })(jQuery);
  12879. (function( $, undefined ) {
  12880. $.effects.effect.transfer = function( o, done ) {
  12881. var elem = $( this ),
  12882. target = $( o.to ),
  12883. targetFixed = target.css( "position" ) === "fixed",
  12884. body = $("body"),
  12885. fixTop = targetFixed ? body.scrollTop() : 0,
  12886. fixLeft = targetFixed ? body.scrollLeft() : 0,
  12887. endPosition = target.offset(),
  12888. animation = {
  12889. top: endPosition.top - fixTop ,
  12890. left: endPosition.left - fixLeft ,
  12891. height: target.innerHeight(),
  12892. width: target.innerWidth()
  12893. },
  12894. startPosition = elem.offset(),
  12895. transfer = $( "<div class='ui-effects-transfer'></div>" )
  12896. .appendTo( document.body )
  12897. .addClass( o.className )
  12898. .css({
  12899. top: startPosition.top - fixTop ,
  12900. left: startPosition.left - fixLeft ,
  12901. height: elem.innerHeight(),
  12902. width: elem.innerWidth(),
  12903. position: targetFixed ? "fixed" : "absolute"
  12904. })
  12905. .animate( animation, o.duration, o.easing, function() {
  12906. transfer.remove();
  12907. done();
  12908. });
  12909. };
  12910. })(jQuery);