jquery-ui.js 451 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150
  1. /*! jQuery UI - v1.11.0 - 2014-06-26
  2. * http://jqueryui.com
  3. * Includes: core.js, widget.js, mouse.js, position.js, accordion.js, autocomplete.js, button.js, datepicker.js, dialog.js, draggable.js, droppable.js, effect.js, effect-blind.js, effect-bounce.js, effect-clip.js, effect-drop.js, effect-explode.js, effect-fade.js, effect-fold.js, effect-highlight.js, effect-puff.js, effect-pulsate.js, effect-scale.js, effect-shake.js, effect-size.js, effect-slide.js, effect-transfer.js, menu.js, progressbar.js, resizable.js, selectable.js, selectmenu.js, slider.js, sortable.js, spinner.js, tabs.js, tooltip.js
  4. * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
  5. (function( factory ) {
  6. if ( typeof define === "function" && define.amd ) {
  7. // AMD. Register as an anonymous module.
  8. define([ "jquery" ], factory );
  9. } else {
  10. // Browser globals
  11. factory( jQuery );
  12. }
  13. }(function( $ ) {
  14. /*!
  15. * jQuery UI Core 1.11.0
  16. * http://jqueryui.com
  17. *
  18. * Copyright 2014 jQuery Foundation and other contributors
  19. * Released under the MIT license.
  20. * http://jquery.org/license
  21. *
  22. * http://api.jqueryui.com/category/ui-core/
  23. */
  24. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  25. $.ui = $.ui || {};
  26. $.extend( $.ui, {
  27. version: "1.11.0",
  28. keyCode: {
  29. BACKSPACE: 8,
  30. COMMA: 188,
  31. DELETE: 46,
  32. DOWN: 40,
  33. END: 35,
  34. ENTER: 13,
  35. ESCAPE: 27,
  36. HOME: 36,
  37. LEFT: 37,
  38. PAGE_DOWN: 34,
  39. PAGE_UP: 33,
  40. PERIOD: 190,
  41. RIGHT: 39,
  42. SPACE: 32,
  43. TAB: 9,
  44. UP: 38
  45. }
  46. });
  47. // plugins
  48. $.fn.extend({
  49. scrollParent: function() {
  50. var position = this.css( "position" ),
  51. excludeStaticParent = position === "absolute",
  52. scrollParent = this.parents().filter( function() {
  53. var parent = $( this );
  54. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  55. return false;
  56. }
  57. return (/(auto|scroll)/).test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
  58. }).eq( 0 );
  59. return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
  60. },
  61. uniqueId: (function() {
  62. var uuid = 0;
  63. return function() {
  64. return this.each(function() {
  65. if ( !this.id ) {
  66. this.id = "ui-id-" + ( ++uuid );
  67. }
  68. });
  69. };
  70. })(),
  71. removeUniqueId: function() {
  72. return this.each(function() {
  73. if ( /^ui-id-\d+$/.test( this.id ) ) {
  74. $( this ).removeAttr( "id" );
  75. }
  76. });
  77. }
  78. });
  79. // selectors
  80. function focusable( element, isTabIndexNotNaN ) {
  81. var map, mapName, img,
  82. nodeName = element.nodeName.toLowerCase();
  83. if ( "area" === nodeName ) {
  84. map = element.parentNode;
  85. mapName = map.name;
  86. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  87. return false;
  88. }
  89. img = $( "img[usemap=#" + mapName + "]" )[0];
  90. return !!img && visible( img );
  91. }
  92. return ( /input|select|textarea|button|object/.test( nodeName ) ?
  93. !element.disabled :
  94. "a" === nodeName ?
  95. element.href || isTabIndexNotNaN :
  96. isTabIndexNotNaN) &&
  97. // the element and all of its ancestors must be visible
  98. visible( element );
  99. }
  100. function visible( element ) {
  101. return $.expr.filters.visible( element ) &&
  102. !$( element ).parents().addBack().filter(function() {
  103. return $.css( this, "visibility" ) === "hidden";
  104. }).length;
  105. }
  106. $.extend( $.expr[ ":" ], {
  107. data: $.expr.createPseudo ?
  108. $.expr.createPseudo(function( dataName ) {
  109. return function( elem ) {
  110. return !!$.data( elem, dataName );
  111. };
  112. }) :
  113. // support: jQuery <1.8
  114. function( elem, i, match ) {
  115. return !!$.data( elem, match[ 3 ] );
  116. },
  117. focusable: function( element ) {
  118. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  119. },
  120. tabbable: function( element ) {
  121. var tabIndex = $.attr( element, "tabindex" ),
  122. isTabIndexNaN = isNaN( tabIndex );
  123. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  124. }
  125. });
  126. // support: jQuery <1.8
  127. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  128. $.each( [ "Width", "Height" ], function( i, name ) {
  129. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  130. type = name.toLowerCase(),
  131. orig = {
  132. innerWidth: $.fn.innerWidth,
  133. innerHeight: $.fn.innerHeight,
  134. outerWidth: $.fn.outerWidth,
  135. outerHeight: $.fn.outerHeight
  136. };
  137. function reduce( elem, size, border, margin ) {
  138. $.each( side, function() {
  139. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  140. if ( border ) {
  141. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  142. }
  143. if ( margin ) {
  144. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  145. }
  146. });
  147. return size;
  148. }
  149. $.fn[ "inner" + name ] = function( size ) {
  150. if ( size === undefined ) {
  151. return orig[ "inner" + name ].call( this );
  152. }
  153. return this.each(function() {
  154. $( this ).css( type, reduce( this, size ) + "px" );
  155. });
  156. };
  157. $.fn[ "outer" + name] = function( size, margin ) {
  158. if ( typeof size !== "number" ) {
  159. return orig[ "outer" + name ].call( this, size );
  160. }
  161. return this.each(function() {
  162. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  163. });
  164. };
  165. });
  166. }
  167. // support: jQuery <1.8
  168. if ( !$.fn.addBack ) {
  169. $.fn.addBack = function( selector ) {
  170. return this.add( selector == null ?
  171. this.prevObject : this.prevObject.filter( selector )
  172. );
  173. };
  174. }
  175. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  176. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  177. $.fn.removeData = (function( removeData ) {
  178. return function( key ) {
  179. if ( arguments.length ) {
  180. return removeData.call( this, $.camelCase( key ) );
  181. } else {
  182. return removeData.call( this );
  183. }
  184. };
  185. })( $.fn.removeData );
  186. }
  187. // deprecated
  188. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  189. $.fn.extend({
  190. focus: (function( orig ) {
  191. return function( delay, fn ) {
  192. return typeof delay === "number" ?
  193. this.each(function() {
  194. var elem = this;
  195. setTimeout(function() {
  196. $( elem ).focus();
  197. if ( fn ) {
  198. fn.call( elem );
  199. }
  200. }, delay );
  201. }) :
  202. orig.apply( this, arguments );
  203. };
  204. })( $.fn.focus ),
  205. disableSelection: (function() {
  206. var eventType = "onselectstart" in document.createElement( "div" ) ?
  207. "selectstart" :
  208. "mousedown";
  209. return function() {
  210. return this.bind( eventType + ".ui-disableSelection", function( event ) {
  211. event.preventDefault();
  212. });
  213. };
  214. })(),
  215. enableSelection: function() {
  216. return this.unbind( ".ui-disableSelection" );
  217. },
  218. zIndex: function( zIndex ) {
  219. if ( zIndex !== undefined ) {
  220. return this.css( "zIndex", zIndex );
  221. }
  222. if ( this.length ) {
  223. var elem = $( this[ 0 ] ), position, value;
  224. while ( elem.length && elem[ 0 ] !== document ) {
  225. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  226. // This makes behavior of this function consistent across browsers
  227. // WebKit always returns auto if the element is positioned
  228. position = elem.css( "position" );
  229. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  230. // IE returns 0 when zIndex is not specified
  231. // other browsers return a string
  232. // we ignore the case of nested elements with an explicit value of 0
  233. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  234. value = parseInt( elem.css( "zIndex" ), 10 );
  235. if ( !isNaN( value ) && value !== 0 ) {
  236. return value;
  237. }
  238. }
  239. elem = elem.parent();
  240. }
  241. }
  242. return 0;
  243. }
  244. });
  245. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  246. $.ui.plugin = {
  247. add: function( module, option, set ) {
  248. var i,
  249. proto = $.ui[ module ].prototype;
  250. for ( i in set ) {
  251. proto.plugins[ i ] = proto.plugins[ i ] || [];
  252. proto.plugins[ i ].push( [ option, set[ i ] ] );
  253. }
  254. },
  255. call: function( instance, name, args, allowDisconnected ) {
  256. var i,
  257. set = instance.plugins[ name ];
  258. if ( !set ) {
  259. return;
  260. }
  261. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  262. return;
  263. }
  264. for ( i = 0; i < set.length; i++ ) {
  265. if ( instance.options[ set[ i ][ 0 ] ] ) {
  266. set[ i ][ 1 ].apply( instance.element, args );
  267. }
  268. }
  269. }
  270. };
  271. /*!
  272. * jQuery UI Widget 1.11.0
  273. * http://jqueryui.com
  274. *
  275. * Copyright 2014 jQuery Foundation and other contributors
  276. * Released under the MIT license.
  277. * http://jquery.org/license
  278. *
  279. * http://api.jqueryui.com/jQuery.widget/
  280. */
  281. var widget_uuid = 0,
  282. widget_slice = Array.prototype.slice;
  283. $.cleanData = (function( orig ) {
  284. return function( elems ) {
  285. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  286. try {
  287. $( elem ).triggerHandler( "remove" );
  288. // http://bugs.jquery.com/ticket/8235
  289. } catch( e ) {}
  290. }
  291. orig( elems );
  292. };
  293. })( $.cleanData );
  294. $.widget = function( name, base, prototype ) {
  295. var fullName, existingConstructor, constructor, basePrototype,
  296. // proxiedPrototype allows the provided prototype to remain unmodified
  297. // so that it can be used as a mixin for multiple widgets (#8876)
  298. proxiedPrototype = {},
  299. namespace = name.split( "." )[ 0 ];
  300. name = name.split( "." )[ 1 ];
  301. fullName = namespace + "-" + name;
  302. if ( !prototype ) {
  303. prototype = base;
  304. base = $.Widget;
  305. }
  306. // create selector for plugin
  307. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  308. return !!$.data( elem, fullName );
  309. };
  310. $[ namespace ] = $[ namespace ] || {};
  311. existingConstructor = $[ namespace ][ name ];
  312. constructor = $[ namespace ][ name ] = function( options, element ) {
  313. // allow instantiation without "new" keyword
  314. if ( !this._createWidget ) {
  315. return new constructor( options, element );
  316. }
  317. // allow instantiation without initializing for simple inheritance
  318. // must use "new" keyword (the code above always passes args)
  319. if ( arguments.length ) {
  320. this._createWidget( options, element );
  321. }
  322. };
  323. // extend with the existing constructor to carry over any static properties
  324. $.extend( constructor, existingConstructor, {
  325. version: prototype.version,
  326. // copy the object used to create the prototype in case we need to
  327. // redefine the widget later
  328. _proto: $.extend( {}, prototype ),
  329. // track widgets that inherit from this widget in case this widget is
  330. // redefined after a widget inherits from it
  331. _childConstructors: []
  332. });
  333. basePrototype = new base();
  334. // we need to make the options hash a property directly on the new instance
  335. // otherwise we'll modify the options hash on the prototype that we're
  336. // inheriting from
  337. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  338. $.each( prototype, function( prop, value ) {
  339. if ( !$.isFunction( value ) ) {
  340. proxiedPrototype[ prop ] = value;
  341. return;
  342. }
  343. proxiedPrototype[ prop ] = (function() {
  344. var _super = function() {
  345. return base.prototype[ prop ].apply( this, arguments );
  346. },
  347. _superApply = function( args ) {
  348. return base.prototype[ prop ].apply( this, args );
  349. };
  350. return function() {
  351. var __super = this._super,
  352. __superApply = this._superApply,
  353. returnValue;
  354. this._super = _super;
  355. this._superApply = _superApply;
  356. returnValue = value.apply( this, arguments );
  357. this._super = __super;
  358. this._superApply = __superApply;
  359. return returnValue;
  360. };
  361. })();
  362. });
  363. constructor.prototype = $.widget.extend( basePrototype, {
  364. // TODO: remove support for widgetEventPrefix
  365. // always use the name + a colon as the prefix, e.g., draggable:start
  366. // don't prefix for widgets that aren't DOM-based
  367. widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
  368. }, proxiedPrototype, {
  369. constructor: constructor,
  370. namespace: namespace,
  371. widgetName: name,
  372. widgetFullName: fullName
  373. });
  374. // If this widget is being redefined then we need to find all widgets that
  375. // are inheriting from it and redefine all of them so that they inherit from
  376. // the new version of this widget. We're essentially trying to replace one
  377. // level in the prototype chain.
  378. if ( existingConstructor ) {
  379. $.each( existingConstructor._childConstructors, function( i, child ) {
  380. var childPrototype = child.prototype;
  381. // redefine the child widget using the same prototype that was
  382. // originally used, but inherit from the new version of the base
  383. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  384. });
  385. // remove the list of existing child constructors from the old constructor
  386. // so the old child constructors can be garbage collected
  387. delete existingConstructor._childConstructors;
  388. } else {
  389. base._childConstructors.push( constructor );
  390. }
  391. $.widget.bridge( name, constructor );
  392. return constructor;
  393. };
  394. $.widget.extend = function( target ) {
  395. var input = widget_slice.call( arguments, 1 ),
  396. inputIndex = 0,
  397. inputLength = input.length,
  398. key,
  399. value;
  400. for ( ; inputIndex < inputLength; inputIndex++ ) {
  401. for ( key in input[ inputIndex ] ) {
  402. value = input[ inputIndex ][ key ];
  403. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  404. // Clone objects
  405. if ( $.isPlainObject( value ) ) {
  406. target[ key ] = $.isPlainObject( target[ key ] ) ?
  407. $.widget.extend( {}, target[ key ], value ) :
  408. // Don't extend strings, arrays, etc. with objects
  409. $.widget.extend( {}, value );
  410. // Copy everything else by reference
  411. } else {
  412. target[ key ] = value;
  413. }
  414. }
  415. }
  416. }
  417. return target;
  418. };
  419. $.widget.bridge = function( name, object ) {
  420. var fullName = object.prototype.widgetFullName || name;
  421. $.fn[ name ] = function( options ) {
  422. var isMethodCall = typeof options === "string",
  423. args = widget_slice.call( arguments, 1 ),
  424. returnValue = this;
  425. // allow multiple hashes to be passed on init
  426. options = !isMethodCall && args.length ?
  427. $.widget.extend.apply( null, [ options ].concat(args) ) :
  428. options;
  429. if ( isMethodCall ) {
  430. this.each(function() {
  431. var methodValue,
  432. instance = $.data( this, fullName );
  433. if ( options === "instance" ) {
  434. returnValue = instance;
  435. return false;
  436. }
  437. if ( !instance ) {
  438. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  439. "attempted to call method '" + options + "'" );
  440. }
  441. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  442. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  443. }
  444. methodValue = instance[ options ].apply( instance, args );
  445. if ( methodValue !== instance && methodValue !== undefined ) {
  446. returnValue = methodValue && methodValue.jquery ?
  447. returnValue.pushStack( methodValue.get() ) :
  448. methodValue;
  449. return false;
  450. }
  451. });
  452. } else {
  453. this.each(function() {
  454. var instance = $.data( this, fullName );
  455. if ( instance ) {
  456. instance.option( options || {} );
  457. if ( instance._init ) {
  458. instance._init();
  459. }
  460. } else {
  461. $.data( this, fullName, new object( options, this ) );
  462. }
  463. });
  464. }
  465. return returnValue;
  466. };
  467. };
  468. $.Widget = function( /* options, element */ ) {};
  469. $.Widget._childConstructors = [];
  470. $.Widget.prototype = {
  471. widgetName: "widget",
  472. widgetEventPrefix: "",
  473. defaultElement: "<div>",
  474. options: {
  475. disabled: false,
  476. // callbacks
  477. create: null
  478. },
  479. _createWidget: function( options, element ) {
  480. element = $( element || this.defaultElement || this )[ 0 ];
  481. this.element = $( element );
  482. this.uuid = widget_uuid++;
  483. this.eventNamespace = "." + this.widgetName + this.uuid;
  484. this.options = $.widget.extend( {},
  485. this.options,
  486. this._getCreateOptions(),
  487. options );
  488. this.bindings = $();
  489. this.hoverable = $();
  490. this.focusable = $();
  491. if ( element !== this ) {
  492. $.data( element, this.widgetFullName, this );
  493. this._on( true, this.element, {
  494. remove: function( event ) {
  495. if ( event.target === element ) {
  496. this.destroy();
  497. }
  498. }
  499. });
  500. this.document = $( element.style ?
  501. // element within the document
  502. element.ownerDocument :
  503. // element is window or document
  504. element.document || element );
  505. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  506. }
  507. this._create();
  508. this._trigger( "create", null, this._getCreateEventData() );
  509. this._init();
  510. },
  511. _getCreateOptions: $.noop,
  512. _getCreateEventData: $.noop,
  513. _create: $.noop,
  514. _init: $.noop,
  515. destroy: function() {
  516. this._destroy();
  517. // we can probably remove the unbind calls in 2.0
  518. // all event bindings should go through this._on()
  519. this.element
  520. .unbind( this.eventNamespace )
  521. .removeData( this.widgetFullName )
  522. // support: jquery <1.6.3
  523. // http://bugs.jquery.com/ticket/9413
  524. .removeData( $.camelCase( this.widgetFullName ) );
  525. this.widget()
  526. .unbind( this.eventNamespace )
  527. .removeAttr( "aria-disabled" )
  528. .removeClass(
  529. this.widgetFullName + "-disabled " +
  530. "ui-state-disabled" );
  531. // clean up events and states
  532. this.bindings.unbind( this.eventNamespace );
  533. this.hoverable.removeClass( "ui-state-hover" );
  534. this.focusable.removeClass( "ui-state-focus" );
  535. },
  536. _destroy: $.noop,
  537. widget: function() {
  538. return this.element;
  539. },
  540. option: function( key, value ) {
  541. var options = key,
  542. parts,
  543. curOption,
  544. i;
  545. if ( arguments.length === 0 ) {
  546. // don't return a reference to the internal hash
  547. return $.widget.extend( {}, this.options );
  548. }
  549. if ( typeof key === "string" ) {
  550. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  551. options = {};
  552. parts = key.split( "." );
  553. key = parts.shift();
  554. if ( parts.length ) {
  555. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  556. for ( i = 0; i < parts.length - 1; i++ ) {
  557. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  558. curOption = curOption[ parts[ i ] ];
  559. }
  560. key = parts.pop();
  561. if ( arguments.length === 1 ) {
  562. return curOption[ key ] === undefined ? null : curOption[ key ];
  563. }
  564. curOption[ key ] = value;
  565. } else {
  566. if ( arguments.length === 1 ) {
  567. return this.options[ key ] === undefined ? null : this.options[ key ];
  568. }
  569. options[ key ] = value;
  570. }
  571. }
  572. this._setOptions( options );
  573. return this;
  574. },
  575. _setOptions: function( options ) {
  576. var key;
  577. for ( key in options ) {
  578. this._setOption( key, options[ key ] );
  579. }
  580. return this;
  581. },
  582. _setOption: function( key, value ) {
  583. this.options[ key ] = value;
  584. if ( key === "disabled" ) {
  585. this.widget()
  586. .toggleClass( this.widgetFullName + "-disabled", !!value );
  587. // If the widget is becoming disabled, then nothing is interactive
  588. if ( value ) {
  589. this.hoverable.removeClass( "ui-state-hover" );
  590. this.focusable.removeClass( "ui-state-focus" );
  591. }
  592. }
  593. return this;
  594. },
  595. enable: function() {
  596. return this._setOptions({ disabled: false });
  597. },
  598. disable: function() {
  599. return this._setOptions({ disabled: true });
  600. },
  601. _on: function( suppressDisabledCheck, element, handlers ) {
  602. var delegateElement,
  603. instance = this;
  604. // no suppressDisabledCheck flag, shuffle arguments
  605. if ( typeof suppressDisabledCheck !== "boolean" ) {
  606. handlers = element;
  607. element = suppressDisabledCheck;
  608. suppressDisabledCheck = false;
  609. }
  610. // no element argument, shuffle and use this.element
  611. if ( !handlers ) {
  612. handlers = element;
  613. element = this.element;
  614. delegateElement = this.widget();
  615. } else {
  616. element = delegateElement = $( element );
  617. this.bindings = this.bindings.add( element );
  618. }
  619. $.each( handlers, function( event, handler ) {
  620. function handlerProxy() {
  621. // allow widgets to customize the disabled handling
  622. // - disabled as an array instead of boolean
  623. // - disabled class as method for disabling individual parts
  624. if ( !suppressDisabledCheck &&
  625. ( instance.options.disabled === true ||
  626. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  627. return;
  628. }
  629. return ( typeof handler === "string" ? instance[ handler ] : handler )
  630. .apply( instance, arguments );
  631. }
  632. // copy the guid so direct unbinding works
  633. if ( typeof handler !== "string" ) {
  634. handlerProxy.guid = handler.guid =
  635. handler.guid || handlerProxy.guid || $.guid++;
  636. }
  637. var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
  638. eventName = match[1] + instance.eventNamespace,
  639. selector = match[2];
  640. if ( selector ) {
  641. delegateElement.delegate( selector, eventName, handlerProxy );
  642. } else {
  643. element.bind( eventName, handlerProxy );
  644. }
  645. });
  646. },
  647. _off: function( element, eventName ) {
  648. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
  649. element.unbind( eventName ).undelegate( eventName );
  650. },
  651. _delay: function( handler, delay ) {
  652. function handlerProxy() {
  653. return ( typeof handler === "string" ? instance[ handler ] : handler )
  654. .apply( instance, arguments );
  655. }
  656. var instance = this;
  657. return setTimeout( handlerProxy, delay || 0 );
  658. },
  659. _hoverable: function( element ) {
  660. this.hoverable = this.hoverable.add( element );
  661. this._on( element, {
  662. mouseenter: function( event ) {
  663. $( event.currentTarget ).addClass( "ui-state-hover" );
  664. },
  665. mouseleave: function( event ) {
  666. $( event.currentTarget ).removeClass( "ui-state-hover" );
  667. }
  668. });
  669. },
  670. _focusable: function( element ) {
  671. this.focusable = this.focusable.add( element );
  672. this._on( element, {
  673. focusin: function( event ) {
  674. $( event.currentTarget ).addClass( "ui-state-focus" );
  675. },
  676. focusout: function( event ) {
  677. $( event.currentTarget ).removeClass( "ui-state-focus" );
  678. }
  679. });
  680. },
  681. _trigger: function( type, event, data ) {
  682. var prop, orig,
  683. callback = this.options[ type ];
  684. data = data || {};
  685. event = $.Event( event );
  686. event.type = ( type === this.widgetEventPrefix ?
  687. type :
  688. this.widgetEventPrefix + type ).toLowerCase();
  689. // the original event may come from any element
  690. // so we need to reset the target on the new event
  691. event.target = this.element[ 0 ];
  692. // copy original event properties over to the new event
  693. orig = event.originalEvent;
  694. if ( orig ) {
  695. for ( prop in orig ) {
  696. if ( !( prop in event ) ) {
  697. event[ prop ] = orig[ prop ];
  698. }
  699. }
  700. }
  701. this.element.trigger( event, data );
  702. return !( $.isFunction( callback ) &&
  703. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  704. event.isDefaultPrevented() );
  705. }
  706. };
  707. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  708. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  709. if ( typeof options === "string" ) {
  710. options = { effect: options };
  711. }
  712. var hasOptions,
  713. effectName = !options ?
  714. method :
  715. options === true || typeof options === "number" ?
  716. defaultEffect :
  717. options.effect || defaultEffect;
  718. options = options || {};
  719. if ( typeof options === "number" ) {
  720. options = { duration: options };
  721. }
  722. hasOptions = !$.isEmptyObject( options );
  723. options.complete = callback;
  724. if ( options.delay ) {
  725. element.delay( options.delay );
  726. }
  727. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  728. element[ method ]( options );
  729. } else if ( effectName !== method && element[ effectName ] ) {
  730. element[ effectName ]( options.duration, options.easing, callback );
  731. } else {
  732. element.queue(function( next ) {
  733. $( this )[ method ]();
  734. if ( callback ) {
  735. callback.call( element[ 0 ] );
  736. }
  737. next();
  738. });
  739. }
  740. };
  741. });
  742. var widget = $.widget;
  743. /*!
  744. * jQuery UI Mouse 1.11.0
  745. * http://jqueryui.com
  746. *
  747. * Copyright 2014 jQuery Foundation and other contributors
  748. * Released under the MIT license.
  749. * http://jquery.org/license
  750. *
  751. * http://api.jqueryui.com/mouse/
  752. */
  753. var mouseHandled = false;
  754. $( document ).mouseup( function() {
  755. mouseHandled = false;
  756. });
  757. var mouse = $.widget("ui.mouse", {
  758. version: "1.11.0",
  759. options: {
  760. cancel: "input,textarea,button,select,option",
  761. distance: 1,
  762. delay: 0
  763. },
  764. _mouseInit: function() {
  765. var that = this;
  766. this.element
  767. .bind("mousedown." + this.widgetName, function(event) {
  768. return that._mouseDown(event);
  769. })
  770. .bind("click." + this.widgetName, function(event) {
  771. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  772. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  773. event.stopImmediatePropagation();
  774. return false;
  775. }
  776. });
  777. this.started = false;
  778. },
  779. // TODO: make sure destroying one instance of mouse doesn't mess with
  780. // other instances of mouse
  781. _mouseDestroy: function() {
  782. this.element.unbind("." + this.widgetName);
  783. if ( this._mouseMoveDelegate ) {
  784. this.document
  785. .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate)
  786. .unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
  787. }
  788. },
  789. _mouseDown: function(event) {
  790. // don't let more than one widget handle mouseStart
  791. if ( mouseHandled ) {
  792. return;
  793. }
  794. // we may have missed mouseup (out of window)
  795. (this._mouseStarted && this._mouseUp(event));
  796. this._mouseDownEvent = event;
  797. var that = this,
  798. btnIsLeft = (event.which === 1),
  799. // event.target.nodeName works around a bug in IE 8 with
  800. // disabled inputs (#7620)
  801. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  802. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  803. return true;
  804. }
  805. this.mouseDelayMet = !this.options.delay;
  806. if (!this.mouseDelayMet) {
  807. this._mouseDelayTimer = setTimeout(function() {
  808. that.mouseDelayMet = true;
  809. }, this.options.delay);
  810. }
  811. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  812. this._mouseStarted = (this._mouseStart(event) !== false);
  813. if (!this._mouseStarted) {
  814. event.preventDefault();
  815. return true;
  816. }
  817. }
  818. // Click event may never have fired (Gecko & Opera)
  819. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  820. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  821. }
  822. // these delegates are required to keep context
  823. this._mouseMoveDelegate = function(event) {
  824. return that._mouseMove(event);
  825. };
  826. this._mouseUpDelegate = function(event) {
  827. return that._mouseUp(event);
  828. };
  829. this.document
  830. .bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  831. .bind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  832. event.preventDefault();
  833. mouseHandled = true;
  834. return true;
  835. },
  836. _mouseMove: function(event) {
  837. // IE mouseup check - mouseup happened when mouse was out of window
  838. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  839. return this._mouseUp(event);
  840. // Iframe mouseup check - mouseup occurred in another document
  841. } else if ( !event.which ) {
  842. return this._mouseUp( event );
  843. }
  844. if (this._mouseStarted) {
  845. this._mouseDrag(event);
  846. return event.preventDefault();
  847. }
  848. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  849. this._mouseStarted =
  850. (this._mouseStart(this._mouseDownEvent, event) !== false);
  851. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  852. }
  853. return !this._mouseStarted;
  854. },
  855. _mouseUp: function(event) {
  856. this.document
  857. .unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  858. .unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  859. if (this._mouseStarted) {
  860. this._mouseStarted = false;
  861. if (event.target === this._mouseDownEvent.target) {
  862. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  863. }
  864. this._mouseStop(event);
  865. }
  866. mouseHandled = false;
  867. return false;
  868. },
  869. _mouseDistanceMet: function(event) {
  870. return (Math.max(
  871. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  872. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  873. ) >= this.options.distance
  874. );
  875. },
  876. _mouseDelayMet: function(/* event */) {
  877. return this.mouseDelayMet;
  878. },
  879. // These are placeholder methods, to be overriden by extending plugin
  880. _mouseStart: function(/* event */) {},
  881. _mouseDrag: function(/* event */) {},
  882. _mouseStop: function(/* event */) {},
  883. _mouseCapture: function(/* event */) { return true; }
  884. });
  885. /*!
  886. * jQuery UI Position 1.11.0
  887. * http://jqueryui.com
  888. *
  889. * Copyright 2014 jQuery Foundation and other contributors
  890. * Released under the MIT license.
  891. * http://jquery.org/license
  892. *
  893. * http://api.jqueryui.com/position/
  894. */
  895. (function() {
  896. $.ui = $.ui || {};
  897. var cachedScrollbarWidth, supportsOffsetFractions,
  898. max = Math.max,
  899. abs = Math.abs,
  900. round = Math.round,
  901. rhorizontal = /left|center|right/,
  902. rvertical = /top|center|bottom/,
  903. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  904. rposition = /^\w+/,
  905. rpercent = /%$/,
  906. _position = $.fn.position;
  907. function getOffsets( offsets, width, height ) {
  908. return [
  909. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  910. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  911. ];
  912. }
  913. function parseCss( element, property ) {
  914. return parseInt( $.css( element, property ), 10 ) || 0;
  915. }
  916. function getDimensions( elem ) {
  917. var raw = elem[0];
  918. if ( raw.nodeType === 9 ) {
  919. return {
  920. width: elem.width(),
  921. height: elem.height(),
  922. offset: { top: 0, left: 0 }
  923. };
  924. }
  925. if ( $.isWindow( raw ) ) {
  926. return {
  927. width: elem.width(),
  928. height: elem.height(),
  929. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  930. };
  931. }
  932. if ( raw.preventDefault ) {
  933. return {
  934. width: 0,
  935. height: 0,
  936. offset: { top: raw.pageY, left: raw.pageX }
  937. };
  938. }
  939. return {
  940. width: elem.outerWidth(),
  941. height: elem.outerHeight(),
  942. offset: elem.offset()
  943. };
  944. }
  945. $.position = {
  946. scrollbarWidth: function() {
  947. if ( cachedScrollbarWidth !== undefined ) {
  948. return cachedScrollbarWidth;
  949. }
  950. var w1, w2,
  951. div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  952. innerDiv = div.children()[0];
  953. $( "body" ).append( div );
  954. w1 = innerDiv.offsetWidth;
  955. div.css( "overflow", "scroll" );
  956. w2 = innerDiv.offsetWidth;
  957. if ( w1 === w2 ) {
  958. w2 = div[0].clientWidth;
  959. }
  960. div.remove();
  961. return (cachedScrollbarWidth = w1 - w2);
  962. },
  963. getScrollInfo: function( within ) {
  964. var overflowX = within.isWindow || within.isDocument ? "" :
  965. within.element.css( "overflow-x" ),
  966. overflowY = within.isWindow || within.isDocument ? "" :
  967. within.element.css( "overflow-y" ),
  968. hasOverflowX = overflowX === "scroll" ||
  969. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  970. hasOverflowY = overflowY === "scroll" ||
  971. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  972. return {
  973. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  974. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  975. };
  976. },
  977. getWithinInfo: function( element ) {
  978. var withinElement = $( element || window ),
  979. isWindow = $.isWindow( withinElement[0] ),
  980. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
  981. return {
  982. element: withinElement,
  983. isWindow: isWindow,
  984. isDocument: isDocument,
  985. offset: withinElement.offset() || { left: 0, top: 0 },
  986. scrollLeft: withinElement.scrollLeft(),
  987. scrollTop: withinElement.scrollTop(),
  988. width: isWindow ? withinElement.width() : withinElement.outerWidth(),
  989. height: isWindow ? withinElement.height() : withinElement.outerHeight()
  990. };
  991. }
  992. };
  993. $.fn.position = function( options ) {
  994. if ( !options || !options.of ) {
  995. return _position.apply( this, arguments );
  996. }
  997. // make a copy, we don't want to modify arguments
  998. options = $.extend( {}, options );
  999. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  1000. target = $( options.of ),
  1001. within = $.position.getWithinInfo( options.within ),
  1002. scrollInfo = $.position.getScrollInfo( within ),
  1003. collision = ( options.collision || "flip" ).split( " " ),
  1004. offsets = {};
  1005. dimensions = getDimensions( target );
  1006. if ( target[0].preventDefault ) {
  1007. // force left top to allow flipping
  1008. options.at = "left top";
  1009. }
  1010. targetWidth = dimensions.width;
  1011. targetHeight = dimensions.height;
  1012. targetOffset = dimensions.offset;
  1013. // clone to reuse original targetOffset later
  1014. basePosition = $.extend( {}, targetOffset );
  1015. // force my and at to have valid horizontal and vertical positions
  1016. // if a value is missing or invalid, it will be converted to center
  1017. $.each( [ "my", "at" ], function() {
  1018. var pos = ( options[ this ] || "" ).split( " " ),
  1019. horizontalOffset,
  1020. verticalOffset;
  1021. if ( pos.length === 1) {
  1022. pos = rhorizontal.test( pos[ 0 ] ) ?
  1023. pos.concat( [ "center" ] ) :
  1024. rvertical.test( pos[ 0 ] ) ?
  1025. [ "center" ].concat( pos ) :
  1026. [ "center", "center" ];
  1027. }
  1028. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  1029. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  1030. // calculate offsets
  1031. horizontalOffset = roffset.exec( pos[ 0 ] );
  1032. verticalOffset = roffset.exec( pos[ 1 ] );
  1033. offsets[ this ] = [
  1034. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  1035. verticalOffset ? verticalOffset[ 0 ] : 0
  1036. ];
  1037. // reduce to just the positions without the offsets
  1038. options[ this ] = [
  1039. rposition.exec( pos[ 0 ] )[ 0 ],
  1040. rposition.exec( pos[ 1 ] )[ 0 ]
  1041. ];
  1042. });
  1043. // normalize collision option
  1044. if ( collision.length === 1 ) {
  1045. collision[ 1 ] = collision[ 0 ];
  1046. }
  1047. if ( options.at[ 0 ] === "right" ) {
  1048. basePosition.left += targetWidth;
  1049. } else if ( options.at[ 0 ] === "center" ) {
  1050. basePosition.left += targetWidth / 2;
  1051. }
  1052. if ( options.at[ 1 ] === "bottom" ) {
  1053. basePosition.top += targetHeight;
  1054. } else if ( options.at[ 1 ] === "center" ) {
  1055. basePosition.top += targetHeight / 2;
  1056. }
  1057. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  1058. basePosition.left += atOffset[ 0 ];
  1059. basePosition.top += atOffset[ 1 ];
  1060. return this.each(function() {
  1061. var collisionPosition, using,
  1062. elem = $( this ),
  1063. elemWidth = elem.outerWidth(),
  1064. elemHeight = elem.outerHeight(),
  1065. marginLeft = parseCss( this, "marginLeft" ),
  1066. marginTop = parseCss( this, "marginTop" ),
  1067. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  1068. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  1069. position = $.extend( {}, basePosition ),
  1070. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  1071. if ( options.my[ 0 ] === "right" ) {
  1072. position.left -= elemWidth;
  1073. } else if ( options.my[ 0 ] === "center" ) {
  1074. position.left -= elemWidth / 2;
  1075. }
  1076. if ( options.my[ 1 ] === "bottom" ) {
  1077. position.top -= elemHeight;
  1078. } else if ( options.my[ 1 ] === "center" ) {
  1079. position.top -= elemHeight / 2;
  1080. }
  1081. position.left += myOffset[ 0 ];
  1082. position.top += myOffset[ 1 ];
  1083. // if the browser doesn't support fractions, then round for consistent results
  1084. if ( !supportsOffsetFractions ) {
  1085. position.left = round( position.left );
  1086. position.top = round( position.top );
  1087. }
  1088. collisionPosition = {
  1089. marginLeft: marginLeft,
  1090. marginTop: marginTop
  1091. };
  1092. $.each( [ "left", "top" ], function( i, dir ) {
  1093. if ( $.ui.position[ collision[ i ] ] ) {
  1094. $.ui.position[ collision[ i ] ][ dir ]( position, {
  1095. targetWidth: targetWidth,
  1096. targetHeight: targetHeight,
  1097. elemWidth: elemWidth,
  1098. elemHeight: elemHeight,
  1099. collisionPosition: collisionPosition,
  1100. collisionWidth: collisionWidth,
  1101. collisionHeight: collisionHeight,
  1102. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  1103. my: options.my,
  1104. at: options.at,
  1105. within: within,
  1106. elem: elem
  1107. });
  1108. }
  1109. });
  1110. if ( options.using ) {
  1111. // adds feedback as second argument to using callback, if present
  1112. using = function( props ) {
  1113. var left = targetOffset.left - position.left,
  1114. right = left + targetWidth - elemWidth,
  1115. top = targetOffset.top - position.top,
  1116. bottom = top + targetHeight - elemHeight,
  1117. feedback = {
  1118. target: {
  1119. element: target,
  1120. left: targetOffset.left,
  1121. top: targetOffset.top,
  1122. width: targetWidth,
  1123. height: targetHeight
  1124. },
  1125. element: {
  1126. element: elem,
  1127. left: position.left,
  1128. top: position.top,
  1129. width: elemWidth,
  1130. height: elemHeight
  1131. },
  1132. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1133. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1134. };
  1135. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1136. feedback.horizontal = "center";
  1137. }
  1138. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1139. feedback.vertical = "middle";
  1140. }
  1141. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1142. feedback.important = "horizontal";
  1143. } else {
  1144. feedback.important = "vertical";
  1145. }
  1146. options.using.call( this, props, feedback );
  1147. };
  1148. }
  1149. elem.offset( $.extend( position, { using: using } ) );
  1150. });
  1151. };
  1152. $.ui.position = {
  1153. fit: {
  1154. left: function( position, data ) {
  1155. var within = data.within,
  1156. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1157. outerWidth = within.width,
  1158. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1159. overLeft = withinOffset - collisionPosLeft,
  1160. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1161. newOverRight;
  1162. // element is wider than within
  1163. if ( data.collisionWidth > outerWidth ) {
  1164. // element is initially over the left side of within
  1165. if ( overLeft > 0 && overRight <= 0 ) {
  1166. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1167. position.left += overLeft - newOverRight;
  1168. // element is initially over right side of within
  1169. } else if ( overRight > 0 && overLeft <= 0 ) {
  1170. position.left = withinOffset;
  1171. // element is initially over both left and right sides of within
  1172. } else {
  1173. if ( overLeft > overRight ) {
  1174. position.left = withinOffset + outerWidth - data.collisionWidth;
  1175. } else {
  1176. position.left = withinOffset;
  1177. }
  1178. }
  1179. // too far left -> align with left edge
  1180. } else if ( overLeft > 0 ) {
  1181. position.left += overLeft;
  1182. // too far right -> align with right edge
  1183. } else if ( overRight > 0 ) {
  1184. position.left -= overRight;
  1185. // adjust based on position and margin
  1186. } else {
  1187. position.left = max( position.left - collisionPosLeft, position.left );
  1188. }
  1189. },
  1190. top: function( position, data ) {
  1191. var within = data.within,
  1192. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1193. outerHeight = data.within.height,
  1194. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1195. overTop = withinOffset - collisionPosTop,
  1196. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1197. newOverBottom;
  1198. // element is taller than within
  1199. if ( data.collisionHeight > outerHeight ) {
  1200. // element is initially over the top of within
  1201. if ( overTop > 0 && overBottom <= 0 ) {
  1202. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1203. position.top += overTop - newOverBottom;
  1204. // element is initially over bottom of within
  1205. } else if ( overBottom > 0 && overTop <= 0 ) {
  1206. position.top = withinOffset;
  1207. // element is initially over both top and bottom of within
  1208. } else {
  1209. if ( overTop > overBottom ) {
  1210. position.top = withinOffset + outerHeight - data.collisionHeight;
  1211. } else {
  1212. position.top = withinOffset;
  1213. }
  1214. }
  1215. // too far up -> align with top
  1216. } else if ( overTop > 0 ) {
  1217. position.top += overTop;
  1218. // too far down -> align with bottom edge
  1219. } else if ( overBottom > 0 ) {
  1220. position.top -= overBottom;
  1221. // adjust based on position and margin
  1222. } else {
  1223. position.top = max( position.top - collisionPosTop, position.top );
  1224. }
  1225. }
  1226. },
  1227. flip: {
  1228. left: function( position, data ) {
  1229. var within = data.within,
  1230. withinOffset = within.offset.left + within.scrollLeft,
  1231. outerWidth = within.width,
  1232. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1233. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1234. overLeft = collisionPosLeft - offsetLeft,
  1235. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1236. myOffset = data.my[ 0 ] === "left" ?
  1237. -data.elemWidth :
  1238. data.my[ 0 ] === "right" ?
  1239. data.elemWidth :
  1240. 0,
  1241. atOffset = data.at[ 0 ] === "left" ?
  1242. data.targetWidth :
  1243. data.at[ 0 ] === "right" ?
  1244. -data.targetWidth :
  1245. 0,
  1246. offset = -2 * data.offset[ 0 ],
  1247. newOverRight,
  1248. newOverLeft;
  1249. if ( overLeft < 0 ) {
  1250. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1251. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1252. position.left += myOffset + atOffset + offset;
  1253. }
  1254. } else if ( overRight > 0 ) {
  1255. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1256. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1257. position.left += myOffset + atOffset + offset;
  1258. }
  1259. }
  1260. },
  1261. top: function( position, data ) {
  1262. var within = data.within,
  1263. withinOffset = within.offset.top + within.scrollTop,
  1264. outerHeight = within.height,
  1265. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1266. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1267. overTop = collisionPosTop - offsetTop,
  1268. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1269. top = data.my[ 1 ] === "top",
  1270. myOffset = top ?
  1271. -data.elemHeight :
  1272. data.my[ 1 ] === "bottom" ?
  1273. data.elemHeight :
  1274. 0,
  1275. atOffset = data.at[ 1 ] === "top" ?
  1276. data.targetHeight :
  1277. data.at[ 1 ] === "bottom" ?
  1278. -data.targetHeight :
  1279. 0,
  1280. offset = -2 * data.offset[ 1 ],
  1281. newOverTop,
  1282. newOverBottom;
  1283. if ( overTop < 0 ) {
  1284. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1285. if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
  1286. position.top += myOffset + atOffset + offset;
  1287. }
  1288. } else if ( overBottom > 0 ) {
  1289. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1290. if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
  1291. position.top += myOffset + atOffset + offset;
  1292. }
  1293. }
  1294. }
  1295. },
  1296. flipfit: {
  1297. left: function() {
  1298. $.ui.position.flip.left.apply( this, arguments );
  1299. $.ui.position.fit.left.apply( this, arguments );
  1300. },
  1301. top: function() {
  1302. $.ui.position.flip.top.apply( this, arguments );
  1303. $.ui.position.fit.top.apply( this, arguments );
  1304. }
  1305. }
  1306. };
  1307. // fraction support test
  1308. (function() {
  1309. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1310. body = document.getElementsByTagName( "body" )[ 0 ],
  1311. div = document.createElement( "div" );
  1312. //Create a "fake body" for testing based on method used in jQuery.support
  1313. testElement = document.createElement( body ? "div" : "body" );
  1314. testElementStyle = {
  1315. visibility: "hidden",
  1316. width: 0,
  1317. height: 0,
  1318. border: 0,
  1319. margin: 0,
  1320. background: "none"
  1321. };
  1322. if ( body ) {
  1323. $.extend( testElementStyle, {
  1324. position: "absolute",
  1325. left: "-1000px",
  1326. top: "-1000px"
  1327. });
  1328. }
  1329. for ( i in testElementStyle ) {
  1330. testElement.style[ i ] = testElementStyle[ i ];
  1331. }
  1332. testElement.appendChild( div );
  1333. testElementParent = body || document.documentElement;
  1334. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1335. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1336. offsetLeft = $( div ).offset().left;
  1337. supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1338. testElement.innerHTML = "";
  1339. testElementParent.removeChild( testElement );
  1340. })();
  1341. })();
  1342. var position = $.ui.position;
  1343. /*!
  1344. * jQuery UI Accordion 1.11.0
  1345. * http://jqueryui.com
  1346. *
  1347. * Copyright 2014 jQuery Foundation and other contributors
  1348. * Released under the MIT license.
  1349. * http://jquery.org/license
  1350. *
  1351. * http://api.jqueryui.com/accordion/
  1352. */
  1353. var accordion = $.widget( "ui.accordion", {
  1354. version: "1.11.0",
  1355. options: {
  1356. active: 0,
  1357. animate: {},
  1358. collapsible: false,
  1359. event: "click",
  1360. header: "> li > :first-child,> :not(li):even",
  1361. heightStyle: "auto",
  1362. icons: {
  1363. activeHeader: "ui-icon-triangle-1-s",
  1364. header: "ui-icon-triangle-1-e"
  1365. },
  1366. // callbacks
  1367. activate: null,
  1368. beforeActivate: null
  1369. },
  1370. hideProps: {
  1371. borderTopWidth: "hide",
  1372. borderBottomWidth: "hide",
  1373. paddingTop: "hide",
  1374. paddingBottom: "hide",
  1375. height: "hide"
  1376. },
  1377. showProps: {
  1378. borderTopWidth: "show",
  1379. borderBottomWidth: "show",
  1380. paddingTop: "show",
  1381. paddingBottom: "show",
  1382. height: "show"
  1383. },
  1384. _create: function() {
  1385. var options = this.options;
  1386. this.prevShow = this.prevHide = $();
  1387. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  1388. // ARIA
  1389. .attr( "role", "tablist" );
  1390. // don't allow collapsible: false and active: false / null
  1391. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  1392. options.active = 0;
  1393. }
  1394. this._processPanels();
  1395. // handle negative values
  1396. if ( options.active < 0 ) {
  1397. options.active += this.headers.length;
  1398. }
  1399. this._refresh();
  1400. },
  1401. _getCreateEventData: function() {
  1402. return {
  1403. header: this.active,
  1404. panel: !this.active.length ? $() : this.active.next()
  1405. };
  1406. },
  1407. _createIcons: function() {
  1408. var icons = this.options.icons;
  1409. if ( icons ) {
  1410. $( "<span>" )
  1411. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  1412. .prependTo( this.headers );
  1413. this.active.children( ".ui-accordion-header-icon" )
  1414. .removeClass( icons.header )
  1415. .addClass( icons.activeHeader );
  1416. this.headers.addClass( "ui-accordion-icons" );
  1417. }
  1418. },
  1419. _destroyIcons: function() {
  1420. this.headers
  1421. .removeClass( "ui-accordion-icons" )
  1422. .children( ".ui-accordion-header-icon" )
  1423. .remove();
  1424. },
  1425. _destroy: function() {
  1426. var contents;
  1427. // clean up main element
  1428. this.element
  1429. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  1430. .removeAttr( "role" );
  1431. // clean up headers
  1432. this.headers
  1433. .removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " +
  1434. "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
  1435. .removeAttr( "role" )
  1436. .removeAttr( "aria-expanded" )
  1437. .removeAttr( "aria-selected" )
  1438. .removeAttr( "aria-controls" )
  1439. .removeAttr( "tabIndex" )
  1440. .removeUniqueId();
  1441. this._destroyIcons();
  1442. // clean up content panels
  1443. contents = this.headers.next()
  1444. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " +
  1445. "ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  1446. .css( "display", "" )
  1447. .removeAttr( "role" )
  1448. .removeAttr( "aria-hidden" )
  1449. .removeAttr( "aria-labelledby" )
  1450. .removeUniqueId();
  1451. if ( this.options.heightStyle !== "content" ) {
  1452. contents.css( "height", "" );
  1453. }
  1454. },
  1455. _setOption: function( key, value ) {
  1456. if ( key === "active" ) {
  1457. // _activate() will handle invalid values and update this.options
  1458. this._activate( value );
  1459. return;
  1460. }
  1461. if ( key === "event" ) {
  1462. if ( this.options.event ) {
  1463. this._off( this.headers, this.options.event );
  1464. }
  1465. this._setupEvents( value );
  1466. }
  1467. this._super( key, value );
  1468. // setting collapsible: false while collapsed; open first panel
  1469. if ( key === "collapsible" && !value && this.options.active === false ) {
  1470. this._activate( 0 );
  1471. }
  1472. if ( key === "icons" ) {
  1473. this._destroyIcons();
  1474. if ( value ) {
  1475. this._createIcons();
  1476. }
  1477. }
  1478. // #5332 - opacity doesn't cascade to positioned elements in IE
  1479. // so we need to add the disabled class to the headers and panels
  1480. if ( key === "disabled" ) {
  1481. this.element
  1482. .toggleClass( "ui-state-disabled", !!value )
  1483. .attr( "aria-disabled", value );
  1484. this.headers.add( this.headers.next() )
  1485. .toggleClass( "ui-state-disabled", !!value );
  1486. }
  1487. },
  1488. _keydown: function( event ) {
  1489. if ( event.altKey || event.ctrlKey ) {
  1490. return;
  1491. }
  1492. var keyCode = $.ui.keyCode,
  1493. length = this.headers.length,
  1494. currentIndex = this.headers.index( event.target ),
  1495. toFocus = false;
  1496. switch ( event.keyCode ) {
  1497. case keyCode.RIGHT:
  1498. case keyCode.DOWN:
  1499. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  1500. break;
  1501. case keyCode.LEFT:
  1502. case keyCode.UP:
  1503. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  1504. break;
  1505. case keyCode.SPACE:
  1506. case keyCode.ENTER:
  1507. this._eventHandler( event );
  1508. break;
  1509. case keyCode.HOME:
  1510. toFocus = this.headers[ 0 ];
  1511. break;
  1512. case keyCode.END:
  1513. toFocus = this.headers[ length - 1 ];
  1514. break;
  1515. }
  1516. if ( toFocus ) {
  1517. $( event.target ).attr( "tabIndex", -1 );
  1518. $( toFocus ).attr( "tabIndex", 0 );
  1519. toFocus.focus();
  1520. event.preventDefault();
  1521. }
  1522. },
  1523. _panelKeyDown: function( event ) {
  1524. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  1525. $( event.currentTarget ).prev().focus();
  1526. }
  1527. },
  1528. refresh: function() {
  1529. var options = this.options;
  1530. this._processPanels();
  1531. // was collapsed or no panel
  1532. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  1533. options.active = false;
  1534. this.active = $();
  1535. // active false only when collapsible is true
  1536. } else if ( options.active === false ) {
  1537. this._activate( 0 );
  1538. // was active, but active panel is gone
  1539. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  1540. // all remaining panel are disabled
  1541. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  1542. options.active = false;
  1543. this.active = $();
  1544. // activate previous panel
  1545. } else {
  1546. this._activate( Math.max( 0, options.active - 1 ) );
  1547. }
  1548. // was active, active panel still exists
  1549. } else {
  1550. // make sure active index is correct
  1551. options.active = this.headers.index( this.active );
  1552. }
  1553. this._destroyIcons();
  1554. this._refresh();
  1555. },
  1556. _processPanels: function() {
  1557. this.headers = this.element.find( this.options.header )
  1558. .addClass( "ui-accordion-header ui-state-default ui-corner-all" );
  1559. this.headers.next()
  1560. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  1561. .filter( ":not(.ui-accordion-content-active)" )
  1562. .hide();
  1563. },
  1564. _refresh: function() {
  1565. var maxHeight,
  1566. options = this.options,
  1567. heightStyle = options.heightStyle,
  1568. parent = this.element.parent();
  1569. this.active = this._findActive( options.active )
  1570. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  1571. .removeClass( "ui-corner-all" );
  1572. this.active.next()
  1573. .addClass( "ui-accordion-content-active" )
  1574. .show();
  1575. this.headers
  1576. .attr( "role", "tab" )
  1577. .each(function() {
  1578. var header = $( this ),
  1579. headerId = header.uniqueId().attr( "id" ),
  1580. panel = header.next(),
  1581. panelId = panel.uniqueId().attr( "id" );
  1582. header.attr( "aria-controls", panelId );
  1583. panel.attr( "aria-labelledby", headerId );
  1584. })
  1585. .next()
  1586. .attr( "role", "tabpanel" );
  1587. this.headers
  1588. .not( this.active )
  1589. .attr({
  1590. "aria-selected": "false",
  1591. "aria-expanded": "false",
  1592. tabIndex: -1
  1593. })
  1594. .next()
  1595. .attr({
  1596. "aria-hidden": "true"
  1597. })
  1598. .hide();
  1599. // make sure at least one header is in the tab order
  1600. if ( !this.active.length ) {
  1601. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  1602. } else {
  1603. this.active.attr({
  1604. "aria-selected": "true",
  1605. "aria-expanded": "true",
  1606. tabIndex: 0
  1607. })
  1608. .next()
  1609. .attr({
  1610. "aria-hidden": "false"
  1611. });
  1612. }
  1613. this._createIcons();
  1614. this._setupEvents( options.event );
  1615. if ( heightStyle === "fill" ) {
  1616. maxHeight = parent.height();
  1617. this.element.siblings( ":visible" ).each(function() {
  1618. var elem = $( this ),
  1619. position = elem.css( "position" );
  1620. if ( position === "absolute" || position === "fixed" ) {
  1621. return;
  1622. }
  1623. maxHeight -= elem.outerHeight( true );
  1624. });
  1625. this.headers.each(function() {
  1626. maxHeight -= $( this ).outerHeight( true );
  1627. });
  1628. this.headers.next()
  1629. .each(function() {
  1630. $( this ).height( Math.max( 0, maxHeight -
  1631. $( this ).innerHeight() + $( this ).height() ) );
  1632. })
  1633. .css( "overflow", "auto" );
  1634. } else if ( heightStyle === "auto" ) {
  1635. maxHeight = 0;
  1636. this.headers.next()
  1637. .each(function() {
  1638. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  1639. })
  1640. .height( maxHeight );
  1641. }
  1642. },
  1643. _activate: function( index ) {
  1644. var active = this._findActive( index )[ 0 ];
  1645. // trying to activate the already active panel
  1646. if ( active === this.active[ 0 ] ) {
  1647. return;
  1648. }
  1649. // trying to collapse, simulate a click on the currently active header
  1650. active = active || this.active[ 0 ];
  1651. this._eventHandler({
  1652. target: active,
  1653. currentTarget: active,
  1654. preventDefault: $.noop
  1655. });
  1656. },
  1657. _findActive: function( selector ) {
  1658. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  1659. },
  1660. _setupEvents: function( event ) {
  1661. var events = {
  1662. keydown: "_keydown"
  1663. };
  1664. if ( event ) {
  1665. $.each( event.split( " " ), function( index, eventName ) {
  1666. events[ eventName ] = "_eventHandler";
  1667. });
  1668. }
  1669. this._off( this.headers.add( this.headers.next() ) );
  1670. this._on( this.headers, events );
  1671. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  1672. this._hoverable( this.headers );
  1673. this._focusable( this.headers );
  1674. },
  1675. _eventHandler: function( event ) {
  1676. var options = this.options,
  1677. active = this.active,
  1678. clicked = $( event.currentTarget ),
  1679. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  1680. collapsing = clickedIsActive && options.collapsible,
  1681. toShow = collapsing ? $() : clicked.next(),
  1682. toHide = active.next(),
  1683. eventData = {
  1684. oldHeader: active,
  1685. oldPanel: toHide,
  1686. newHeader: collapsing ? $() : clicked,
  1687. newPanel: toShow
  1688. };
  1689. event.preventDefault();
  1690. if (
  1691. // click on active header, but not collapsible
  1692. ( clickedIsActive && !options.collapsible ) ||
  1693. // allow canceling activation
  1694. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  1695. return;
  1696. }
  1697. options.active = collapsing ? false : this.headers.index( clicked );
  1698. // when the call to ._toggle() comes after the class changes
  1699. // it causes a very odd bug in IE 8 (see #6720)
  1700. this.active = clickedIsActive ? $() : clicked;
  1701. this._toggle( eventData );
  1702. // switch classes
  1703. // corner classes on the previously active header stay after the animation
  1704. active.removeClass( "ui-accordion-header-active ui-state-active" );
  1705. if ( options.icons ) {
  1706. active.children( ".ui-accordion-header-icon" )
  1707. .removeClass( options.icons.activeHeader )
  1708. .addClass( options.icons.header );
  1709. }
  1710. if ( !clickedIsActive ) {
  1711. clicked
  1712. .removeClass( "ui-corner-all" )
  1713. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  1714. if ( options.icons ) {
  1715. clicked.children( ".ui-accordion-header-icon" )
  1716. .removeClass( options.icons.header )
  1717. .addClass( options.icons.activeHeader );
  1718. }
  1719. clicked
  1720. .next()
  1721. .addClass( "ui-accordion-content-active" );
  1722. }
  1723. },
  1724. _toggle: function( data ) {
  1725. var toShow = data.newPanel,
  1726. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  1727. // handle activating a panel during the animation for another activation
  1728. this.prevShow.add( this.prevHide ).stop( true, true );
  1729. this.prevShow = toShow;
  1730. this.prevHide = toHide;
  1731. if ( this.options.animate ) {
  1732. this._animate( toShow, toHide, data );
  1733. } else {
  1734. toHide.hide();
  1735. toShow.show();
  1736. this._toggleComplete( data );
  1737. }
  1738. toHide.attr({
  1739. "aria-hidden": "true"
  1740. });
  1741. toHide.prev().attr( "aria-selected", "false" );
  1742. // if we're switching panels, remove the old header from the tab order
  1743. // if we're opening from collapsed state, remove the previous header from the tab order
  1744. // if we're collapsing, then keep the collapsing header in the tab order
  1745. if ( toShow.length && toHide.length ) {
  1746. toHide.prev().attr({
  1747. "tabIndex": -1,
  1748. "aria-expanded": "false"
  1749. });
  1750. } else if ( toShow.length ) {
  1751. this.headers.filter(function() {
  1752. return $( this ).attr( "tabIndex" ) === 0;
  1753. })
  1754. .attr( "tabIndex", -1 );
  1755. }
  1756. toShow
  1757. .attr( "aria-hidden", "false" )
  1758. .prev()
  1759. .attr({
  1760. "aria-selected": "true",
  1761. tabIndex: 0,
  1762. "aria-expanded": "true"
  1763. });
  1764. },
  1765. _animate: function( toShow, toHide, data ) {
  1766. var total, easing, duration,
  1767. that = this,
  1768. adjust = 0,
  1769. down = toShow.length &&
  1770. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  1771. animate = this.options.animate || {},
  1772. options = down && animate.down || animate,
  1773. complete = function() {
  1774. that._toggleComplete( data );
  1775. };
  1776. if ( typeof options === "number" ) {
  1777. duration = options;
  1778. }
  1779. if ( typeof options === "string" ) {
  1780. easing = options;
  1781. }
  1782. // fall back from options to animation in case of partial down settings
  1783. easing = easing || options.easing || animate.easing;
  1784. duration = duration || options.duration || animate.duration;
  1785. if ( !toHide.length ) {
  1786. return toShow.animate( this.showProps, duration, easing, complete );
  1787. }
  1788. if ( !toShow.length ) {
  1789. return toHide.animate( this.hideProps, duration, easing, complete );
  1790. }
  1791. total = toShow.show().outerHeight();
  1792. toHide.animate( this.hideProps, {
  1793. duration: duration,
  1794. easing: easing,
  1795. step: function( now, fx ) {
  1796. fx.now = Math.round( now );
  1797. }
  1798. });
  1799. toShow
  1800. .hide()
  1801. .animate( this.showProps, {
  1802. duration: duration,
  1803. easing: easing,
  1804. complete: complete,
  1805. step: function( now, fx ) {
  1806. fx.now = Math.round( now );
  1807. if ( fx.prop !== "height" ) {
  1808. adjust += fx.now;
  1809. } else if ( that.options.heightStyle !== "content" ) {
  1810. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  1811. adjust = 0;
  1812. }
  1813. }
  1814. });
  1815. },
  1816. _toggleComplete: function( data ) {
  1817. var toHide = data.oldPanel;
  1818. toHide
  1819. .removeClass( "ui-accordion-content-active" )
  1820. .prev()
  1821. .removeClass( "ui-corner-top" )
  1822. .addClass( "ui-corner-all" );
  1823. // Work around for rendering bug in IE (#5421)
  1824. if ( toHide.length ) {
  1825. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  1826. }
  1827. this._trigger( "activate", null, data );
  1828. }
  1829. });
  1830. /*!
  1831. * jQuery UI Menu 1.11.0
  1832. * http://jqueryui.com
  1833. *
  1834. * Copyright 2014 jQuery Foundation and other contributors
  1835. * Released under the MIT license.
  1836. * http://jquery.org/license
  1837. *
  1838. * http://api.jqueryui.com/menu/
  1839. */
  1840. var menu = $.widget( "ui.menu", {
  1841. version: "1.11.0",
  1842. defaultElement: "<ul>",
  1843. delay: 300,
  1844. options: {
  1845. icons: {
  1846. submenu: "ui-icon-carat-1-e"
  1847. },
  1848. items: "> *",
  1849. menus: "ul",
  1850. position: {
  1851. my: "left-1 top",
  1852. at: "right top"
  1853. },
  1854. role: "menu",
  1855. // callbacks
  1856. blur: null,
  1857. focus: null,
  1858. select: null
  1859. },
  1860. _create: function() {
  1861. this.activeMenu = this.element;
  1862. // Flag used to prevent firing of the click handler
  1863. // as the event bubbles up through nested menus
  1864. this.mouseHandled = false;
  1865. this.element
  1866. .uniqueId()
  1867. .addClass( "ui-menu ui-widget ui-widget-content" )
  1868. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  1869. .attr({
  1870. role: this.options.role,
  1871. tabIndex: 0
  1872. });
  1873. if ( this.options.disabled ) {
  1874. this.element
  1875. .addClass( "ui-state-disabled" )
  1876. .attr( "aria-disabled", "true" );
  1877. }
  1878. this._on({
  1879. // Prevent focus from sticking to links inside menu after clicking
  1880. // them (focus should always stay on UL during navigation).
  1881. "mousedown .ui-menu-item": function( event ) {
  1882. event.preventDefault();
  1883. },
  1884. "click .ui-menu-item": function( event ) {
  1885. var target = $( event.target );
  1886. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  1887. this.select( event );
  1888. // Only set the mouseHandled flag if the event will bubble, see #9469.
  1889. if ( !event.isPropagationStopped() ) {
  1890. this.mouseHandled = true;
  1891. }
  1892. // Open submenu on click
  1893. if ( target.has( ".ui-menu" ).length ) {
  1894. this.expand( event );
  1895. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  1896. // Redirect focus to the menu
  1897. this.element.trigger( "focus", [ true ] );
  1898. // If the active item is on the top level, let it stay active.
  1899. // Otherwise, blur the active item since it is no longer visible.
  1900. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  1901. clearTimeout( this.timer );
  1902. }
  1903. }
  1904. }
  1905. },
  1906. "mouseenter .ui-menu-item": function( event ) {
  1907. var target = $( event.currentTarget );
  1908. // Remove ui-state-active class from siblings of the newly focused menu item
  1909. // to avoid a jump caused by adjacent elements both having a class with a border
  1910. target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
  1911. this.focus( event, target );
  1912. },
  1913. mouseleave: "collapseAll",
  1914. "mouseleave .ui-menu": "collapseAll",
  1915. focus: function( event, keepActiveItem ) {
  1916. // If there's already an active item, keep it active
  1917. // If not, activate the first item
  1918. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  1919. if ( !keepActiveItem ) {
  1920. this.focus( event, item );
  1921. }
  1922. },
  1923. blur: function( event ) {
  1924. this._delay(function() {
  1925. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  1926. this.collapseAll( event );
  1927. }
  1928. });
  1929. },
  1930. keydown: "_keydown"
  1931. });
  1932. this.refresh();
  1933. // Clicks outside of a menu collapse any open menus
  1934. this._on( this.document, {
  1935. click: function( event ) {
  1936. if ( this._closeOnDocumentClick( event ) ) {
  1937. this.collapseAll( event );
  1938. }
  1939. // Reset the mouseHandled flag
  1940. this.mouseHandled = false;
  1941. }
  1942. });
  1943. },
  1944. _destroy: function() {
  1945. // Destroy (sub)menus
  1946. this.element
  1947. .removeAttr( "aria-activedescendant" )
  1948. .find( ".ui-menu" ).addBack()
  1949. .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
  1950. .removeAttr( "role" )
  1951. .removeAttr( "tabIndex" )
  1952. .removeAttr( "aria-labelledby" )
  1953. .removeAttr( "aria-expanded" )
  1954. .removeAttr( "aria-hidden" )
  1955. .removeAttr( "aria-disabled" )
  1956. .removeUniqueId()
  1957. .show();
  1958. // Destroy menu items
  1959. this.element.find( ".ui-menu-item" )
  1960. .removeClass( "ui-menu-item" )
  1961. .removeAttr( "role" )
  1962. .removeAttr( "aria-disabled" )
  1963. .removeUniqueId()
  1964. .removeClass( "ui-state-hover" )
  1965. .removeAttr( "tabIndex" )
  1966. .removeAttr( "role" )
  1967. .removeAttr( "aria-haspopup" )
  1968. .children().each( function() {
  1969. var elem = $( this );
  1970. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  1971. elem.remove();
  1972. }
  1973. });
  1974. // Destroy menu dividers
  1975. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  1976. },
  1977. _keydown: function( event ) {
  1978. var match, prev, character, skip, regex,
  1979. preventDefault = true;
  1980. function escape( value ) {
  1981. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  1982. }
  1983. switch ( event.keyCode ) {
  1984. case $.ui.keyCode.PAGE_UP:
  1985. this.previousPage( event );
  1986. break;
  1987. case $.ui.keyCode.PAGE_DOWN:
  1988. this.nextPage( event );
  1989. break;
  1990. case $.ui.keyCode.HOME:
  1991. this._move( "first", "first", event );
  1992. break;
  1993. case $.ui.keyCode.END:
  1994. this._move( "last", "last", event );
  1995. break;
  1996. case $.ui.keyCode.UP:
  1997. this.previous( event );
  1998. break;
  1999. case $.ui.keyCode.DOWN:
  2000. this.next( event );
  2001. break;
  2002. case $.ui.keyCode.LEFT:
  2003. this.collapse( event );
  2004. break;
  2005. case $.ui.keyCode.RIGHT:
  2006. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  2007. this.expand( event );
  2008. }
  2009. break;
  2010. case $.ui.keyCode.ENTER:
  2011. case $.ui.keyCode.SPACE:
  2012. this._activate( event );
  2013. break;
  2014. case $.ui.keyCode.ESCAPE:
  2015. this.collapse( event );
  2016. break;
  2017. default:
  2018. preventDefault = false;
  2019. prev = this.previousFilter || "";
  2020. character = String.fromCharCode( event.keyCode );
  2021. skip = false;
  2022. clearTimeout( this.filterTimer );
  2023. if ( character === prev ) {
  2024. skip = true;
  2025. } else {
  2026. character = prev + character;
  2027. }
  2028. regex = new RegExp( "^" + escape( character ), "i" );
  2029. match = this.activeMenu.find( this.options.items ).filter(function() {
  2030. return regex.test( $( this ).text() );
  2031. });
  2032. match = skip && match.index( this.active.next() ) !== -1 ?
  2033. this.active.nextAll( ".ui-menu-item" ) :
  2034. match;
  2035. // If no matches on the current filter, reset to the last character pressed
  2036. // to move down the menu to the first item that starts with that character
  2037. if ( !match.length ) {
  2038. character = String.fromCharCode( event.keyCode );
  2039. regex = new RegExp( "^" + escape( character ), "i" );
  2040. match = this.activeMenu.find( this.options.items ).filter(function() {
  2041. return regex.test( $( this ).text() );
  2042. });
  2043. }
  2044. if ( match.length ) {
  2045. this.focus( event, match );
  2046. if ( match.length > 1 ) {
  2047. this.previousFilter = character;
  2048. this.filterTimer = this._delay(function() {
  2049. delete this.previousFilter;
  2050. }, 1000 );
  2051. } else {
  2052. delete this.previousFilter;
  2053. }
  2054. } else {
  2055. delete this.previousFilter;
  2056. }
  2057. }
  2058. if ( preventDefault ) {
  2059. event.preventDefault();
  2060. }
  2061. },
  2062. _activate: function( event ) {
  2063. if ( !this.active.is( ".ui-state-disabled" ) ) {
  2064. if ( this.active.is( "[aria-haspopup='true']" ) ) {
  2065. this.expand( event );
  2066. } else {
  2067. this.select( event );
  2068. }
  2069. }
  2070. },
  2071. refresh: function() {
  2072. var menus, items,
  2073. that = this,
  2074. icon = this.options.icons.submenu,
  2075. submenus = this.element.find( this.options.menus );
  2076. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  2077. // Initialize nested menus
  2078. submenus.filter( ":not(.ui-menu)" )
  2079. .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
  2080. .hide()
  2081. .attr({
  2082. role: this.options.role,
  2083. "aria-hidden": "true",
  2084. "aria-expanded": "false"
  2085. })
  2086. .each(function() {
  2087. var menu = $( this ),
  2088. item = menu.parent(),
  2089. submenuCarat = $( "<span>" )
  2090. .addClass( "ui-menu-icon ui-icon " + icon )
  2091. .data( "ui-menu-submenu-carat", true );
  2092. item
  2093. .attr( "aria-haspopup", "true" )
  2094. .prepend( submenuCarat );
  2095. menu.attr( "aria-labelledby", item.attr( "id" ) );
  2096. });
  2097. menus = submenus.add( this.element );
  2098. items = menus.find( this.options.items );
  2099. // Initialize menu-items containing spaces and/or dashes only as dividers
  2100. items.not( ".ui-menu-item" ).each(function() {
  2101. var item = $( this );
  2102. if ( that._isDivider( item ) ) {
  2103. item.addClass( "ui-widget-content ui-menu-divider" );
  2104. }
  2105. });
  2106. // Don't refresh list items that are already adapted
  2107. items.not( ".ui-menu-item, .ui-menu-divider" )
  2108. .addClass( "ui-menu-item" )
  2109. .uniqueId()
  2110. .attr({
  2111. tabIndex: -1,
  2112. role: this._itemRole()
  2113. });
  2114. // Add aria-disabled attribute to any disabled menu item
  2115. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  2116. // If the active item has been removed, blur the menu
  2117. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  2118. this.blur();
  2119. }
  2120. },
  2121. _itemRole: function() {
  2122. return {
  2123. menu: "menuitem",
  2124. listbox: "option"
  2125. }[ this.options.role ];
  2126. },
  2127. _setOption: function( key, value ) {
  2128. if ( key === "icons" ) {
  2129. this.element.find( ".ui-menu-icon" )
  2130. .removeClass( this.options.icons.submenu )
  2131. .addClass( value.submenu );
  2132. }
  2133. if ( key === "disabled" ) {
  2134. this.element
  2135. .toggleClass( "ui-state-disabled", !!value )
  2136. .attr( "aria-disabled", value );
  2137. }
  2138. this._super( key, value );
  2139. },
  2140. focus: function( event, item ) {
  2141. var nested, focused;
  2142. this.blur( event, event && event.type === "focus" );
  2143. this._scrollIntoView( item );
  2144. this.active = item.first();
  2145. focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
  2146. // Only update aria-activedescendant if there's a role
  2147. // otherwise we assume focus is managed elsewhere
  2148. if ( this.options.role ) {
  2149. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  2150. }
  2151. // Highlight active parent menu item, if any
  2152. this.active
  2153. .parent()
  2154. .closest( ".ui-menu-item" )
  2155. .addClass( "ui-state-active" );
  2156. if ( event && event.type === "keydown" ) {
  2157. this._close();
  2158. } else {
  2159. this.timer = this._delay(function() {
  2160. this._close();
  2161. }, this.delay );
  2162. }
  2163. nested = item.children( ".ui-menu" );
  2164. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  2165. this._startOpening(nested);
  2166. }
  2167. this.activeMenu = item.parent();
  2168. this._trigger( "focus", event, { item: item } );
  2169. },
  2170. _scrollIntoView: function( item ) {
  2171. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  2172. if ( this._hasScroll() ) {
  2173. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  2174. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  2175. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  2176. scroll = this.activeMenu.scrollTop();
  2177. elementHeight = this.activeMenu.height();
  2178. itemHeight = item.outerHeight();
  2179. if ( offset < 0 ) {
  2180. this.activeMenu.scrollTop( scroll + offset );
  2181. } else if ( offset + itemHeight > elementHeight ) {
  2182. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  2183. }
  2184. }
  2185. },
  2186. blur: function( event, fromFocus ) {
  2187. if ( !fromFocus ) {
  2188. clearTimeout( this.timer );
  2189. }
  2190. if ( !this.active ) {
  2191. return;
  2192. }
  2193. this.active.removeClass( "ui-state-focus" );
  2194. this.active = null;
  2195. this._trigger( "blur", event, { item: this.active } );
  2196. },
  2197. _startOpening: function( submenu ) {
  2198. clearTimeout( this.timer );
  2199. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  2200. // shift in the submenu position when mousing over the carat icon
  2201. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  2202. return;
  2203. }
  2204. this.timer = this._delay(function() {
  2205. this._close();
  2206. this._open( submenu );
  2207. }, this.delay );
  2208. },
  2209. _open: function( submenu ) {
  2210. var position = $.extend({
  2211. of: this.active
  2212. }, this.options.position );
  2213. clearTimeout( this.timer );
  2214. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  2215. .hide()
  2216. .attr( "aria-hidden", "true" );
  2217. submenu
  2218. .show()
  2219. .removeAttr( "aria-hidden" )
  2220. .attr( "aria-expanded", "true" )
  2221. .position( position );
  2222. },
  2223. collapseAll: function( event, all ) {
  2224. clearTimeout( this.timer );
  2225. this.timer = this._delay(function() {
  2226. // If we were passed an event, look for the submenu that contains the event
  2227. var currentMenu = all ? this.element :
  2228. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  2229. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  2230. if ( !currentMenu.length ) {
  2231. currentMenu = this.element;
  2232. }
  2233. this._close( currentMenu );
  2234. this.blur( event );
  2235. this.activeMenu = currentMenu;
  2236. }, this.delay );
  2237. },
  2238. // With no arguments, closes the currently active menu - if nothing is active
  2239. // it closes all menus. If passed an argument, it will search for menus BELOW
  2240. _close: function( startMenu ) {
  2241. if ( !startMenu ) {
  2242. startMenu = this.active ? this.active.parent() : this.element;
  2243. }
  2244. startMenu
  2245. .find( ".ui-menu" )
  2246. .hide()
  2247. .attr( "aria-hidden", "true" )
  2248. .attr( "aria-expanded", "false" )
  2249. .end()
  2250. .find( ".ui-state-active" ).not( ".ui-state-focus" )
  2251. .removeClass( "ui-state-active" );
  2252. },
  2253. _closeOnDocumentClick: function( event ) {
  2254. return !$( event.target ).closest( ".ui-menu" ).length;
  2255. },
  2256. _isDivider: function( item ) {
  2257. // Match hyphen, em dash, en dash
  2258. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  2259. },
  2260. collapse: function( event ) {
  2261. var newItem = this.active &&
  2262. this.active.parent().closest( ".ui-menu-item", this.element );
  2263. if ( newItem && newItem.length ) {
  2264. this._close();
  2265. this.focus( event, newItem );
  2266. }
  2267. },
  2268. expand: function( event ) {
  2269. var newItem = this.active &&
  2270. this.active
  2271. .children( ".ui-menu " )
  2272. .find( this.options.items )
  2273. .first();
  2274. if ( newItem && newItem.length ) {
  2275. this._open( newItem.parent() );
  2276. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  2277. this._delay(function() {
  2278. this.focus( event, newItem );
  2279. });
  2280. }
  2281. },
  2282. next: function( event ) {
  2283. this._move( "next", "first", event );
  2284. },
  2285. previous: function( event ) {
  2286. this._move( "prev", "last", event );
  2287. },
  2288. isFirstItem: function() {
  2289. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  2290. },
  2291. isLastItem: function() {
  2292. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  2293. },
  2294. _move: function( direction, filter, event ) {
  2295. var next;
  2296. if ( this.active ) {
  2297. if ( direction === "first" || direction === "last" ) {
  2298. next = this.active
  2299. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  2300. .eq( -1 );
  2301. } else {
  2302. next = this.active
  2303. [ direction + "All" ]( ".ui-menu-item" )
  2304. .eq( 0 );
  2305. }
  2306. }
  2307. if ( !next || !next.length || !this.active ) {
  2308. next = this.activeMenu.find( this.options.items )[ filter ]();
  2309. }
  2310. this.focus( event, next );
  2311. },
  2312. nextPage: function( event ) {
  2313. var item, base, height;
  2314. if ( !this.active ) {
  2315. this.next( event );
  2316. return;
  2317. }
  2318. if ( this.isLastItem() ) {
  2319. return;
  2320. }
  2321. if ( this._hasScroll() ) {
  2322. base = this.active.offset().top;
  2323. height = this.element.height();
  2324. this.active.nextAll( ".ui-menu-item" ).each(function() {
  2325. item = $( this );
  2326. return item.offset().top - base - height < 0;
  2327. });
  2328. this.focus( event, item );
  2329. } else {
  2330. this.focus( event, this.activeMenu.find( this.options.items )
  2331. [ !this.active ? "first" : "last" ]() );
  2332. }
  2333. },
  2334. previousPage: function( event ) {
  2335. var item, base, height;
  2336. if ( !this.active ) {
  2337. this.next( event );
  2338. return;
  2339. }
  2340. if ( this.isFirstItem() ) {
  2341. return;
  2342. }
  2343. if ( this._hasScroll() ) {
  2344. base = this.active.offset().top;
  2345. height = this.element.height();
  2346. this.active.prevAll( ".ui-menu-item" ).each(function() {
  2347. item = $( this );
  2348. return item.offset().top - base + height > 0;
  2349. });
  2350. this.focus( event, item );
  2351. } else {
  2352. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  2353. }
  2354. },
  2355. _hasScroll: function() {
  2356. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  2357. },
  2358. select: function( event ) {
  2359. // TODO: It should never be possible to not have an active item at this
  2360. // point, but the tests don't trigger mouseenter before click.
  2361. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  2362. var ui = { item: this.active };
  2363. if ( !this.active.has( ".ui-menu" ).length ) {
  2364. this.collapseAll( event, true );
  2365. }
  2366. this._trigger( "select", event, ui );
  2367. }
  2368. });
  2369. /*!
  2370. * jQuery UI Autocomplete 1.11.0
  2371. * http://jqueryui.com
  2372. *
  2373. * Copyright 2014 jQuery Foundation and other contributors
  2374. * Released under the MIT license.
  2375. * http://jquery.org/license
  2376. *
  2377. * http://api.jqueryui.com/autocomplete/
  2378. */
  2379. $.widget( "ui.autocomplete", {
  2380. version: "1.11.0",
  2381. defaultElement: "<input>",
  2382. options: {
  2383. appendTo: null,
  2384. autoFocus: false,
  2385. delay: 300,
  2386. minLength: 1,
  2387. position: {
  2388. my: "left top",
  2389. at: "left bottom",
  2390. collision: "none"
  2391. },
  2392. source: null,
  2393. // callbacks
  2394. change: null,
  2395. close: null,
  2396. focus: null,
  2397. open: null,
  2398. response: null,
  2399. search: null,
  2400. select: null
  2401. },
  2402. requestIndex: 0,
  2403. pending: 0,
  2404. _create: function() {
  2405. // Some browsers only repeat keydown events, not keypress events,
  2406. // so we use the suppressKeyPress flag to determine if we've already
  2407. // handled the keydown event. #7269
  2408. // Unfortunately the code for & in keypress is the same as the up arrow,
  2409. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  2410. // events when we know the keydown event was used to modify the
  2411. // search term. #7799
  2412. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  2413. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  2414. isTextarea = nodeName === "textarea",
  2415. isInput = nodeName === "input";
  2416. this.isMultiLine =
  2417. // Textareas are always multi-line
  2418. isTextarea ? true :
  2419. // Inputs are always single-line, even if inside a contentEditable element
  2420. // IE also treats inputs as contentEditable
  2421. isInput ? false :
  2422. // All other element types are determined by whether or not they're contentEditable
  2423. this.element.prop( "isContentEditable" );
  2424. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  2425. this.isNewMenu = true;
  2426. this.element
  2427. .addClass( "ui-autocomplete-input" )
  2428. .attr( "autocomplete", "off" );
  2429. this._on( this.element, {
  2430. keydown: function( event ) {
  2431. if ( this.element.prop( "readOnly" ) ) {
  2432. suppressKeyPress = true;
  2433. suppressInput = true;
  2434. suppressKeyPressRepeat = true;
  2435. return;
  2436. }
  2437. suppressKeyPress = false;
  2438. suppressInput = false;
  2439. suppressKeyPressRepeat = false;
  2440. var keyCode = $.ui.keyCode;
  2441. switch ( event.keyCode ) {
  2442. case keyCode.PAGE_UP:
  2443. suppressKeyPress = true;
  2444. this._move( "previousPage", event );
  2445. break;
  2446. case keyCode.PAGE_DOWN:
  2447. suppressKeyPress = true;
  2448. this._move( "nextPage", event );
  2449. break;
  2450. case keyCode.UP:
  2451. suppressKeyPress = true;
  2452. this._keyEvent( "previous", event );
  2453. break;
  2454. case keyCode.DOWN:
  2455. suppressKeyPress = true;
  2456. this._keyEvent( "next", event );
  2457. break;
  2458. case keyCode.ENTER:
  2459. // when menu is open and has focus
  2460. if ( this.menu.active ) {
  2461. // #6055 - Opera still allows the keypress to occur
  2462. // which causes forms to submit
  2463. suppressKeyPress = true;
  2464. event.preventDefault();
  2465. this.menu.select( event );
  2466. }
  2467. break;
  2468. case keyCode.TAB:
  2469. if ( this.menu.active ) {
  2470. this.menu.select( event );
  2471. }
  2472. break;
  2473. case keyCode.ESCAPE:
  2474. if ( this.menu.element.is( ":visible" ) ) {
  2475. this._value( this.term );
  2476. this.close( event );
  2477. // Different browsers have different default behavior for escape
  2478. // Single press can mean undo or clear
  2479. // Double press in IE means clear the whole form
  2480. event.preventDefault();
  2481. }
  2482. break;
  2483. default:
  2484. suppressKeyPressRepeat = true;
  2485. // search timeout should be triggered before the input value is changed
  2486. this._searchTimeout( event );
  2487. break;
  2488. }
  2489. },
  2490. keypress: function( event ) {
  2491. if ( suppressKeyPress ) {
  2492. suppressKeyPress = false;
  2493. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2494. event.preventDefault();
  2495. }
  2496. return;
  2497. }
  2498. if ( suppressKeyPressRepeat ) {
  2499. return;
  2500. }
  2501. // replicate some key handlers to allow them to repeat in Firefox and Opera
  2502. var keyCode = $.ui.keyCode;
  2503. switch ( event.keyCode ) {
  2504. case keyCode.PAGE_UP:
  2505. this._move( "previousPage", event );
  2506. break;
  2507. case keyCode.PAGE_DOWN:
  2508. this._move( "nextPage", event );
  2509. break;
  2510. case keyCode.UP:
  2511. this._keyEvent( "previous", event );
  2512. break;
  2513. case keyCode.DOWN:
  2514. this._keyEvent( "next", event );
  2515. break;
  2516. }
  2517. },
  2518. input: function( event ) {
  2519. if ( suppressInput ) {
  2520. suppressInput = false;
  2521. event.preventDefault();
  2522. return;
  2523. }
  2524. this._searchTimeout( event );
  2525. },
  2526. focus: function() {
  2527. this.selectedItem = null;
  2528. this.previous = this._value();
  2529. },
  2530. blur: function( event ) {
  2531. if ( this.cancelBlur ) {
  2532. delete this.cancelBlur;
  2533. return;
  2534. }
  2535. clearTimeout( this.searching );
  2536. this.close( event );
  2537. this._change( event );
  2538. }
  2539. });
  2540. this._initSource();
  2541. this.menu = $( "<ul>" )
  2542. .addClass( "ui-autocomplete ui-front" )
  2543. .appendTo( this._appendTo() )
  2544. .menu({
  2545. // disable ARIA support, the live region takes care of that
  2546. role: null
  2547. })
  2548. .hide()
  2549. .menu( "instance" );
  2550. this._on( this.menu.element, {
  2551. mousedown: function( event ) {
  2552. // prevent moving focus out of the text field
  2553. event.preventDefault();
  2554. // IE doesn't prevent moving focus even with event.preventDefault()
  2555. // so we set a flag to know when we should ignore the blur event
  2556. this.cancelBlur = true;
  2557. this._delay(function() {
  2558. delete this.cancelBlur;
  2559. });
  2560. // clicking on the scrollbar causes focus to shift to the body
  2561. // but we can't detect a mouseup or a click immediately afterward
  2562. // so we have to track the next mousedown and close the menu if
  2563. // the user clicks somewhere outside of the autocomplete
  2564. var menuElement = this.menu.element[ 0 ];
  2565. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  2566. this._delay(function() {
  2567. var that = this;
  2568. this.document.one( "mousedown", function( event ) {
  2569. if ( event.target !== that.element[ 0 ] &&
  2570. event.target !== menuElement &&
  2571. !$.contains( menuElement, event.target ) ) {
  2572. that.close();
  2573. }
  2574. });
  2575. });
  2576. }
  2577. },
  2578. menufocus: function( event, ui ) {
  2579. var label, item;
  2580. // support: Firefox
  2581. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  2582. if ( this.isNewMenu ) {
  2583. this.isNewMenu = false;
  2584. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  2585. this.menu.blur();
  2586. this.document.one( "mousemove", function() {
  2587. $( event.target ).trigger( event.originalEvent );
  2588. });
  2589. return;
  2590. }
  2591. }
  2592. item = ui.item.data( "ui-autocomplete-item" );
  2593. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  2594. // use value to match what will end up in the input, if it was a key event
  2595. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  2596. this._value( item.value );
  2597. }
  2598. }
  2599. // Announce the value in the liveRegion
  2600. label = ui.item.attr( "aria-label" ) || item.value;
  2601. if ( label && jQuery.trim( label ).length ) {
  2602. this.liveRegion.children().hide();
  2603. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  2604. }
  2605. },
  2606. menuselect: function( event, ui ) {
  2607. var item = ui.item.data( "ui-autocomplete-item" ),
  2608. previous = this.previous;
  2609. // only trigger when focus was lost (click on menu)
  2610. if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
  2611. this.element.focus();
  2612. this.previous = previous;
  2613. // #6109 - IE triggers two focus events and the second
  2614. // is asynchronous, so we need to reset the previous
  2615. // term synchronously and asynchronously :-(
  2616. this._delay(function() {
  2617. this.previous = previous;
  2618. this.selectedItem = item;
  2619. });
  2620. }
  2621. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  2622. this._value( item.value );
  2623. }
  2624. // reset the term after the select event
  2625. // this allows custom select handling to work properly
  2626. this.term = this._value();
  2627. this.close( event );
  2628. this.selectedItem = item;
  2629. }
  2630. });
  2631. this.liveRegion = $( "<span>", {
  2632. role: "status",
  2633. "aria-live": "assertive",
  2634. "aria-relevant": "additions"
  2635. })
  2636. .addClass( "ui-helper-hidden-accessible" )
  2637. .appendTo( this.document[ 0 ].body );
  2638. // turning off autocomplete prevents the browser from remembering the
  2639. // value when navigating through history, so we re-enable autocomplete
  2640. // if the page is unloaded before the widget is destroyed. #7790
  2641. this._on( this.window, {
  2642. beforeunload: function() {
  2643. this.element.removeAttr( "autocomplete" );
  2644. }
  2645. });
  2646. },
  2647. _destroy: function() {
  2648. clearTimeout( this.searching );
  2649. this.element
  2650. .removeClass( "ui-autocomplete-input" )
  2651. .removeAttr( "autocomplete" );
  2652. this.menu.element.remove();
  2653. this.liveRegion.remove();
  2654. },
  2655. _setOption: function( key, value ) {
  2656. this._super( key, value );
  2657. if ( key === "source" ) {
  2658. this._initSource();
  2659. }
  2660. if ( key === "appendTo" ) {
  2661. this.menu.element.appendTo( this._appendTo() );
  2662. }
  2663. if ( key === "disabled" && value && this.xhr ) {
  2664. this.xhr.abort();
  2665. }
  2666. },
  2667. _appendTo: function() {
  2668. var element = this.options.appendTo;
  2669. if ( element ) {
  2670. element = element.jquery || element.nodeType ?
  2671. $( element ) :
  2672. this.document.find( element ).eq( 0 );
  2673. }
  2674. if ( !element || !element[ 0 ] ) {
  2675. element = this.element.closest( ".ui-front" );
  2676. }
  2677. if ( !element.length ) {
  2678. element = this.document[ 0 ].body;
  2679. }
  2680. return element;
  2681. },
  2682. _initSource: function() {
  2683. var array, url,
  2684. that = this;
  2685. if ( $.isArray( this.options.source ) ) {
  2686. array = this.options.source;
  2687. this.source = function( request, response ) {
  2688. response( $.ui.autocomplete.filter( array, request.term ) );
  2689. };
  2690. } else if ( typeof this.options.source === "string" ) {
  2691. url = this.options.source;
  2692. this.source = function( request, response ) {
  2693. if ( that.xhr ) {
  2694. that.xhr.abort();
  2695. }
  2696. that.xhr = $.ajax({
  2697. url: url,
  2698. data: request,
  2699. dataType: "json",
  2700. success: function( data ) {
  2701. response( data );
  2702. },
  2703. error: function() {
  2704. response([]);
  2705. }
  2706. });
  2707. };
  2708. } else {
  2709. this.source = this.options.source;
  2710. }
  2711. },
  2712. _searchTimeout: function( event ) {
  2713. clearTimeout( this.searching );
  2714. this.searching = this._delay(function() {
  2715. // Search if the value has changed, or if the user retypes the same value (see #7434)
  2716. var equalValues = this.term === this._value(),
  2717. menuVisible = this.menu.element.is( ":visible" ),
  2718. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  2719. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  2720. this.selectedItem = null;
  2721. this.search( null, event );
  2722. }
  2723. }, this.options.delay );
  2724. },
  2725. search: function( value, event ) {
  2726. value = value != null ? value : this._value();
  2727. // always save the actual value, not the one passed as an argument
  2728. this.term = this._value();
  2729. if ( value.length < this.options.minLength ) {
  2730. return this.close( event );
  2731. }
  2732. if ( this._trigger( "search", event ) === false ) {
  2733. return;
  2734. }
  2735. return this._search( value );
  2736. },
  2737. _search: function( value ) {
  2738. this.pending++;
  2739. this.element.addClass( "ui-autocomplete-loading" );
  2740. this.cancelSearch = false;
  2741. this.source( { term: value }, this._response() );
  2742. },
  2743. _response: function() {
  2744. var index = ++this.requestIndex;
  2745. return $.proxy(function( content ) {
  2746. if ( index === this.requestIndex ) {
  2747. this.__response( content );
  2748. }
  2749. this.pending--;
  2750. if ( !this.pending ) {
  2751. this.element.removeClass( "ui-autocomplete-loading" );
  2752. }
  2753. }, this );
  2754. },
  2755. __response: function( content ) {
  2756. if ( content ) {
  2757. content = this._normalize( content );
  2758. }
  2759. this._trigger( "response", null, { content: content } );
  2760. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  2761. this._suggest( content );
  2762. this._trigger( "open" );
  2763. } else {
  2764. // use ._close() instead of .close() so we don't cancel future searches
  2765. this._close();
  2766. }
  2767. },
  2768. close: function( event ) {
  2769. this.cancelSearch = true;
  2770. this._close( event );
  2771. },
  2772. _close: function( event ) {
  2773. if ( this.menu.element.is( ":visible" ) ) {
  2774. this.menu.element.hide();
  2775. this.menu.blur();
  2776. this.isNewMenu = true;
  2777. this._trigger( "close", event );
  2778. }
  2779. },
  2780. _change: function( event ) {
  2781. if ( this.previous !== this._value() ) {
  2782. this._trigger( "change", event, { item: this.selectedItem } );
  2783. }
  2784. },
  2785. _normalize: function( items ) {
  2786. // assume all items have the right format when the first item is complete
  2787. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  2788. return items;
  2789. }
  2790. return $.map( items, function( item ) {
  2791. if ( typeof item === "string" ) {
  2792. return {
  2793. label: item,
  2794. value: item
  2795. };
  2796. }
  2797. return $.extend( {}, item, {
  2798. label: item.label || item.value,
  2799. value: item.value || item.label
  2800. });
  2801. });
  2802. },
  2803. _suggest: function( items ) {
  2804. var ul = this.menu.element.empty();
  2805. this._renderMenu( ul, items );
  2806. this.isNewMenu = true;
  2807. this.menu.refresh();
  2808. // size and position menu
  2809. ul.show();
  2810. this._resizeMenu();
  2811. ul.position( $.extend({
  2812. of: this.element
  2813. }, this.options.position ) );
  2814. if ( this.options.autoFocus ) {
  2815. this.menu.next();
  2816. }
  2817. },
  2818. _resizeMenu: function() {
  2819. var ul = this.menu.element;
  2820. ul.outerWidth( Math.max(
  2821. // Firefox wraps long text (possibly a rounding bug)
  2822. // so we add 1px to avoid the wrapping (#7513)
  2823. ul.width( "" ).outerWidth() + 1,
  2824. this.element.outerWidth()
  2825. ) );
  2826. },
  2827. _renderMenu: function( ul, items ) {
  2828. var that = this;
  2829. $.each( items, function( index, item ) {
  2830. that._renderItemData( ul, item );
  2831. });
  2832. },
  2833. _renderItemData: function( ul, item ) {
  2834. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  2835. },
  2836. _renderItem: function( ul, item ) {
  2837. return $( "<li>" ).text( item.label ).appendTo( ul );
  2838. },
  2839. _move: function( direction, event ) {
  2840. if ( !this.menu.element.is( ":visible" ) ) {
  2841. this.search( null, event );
  2842. return;
  2843. }
  2844. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  2845. this.menu.isLastItem() && /^next/.test( direction ) ) {
  2846. if ( !this.isMultiLine ) {
  2847. this._value( this.term );
  2848. }
  2849. this.menu.blur();
  2850. return;
  2851. }
  2852. this.menu[ direction ]( event );
  2853. },
  2854. widget: function() {
  2855. return this.menu.element;
  2856. },
  2857. _value: function() {
  2858. return this.valueMethod.apply( this.element, arguments );
  2859. },
  2860. _keyEvent: function( keyEvent, event ) {
  2861. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2862. this._move( keyEvent, event );
  2863. // prevents moving cursor to beginning/end of the text field in some browsers
  2864. event.preventDefault();
  2865. }
  2866. }
  2867. });
  2868. $.extend( $.ui.autocomplete, {
  2869. escapeRegex: function( value ) {
  2870. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  2871. },
  2872. filter: function( array, term ) {
  2873. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  2874. return $.grep( array, function( value ) {
  2875. return matcher.test( value.label || value.value || value );
  2876. });
  2877. }
  2878. });
  2879. // live region extension, adding a `messages` option
  2880. // NOTE: This is an experimental API. We are still investigating
  2881. // a full solution for string manipulation and internationalization.
  2882. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  2883. options: {
  2884. messages: {
  2885. noResults: "No search results.",
  2886. results: function( amount ) {
  2887. return amount + ( amount > 1 ? " results are" : " result is" ) +
  2888. " available, use up and down arrow keys to navigate.";
  2889. }
  2890. }
  2891. },
  2892. __response: function( content ) {
  2893. var message;
  2894. this._superApply( arguments );
  2895. if ( this.options.disabled || this.cancelSearch ) {
  2896. return;
  2897. }
  2898. if ( content && content.length ) {
  2899. message = this.options.messages.results( content.length );
  2900. } else {
  2901. message = this.options.messages.noResults;
  2902. }
  2903. this.liveRegion.children().hide();
  2904. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  2905. }
  2906. });
  2907. var autocomplete = $.ui.autocomplete;
  2908. /*!
  2909. * jQuery UI Button 1.11.0
  2910. * http://jqueryui.com
  2911. *
  2912. * Copyright 2014 jQuery Foundation and other contributors
  2913. * Released under the MIT license.
  2914. * http://jquery.org/license
  2915. *
  2916. * http://api.jqueryui.com/button/
  2917. */
  2918. var lastActive,
  2919. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  2920. 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",
  2921. formResetHandler = function() {
  2922. var form = $( this );
  2923. setTimeout(function() {
  2924. form.find( ":ui-button" ).button( "refresh" );
  2925. }, 1 );
  2926. },
  2927. radioGroup = function( radio ) {
  2928. var name = radio.name,
  2929. form = radio.form,
  2930. radios = $( [] );
  2931. if ( name ) {
  2932. name = name.replace( /'/g, "\\'" );
  2933. if ( form ) {
  2934. radios = $( form ).find( "[name='" + name + "'][type=radio]" );
  2935. } else {
  2936. radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
  2937. .filter(function() {
  2938. return !this.form;
  2939. });
  2940. }
  2941. }
  2942. return radios;
  2943. };
  2944. $.widget( "ui.button", {
  2945. version: "1.11.0",
  2946. defaultElement: "<button>",
  2947. options: {
  2948. disabled: null,
  2949. text: true,
  2950. label: null,
  2951. icons: {
  2952. primary: null,
  2953. secondary: null
  2954. }
  2955. },
  2956. _create: function() {
  2957. this.element.closest( "form" )
  2958. .unbind( "reset" + this.eventNamespace )
  2959. .bind( "reset" + this.eventNamespace, formResetHandler );
  2960. if ( typeof this.options.disabled !== "boolean" ) {
  2961. this.options.disabled = !!this.element.prop( "disabled" );
  2962. } else {
  2963. this.element.prop( "disabled", this.options.disabled );
  2964. }
  2965. this._determineButtonType();
  2966. this.hasTitle = !!this.buttonElement.attr( "title" );
  2967. var that = this,
  2968. options = this.options,
  2969. toggleButton = this.type === "checkbox" || this.type === "radio",
  2970. activeClass = !toggleButton ? "ui-state-active" : "";
  2971. if ( options.label === null ) {
  2972. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  2973. }
  2974. this._hoverable( this.buttonElement );
  2975. this.buttonElement
  2976. .addClass( baseClasses )
  2977. .attr( "role", "button" )
  2978. .bind( "mouseenter" + this.eventNamespace, function() {
  2979. if ( options.disabled ) {
  2980. return;
  2981. }
  2982. if ( this === lastActive ) {
  2983. $( this ).addClass( "ui-state-active" );
  2984. }
  2985. })
  2986. .bind( "mouseleave" + this.eventNamespace, function() {
  2987. if ( options.disabled ) {
  2988. return;
  2989. }
  2990. $( this ).removeClass( activeClass );
  2991. })
  2992. .bind( "click" + this.eventNamespace, function( event ) {
  2993. if ( options.disabled ) {
  2994. event.preventDefault();
  2995. event.stopImmediatePropagation();
  2996. }
  2997. });
  2998. // Can't use _focusable() because the element that receives focus
  2999. // and the element that gets the ui-state-focus class are different
  3000. this._on({
  3001. focus: function() {
  3002. this.buttonElement.addClass( "ui-state-focus" );
  3003. },
  3004. blur: function() {
  3005. this.buttonElement.removeClass( "ui-state-focus" );
  3006. }
  3007. });
  3008. if ( toggleButton ) {
  3009. this.element.bind( "change" + this.eventNamespace, function() {
  3010. that.refresh();
  3011. });
  3012. }
  3013. if ( this.type === "checkbox" ) {
  3014. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  3015. if ( options.disabled ) {
  3016. return false;
  3017. }
  3018. });
  3019. } else if ( this.type === "radio" ) {
  3020. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  3021. if ( options.disabled ) {
  3022. return false;
  3023. }
  3024. $( this ).addClass( "ui-state-active" );
  3025. that.buttonElement.attr( "aria-pressed", "true" );
  3026. var radio = that.element[ 0 ];
  3027. radioGroup( radio )
  3028. .not( radio )
  3029. .map(function() {
  3030. return $( this ).button( "widget" )[ 0 ];
  3031. })
  3032. .removeClass( "ui-state-active" )
  3033. .attr( "aria-pressed", "false" );
  3034. });
  3035. } else {
  3036. this.buttonElement
  3037. .bind( "mousedown" + this.eventNamespace, function() {
  3038. if ( options.disabled ) {
  3039. return false;
  3040. }
  3041. $( this ).addClass( "ui-state-active" );
  3042. lastActive = this;
  3043. that.document.one( "mouseup", function() {
  3044. lastActive = null;
  3045. });
  3046. })
  3047. .bind( "mouseup" + this.eventNamespace, function() {
  3048. if ( options.disabled ) {
  3049. return false;
  3050. }
  3051. $( this ).removeClass( "ui-state-active" );
  3052. })
  3053. .bind( "keydown" + this.eventNamespace, function(event) {
  3054. if ( options.disabled ) {
  3055. return false;
  3056. }
  3057. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  3058. $( this ).addClass( "ui-state-active" );
  3059. }
  3060. })
  3061. // see #8559, we bind to blur here in case the button element loses
  3062. // focus between keydown and keyup, it would be left in an "active" state
  3063. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  3064. $( this ).removeClass( "ui-state-active" );
  3065. });
  3066. if ( this.buttonElement.is("a") ) {
  3067. this.buttonElement.keyup(function(event) {
  3068. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  3069. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  3070. $( this ).click();
  3071. }
  3072. });
  3073. }
  3074. }
  3075. this._setOption( "disabled", options.disabled );
  3076. this._resetButton();
  3077. },
  3078. _determineButtonType: function() {
  3079. var ancestor, labelSelector, checked;
  3080. if ( this.element.is("[type=checkbox]") ) {
  3081. this.type = "checkbox";
  3082. } else if ( this.element.is("[type=radio]") ) {
  3083. this.type = "radio";
  3084. } else if ( this.element.is("input") ) {
  3085. this.type = "input";
  3086. } else {
  3087. this.type = "button";
  3088. }
  3089. if ( this.type === "checkbox" || this.type === "radio" ) {
  3090. // we don't search against the document in case the element
  3091. // is disconnected from the DOM
  3092. ancestor = this.element.parents().last();
  3093. labelSelector = "label[for='" + this.element.attr("id") + "']";
  3094. this.buttonElement = ancestor.find( labelSelector );
  3095. if ( !this.buttonElement.length ) {
  3096. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  3097. this.buttonElement = ancestor.filter( labelSelector );
  3098. if ( !this.buttonElement.length ) {
  3099. this.buttonElement = ancestor.find( labelSelector );
  3100. }
  3101. }
  3102. this.element.addClass( "ui-helper-hidden-accessible" );
  3103. checked = this.element.is( ":checked" );
  3104. if ( checked ) {
  3105. this.buttonElement.addClass( "ui-state-active" );
  3106. }
  3107. this.buttonElement.prop( "aria-pressed", checked );
  3108. } else {
  3109. this.buttonElement = this.element;
  3110. }
  3111. },
  3112. widget: function() {
  3113. return this.buttonElement;
  3114. },
  3115. _destroy: function() {
  3116. this.element
  3117. .removeClass( "ui-helper-hidden-accessible" );
  3118. this.buttonElement
  3119. .removeClass( baseClasses + " ui-state-active " + typeClasses )
  3120. .removeAttr( "role" )
  3121. .removeAttr( "aria-pressed" )
  3122. .html( this.buttonElement.find(".ui-button-text").html() );
  3123. if ( !this.hasTitle ) {
  3124. this.buttonElement.removeAttr( "title" );
  3125. }
  3126. },
  3127. _setOption: function( key, value ) {
  3128. this._super( key, value );
  3129. if ( key === "disabled" ) {
  3130. this.widget().toggleClass( "ui-state-disabled", !!value );
  3131. this.element.prop( "disabled", !!value );
  3132. if ( value ) {
  3133. if ( this.type === "checkbox" || this.type === "radio" ) {
  3134. this.buttonElement.removeClass( "ui-state-focus" );
  3135. } else {
  3136. this.buttonElement.removeClass( "ui-state-focus ui-state-active" );
  3137. }
  3138. }
  3139. return;
  3140. }
  3141. this._resetButton();
  3142. },
  3143. refresh: function() {
  3144. //See #8237 & #8828
  3145. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  3146. if ( isDisabled !== this.options.disabled ) {
  3147. this._setOption( "disabled", isDisabled );
  3148. }
  3149. if ( this.type === "radio" ) {
  3150. radioGroup( this.element[0] ).each(function() {
  3151. if ( $( this ).is( ":checked" ) ) {
  3152. $( this ).button( "widget" )
  3153. .addClass( "ui-state-active" )
  3154. .attr( "aria-pressed", "true" );
  3155. } else {
  3156. $( this ).button( "widget" )
  3157. .removeClass( "ui-state-active" )
  3158. .attr( "aria-pressed", "false" );
  3159. }
  3160. });
  3161. } else if ( this.type === "checkbox" ) {
  3162. if ( this.element.is( ":checked" ) ) {
  3163. this.buttonElement
  3164. .addClass( "ui-state-active" )
  3165. .attr( "aria-pressed", "true" );
  3166. } else {
  3167. this.buttonElement
  3168. .removeClass( "ui-state-active" )
  3169. .attr( "aria-pressed", "false" );
  3170. }
  3171. }
  3172. },
  3173. _resetButton: function() {
  3174. if ( this.type === "input" ) {
  3175. if ( this.options.label ) {
  3176. this.element.val( this.options.label );
  3177. }
  3178. return;
  3179. }
  3180. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  3181. buttonText = $( "<span></span>", this.document[0] )
  3182. .addClass( "ui-button-text" )
  3183. .html( this.options.label )
  3184. .appendTo( buttonElement.empty() )
  3185. .text(),
  3186. icons = this.options.icons,
  3187. multipleIcons = icons.primary && icons.secondary,
  3188. buttonClasses = [];
  3189. if ( icons.primary || icons.secondary ) {
  3190. if ( this.options.text ) {
  3191. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  3192. }
  3193. if ( icons.primary ) {
  3194. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  3195. }
  3196. if ( icons.secondary ) {
  3197. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  3198. }
  3199. if ( !this.options.text ) {
  3200. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  3201. if ( !this.hasTitle ) {
  3202. buttonElement.attr( "title", $.trim( buttonText ) );
  3203. }
  3204. }
  3205. } else {
  3206. buttonClasses.push( "ui-button-text-only" );
  3207. }
  3208. buttonElement.addClass( buttonClasses.join( " " ) );
  3209. }
  3210. });
  3211. $.widget( "ui.buttonset", {
  3212. version: "1.11.0",
  3213. options: {
  3214. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  3215. },
  3216. _create: function() {
  3217. this.element.addClass( "ui-buttonset" );
  3218. },
  3219. _init: function() {
  3220. this.refresh();
  3221. },
  3222. _setOption: function( key, value ) {
  3223. if ( key === "disabled" ) {
  3224. this.buttons.button( "option", key, value );
  3225. }
  3226. this._super( key, value );
  3227. },
  3228. refresh: function() {
  3229. var rtl = this.element.css( "direction" ) === "rtl",
  3230. allButtons = this.element.find( this.options.items ),
  3231. existingButtons = allButtons.filter( ":ui-button" );
  3232. // Initialize new buttons
  3233. allButtons.not( ":ui-button" ).button();
  3234. // Refresh existing buttons
  3235. existingButtons.button( "refresh" );
  3236. this.buttons = allButtons
  3237. .map(function() {
  3238. return $( this ).button( "widget" )[ 0 ];
  3239. })
  3240. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  3241. .filter( ":first" )
  3242. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  3243. .end()
  3244. .filter( ":last" )
  3245. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  3246. .end()
  3247. .end();
  3248. },
  3249. _destroy: function() {
  3250. this.element.removeClass( "ui-buttonset" );
  3251. this.buttons
  3252. .map(function() {
  3253. return $( this ).button( "widget" )[ 0 ];
  3254. })
  3255. .removeClass( "ui-corner-left ui-corner-right" )
  3256. .end()
  3257. .button( "destroy" );
  3258. }
  3259. });
  3260. var button = $.ui.button;
  3261. /*!
  3262. * jQuery UI Datepicker 1.11.0
  3263. * http://jqueryui.com
  3264. *
  3265. * Copyright 2014 jQuery Foundation and other contributors
  3266. * Released under the MIT license.
  3267. * http://jquery.org/license
  3268. *
  3269. * http://api.jqueryui.com/datepicker/
  3270. */
  3271. $.extend($.ui, { datepicker: { version: "1.11.0" } });
  3272. var datepicker_instActive;
  3273. function datepicker_getZindex( elem ) {
  3274. var position, value;
  3275. while ( elem.length && elem[ 0 ] !== document ) {
  3276. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  3277. // This makes behavior of this function consistent across browsers
  3278. // WebKit always returns auto if the element is positioned
  3279. position = elem.css( "position" );
  3280. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  3281. // IE returns 0 when zIndex is not specified
  3282. // other browsers return a string
  3283. // we ignore the case of nested elements with an explicit value of 0
  3284. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  3285. value = parseInt( elem.css( "zIndex" ), 10 );
  3286. if ( !isNaN( value ) && value !== 0 ) {
  3287. return value;
  3288. }
  3289. }
  3290. elem = elem.parent();
  3291. }
  3292. return 0;
  3293. }
  3294. /* Date picker manager.
  3295. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  3296. Settings for (groups of) date pickers are maintained in an instance object,
  3297. allowing multiple different settings on the same page. */
  3298. function Datepicker() {
  3299. this._curInst = null; // The current instance in use
  3300. this._keyEvent = false; // If the last event was a key event
  3301. this._disabledInputs = []; // List of date picker inputs that have been disabled
  3302. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  3303. this._inDialog = false; // True if showing within a "dialog", false if not
  3304. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  3305. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  3306. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  3307. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  3308. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  3309. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  3310. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  3311. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  3312. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  3313. this.regional = []; // Available regional settings, indexed by language code
  3314. this.regional[""] = { // Default regional settings
  3315. closeText: "Done", // Display text for close link
  3316. prevText: "Prev", // Display text for previous month link
  3317. nextText: "Next", // Display text for next month link
  3318. currentText: "Today", // Display text for current month link
  3319. monthNames: ["January","February","March","April","May","June",
  3320. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  3321. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  3322. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  3323. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  3324. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  3325. weekHeader: "Wk", // Column header for week of the year
  3326. dateFormat: "mm/dd/yy", // See format options on parseDate
  3327. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  3328. isRTL: false, // True if right-to-left language, false if left-to-right
  3329. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  3330. yearSuffix: "" // Additional text to append to the year in the month headers
  3331. };
  3332. this._defaults = { // Global defaults for all the date picker instances
  3333. showOn: "focus", // "focus" for popup on focus,
  3334. // "button" for trigger button, or "both" for either
  3335. showAnim: "fadeIn", // Name of jQuery animation for popup
  3336. showOptions: {}, // Options for enhanced animations
  3337. defaultDate: null, // Used when field is blank: actual date,
  3338. // +/-number for offset from today, null for today
  3339. appendText: "", // Display text following the input box, e.g. showing the format
  3340. buttonText: "...", // Text for trigger button
  3341. buttonImage: "", // URL for trigger button image
  3342. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  3343. hideIfNoPrevNext: false, // True to hide next/previous month links
  3344. // if not applicable, false to just disable them
  3345. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  3346. gotoCurrent: false, // True if today link goes back to current selection instead
  3347. changeMonth: false, // True if month can be selected directly, false if only prev/next
  3348. changeYear: false, // True if year can be selected directly, false if only prev/next
  3349. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  3350. // either relative to today's year (-nn:+nn), relative to currently displayed year
  3351. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  3352. showOtherMonths: false, // True to show dates in other months, false to leave blank
  3353. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  3354. showWeek: false, // True to show week of the year, false to not show it
  3355. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  3356. // takes a Date and returns the number of the week for it
  3357. shortYearCutoff: "+10", // Short year values < this are in the current century,
  3358. // > this are in the previous century,
  3359. // string value starting with "+" for current year + value
  3360. minDate: null, // The earliest selectable date, or null for no limit
  3361. maxDate: null, // The latest selectable date, or null for no limit
  3362. duration: "fast", // Duration of display/closure
  3363. beforeShowDay: null, // Function that takes a date and returns an array with
  3364. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  3365. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  3366. beforeShow: null, // Function that takes an input field and
  3367. // returns a set of custom settings for the date picker
  3368. onSelect: null, // Define a callback function when a date is selected
  3369. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  3370. onClose: null, // Define a callback function when the datepicker is closed
  3371. numberOfMonths: 1, // Number of months to show at a time
  3372. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  3373. stepMonths: 1, // Number of months to step back/forward
  3374. stepBigMonths: 12, // Number of months to step back/forward for the big links
  3375. altField: "", // Selector for an alternate field to store selected dates into
  3376. altFormat: "", // The date format to use for the alternate field
  3377. constrainInput: true, // The input is constrained by the current date format
  3378. showButtonPanel: false, // True to show button panel, false to not show it
  3379. autoSize: false, // True to size the input for the date format, false to leave as is
  3380. disabled: false // The initial disabled state
  3381. };
  3382. $.extend(this._defaults, this.regional[""]);
  3383. this.regional.en = $.extend( true, {}, this.regional[ "" ]);
  3384. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  3385. this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  3386. }
  3387. $.extend(Datepicker.prototype, {
  3388. /* Class name added to elements to indicate already configured with a date picker. */
  3389. markerClassName: "hasDatepicker",
  3390. //Keep track of the maximum number of rows displayed (see #7043)
  3391. maxRows: 4,
  3392. // TODO rename to "widget" when switching to widget factory
  3393. _widgetDatepicker: function() {
  3394. return this.dpDiv;
  3395. },
  3396. /* Override the default settings for all instances of the date picker.
  3397. * @param settings object - the new settings to use as defaults (anonymous object)
  3398. * @return the manager object
  3399. */
  3400. setDefaults: function(settings) {
  3401. datepicker_extendRemove(this._defaults, settings || {});
  3402. return this;
  3403. },
  3404. /* Attach the date picker to a jQuery selection.
  3405. * @param target element - the target input field or division or span
  3406. * @param settings object - the new settings to use for this date picker instance (anonymous)
  3407. */
  3408. _attachDatepicker: function(target, settings) {
  3409. var nodeName, inline, inst;
  3410. nodeName = target.nodeName.toLowerCase();
  3411. inline = (nodeName === "div" || nodeName === "span");
  3412. if (!target.id) {
  3413. this.uuid += 1;
  3414. target.id = "dp" + this.uuid;
  3415. }
  3416. inst = this._newInst($(target), inline);
  3417. inst.settings = $.extend({}, settings || {});
  3418. if (nodeName === "input") {
  3419. this._connectDatepicker(target, inst);
  3420. } else if (inline) {
  3421. this._inlineDatepicker(target, inst);
  3422. }
  3423. },
  3424. /* Create a new instance object. */
  3425. _newInst: function(target, inline) {
  3426. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  3427. return {id: id, input: target, // associated target
  3428. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  3429. drawMonth: 0, drawYear: 0, // month being drawn
  3430. inline: inline, // is datepicker inline or not
  3431. dpDiv: (!inline ? this.dpDiv : // presentation div
  3432. datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  3433. },
  3434. /* Attach the date picker to an input field. */
  3435. _connectDatepicker: function(target, inst) {
  3436. var input = $(target);
  3437. inst.append = $([]);
  3438. inst.trigger = $([]);
  3439. if (input.hasClass(this.markerClassName)) {
  3440. return;
  3441. }
  3442. this._attachments(input, inst);
  3443. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  3444. keypress(this._doKeyPress).keyup(this._doKeyUp);
  3445. this._autoSize(inst);
  3446. $.data(target, "datepicker", inst);
  3447. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  3448. if( inst.settings.disabled ) {
  3449. this._disableDatepicker( target );
  3450. }
  3451. },
  3452. /* Make attachments based on settings. */
  3453. _attachments: function(input, inst) {
  3454. var showOn, buttonText, buttonImage,
  3455. appendText = this._get(inst, "appendText"),
  3456. isRTL = this._get(inst, "isRTL");
  3457. if (inst.append) {
  3458. inst.append.remove();
  3459. }
  3460. if (appendText) {
  3461. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  3462. input[isRTL ? "before" : "after"](inst.append);
  3463. }
  3464. input.unbind("focus", this._showDatepicker);
  3465. if (inst.trigger) {
  3466. inst.trigger.remove();
  3467. }
  3468. showOn = this._get(inst, "showOn");
  3469. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  3470. input.focus(this._showDatepicker);
  3471. }
  3472. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  3473. buttonText = this._get(inst, "buttonText");
  3474. buttonImage = this._get(inst, "buttonImage");
  3475. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  3476. $("<img/>").addClass(this._triggerClass).
  3477. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  3478. $("<button type='button'></button>").addClass(this._triggerClass).
  3479. html(!buttonImage ? buttonText : $("<img/>").attr(
  3480. { src:buttonImage, alt:buttonText, title:buttonText })));
  3481. input[isRTL ? "before" : "after"](inst.trigger);
  3482. inst.trigger.click(function() {
  3483. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  3484. $.datepicker._hideDatepicker();
  3485. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  3486. $.datepicker._hideDatepicker();
  3487. $.datepicker._showDatepicker(input[0]);
  3488. } else {
  3489. $.datepicker._showDatepicker(input[0]);
  3490. }
  3491. return false;
  3492. });
  3493. }
  3494. },
  3495. /* Apply the maximum length for the date format. */
  3496. _autoSize: function(inst) {
  3497. if (this._get(inst, "autoSize") && !inst.inline) {
  3498. var findMax, max, maxI, i,
  3499. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  3500. dateFormat = this._get(inst, "dateFormat");
  3501. if (dateFormat.match(/[DM]/)) {
  3502. findMax = function(names) {
  3503. max = 0;
  3504. maxI = 0;
  3505. for (i = 0; i < names.length; i++) {
  3506. if (names[i].length > max) {
  3507. max = names[i].length;
  3508. maxI = i;
  3509. }
  3510. }
  3511. return maxI;
  3512. };
  3513. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  3514. "monthNames" : "monthNamesShort"))));
  3515. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  3516. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  3517. }
  3518. inst.input.attr("size", this._formatDate(inst, date).length);
  3519. }
  3520. },
  3521. /* Attach an inline date picker to a div. */
  3522. _inlineDatepicker: function(target, inst) {
  3523. var divSpan = $(target);
  3524. if (divSpan.hasClass(this.markerClassName)) {
  3525. return;
  3526. }
  3527. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  3528. $.data(target, "datepicker", inst);
  3529. this._setDate(inst, this._getDefaultDate(inst), true);
  3530. this._updateDatepicker(inst);
  3531. this._updateAlternate(inst);
  3532. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  3533. if( inst.settings.disabled ) {
  3534. this._disableDatepicker( target );
  3535. }
  3536. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  3537. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  3538. inst.dpDiv.css( "display", "block" );
  3539. },
  3540. /* Pop-up the date picker in a "dialog" box.
  3541. * @param input element - ignored
  3542. * @param date string or Date - the initial date to display
  3543. * @param onSelect function - the function to call when a date is selected
  3544. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  3545. * @param pos int[2] - coordinates for the dialog's position within the screen or
  3546. * event - with x/y coordinates or
  3547. * leave empty for default (screen centre)
  3548. * @return the manager object
  3549. */
  3550. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  3551. var id, browserWidth, browserHeight, scrollX, scrollY,
  3552. inst = this._dialogInst; // internal instance
  3553. if (!inst) {
  3554. this.uuid += 1;
  3555. id = "dp" + this.uuid;
  3556. this._dialogInput = $("<input type='text' id='" + id +
  3557. "' style='position: absolute; top: -100px; width: 0px;'/>");
  3558. this._dialogInput.keydown(this._doKeyDown);
  3559. $("body").append(this._dialogInput);
  3560. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  3561. inst.settings = {};
  3562. $.data(this._dialogInput[0], "datepicker", inst);
  3563. }
  3564. datepicker_extendRemove(inst.settings, settings || {});
  3565. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  3566. this._dialogInput.val(date);
  3567. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  3568. if (!this._pos) {
  3569. browserWidth = document.documentElement.clientWidth;
  3570. browserHeight = document.documentElement.clientHeight;
  3571. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  3572. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  3573. this._pos = // should use actual width/height below
  3574. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  3575. }
  3576. // move input on screen for focus, but hidden behind dialog
  3577. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  3578. inst.settings.onSelect = onSelect;
  3579. this._inDialog = true;
  3580. this.dpDiv.addClass(this._dialogClass);
  3581. this._showDatepicker(this._dialogInput[0]);
  3582. if ($.blockUI) {
  3583. $.blockUI(this.dpDiv);
  3584. }
  3585. $.data(this._dialogInput[0], "datepicker", inst);
  3586. return this;
  3587. },
  3588. /* Detach a datepicker from its control.
  3589. * @param target element - the target input field or division or span
  3590. */
  3591. _destroyDatepicker: function(target) {
  3592. var nodeName,
  3593. $target = $(target),
  3594. inst = $.data(target, "datepicker");
  3595. if (!$target.hasClass(this.markerClassName)) {
  3596. return;
  3597. }
  3598. nodeName = target.nodeName.toLowerCase();
  3599. $.removeData(target, "datepicker");
  3600. if (nodeName === "input") {
  3601. inst.append.remove();
  3602. inst.trigger.remove();
  3603. $target.removeClass(this.markerClassName).
  3604. unbind("focus", this._showDatepicker).
  3605. unbind("keydown", this._doKeyDown).
  3606. unbind("keypress", this._doKeyPress).
  3607. unbind("keyup", this._doKeyUp);
  3608. } else if (nodeName === "div" || nodeName === "span") {
  3609. $target.removeClass(this.markerClassName).empty();
  3610. }
  3611. },
  3612. /* Enable the date picker to a jQuery selection.
  3613. * @param target element - the target input field or division or span
  3614. */
  3615. _enableDatepicker: function(target) {
  3616. var nodeName, inline,
  3617. $target = $(target),
  3618. inst = $.data(target, "datepicker");
  3619. if (!$target.hasClass(this.markerClassName)) {
  3620. return;
  3621. }
  3622. nodeName = target.nodeName.toLowerCase();
  3623. if (nodeName === "input") {
  3624. target.disabled = false;
  3625. inst.trigger.filter("button").
  3626. each(function() { this.disabled = false; }).end().
  3627. filter("img").css({opacity: "1.0", cursor: ""});
  3628. } else if (nodeName === "div" || nodeName === "span") {
  3629. inline = $target.children("." + this._inlineClass);
  3630. inline.children().removeClass("ui-state-disabled");
  3631. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3632. prop("disabled", false);
  3633. }
  3634. this._disabledInputs = $.map(this._disabledInputs,
  3635. function(value) { return (value === target ? null : value); }); // delete entry
  3636. },
  3637. /* Disable the date picker to a jQuery selection.
  3638. * @param target element - the target input field or division or span
  3639. */
  3640. _disableDatepicker: function(target) {
  3641. var nodeName, inline,
  3642. $target = $(target),
  3643. inst = $.data(target, "datepicker");
  3644. if (!$target.hasClass(this.markerClassName)) {
  3645. return;
  3646. }
  3647. nodeName = target.nodeName.toLowerCase();
  3648. if (nodeName === "input") {
  3649. target.disabled = true;
  3650. inst.trigger.filter("button").
  3651. each(function() { this.disabled = true; }).end().
  3652. filter("img").css({opacity: "0.5", cursor: "default"});
  3653. } else if (nodeName === "div" || nodeName === "span") {
  3654. inline = $target.children("." + this._inlineClass);
  3655. inline.children().addClass("ui-state-disabled");
  3656. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3657. prop("disabled", true);
  3658. }
  3659. this._disabledInputs = $.map(this._disabledInputs,
  3660. function(value) { return (value === target ? null : value); }); // delete entry
  3661. this._disabledInputs[this._disabledInputs.length] = target;
  3662. },
  3663. /* Is the first field in a jQuery collection disabled as a datepicker?
  3664. * @param target element - the target input field or division or span
  3665. * @return boolean - true if disabled, false if enabled
  3666. */
  3667. _isDisabledDatepicker: function(target) {
  3668. if (!target) {
  3669. return false;
  3670. }
  3671. for (var i = 0; i < this._disabledInputs.length; i++) {
  3672. if (this._disabledInputs[i] === target) {
  3673. return true;
  3674. }
  3675. }
  3676. return false;
  3677. },
  3678. /* Retrieve the instance data for the target control.
  3679. * @param target element - the target input field or division or span
  3680. * @return object - the associated instance data
  3681. * @throws error if a jQuery problem getting data
  3682. */
  3683. _getInst: function(target) {
  3684. try {
  3685. return $.data(target, "datepicker");
  3686. }
  3687. catch (err) {
  3688. throw "Missing instance data for this datepicker";
  3689. }
  3690. },
  3691. /* Update or retrieve the settings for a date picker attached to an input field or division.
  3692. * @param target element - the target input field or division or span
  3693. * @param name object - the new settings to update or
  3694. * string - the name of the setting to change or retrieve,
  3695. * when retrieving also "all" for all instance settings or
  3696. * "defaults" for all global defaults
  3697. * @param value any - the new value for the setting
  3698. * (omit if above is an object or to retrieve a value)
  3699. */
  3700. _optionDatepicker: function(target, name, value) {
  3701. var settings, date, minDate, maxDate,
  3702. inst = this._getInst(target);
  3703. if (arguments.length === 2 && typeof name === "string") {
  3704. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  3705. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  3706. this._get(inst, name)) : null));
  3707. }
  3708. settings = name || {};
  3709. if (typeof name === "string") {
  3710. settings = {};
  3711. settings[name] = value;
  3712. }
  3713. if (inst) {
  3714. if (this._curInst === inst) {
  3715. this._hideDatepicker();
  3716. }
  3717. date = this._getDateDatepicker(target, true);
  3718. minDate = this._getMinMaxDate(inst, "min");
  3719. maxDate = this._getMinMaxDate(inst, "max");
  3720. datepicker_extendRemove(inst.settings, settings);
  3721. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  3722. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  3723. inst.settings.minDate = this._formatDate(inst, minDate);
  3724. }
  3725. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  3726. inst.settings.maxDate = this._formatDate(inst, maxDate);
  3727. }
  3728. if ( "disabled" in settings ) {
  3729. if ( settings.disabled ) {
  3730. this._disableDatepicker(target);
  3731. } else {
  3732. this._enableDatepicker(target);
  3733. }
  3734. }
  3735. this._attachments($(target), inst);
  3736. this._autoSize(inst);
  3737. this._setDate(inst, date);
  3738. this._updateAlternate(inst);
  3739. this._updateDatepicker(inst);
  3740. }
  3741. },
  3742. // change method deprecated
  3743. _changeDatepicker: function(target, name, value) {
  3744. this._optionDatepicker(target, name, value);
  3745. },
  3746. /* Redraw the date picker attached to an input field or division.
  3747. * @param target element - the target input field or division or span
  3748. */
  3749. _refreshDatepicker: function(target) {
  3750. var inst = this._getInst(target);
  3751. if (inst) {
  3752. this._updateDatepicker(inst);
  3753. }
  3754. },
  3755. /* Set the dates for a jQuery selection.
  3756. * @param target element - the target input field or division or span
  3757. * @param date Date - the new date
  3758. */
  3759. _setDateDatepicker: function(target, date) {
  3760. var inst = this._getInst(target);
  3761. if (inst) {
  3762. this._setDate(inst, date);
  3763. this._updateDatepicker(inst);
  3764. this._updateAlternate(inst);
  3765. }
  3766. },
  3767. /* Get the date(s) for the first entry in a jQuery selection.
  3768. * @param target element - the target input field or division or span
  3769. * @param noDefault boolean - true if no default date is to be used
  3770. * @return Date - the current date
  3771. */
  3772. _getDateDatepicker: function(target, noDefault) {
  3773. var inst = this._getInst(target);
  3774. if (inst && !inst.inline) {
  3775. this._setDateFromField(inst, noDefault);
  3776. }
  3777. return (inst ? this._getDate(inst) : null);
  3778. },
  3779. /* Handle keystrokes. */
  3780. _doKeyDown: function(event) {
  3781. var onSelect, dateStr, sel,
  3782. inst = $.datepicker._getInst(event.target),
  3783. handled = true,
  3784. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  3785. inst._keyEvent = true;
  3786. if ($.datepicker._datepickerShowing) {
  3787. switch (event.keyCode) {
  3788. case 9: $.datepicker._hideDatepicker();
  3789. handled = false;
  3790. break; // hide on tab out
  3791. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  3792. $.datepicker._currentClass + ")", inst.dpDiv);
  3793. if (sel[0]) {
  3794. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  3795. }
  3796. onSelect = $.datepicker._get(inst, "onSelect");
  3797. if (onSelect) {
  3798. dateStr = $.datepicker._formatDate(inst);
  3799. // trigger custom callback
  3800. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  3801. } else {
  3802. $.datepicker._hideDatepicker();
  3803. }
  3804. return false; // don't submit the form
  3805. case 27: $.datepicker._hideDatepicker();
  3806. break; // hide on escape
  3807. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3808. -$.datepicker._get(inst, "stepBigMonths") :
  3809. -$.datepicker._get(inst, "stepMonths")), "M");
  3810. break; // previous month/year on page up/+ ctrl
  3811. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3812. +$.datepicker._get(inst, "stepBigMonths") :
  3813. +$.datepicker._get(inst, "stepMonths")), "M");
  3814. break; // next month/year on page down/+ ctrl
  3815. case 35: if (event.ctrlKey || event.metaKey) {
  3816. $.datepicker._clearDate(event.target);
  3817. }
  3818. handled = event.ctrlKey || event.metaKey;
  3819. break; // clear on ctrl or command +end
  3820. case 36: if (event.ctrlKey || event.metaKey) {
  3821. $.datepicker._gotoToday(event.target);
  3822. }
  3823. handled = event.ctrlKey || event.metaKey;
  3824. break; // current on ctrl or command +home
  3825. case 37: if (event.ctrlKey || event.metaKey) {
  3826. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  3827. }
  3828. handled = event.ctrlKey || event.metaKey;
  3829. // -1 day on ctrl or command +left
  3830. if (event.originalEvent.altKey) {
  3831. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3832. -$.datepicker._get(inst, "stepBigMonths") :
  3833. -$.datepicker._get(inst, "stepMonths")), "M");
  3834. }
  3835. // next month/year on alt +left on Mac
  3836. break;
  3837. case 38: if (event.ctrlKey || event.metaKey) {
  3838. $.datepicker._adjustDate(event.target, -7, "D");
  3839. }
  3840. handled = event.ctrlKey || event.metaKey;
  3841. break; // -1 week on ctrl or command +up
  3842. case 39: if (event.ctrlKey || event.metaKey) {
  3843. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  3844. }
  3845. handled = event.ctrlKey || event.metaKey;
  3846. // +1 day on ctrl or command +right
  3847. if (event.originalEvent.altKey) {
  3848. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3849. +$.datepicker._get(inst, "stepBigMonths") :
  3850. +$.datepicker._get(inst, "stepMonths")), "M");
  3851. }
  3852. // next month/year on alt +right
  3853. break;
  3854. case 40: if (event.ctrlKey || event.metaKey) {
  3855. $.datepicker._adjustDate(event.target, +7, "D");
  3856. }
  3857. handled = event.ctrlKey || event.metaKey;
  3858. break; // +1 week on ctrl or command +down
  3859. default: handled = false;
  3860. }
  3861. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  3862. $.datepicker._showDatepicker(this);
  3863. } else {
  3864. handled = false;
  3865. }
  3866. if (handled) {
  3867. event.preventDefault();
  3868. event.stopPropagation();
  3869. }
  3870. },
  3871. /* Filter entered characters - based on date format. */
  3872. _doKeyPress: function(event) {
  3873. var chars, chr,
  3874. inst = $.datepicker._getInst(event.target);
  3875. if ($.datepicker._get(inst, "constrainInput")) {
  3876. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  3877. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  3878. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  3879. }
  3880. },
  3881. /* Synchronise manual entry and field/alternate field. */
  3882. _doKeyUp: function(event) {
  3883. var date,
  3884. inst = $.datepicker._getInst(event.target);
  3885. if (inst.input.val() !== inst.lastVal) {
  3886. try {
  3887. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  3888. (inst.input ? inst.input.val() : null),
  3889. $.datepicker._getFormatConfig(inst));
  3890. if (date) { // only if valid
  3891. $.datepicker._setDateFromField(inst);
  3892. $.datepicker._updateAlternate(inst);
  3893. $.datepicker._updateDatepicker(inst);
  3894. }
  3895. }
  3896. catch (err) {
  3897. }
  3898. }
  3899. return true;
  3900. },
  3901. /* Pop-up the date picker for a given input field.
  3902. * If false returned from beforeShow event handler do not show.
  3903. * @param input element - the input field attached to the date picker or
  3904. * event - if triggered by focus
  3905. */
  3906. _showDatepicker: function(input) {
  3907. input = input.target || input;
  3908. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  3909. input = $("input", input.parentNode)[0];
  3910. }
  3911. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  3912. return;
  3913. }
  3914. var inst, beforeShow, beforeShowSettings, isFixed,
  3915. offset, showAnim, duration;
  3916. inst = $.datepicker._getInst(input);
  3917. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  3918. $.datepicker._curInst.dpDiv.stop(true, true);
  3919. if ( inst && $.datepicker._datepickerShowing ) {
  3920. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  3921. }
  3922. }
  3923. beforeShow = $.datepicker._get(inst, "beforeShow");
  3924. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  3925. if(beforeShowSettings === false){
  3926. return;
  3927. }
  3928. datepicker_extendRemove(inst.settings, beforeShowSettings);
  3929. inst.lastVal = null;
  3930. $.datepicker._lastInput = input;
  3931. $.datepicker._setDateFromField(inst);
  3932. if ($.datepicker._inDialog) { // hide cursor
  3933. input.value = "";
  3934. }
  3935. if (!$.datepicker._pos) { // position below input
  3936. $.datepicker._pos = $.datepicker._findPos(input);
  3937. $.datepicker._pos[1] += input.offsetHeight; // add the height
  3938. }
  3939. isFixed = false;
  3940. $(input).parents().each(function() {
  3941. isFixed |= $(this).css("position") === "fixed";
  3942. return !isFixed;
  3943. });
  3944. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  3945. $.datepicker._pos = null;
  3946. //to avoid flashes on Firefox
  3947. inst.dpDiv.empty();
  3948. // determine sizing offscreen
  3949. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  3950. $.datepicker._updateDatepicker(inst);
  3951. // fix width for dynamic number of date pickers
  3952. // and adjust position before showing
  3953. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  3954. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  3955. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  3956. left: offset.left + "px", top: offset.top + "px"});
  3957. if (!inst.inline) {
  3958. showAnim = $.datepicker._get(inst, "showAnim");
  3959. duration = $.datepicker._get(inst, "duration");
  3960. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  3961. $.datepicker._datepickerShowing = true;
  3962. if ( $.effects && $.effects.effect[ showAnim ] ) {
  3963. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  3964. } else {
  3965. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  3966. }
  3967. if ( $.datepicker._shouldFocusInput( inst ) ) {
  3968. inst.input.focus();
  3969. }
  3970. $.datepicker._curInst = inst;
  3971. }
  3972. },
  3973. /* Generate the date picker content. */
  3974. _updateDatepicker: function(inst) {
  3975. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  3976. datepicker_instActive = inst; // for delegate hover events
  3977. inst.dpDiv.empty().append(this._generateHTML(inst));
  3978. this._attachHandlers(inst);
  3979. inst.dpDiv.find("." + this._dayOverClass + " a");
  3980. var origyearshtml,
  3981. numMonths = this._getNumberOfMonths(inst),
  3982. cols = numMonths[1],
  3983. width = 17;
  3984. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  3985. if (cols > 1) {
  3986. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  3987. }
  3988. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  3989. "Class"]("ui-datepicker-multi");
  3990. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  3991. "Class"]("ui-datepicker-rtl");
  3992. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  3993. inst.input.focus();
  3994. }
  3995. // deffered render of the years select (to avoid flashes on Firefox)
  3996. if( inst.yearshtml ){
  3997. origyearshtml = inst.yearshtml;
  3998. setTimeout(function(){
  3999. //assure that inst.yearshtml didn't change.
  4000. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  4001. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  4002. }
  4003. origyearshtml = inst.yearshtml = null;
  4004. }, 0);
  4005. }
  4006. },
  4007. // #6694 - don't focus the input if it's already focused
  4008. // this breaks the change event in IE
  4009. // Support: IE and jQuery <1.9
  4010. _shouldFocusInput: function( inst ) {
  4011. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  4012. },
  4013. /* Check positioning to remain on screen. */
  4014. _checkOffset: function(inst, offset, isFixed) {
  4015. var dpWidth = inst.dpDiv.outerWidth(),
  4016. dpHeight = inst.dpDiv.outerHeight(),
  4017. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  4018. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  4019. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  4020. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  4021. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  4022. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  4023. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  4024. // now check if datepicker is showing outside window viewport - move to a better place if so.
  4025. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  4026. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  4027. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  4028. Math.abs(dpHeight + inputHeight) : 0);
  4029. return offset;
  4030. },
  4031. /* Find an object's position on the screen. */
  4032. _findPos: function(obj) {
  4033. var position,
  4034. inst = this._getInst(obj),
  4035. isRTL = this._get(inst, "isRTL");
  4036. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  4037. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  4038. }
  4039. position = $(obj).offset();
  4040. return [position.left, position.top];
  4041. },
  4042. /* Hide the date picker from view.
  4043. * @param input element - the input field attached to the date picker
  4044. */
  4045. _hideDatepicker: function(input) {
  4046. var showAnim, duration, postProcess, onClose,
  4047. inst = this._curInst;
  4048. if (!inst || (input && inst !== $.data(input, "datepicker"))) {
  4049. return;
  4050. }
  4051. if (this._datepickerShowing) {
  4052. showAnim = this._get(inst, "showAnim");
  4053. duration = this._get(inst, "duration");
  4054. postProcess = function() {
  4055. $.datepicker._tidyDialog(inst);
  4056. };
  4057. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  4058. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  4059. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  4060. } else {
  4061. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  4062. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  4063. }
  4064. if (!showAnim) {
  4065. postProcess();
  4066. }
  4067. this._datepickerShowing = false;
  4068. onClose = this._get(inst, "onClose");
  4069. if (onClose) {
  4070. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  4071. }
  4072. this._lastInput = null;
  4073. if (this._inDialog) {
  4074. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  4075. if ($.blockUI) {
  4076. $.unblockUI();
  4077. $("body").append(this.dpDiv);
  4078. }
  4079. }
  4080. this._inDialog = false;
  4081. }
  4082. },
  4083. /* Tidy up after a dialog display. */
  4084. _tidyDialog: function(inst) {
  4085. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  4086. },
  4087. /* Close date picker if clicked elsewhere. */
  4088. _checkExternalClick: function(event) {
  4089. if (!$.datepicker._curInst) {
  4090. return;
  4091. }
  4092. var $target = $(event.target),
  4093. inst = $.datepicker._getInst($target[0]);
  4094. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  4095. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  4096. !$target.hasClass($.datepicker.markerClassName) &&
  4097. !$target.closest("." + $.datepicker._triggerClass).length &&
  4098. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  4099. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  4100. $.datepicker._hideDatepicker();
  4101. }
  4102. },
  4103. /* Adjust one of the date sub-fields. */
  4104. _adjustDate: function(id, offset, period) {
  4105. var target = $(id),
  4106. inst = this._getInst(target[0]);
  4107. if (this._isDisabledDatepicker(target[0])) {
  4108. return;
  4109. }
  4110. this._adjustInstDate(inst, offset +
  4111. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  4112. period);
  4113. this._updateDatepicker(inst);
  4114. },
  4115. /* Action for current link. */
  4116. _gotoToday: function(id) {
  4117. var date,
  4118. target = $(id),
  4119. inst = this._getInst(target[0]);
  4120. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  4121. inst.selectedDay = inst.currentDay;
  4122. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  4123. inst.drawYear = inst.selectedYear = inst.currentYear;
  4124. } else {
  4125. date = new Date();
  4126. inst.selectedDay = date.getDate();
  4127. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4128. inst.drawYear = inst.selectedYear = date.getFullYear();
  4129. }
  4130. this._notifyChange(inst);
  4131. this._adjustDate(target);
  4132. },
  4133. /* Action for selecting a new month/year. */
  4134. _selectMonthYear: function(id, select, period) {
  4135. var target = $(id),
  4136. inst = this._getInst(target[0]);
  4137. inst["selected" + (period === "M" ? "Month" : "Year")] =
  4138. inst["draw" + (period === "M" ? "Month" : "Year")] =
  4139. parseInt(select.options[select.selectedIndex].value,10);
  4140. this._notifyChange(inst);
  4141. this._adjustDate(target);
  4142. },
  4143. /* Action for selecting a day. */
  4144. _selectDay: function(id, month, year, td) {
  4145. var inst,
  4146. target = $(id);
  4147. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  4148. return;
  4149. }
  4150. inst = this._getInst(target[0]);
  4151. inst.selectedDay = inst.currentDay = $("a", td).html();
  4152. inst.selectedMonth = inst.currentMonth = month;
  4153. inst.selectedYear = inst.currentYear = year;
  4154. this._selectDate(id, this._formatDate(inst,
  4155. inst.currentDay, inst.currentMonth, inst.currentYear));
  4156. },
  4157. /* Erase the input field and hide the date picker. */
  4158. _clearDate: function(id) {
  4159. var target = $(id);
  4160. this._selectDate(target, "");
  4161. },
  4162. /* Update the input field with the selected date. */
  4163. _selectDate: function(id, dateStr) {
  4164. var onSelect,
  4165. target = $(id),
  4166. inst = this._getInst(target[0]);
  4167. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  4168. if (inst.input) {
  4169. inst.input.val(dateStr);
  4170. }
  4171. this._updateAlternate(inst);
  4172. onSelect = this._get(inst, "onSelect");
  4173. if (onSelect) {
  4174. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  4175. } else if (inst.input) {
  4176. inst.input.trigger("change"); // fire the change event
  4177. }
  4178. if (inst.inline){
  4179. this._updateDatepicker(inst);
  4180. } else {
  4181. this._hideDatepicker();
  4182. this._lastInput = inst.input[0];
  4183. if (typeof(inst.input[0]) !== "object") {
  4184. inst.input.focus(); // restore focus
  4185. }
  4186. this._lastInput = null;
  4187. }
  4188. },
  4189. /* Update any alternate field to synchronise with the main field. */
  4190. _updateAlternate: function(inst) {
  4191. var altFormat, date, dateStr,
  4192. altField = this._get(inst, "altField");
  4193. if (altField) { // update alternate field too
  4194. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  4195. date = this._getDate(inst);
  4196. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  4197. $(altField).each(function() { $(this).val(dateStr); });
  4198. }
  4199. },
  4200. /* Set as beforeShowDay function to prevent selection of weekends.
  4201. * @param date Date - the date to customise
  4202. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  4203. */
  4204. noWeekends: function(date) {
  4205. var day = date.getDay();
  4206. return [(day > 0 && day < 6), ""];
  4207. },
  4208. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  4209. * @param date Date - the date to get the week for
  4210. * @return number - the number of the week within the year that contains this date
  4211. */
  4212. iso8601Week: function(date) {
  4213. var time,
  4214. checkDate = new Date(date.getTime());
  4215. // Find Thursday of this week starting on Monday
  4216. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  4217. time = checkDate.getTime();
  4218. checkDate.setMonth(0); // Compare with Jan 1
  4219. checkDate.setDate(1);
  4220. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  4221. },
  4222. /* Parse a string value into a date object.
  4223. * See formatDate below for the possible formats.
  4224. *
  4225. * @param format string - the expected format of the date
  4226. * @param value string - the date in the above format
  4227. * @param settings Object - attributes include:
  4228. * shortYearCutoff number - the cutoff year for determining the century (optional)
  4229. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  4230. * dayNames string[7] - names of the days from Sunday (optional)
  4231. * monthNamesShort string[12] - abbreviated names of the months (optional)
  4232. * monthNames string[12] - names of the months (optional)
  4233. * @return Date - the extracted date value or null if value is blank
  4234. */
  4235. parseDate: function (format, value, settings) {
  4236. if (format == null || value == null) {
  4237. throw "Invalid arguments";
  4238. }
  4239. value = (typeof value === "object" ? value.toString() : value + "");
  4240. if (value === "") {
  4241. return null;
  4242. }
  4243. var iFormat, dim, extra,
  4244. iValue = 0,
  4245. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  4246. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  4247. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  4248. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  4249. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  4250. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  4251. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  4252. year = -1,
  4253. month = -1,
  4254. day = -1,
  4255. doy = -1,
  4256. literal = false,
  4257. date,
  4258. // Check whether a format character is doubled
  4259. lookAhead = function(match) {
  4260. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  4261. if (matches) {
  4262. iFormat++;
  4263. }
  4264. return matches;
  4265. },
  4266. // Extract a number from the string value
  4267. getNumber = function(match) {
  4268. var isDoubled = lookAhead(match),
  4269. size = (match === "@" ? 14 : (match === "!" ? 20 :
  4270. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  4271. digits = new RegExp("^\\d{1," + size + "}"),
  4272. num = value.substring(iValue).match(digits);
  4273. if (!num) {
  4274. throw "Missing number at position " + iValue;
  4275. }
  4276. iValue += num[0].length;
  4277. return parseInt(num[0], 10);
  4278. },
  4279. // Extract a name from the string value and convert to an index
  4280. getName = function(match, shortNames, longNames) {
  4281. var index = -1,
  4282. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  4283. return [ [k, v] ];
  4284. }).sort(function (a, b) {
  4285. return -(a[1].length - b[1].length);
  4286. });
  4287. $.each(names, function (i, pair) {
  4288. var name = pair[1];
  4289. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  4290. index = pair[0];
  4291. iValue += name.length;
  4292. return false;
  4293. }
  4294. });
  4295. if (index !== -1) {
  4296. return index + 1;
  4297. } else {
  4298. throw "Unknown name at position " + iValue;
  4299. }
  4300. },
  4301. // Confirm that a literal character matches the string value
  4302. checkLiteral = function() {
  4303. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  4304. throw "Unexpected literal at position " + iValue;
  4305. }
  4306. iValue++;
  4307. };
  4308. for (iFormat = 0; iFormat < format.length; iFormat++) {
  4309. if (literal) {
  4310. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  4311. literal = false;
  4312. } else {
  4313. checkLiteral();
  4314. }
  4315. } else {
  4316. switch (format.charAt(iFormat)) {
  4317. case "d":
  4318. day = getNumber("d");
  4319. break;
  4320. case "D":
  4321. getName("D", dayNamesShort, dayNames);
  4322. break;
  4323. case "o":
  4324. doy = getNumber("o");
  4325. break;
  4326. case "m":
  4327. month = getNumber("m");
  4328. break;
  4329. case "M":
  4330. month = getName("M", monthNamesShort, monthNames);
  4331. break;
  4332. case "y":
  4333. year = getNumber("y");
  4334. break;
  4335. case "@":
  4336. date = new Date(getNumber("@"));
  4337. year = date.getFullYear();
  4338. month = date.getMonth() + 1;
  4339. day = date.getDate();
  4340. break;
  4341. case "!":
  4342. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  4343. year = date.getFullYear();
  4344. month = date.getMonth() + 1;
  4345. day = date.getDate();
  4346. break;
  4347. case "'":
  4348. if (lookAhead("'")){
  4349. checkLiteral();
  4350. } else {
  4351. literal = true;
  4352. }
  4353. break;
  4354. default:
  4355. checkLiteral();
  4356. }
  4357. }
  4358. }
  4359. if (iValue < value.length){
  4360. extra = value.substr(iValue);
  4361. if (!/^\s+/.test(extra)) {
  4362. throw "Extra/unparsed characters found in date: " + extra;
  4363. }
  4364. }
  4365. if (year === -1) {
  4366. year = new Date().getFullYear();
  4367. } else if (year < 100) {
  4368. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  4369. (year <= shortYearCutoff ? 0 : -100);
  4370. }
  4371. if (doy > -1) {
  4372. month = 1;
  4373. day = doy;
  4374. do {
  4375. dim = this._getDaysInMonth(year, month - 1);
  4376. if (day <= dim) {
  4377. break;
  4378. }
  4379. month++;
  4380. day -= dim;
  4381. } while (true);
  4382. }
  4383. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  4384. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  4385. throw "Invalid date"; // E.g. 31/02/00
  4386. }
  4387. return date;
  4388. },
  4389. /* Standard date formats. */
  4390. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  4391. COOKIE: "D, dd M yy",
  4392. ISO_8601: "yy-mm-dd",
  4393. RFC_822: "D, d M y",
  4394. RFC_850: "DD, dd-M-y",
  4395. RFC_1036: "D, d M y",
  4396. RFC_1123: "D, d M yy",
  4397. RFC_2822: "D, d M yy",
  4398. RSS: "D, d M y", // RFC 822
  4399. TICKS: "!",
  4400. TIMESTAMP: "@",
  4401. W3C: "yy-mm-dd", // ISO 8601
  4402. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  4403. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  4404. /* Format a date object into a string value.
  4405. * The format can be combinations of the following:
  4406. * d - day of month (no leading zero)
  4407. * dd - day of month (two digit)
  4408. * o - day of year (no leading zeros)
  4409. * oo - day of year (three digit)
  4410. * D - day name short
  4411. * DD - day name long
  4412. * m - month of year (no leading zero)
  4413. * mm - month of year (two digit)
  4414. * M - month name short
  4415. * MM - month name long
  4416. * y - year (two digit)
  4417. * yy - year (four digit)
  4418. * @ - Unix timestamp (ms since 01/01/1970)
  4419. * ! - Windows ticks (100ns since 01/01/0001)
  4420. * "..." - literal text
  4421. * '' - single quote
  4422. *
  4423. * @param format string - the desired format of the date
  4424. * @param date Date - the date value to format
  4425. * @param settings Object - attributes include:
  4426. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  4427. * dayNames string[7] - names of the days from Sunday (optional)
  4428. * monthNamesShort string[12] - abbreviated names of the months (optional)
  4429. * monthNames string[12] - names of the months (optional)
  4430. * @return string - the date in the above format
  4431. */
  4432. formatDate: function (format, date, settings) {
  4433. if (!date) {
  4434. return "";
  4435. }
  4436. var iFormat,
  4437. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  4438. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  4439. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  4440. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  4441. // Check whether a format character is doubled
  4442. lookAhead = function(match) {
  4443. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  4444. if (matches) {
  4445. iFormat++;
  4446. }
  4447. return matches;
  4448. },
  4449. // Format a number, with leading zero if necessary
  4450. formatNumber = function(match, value, len) {
  4451. var num = "" + value;
  4452. if (lookAhead(match)) {
  4453. while (num.length < len) {
  4454. num = "0" + num;
  4455. }
  4456. }
  4457. return num;
  4458. },
  4459. // Format a name, short or long as requested
  4460. formatName = function(match, value, shortNames, longNames) {
  4461. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  4462. },
  4463. output = "",
  4464. literal = false;
  4465. if (date) {
  4466. for (iFormat = 0; iFormat < format.length; iFormat++) {
  4467. if (literal) {
  4468. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  4469. literal = false;
  4470. } else {
  4471. output += format.charAt(iFormat);
  4472. }
  4473. } else {
  4474. switch (format.charAt(iFormat)) {
  4475. case "d":
  4476. output += formatNumber("d", date.getDate(), 2);
  4477. break;
  4478. case "D":
  4479. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  4480. break;
  4481. case "o":
  4482. output += formatNumber("o",
  4483. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  4484. break;
  4485. case "m":
  4486. output += formatNumber("m", date.getMonth() + 1, 2);
  4487. break;
  4488. case "M":
  4489. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  4490. break;
  4491. case "y":
  4492. output += (lookAhead("y") ? date.getFullYear() :
  4493. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  4494. break;
  4495. case "@":
  4496. output += date.getTime();
  4497. break;
  4498. case "!":
  4499. output += date.getTime() * 10000 + this._ticksTo1970;
  4500. break;
  4501. case "'":
  4502. if (lookAhead("'")) {
  4503. output += "'";
  4504. } else {
  4505. literal = true;
  4506. }
  4507. break;
  4508. default:
  4509. output += format.charAt(iFormat);
  4510. }
  4511. }
  4512. }
  4513. }
  4514. return output;
  4515. },
  4516. /* Extract all possible characters from the date format. */
  4517. _possibleChars: function (format) {
  4518. var iFormat,
  4519. chars = "",
  4520. literal = false,
  4521. // Check whether a format character is doubled
  4522. lookAhead = function(match) {
  4523. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  4524. if (matches) {
  4525. iFormat++;
  4526. }
  4527. return matches;
  4528. };
  4529. for (iFormat = 0; iFormat < format.length; iFormat++) {
  4530. if (literal) {
  4531. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  4532. literal = false;
  4533. } else {
  4534. chars += format.charAt(iFormat);
  4535. }
  4536. } else {
  4537. switch (format.charAt(iFormat)) {
  4538. case "d": case "m": case "y": case "@":
  4539. chars += "0123456789";
  4540. break;
  4541. case "D": case "M":
  4542. return null; // Accept anything
  4543. case "'":
  4544. if (lookAhead("'")) {
  4545. chars += "'";
  4546. } else {
  4547. literal = true;
  4548. }
  4549. break;
  4550. default:
  4551. chars += format.charAt(iFormat);
  4552. }
  4553. }
  4554. }
  4555. return chars;
  4556. },
  4557. /* Get a setting value, defaulting if necessary. */
  4558. _get: function(inst, name) {
  4559. return inst.settings[name] !== undefined ?
  4560. inst.settings[name] : this._defaults[name];
  4561. },
  4562. /* Parse existing date and initialise date picker. */
  4563. _setDateFromField: function(inst, noDefault) {
  4564. if (inst.input.val() === inst.lastVal) {
  4565. return;
  4566. }
  4567. var dateFormat = this._get(inst, "dateFormat"),
  4568. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  4569. defaultDate = this._getDefaultDate(inst),
  4570. date = defaultDate,
  4571. settings = this._getFormatConfig(inst);
  4572. try {
  4573. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  4574. } catch (event) {
  4575. dates = (noDefault ? "" : dates);
  4576. }
  4577. inst.selectedDay = date.getDate();
  4578. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4579. inst.drawYear = inst.selectedYear = date.getFullYear();
  4580. inst.currentDay = (dates ? date.getDate() : 0);
  4581. inst.currentMonth = (dates ? date.getMonth() : 0);
  4582. inst.currentYear = (dates ? date.getFullYear() : 0);
  4583. this._adjustInstDate(inst);
  4584. },
  4585. /* Retrieve the default date shown on opening. */
  4586. _getDefaultDate: function(inst) {
  4587. return this._restrictMinMax(inst,
  4588. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  4589. },
  4590. /* A date may be specified as an exact value or a relative one. */
  4591. _determineDate: function(inst, date, defaultDate) {
  4592. var offsetNumeric = function(offset) {
  4593. var date = new Date();
  4594. date.setDate(date.getDate() + offset);
  4595. return date;
  4596. },
  4597. offsetString = function(offset) {
  4598. try {
  4599. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  4600. offset, $.datepicker._getFormatConfig(inst));
  4601. }
  4602. catch (e) {
  4603. // Ignore
  4604. }
  4605. var date = (offset.toLowerCase().match(/^c/) ?
  4606. $.datepicker._getDate(inst) : null) || new Date(),
  4607. year = date.getFullYear(),
  4608. month = date.getMonth(),
  4609. day = date.getDate(),
  4610. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  4611. matches = pattern.exec(offset);
  4612. while (matches) {
  4613. switch (matches[2] || "d") {
  4614. case "d" : case "D" :
  4615. day += parseInt(matches[1],10); break;
  4616. case "w" : case "W" :
  4617. day += parseInt(matches[1],10) * 7; break;
  4618. case "m" : case "M" :
  4619. month += parseInt(matches[1],10);
  4620. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  4621. break;
  4622. case "y": case "Y" :
  4623. year += parseInt(matches[1],10);
  4624. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  4625. break;
  4626. }
  4627. matches = pattern.exec(offset);
  4628. }
  4629. return new Date(year, month, day);
  4630. },
  4631. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  4632. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  4633. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  4634. if (newDate) {
  4635. newDate.setHours(0);
  4636. newDate.setMinutes(0);
  4637. newDate.setSeconds(0);
  4638. newDate.setMilliseconds(0);
  4639. }
  4640. return this._daylightSavingAdjust(newDate);
  4641. },
  4642. /* Handle switch to/from daylight saving.
  4643. * Hours may be non-zero on daylight saving cut-over:
  4644. * > 12 when midnight changeover, but then cannot generate
  4645. * midnight datetime, so jump to 1AM, otherwise reset.
  4646. * @param date (Date) the date to check
  4647. * @return (Date) the corrected date
  4648. */
  4649. _daylightSavingAdjust: function(date) {
  4650. if (!date) {
  4651. return null;
  4652. }
  4653. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  4654. return date;
  4655. },
  4656. /* Set the date(s) directly. */
  4657. _setDate: function(inst, date, noChange) {
  4658. var clear = !date,
  4659. origMonth = inst.selectedMonth,
  4660. origYear = inst.selectedYear,
  4661. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  4662. inst.selectedDay = inst.currentDay = newDate.getDate();
  4663. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  4664. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  4665. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  4666. this._notifyChange(inst);
  4667. }
  4668. this._adjustInstDate(inst);
  4669. if (inst.input) {
  4670. inst.input.val(clear ? "" : this._formatDate(inst));
  4671. }
  4672. },
  4673. /* Retrieve the date(s) directly. */
  4674. _getDate: function(inst) {
  4675. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  4676. this._daylightSavingAdjust(new Date(
  4677. inst.currentYear, inst.currentMonth, inst.currentDay)));
  4678. return startDate;
  4679. },
  4680. /* Attach the onxxx handlers. These are declared statically so
  4681. * they work with static code transformers like Caja.
  4682. */
  4683. _attachHandlers: function(inst) {
  4684. var stepMonths = this._get(inst, "stepMonths"),
  4685. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  4686. inst.dpDiv.find("[data-handler]").map(function () {
  4687. var handler = {
  4688. prev: function () {
  4689. $.datepicker._adjustDate(id, -stepMonths, "M");
  4690. },
  4691. next: function () {
  4692. $.datepicker._adjustDate(id, +stepMonths, "M");
  4693. },
  4694. hide: function () {
  4695. $.datepicker._hideDatepicker();
  4696. },
  4697. today: function () {
  4698. $.datepicker._gotoToday(id);
  4699. },
  4700. selectDay: function () {
  4701. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  4702. return false;
  4703. },
  4704. selectMonth: function () {
  4705. $.datepicker._selectMonthYear(id, this, "M");
  4706. return false;
  4707. },
  4708. selectYear: function () {
  4709. $.datepicker._selectMonthYear(id, this, "Y");
  4710. return false;
  4711. }
  4712. };
  4713. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  4714. });
  4715. },
  4716. /* Generate the HTML for the current state of the date picker. */
  4717. _generateHTML: function(inst) {
  4718. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  4719. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  4720. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  4721. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  4722. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  4723. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  4724. tempDate = new Date(),
  4725. today = this._daylightSavingAdjust(
  4726. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  4727. isRTL = this._get(inst, "isRTL"),
  4728. showButtonPanel = this._get(inst, "showButtonPanel"),
  4729. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  4730. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  4731. numMonths = this._getNumberOfMonths(inst),
  4732. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  4733. stepMonths = this._get(inst, "stepMonths"),
  4734. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  4735. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  4736. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  4737. minDate = this._getMinMaxDate(inst, "min"),
  4738. maxDate = this._getMinMaxDate(inst, "max"),
  4739. drawMonth = inst.drawMonth - showCurrentAtPos,
  4740. drawYear = inst.drawYear;
  4741. if (drawMonth < 0) {
  4742. drawMonth += 12;
  4743. drawYear--;
  4744. }
  4745. if (maxDate) {
  4746. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  4747. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  4748. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  4749. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  4750. drawMonth--;
  4751. if (drawMonth < 0) {
  4752. drawMonth = 11;
  4753. drawYear--;
  4754. }
  4755. }
  4756. }
  4757. inst.drawMonth = drawMonth;
  4758. inst.drawYear = drawYear;
  4759. prevText = this._get(inst, "prevText");
  4760. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  4761. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  4762. this._getFormatConfig(inst)));
  4763. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  4764. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  4765. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  4766. (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>"));
  4767. nextText = this._get(inst, "nextText");
  4768. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  4769. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  4770. this._getFormatConfig(inst)));
  4771. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  4772. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  4773. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  4774. (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>"));
  4775. currentText = this._get(inst, "currentText");
  4776. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  4777. currentText = (!navigationAsDateFormat ? currentText :
  4778. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  4779. 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'>" +
  4780. this._get(inst, "closeText") + "</button>" : "");
  4781. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  4782. (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'" +
  4783. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  4784. firstDay = parseInt(this._get(inst, "firstDay"),10);
  4785. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  4786. showWeek = this._get(inst, "showWeek");
  4787. dayNames = this._get(inst, "dayNames");
  4788. dayNamesMin = this._get(inst, "dayNamesMin");
  4789. monthNames = this._get(inst, "monthNames");
  4790. monthNamesShort = this._get(inst, "monthNamesShort");
  4791. beforeShowDay = this._get(inst, "beforeShowDay");
  4792. showOtherMonths = this._get(inst, "showOtherMonths");
  4793. selectOtherMonths = this._get(inst, "selectOtherMonths");
  4794. defaultDate = this._getDefaultDate(inst);
  4795. html = "";
  4796. dow;
  4797. for (row = 0; row < numMonths[0]; row++) {
  4798. group = "";
  4799. this.maxRows = 4;
  4800. for (col = 0; col < numMonths[1]; col++) {
  4801. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  4802. cornerClass = " ui-corner-all";
  4803. calender = "";
  4804. if (isMultiMonth) {
  4805. calender += "<div class='ui-datepicker-group";
  4806. if (numMonths[1] > 1) {
  4807. switch (col) {
  4808. case 0: calender += " ui-datepicker-group-first";
  4809. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  4810. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  4811. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  4812. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  4813. }
  4814. }
  4815. calender += "'>";
  4816. }
  4817. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  4818. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  4819. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  4820. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  4821. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  4822. "</div><table class='ui-datepicker-calendar'><thead>" +
  4823. "<tr>";
  4824. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  4825. for (dow = 0; dow < 7; dow++) { // days of the week
  4826. day = (dow + firstDay) % 7;
  4827. thead += "<th scope='col'" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  4828. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  4829. }
  4830. calender += thead + "</tr></thead><tbody>";
  4831. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  4832. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  4833. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  4834. }
  4835. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  4836. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  4837. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  4838. this.maxRows = numRows;
  4839. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  4840. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  4841. calender += "<tr>";
  4842. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  4843. this._get(inst, "calculateWeek")(printDate) + "</td>");
  4844. for (dow = 0; dow < 7; dow++) { // create date picker days
  4845. daySettings = (beforeShowDay ?
  4846. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  4847. otherMonth = (printDate.getMonth() !== drawMonth);
  4848. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  4849. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  4850. tbody += "<td class='" +
  4851. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  4852. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  4853. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  4854. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  4855. // or defaultDate is current printedDate and defaultDate is selectedDate
  4856. " " + this._dayOverClass : "") + // highlight selected day
  4857. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  4858. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  4859. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  4860. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  4861. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  4862. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  4863. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  4864. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  4865. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  4866. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  4867. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  4868. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  4869. printDate.setDate(printDate.getDate() + 1);
  4870. printDate = this._daylightSavingAdjust(printDate);
  4871. }
  4872. calender += tbody + "</tr>";
  4873. }
  4874. drawMonth++;
  4875. if (drawMonth > 11) {
  4876. drawMonth = 0;
  4877. drawYear++;
  4878. }
  4879. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  4880. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  4881. group += calender;
  4882. }
  4883. html += group;
  4884. }
  4885. html += buttonPanel;
  4886. inst._keyEvent = false;
  4887. return html;
  4888. },
  4889. /* Generate the month and year header. */
  4890. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  4891. secondary, monthNames, monthNamesShort) {
  4892. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  4893. changeMonth = this._get(inst, "changeMonth"),
  4894. changeYear = this._get(inst, "changeYear"),
  4895. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  4896. html = "<div class='ui-datepicker-title'>",
  4897. monthHtml = "";
  4898. // month selection
  4899. if (secondary || !changeMonth) {
  4900. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  4901. } else {
  4902. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  4903. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  4904. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  4905. for ( month = 0; month < 12; month++) {
  4906. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  4907. monthHtml += "<option value='" + month + "'" +
  4908. (month === drawMonth ? " selected='selected'" : "") +
  4909. ">" + monthNamesShort[month] + "</option>";
  4910. }
  4911. }
  4912. monthHtml += "</select>";
  4913. }
  4914. if (!showMonthAfterYear) {
  4915. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  4916. }
  4917. // year selection
  4918. if ( !inst.yearshtml ) {
  4919. inst.yearshtml = "";
  4920. if (secondary || !changeYear) {
  4921. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  4922. } else {
  4923. // determine range of years to display
  4924. years = this._get(inst, "yearRange").split(":");
  4925. thisYear = new Date().getFullYear();
  4926. determineYear = function(value) {
  4927. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  4928. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  4929. parseInt(value, 10)));
  4930. return (isNaN(year) ? thisYear : year);
  4931. };
  4932. year = determineYear(years[0]);
  4933. endYear = Math.max(year, determineYear(years[1] || ""));
  4934. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  4935. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  4936. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  4937. for (; year <= endYear; year++) {
  4938. inst.yearshtml += "<option value='" + year + "'" +
  4939. (year === drawYear ? " selected='selected'" : "") +
  4940. ">" + year + "</option>";
  4941. }
  4942. inst.yearshtml += "</select>";
  4943. html += inst.yearshtml;
  4944. inst.yearshtml = null;
  4945. }
  4946. }
  4947. html += this._get(inst, "yearSuffix");
  4948. if (showMonthAfterYear) {
  4949. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  4950. }
  4951. html += "</div>"; // Close datepicker_header
  4952. return html;
  4953. },
  4954. /* Adjust one of the date sub-fields. */
  4955. _adjustInstDate: function(inst, offset, period) {
  4956. var year = inst.drawYear + (period === "Y" ? offset : 0),
  4957. month = inst.drawMonth + (period === "M" ? offset : 0),
  4958. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  4959. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  4960. inst.selectedDay = date.getDate();
  4961. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4962. inst.drawYear = inst.selectedYear = date.getFullYear();
  4963. if (period === "M" || period === "Y") {
  4964. this._notifyChange(inst);
  4965. }
  4966. },
  4967. /* Ensure a date is within any min/max bounds. */
  4968. _restrictMinMax: function(inst, date) {
  4969. var minDate = this._getMinMaxDate(inst, "min"),
  4970. maxDate = this._getMinMaxDate(inst, "max"),
  4971. newDate = (minDate && date < minDate ? minDate : date);
  4972. return (maxDate && newDate > maxDate ? maxDate : newDate);
  4973. },
  4974. /* Notify change of month/year. */
  4975. _notifyChange: function(inst) {
  4976. var onChange = this._get(inst, "onChangeMonthYear");
  4977. if (onChange) {
  4978. onChange.apply((inst.input ? inst.input[0] : null),
  4979. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  4980. }
  4981. },
  4982. /* Determine the number of months to show. */
  4983. _getNumberOfMonths: function(inst) {
  4984. var numMonths = this._get(inst, "numberOfMonths");
  4985. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  4986. },
  4987. /* Determine the current maximum date - ensure no time components are set. */
  4988. _getMinMaxDate: function(inst, minMax) {
  4989. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  4990. },
  4991. /* Find the number of days in a given month. */
  4992. _getDaysInMonth: function(year, month) {
  4993. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  4994. },
  4995. /* Find the day of the week of the first of a month. */
  4996. _getFirstDayOfMonth: function(year, month) {
  4997. return new Date(year, month, 1).getDay();
  4998. },
  4999. /* Determines if we should allow a "next/prev" month display change. */
  5000. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  5001. var numMonths = this._getNumberOfMonths(inst),
  5002. date = this._daylightSavingAdjust(new Date(curYear,
  5003. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  5004. if (offset < 0) {
  5005. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  5006. }
  5007. return this._isInRange(inst, date);
  5008. },
  5009. /* Is the given date in the accepted range? */
  5010. _isInRange: function(inst, date) {
  5011. var yearSplit, currentYear,
  5012. minDate = this._getMinMaxDate(inst, "min"),
  5013. maxDate = this._getMinMaxDate(inst, "max"),
  5014. minYear = null,
  5015. maxYear = null,
  5016. years = this._get(inst, "yearRange");
  5017. if (years){
  5018. yearSplit = years.split(":");
  5019. currentYear = new Date().getFullYear();
  5020. minYear = parseInt(yearSplit[0], 10);
  5021. maxYear = parseInt(yearSplit[1], 10);
  5022. if ( yearSplit[0].match(/[+\-].*/) ) {
  5023. minYear += currentYear;
  5024. }
  5025. if ( yearSplit[1].match(/[+\-].*/) ) {
  5026. maxYear += currentYear;
  5027. }
  5028. }
  5029. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  5030. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  5031. (!minYear || date.getFullYear() >= minYear) &&
  5032. (!maxYear || date.getFullYear() <= maxYear));
  5033. },
  5034. /* Provide the configuration settings for formatting/parsing. */
  5035. _getFormatConfig: function(inst) {
  5036. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  5037. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  5038. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  5039. return {shortYearCutoff: shortYearCutoff,
  5040. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  5041. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  5042. },
  5043. /* Format the given date for display. */
  5044. _formatDate: function(inst, day, month, year) {
  5045. if (!day) {
  5046. inst.currentDay = inst.selectedDay;
  5047. inst.currentMonth = inst.selectedMonth;
  5048. inst.currentYear = inst.selectedYear;
  5049. }
  5050. var date = (day ? (typeof day === "object" ? day :
  5051. this._daylightSavingAdjust(new Date(year, month, day))) :
  5052. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  5053. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  5054. }
  5055. });
  5056. /*
  5057. * Bind hover events for datepicker elements.
  5058. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  5059. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  5060. */
  5061. function datepicker_bindHover(dpDiv) {
  5062. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  5063. return dpDiv.delegate(selector, "mouseout", function() {
  5064. $(this).removeClass("ui-state-hover");
  5065. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  5066. $(this).removeClass("ui-datepicker-prev-hover");
  5067. }
  5068. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  5069. $(this).removeClass("ui-datepicker-next-hover");
  5070. }
  5071. })
  5072. .delegate(selector, "mouseover", function(){
  5073. if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? dpDiv.parent()[0] : datepicker_instActive.input[0])) {
  5074. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  5075. $(this).addClass("ui-state-hover");
  5076. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  5077. $(this).addClass("ui-datepicker-prev-hover");
  5078. }
  5079. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  5080. $(this).addClass("ui-datepicker-next-hover");
  5081. }
  5082. }
  5083. });
  5084. }
  5085. /* jQuery extend now ignores nulls! */
  5086. function datepicker_extendRemove(target, props) {
  5087. $.extend(target, props);
  5088. for (var name in props) {
  5089. if (props[name] == null) {
  5090. target[name] = props[name];
  5091. }
  5092. }
  5093. return target;
  5094. }
  5095. /* Invoke the datepicker functionality.
  5096. @param options string - a command, optionally followed by additional parameters or
  5097. Object - settings for attaching new datepicker functionality
  5098. @return jQuery object */
  5099. $.fn.datepicker = function(options){
  5100. /* Verify an empty collection wasn't passed - Fixes #6976 */
  5101. if ( !this.length ) {
  5102. return this;
  5103. }
  5104. /* Initialise the date picker. */
  5105. if (!$.datepicker.initialized) {
  5106. $(document).mousedown($.datepicker._checkExternalClick);
  5107. $.datepicker.initialized = true;
  5108. }
  5109. /* Append datepicker main container to body if not exist. */
  5110. if ($("#"+$.datepicker._mainDivId).length === 0) {
  5111. $("body").append($.datepicker.dpDiv);
  5112. }
  5113. var otherArgs = Array.prototype.slice.call(arguments, 1);
  5114. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  5115. return $.datepicker["_" + options + "Datepicker"].
  5116. apply($.datepicker, [this[0]].concat(otherArgs));
  5117. }
  5118. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  5119. return $.datepicker["_" + options + "Datepicker"].
  5120. apply($.datepicker, [this[0]].concat(otherArgs));
  5121. }
  5122. return this.each(function() {
  5123. typeof options === "string" ?
  5124. $.datepicker["_" + options + "Datepicker"].
  5125. apply($.datepicker, [this].concat(otherArgs)) :
  5126. $.datepicker._attachDatepicker(this, options);
  5127. });
  5128. };
  5129. $.datepicker = new Datepicker(); // singleton instance
  5130. $.datepicker.initialized = false;
  5131. $.datepicker.uuid = new Date().getTime();
  5132. $.datepicker.version = "1.11.0";
  5133. var datepicker = $.datepicker;
  5134. /*!
  5135. * jQuery UI Draggable 1.11.0
  5136. * http://jqueryui.com
  5137. *
  5138. * Copyright 2014 jQuery Foundation and other contributors
  5139. * Released under the MIT license.
  5140. * http://jquery.org/license
  5141. *
  5142. * http://api.jqueryui.com/draggable/
  5143. */
  5144. $.widget("ui.draggable", $.ui.mouse, {
  5145. version: "1.11.0",
  5146. widgetEventPrefix: "drag",
  5147. options: {
  5148. addClasses: true,
  5149. appendTo: "parent",
  5150. axis: false,
  5151. connectToSortable: false,
  5152. containment: false,
  5153. cursor: "auto",
  5154. cursorAt: false,
  5155. grid: false,
  5156. handle: false,
  5157. helper: "original",
  5158. iframeFix: false,
  5159. opacity: false,
  5160. refreshPositions: false,
  5161. revert: false,
  5162. revertDuration: 500,
  5163. scope: "default",
  5164. scroll: true,
  5165. scrollSensitivity: 20,
  5166. scrollSpeed: 20,
  5167. snap: false,
  5168. snapMode: "both",
  5169. snapTolerance: 20,
  5170. stack: false,
  5171. zIndex: false,
  5172. // callbacks
  5173. drag: null,
  5174. start: null,
  5175. stop: null
  5176. },
  5177. _create: function() {
  5178. if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
  5179. this.element[0].style.position = "relative";
  5180. }
  5181. if (this.options.addClasses){
  5182. this.element.addClass("ui-draggable");
  5183. }
  5184. if (this.options.disabled){
  5185. this.element.addClass("ui-draggable-disabled");
  5186. }
  5187. this._setHandleClassName();
  5188. this._mouseInit();
  5189. },
  5190. _setOption: function( key, value ) {
  5191. this._super( key, value );
  5192. if ( key === "handle" ) {
  5193. this._setHandleClassName();
  5194. }
  5195. },
  5196. _destroy: function() {
  5197. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  5198. this.destroyOnClear = true;
  5199. return;
  5200. }
  5201. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  5202. this._removeHandleClassName();
  5203. this._mouseDestroy();
  5204. },
  5205. _mouseCapture: function(event) {
  5206. var document = this.document[ 0 ],
  5207. o = this.options;
  5208. // support: IE9
  5209. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  5210. try {
  5211. // Support: IE9+
  5212. // If the <body> is blurred, IE will switch windows, see #9520
  5213. if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
  5214. // Blur any element that currently has focus, see #4261
  5215. $( document.activeElement ).blur();
  5216. }
  5217. } catch ( error ) {}
  5218. // among others, prevent a drag on a resizable-handle
  5219. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  5220. return false;
  5221. }
  5222. //Quit if we're not on a valid handle
  5223. this.handle = this._getHandle(event);
  5224. if (!this.handle) {
  5225. return false;
  5226. }
  5227. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  5228. $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
  5229. .css({
  5230. width: this.offsetWidth + "px", height: this.offsetHeight + "px",
  5231. position: "absolute", opacity: "0.001", zIndex: 1000
  5232. })
  5233. .css($(this).offset())
  5234. .appendTo("body");
  5235. });
  5236. return true;
  5237. },
  5238. _mouseStart: function(event) {
  5239. var o = this.options;
  5240. //Create and append the visible helper
  5241. this.helper = this._createHelper(event);
  5242. this.helper.addClass("ui-draggable-dragging");
  5243. //Cache the helper size
  5244. this._cacheHelperProportions();
  5245. //If ddmanager is used for droppables, set the global draggable
  5246. if ($.ui.ddmanager) {
  5247. $.ui.ddmanager.current = this;
  5248. }
  5249. /*
  5250. * - Position generation -
  5251. * This block generates everything position related - it's the core of draggables.
  5252. */
  5253. //Cache the margins of the original element
  5254. this._cacheMargins();
  5255. //Store the helper's css position
  5256. this.cssPosition = this.helper.css( "position" );
  5257. this.scrollParent = this.helper.scrollParent();
  5258. this.offsetParent = this.helper.offsetParent();
  5259. this.offsetParentCssPosition = this.offsetParent.css( "position" );
  5260. //The element's absolute position on the page minus margins
  5261. this.offset = this.positionAbs = this.element.offset();
  5262. this.offset = {
  5263. top: this.offset.top - this.margins.top,
  5264. left: this.offset.left - this.margins.left
  5265. };
  5266. //Reset scroll cache
  5267. this.offset.scroll = false;
  5268. $.extend(this.offset, {
  5269. click: { //Where the click happened, relative to the element
  5270. left: event.pageX - this.offset.left,
  5271. top: event.pageY - this.offset.top
  5272. },
  5273. parent: this._getParentOffset(),
  5274. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  5275. });
  5276. //Generate the original position
  5277. this.originalPosition = this.position = this._generatePosition( event, false );
  5278. this.originalPageX = event.pageX;
  5279. this.originalPageY = event.pageY;
  5280. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  5281. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  5282. //Set a containment if given in the options
  5283. this._setContainment();
  5284. //Trigger event + callbacks
  5285. if (this._trigger("start", event) === false) {
  5286. this._clear();
  5287. return false;
  5288. }
  5289. //Recache the helper size
  5290. this._cacheHelperProportions();
  5291. //Prepare the droppable offsets
  5292. if ($.ui.ddmanager && !o.dropBehaviour) {
  5293. $.ui.ddmanager.prepareOffsets(this, event);
  5294. }
  5295. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  5296. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  5297. if ( $.ui.ddmanager ) {
  5298. $.ui.ddmanager.dragStart(this, event);
  5299. }
  5300. return true;
  5301. },
  5302. _mouseDrag: function(event, noPropagation) {
  5303. // reset any necessary cached properties (see #5009)
  5304. if ( this.offsetParentCssPosition === "fixed" ) {
  5305. this.offset.parent = this._getParentOffset();
  5306. }
  5307. //Compute the helpers position
  5308. this.position = this._generatePosition( event, true );
  5309. this.positionAbs = this._convertPositionTo("absolute");
  5310. //Call plugins and callbacks and use the resulting position if something is returned
  5311. if (!noPropagation) {
  5312. var ui = this._uiHash();
  5313. if (this._trigger("drag", event, ui) === false) {
  5314. this._mouseUp({});
  5315. return false;
  5316. }
  5317. this.position = ui.position;
  5318. }
  5319. this.helper[ 0 ].style.left = this.position.left + "px";
  5320. this.helper[ 0 ].style.top = this.position.top + "px";
  5321. if ($.ui.ddmanager) {
  5322. $.ui.ddmanager.drag(this, event);
  5323. }
  5324. return false;
  5325. },
  5326. _mouseStop: function(event) {
  5327. //If we are using droppables, inform the manager about the drop
  5328. var that = this,
  5329. dropped = false;
  5330. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  5331. dropped = $.ui.ddmanager.drop(this, event);
  5332. }
  5333. //if a drop comes from outside (a sortable)
  5334. if (this.dropped) {
  5335. dropped = this.dropped;
  5336. this.dropped = false;
  5337. }
  5338. 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))) {
  5339. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  5340. if (that._trigger("stop", event) !== false) {
  5341. that._clear();
  5342. }
  5343. });
  5344. } else {
  5345. if (this._trigger("stop", event) !== false) {
  5346. this._clear();
  5347. }
  5348. }
  5349. return false;
  5350. },
  5351. _mouseUp: function(event) {
  5352. //Remove frame helpers
  5353. $("div.ui-draggable-iframeFix").each(function() {
  5354. this.parentNode.removeChild(this);
  5355. });
  5356. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  5357. if ( $.ui.ddmanager ) {
  5358. $.ui.ddmanager.dragStop(this, event);
  5359. }
  5360. // The interaction is over; whether or not the click resulted in a drag, focus the element
  5361. this.element.focus();
  5362. return $.ui.mouse.prototype._mouseUp.call(this, event);
  5363. },
  5364. cancel: function() {
  5365. if (this.helper.is(".ui-draggable-dragging")) {
  5366. this._mouseUp({});
  5367. } else {
  5368. this._clear();
  5369. }
  5370. return this;
  5371. },
  5372. _getHandle: function(event) {
  5373. return this.options.handle ?
  5374. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  5375. true;
  5376. },
  5377. _setHandleClassName: function() {
  5378. this._removeHandleClassName();
  5379. $( this.options.handle || this.element ).addClass( "ui-draggable-handle" );
  5380. },
  5381. _removeHandleClassName: function() {
  5382. this.element.find( ".ui-draggable-handle" )
  5383. .addBack()
  5384. .removeClass( "ui-draggable-handle" );
  5385. },
  5386. _createHelper: function(event) {
  5387. var o = this.options,
  5388. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[ 0 ], [ event ])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
  5389. if (!helper.parents("body").length) {
  5390. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  5391. }
  5392. if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  5393. helper.css("position", "absolute");
  5394. }
  5395. return helper;
  5396. },
  5397. _adjustOffsetFromHelper: function(obj) {
  5398. if (typeof obj === "string") {
  5399. obj = obj.split(" ");
  5400. }
  5401. if ($.isArray(obj)) {
  5402. obj = { left: +obj[0], top: +obj[1] || 0 };
  5403. }
  5404. if ("left" in obj) {
  5405. this.offset.click.left = obj.left + this.margins.left;
  5406. }
  5407. if ("right" in obj) {
  5408. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  5409. }
  5410. if ("top" in obj) {
  5411. this.offset.click.top = obj.top + this.margins.top;
  5412. }
  5413. if ("bottom" in obj) {
  5414. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  5415. }
  5416. },
  5417. _isRootNode: function( element ) {
  5418. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  5419. },
  5420. _getParentOffset: function() {
  5421. //Get the offsetParent and cache its position
  5422. var po = this.offsetParent.offset(),
  5423. document = this.document[ 0 ];
  5424. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  5425. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  5426. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  5427. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  5428. if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  5429. po.left += this.scrollParent.scrollLeft();
  5430. po.top += this.scrollParent.scrollTop();
  5431. }
  5432. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  5433. po = { top: 0, left: 0 };
  5434. }
  5435. return {
  5436. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  5437. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  5438. };
  5439. },
  5440. _getRelativeOffset: function() {
  5441. if ( this.cssPosition !== "relative" ) {
  5442. return { top: 0, left: 0 };
  5443. }
  5444. var p = this.element.position(),
  5445. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  5446. return {
  5447. top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  5448. left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  5449. };
  5450. },
  5451. _cacheMargins: function() {
  5452. this.margins = {
  5453. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  5454. top: (parseInt(this.element.css("marginTop"),10) || 0),
  5455. right: (parseInt(this.element.css("marginRight"),10) || 0),
  5456. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  5457. };
  5458. },
  5459. _cacheHelperProportions: function() {
  5460. this.helperProportions = {
  5461. width: this.helper.outerWidth(),
  5462. height: this.helper.outerHeight()
  5463. };
  5464. },
  5465. _setContainment: function() {
  5466. var over, c, ce,
  5467. o = this.options,
  5468. document = this.document[ 0 ];
  5469. this.relative_container = null;
  5470. if ( !o.containment ) {
  5471. this.containment = null;
  5472. return;
  5473. }
  5474. if ( o.containment === "window" ) {
  5475. this.containment = [
  5476. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  5477. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  5478. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  5479. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  5480. ];
  5481. return;
  5482. }
  5483. if ( o.containment === "document") {
  5484. this.containment = [
  5485. 0,
  5486. 0,
  5487. $( document ).width() - this.helperProportions.width - this.margins.left,
  5488. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  5489. ];
  5490. return;
  5491. }
  5492. if ( o.containment.constructor === Array ) {
  5493. this.containment = o.containment;
  5494. return;
  5495. }
  5496. if ( o.containment === "parent" ) {
  5497. o.containment = this.helper[ 0 ].parentNode;
  5498. }
  5499. c = $( o.containment );
  5500. ce = c[ 0 ];
  5501. if ( !ce ) {
  5502. return;
  5503. }
  5504. over = c.css( "overflow" ) !== "hidden";
  5505. this.containment = [
  5506. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  5507. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  5508. ( 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,
  5509. ( 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
  5510. ];
  5511. this.relative_container = c;
  5512. },
  5513. _convertPositionTo: function(d, pos) {
  5514. if (!pos) {
  5515. pos = this.position;
  5516. }
  5517. var mod = d === "absolute" ? 1 : -1,
  5518. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  5519. return {
  5520. top: (
  5521. pos.top + // The absolute mouse position
  5522. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  5523. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  5524. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
  5525. ),
  5526. left: (
  5527. pos.left + // The absolute mouse position
  5528. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  5529. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  5530. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod)
  5531. )
  5532. };
  5533. },
  5534. _generatePosition: function( event, constrainPosition ) {
  5535. var containment, co, top, left,
  5536. o = this.options,
  5537. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  5538. pageX = event.pageX,
  5539. pageY = event.pageY;
  5540. // Cache the scroll
  5541. if ( !scrollIsRootNode || !this.offset.scroll ) {
  5542. this.offset.scroll = {
  5543. top: this.scrollParent.scrollTop(),
  5544. left: this.scrollParent.scrollLeft()
  5545. };
  5546. }
  5547. /*
  5548. * - Position constraining -
  5549. * Constrain the position to a mix of grid, containment.
  5550. */
  5551. // If we are not dragging yet, we won't check for options
  5552. if ( constrainPosition ) {
  5553. if ( this.containment ) {
  5554. if ( this.relative_container ){
  5555. co = this.relative_container.offset();
  5556. containment = [
  5557. this.containment[ 0 ] + co.left,
  5558. this.containment[ 1 ] + co.top,
  5559. this.containment[ 2 ] + co.left,
  5560. this.containment[ 3 ] + co.top
  5561. ];
  5562. } else {
  5563. containment = this.containment;
  5564. }
  5565. if (event.pageX - this.offset.click.left < containment[0]) {
  5566. pageX = containment[0] + this.offset.click.left;
  5567. }
  5568. if (event.pageY - this.offset.click.top < containment[1]) {
  5569. pageY = containment[1] + this.offset.click.top;
  5570. }
  5571. if (event.pageX - this.offset.click.left > containment[2]) {
  5572. pageX = containment[2] + this.offset.click.left;
  5573. }
  5574. if (event.pageY - this.offset.click.top > containment[3]) {
  5575. pageY = containment[3] + this.offset.click.top;
  5576. }
  5577. }
  5578. if (o.grid) {
  5579. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  5580. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  5581. 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;
  5582. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  5583. 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;
  5584. }
  5585. if ( o.axis === "y" ) {
  5586. pageX = this.originalPageX;
  5587. }
  5588. if ( o.axis === "x" ) {
  5589. pageY = this.originalPageY;
  5590. }
  5591. }
  5592. return {
  5593. top: (
  5594. pageY - // The absolute mouse position
  5595. this.offset.click.top - // Click offset (relative to the element)
  5596. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  5597. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  5598. ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  5599. ),
  5600. left: (
  5601. pageX - // The absolute mouse position
  5602. this.offset.click.left - // Click offset (relative to the element)
  5603. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  5604. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  5605. ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  5606. )
  5607. };
  5608. },
  5609. _clear: function() {
  5610. this.helper.removeClass("ui-draggable-dragging");
  5611. if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  5612. this.helper.remove();
  5613. }
  5614. this.helper = null;
  5615. this.cancelHelperRemoval = false;
  5616. if ( this.destroyOnClear ) {
  5617. this.destroy();
  5618. }
  5619. },
  5620. // From now on bulk stuff - mainly helpers
  5621. _trigger: function(type, event, ui) {
  5622. ui = ui || this._uiHash();
  5623. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  5624. //The absolute position has to be recalculated after plugins
  5625. if (type === "drag") {
  5626. this.positionAbs = this._convertPositionTo("absolute");
  5627. }
  5628. return $.Widget.prototype._trigger.call(this, type, event, ui);
  5629. },
  5630. plugins: {},
  5631. _uiHash: function() {
  5632. return {
  5633. helper: this.helper,
  5634. position: this.position,
  5635. originalPosition: this.originalPosition,
  5636. offset: this.positionAbs
  5637. };
  5638. }
  5639. });
  5640. $.ui.plugin.add("draggable", "connectToSortable", {
  5641. start: function( event, ui, inst ) {
  5642. var o = inst.options,
  5643. uiSortable = $.extend({}, ui, { item: inst.element });
  5644. inst.sortables = [];
  5645. $(o.connectToSortable).each(function() {
  5646. var sortable = $( this ).sortable( "instance" );
  5647. if (sortable && !sortable.options.disabled) {
  5648. inst.sortables.push({
  5649. instance: sortable,
  5650. shouldRevert: sortable.options.revert
  5651. });
  5652. 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).
  5653. sortable._trigger("activate", event, uiSortable);
  5654. }
  5655. });
  5656. },
  5657. stop: function( event, ui, inst ) {
  5658. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  5659. var uiSortable = $.extend( {}, ui, {
  5660. item: inst.element
  5661. });
  5662. $.each(inst.sortables, function() {
  5663. if (this.instance.isOver) {
  5664. this.instance.isOver = 0;
  5665. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  5666. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  5667. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
  5668. if (this.shouldRevert) {
  5669. this.instance.options.revert = this.shouldRevert;
  5670. }
  5671. //Trigger the stop of the sortable
  5672. this.instance._mouseStop(event);
  5673. this.instance.options.helper = this.instance.options._helper;
  5674. //If the helper has been the original item, restore properties in the sortable
  5675. if (inst.options.helper === "original") {
  5676. this.instance.currentItem.css({ top: "auto", left: "auto" });
  5677. }
  5678. } else {
  5679. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  5680. this.instance._trigger("deactivate", event, uiSortable);
  5681. }
  5682. });
  5683. },
  5684. drag: function( event, ui, inst ) {
  5685. var that = this;
  5686. $.each(inst.sortables, function() {
  5687. var innermostIntersecting = false,
  5688. thisSortable = this;
  5689. //Copy over some variables to allow calling the sortable's native _intersectsWith
  5690. this.instance.positionAbs = inst.positionAbs;
  5691. this.instance.helperProportions = inst.helperProportions;
  5692. this.instance.offset.click = inst.offset.click;
  5693. if (this.instance._intersectsWith(this.instance.containerCache)) {
  5694. innermostIntersecting = true;
  5695. $.each(inst.sortables, function() {
  5696. this.instance.positionAbs = inst.positionAbs;
  5697. this.instance.helperProportions = inst.helperProportions;
  5698. this.instance.offset.click = inst.offset.click;
  5699. if (this !== thisSortable &&
  5700. this.instance._intersectsWith(this.instance.containerCache) &&
  5701. $.contains(thisSortable.instance.element[0], this.instance.element[0])
  5702. ) {
  5703. innermostIntersecting = false;
  5704. }
  5705. return innermostIntersecting;
  5706. });
  5707. }
  5708. if (innermostIntersecting) {
  5709. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  5710. if (!this.instance.isOver) {
  5711. this.instance.isOver = 1;
  5712. //Now we fake the start of dragging for the sortable instance,
  5713. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  5714. //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)
  5715. this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
  5716. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  5717. this.instance.options.helper = function() { return ui.helper[0]; };
  5718. event.target = this.instance.currentItem[0];
  5719. this.instance._mouseCapture(event, true);
  5720. this.instance._mouseStart(event, true, true);
  5721. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  5722. this.instance.offset.click.top = inst.offset.click.top;
  5723. this.instance.offset.click.left = inst.offset.click.left;
  5724. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  5725. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  5726. inst._trigger("toSortable", event);
  5727. inst.dropped = this.instance.element; //draggable revert needs that
  5728. //hack so receive/update callbacks work (mostly)
  5729. inst.currentItem = inst.element;
  5730. this.instance.fromOutside = inst;
  5731. }
  5732. //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
  5733. if (this.instance.currentItem) {
  5734. this.instance._mouseDrag(event);
  5735. }
  5736. } else {
  5737. //If it doesn't intersect with the sortable, and it intersected before,
  5738. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  5739. if (this.instance.isOver) {
  5740. this.instance.isOver = 0;
  5741. this.instance.cancelHelperRemoval = true;
  5742. //Prevent reverting on this forced stop
  5743. this.instance.options.revert = false;
  5744. // The out event needs to be triggered independently
  5745. this.instance._trigger("out", event, this.instance._uiHash(this.instance));
  5746. this.instance._mouseStop(event, true);
  5747. this.instance.options.helper = this.instance.options._helper;
  5748. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  5749. this.instance.currentItem.remove();
  5750. if (this.instance.placeholder) {
  5751. this.instance.placeholder.remove();
  5752. }
  5753. inst._trigger("fromSortable", event);
  5754. inst.dropped = false; //draggable revert needs that
  5755. }
  5756. }
  5757. });
  5758. }
  5759. });
  5760. $.ui.plugin.add("draggable", "cursor", {
  5761. start: function( event, ui, instance ) {
  5762. var t = $( "body" ),
  5763. o = instance.options;
  5764. if (t.css("cursor")) {
  5765. o._cursor = t.css("cursor");
  5766. }
  5767. t.css("cursor", o.cursor);
  5768. },
  5769. stop: function( event, ui, instance ) {
  5770. var o = instance.options;
  5771. if (o._cursor) {
  5772. $("body").css("cursor", o._cursor);
  5773. }
  5774. }
  5775. });
  5776. $.ui.plugin.add("draggable", "opacity", {
  5777. start: function( event, ui, instance ) {
  5778. var t = $( ui.helper ),
  5779. o = instance.options;
  5780. if (t.css("opacity")) {
  5781. o._opacity = t.css("opacity");
  5782. }
  5783. t.css("opacity", o.opacity);
  5784. },
  5785. stop: function( event, ui, instance ) {
  5786. var o = instance.options;
  5787. if (o._opacity) {
  5788. $(ui.helper).css("opacity", o._opacity);
  5789. }
  5790. }
  5791. });
  5792. $.ui.plugin.add("draggable", "scroll", {
  5793. start: function( event, ui, i ) {
  5794. if ( i.scrollParent[ 0 ] !== i.document[ 0 ] && i.scrollParent[ 0 ].tagName !== "HTML" ) {
  5795. i.overflowOffset = i.scrollParent.offset();
  5796. }
  5797. },
  5798. drag: function( event, ui, i ) {
  5799. var o = i.options,
  5800. scrolled = false,
  5801. document = i.document[ 0 ];
  5802. if ( i.scrollParent[ 0 ] !== document && i.scrollParent[ 0 ].tagName !== "HTML" ) {
  5803. if (!o.axis || o.axis !== "x") {
  5804. if ((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  5805. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  5806. } else if (event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
  5807. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  5808. }
  5809. }
  5810. if (!o.axis || o.axis !== "y") {
  5811. if ((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  5812. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  5813. } else if (event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
  5814. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  5815. }
  5816. }
  5817. } else {
  5818. if (!o.axis || o.axis !== "x") {
  5819. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  5820. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  5821. } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  5822. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  5823. }
  5824. }
  5825. if (!o.axis || o.axis !== "y") {
  5826. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  5827. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  5828. } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  5829. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  5830. }
  5831. }
  5832. }
  5833. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  5834. $.ui.ddmanager.prepareOffsets(i, event);
  5835. }
  5836. }
  5837. });
  5838. $.ui.plugin.add("draggable", "snap", {
  5839. start: function( event, ui, i ) {
  5840. var o = i.options;
  5841. i.snapElements = [];
  5842. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  5843. var $t = $(this),
  5844. $o = $t.offset();
  5845. if (this !== i.element[0]) {
  5846. i.snapElements.push({
  5847. item: this,
  5848. width: $t.outerWidth(), height: $t.outerHeight(),
  5849. top: $o.top, left: $o.left
  5850. });
  5851. }
  5852. });
  5853. },
  5854. drag: function( event, ui, inst ) {
  5855. var ts, bs, ls, rs, l, r, t, b, i, first,
  5856. o = inst.options,
  5857. d = o.snapTolerance,
  5858. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  5859. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  5860. for (i = inst.snapElements.length - 1; i >= 0; i--){
  5861. l = inst.snapElements[i].left;
  5862. r = l + inst.snapElements[i].width;
  5863. t = inst.snapElements[i].top;
  5864. b = t + inst.snapElements[i].height;
  5865. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  5866. if (inst.snapElements[i].snapping) {
  5867. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  5868. }
  5869. inst.snapElements[i].snapping = false;
  5870. continue;
  5871. }
  5872. if (o.snapMode !== "inner") {
  5873. ts = Math.abs(t - y2) <= d;
  5874. bs = Math.abs(b - y1) <= d;
  5875. ls = Math.abs(l - x2) <= d;
  5876. rs = Math.abs(r - x1) <= d;
  5877. if (ts) {
  5878. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  5879. }
  5880. if (bs) {
  5881. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  5882. }
  5883. if (ls) {
  5884. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  5885. }
  5886. if (rs) {
  5887. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  5888. }
  5889. }
  5890. first = (ts || bs || ls || rs);
  5891. if (o.snapMode !== "outer") {
  5892. ts = Math.abs(t - y1) <= d;
  5893. bs = Math.abs(b - y2) <= d;
  5894. ls = Math.abs(l - x1) <= d;
  5895. rs = Math.abs(r - x2) <= d;
  5896. if (ts) {
  5897. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  5898. }
  5899. if (bs) {
  5900. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  5901. }
  5902. if (ls) {
  5903. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  5904. }
  5905. if (rs) {
  5906. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  5907. }
  5908. }
  5909. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  5910. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  5911. }
  5912. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  5913. }
  5914. }
  5915. });
  5916. $.ui.plugin.add("draggable", "stack", {
  5917. start: function( event, ui, instance ) {
  5918. var min,
  5919. o = instance.options,
  5920. group = $.makeArray($(o.stack)).sort(function(a,b) {
  5921. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  5922. });
  5923. if (!group.length) { return; }
  5924. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  5925. $(group).each(function(i) {
  5926. $(this).css("zIndex", min + i);
  5927. });
  5928. this.css("zIndex", (min + group.length));
  5929. }
  5930. });
  5931. $.ui.plugin.add("draggable", "zIndex", {
  5932. start: function( event, ui, instance ) {
  5933. var t = $( ui.helper ),
  5934. o = instance.options;
  5935. if (t.css("zIndex")) {
  5936. o._zIndex = t.css("zIndex");
  5937. }
  5938. t.css("zIndex", o.zIndex);
  5939. },
  5940. stop: function( event, ui, instance ) {
  5941. var o = instance.options;
  5942. if (o._zIndex) {
  5943. $(ui.helper).css("zIndex", o._zIndex);
  5944. }
  5945. }
  5946. });
  5947. var draggable = $.ui.draggable;
  5948. /*!
  5949. * jQuery UI Resizable 1.11.0
  5950. * http://jqueryui.com
  5951. *
  5952. * Copyright 2014 jQuery Foundation and other contributors
  5953. * Released under the MIT license.
  5954. * http://jquery.org/license
  5955. *
  5956. * http://api.jqueryui.com/resizable/
  5957. */
  5958. $.widget("ui.resizable", $.ui.mouse, {
  5959. version: "1.11.0",
  5960. widgetEventPrefix: "resize",
  5961. options: {
  5962. alsoResize: false,
  5963. animate: false,
  5964. animateDuration: "slow",
  5965. animateEasing: "swing",
  5966. aspectRatio: false,
  5967. autoHide: false,
  5968. containment: false,
  5969. ghost: false,
  5970. grid: false,
  5971. handles: "e,s,se",
  5972. helper: false,
  5973. maxHeight: null,
  5974. maxWidth: null,
  5975. minHeight: 10,
  5976. minWidth: 10,
  5977. // See #7960
  5978. zIndex: 90,
  5979. // callbacks
  5980. resize: null,
  5981. start: null,
  5982. stop: null
  5983. },
  5984. _num: function( value ) {
  5985. return parseInt( value, 10 ) || 0;
  5986. },
  5987. _isNumber: function( value ) {
  5988. return !isNaN( parseInt( value , 10 ) );
  5989. },
  5990. _hasScroll: function( el, a ) {
  5991. if ( $( el ).css( "overflow" ) === "hidden") {
  5992. return false;
  5993. }
  5994. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  5995. has = false;
  5996. if ( el[ scroll ] > 0 ) {
  5997. return true;
  5998. }
  5999. // TODO: determine which cases actually cause this to happen
  6000. // if the element doesn't have the scroll set, see if it's possible to
  6001. // set the scroll
  6002. el[ scroll ] = 1;
  6003. has = ( el[ scroll ] > 0 );
  6004. el[ scroll ] = 0;
  6005. return has;
  6006. },
  6007. _create: function() {
  6008. var n, i, handle, axis, hname,
  6009. that = this,
  6010. o = this.options;
  6011. this.element.addClass("ui-resizable");
  6012. $.extend(this, {
  6013. _aspectRatio: !!(o.aspectRatio),
  6014. aspectRatio: o.aspectRatio,
  6015. originalElement: this.element,
  6016. _proportionallyResizeElements: [],
  6017. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  6018. });
  6019. // Wrap the element if it cannot hold child nodes
  6020. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  6021. this.element.wrap(
  6022. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  6023. position: this.element.css("position"),
  6024. width: this.element.outerWidth(),
  6025. height: this.element.outerHeight(),
  6026. top: this.element.css("top"),
  6027. left: this.element.css("left")
  6028. })
  6029. );
  6030. this.element = this.element.parent().data(
  6031. "ui-resizable", this.element.resizable( "instance" )
  6032. );
  6033. this.elementIsWrapper = true;
  6034. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  6035. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  6036. // support: Safari
  6037. // Prevent Safari textarea resize
  6038. this.originalResizeStyle = this.originalElement.css("resize");
  6039. this.originalElement.css("resize", "none");
  6040. this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
  6041. // support: IE9
  6042. // avoid IE jump (hard set the margin)
  6043. this.originalElement.css({ margin: this.originalElement.css("margin") });
  6044. this._proportionallyResize();
  6045. }
  6046. 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" });
  6047. if(this.handles.constructor === String) {
  6048. if ( this.handles === "all") {
  6049. this.handles = "n,e,s,w,se,sw,ne,nw";
  6050. }
  6051. n = this.handles.split(",");
  6052. this.handles = {};
  6053. for(i = 0; i < n.length; i++) {
  6054. handle = $.trim(n[i]);
  6055. hname = "ui-resizable-"+handle;
  6056. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  6057. axis.css({ zIndex: o.zIndex });
  6058. // TODO : What's going on here?
  6059. if ("se" === handle) {
  6060. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  6061. }
  6062. this.handles[handle] = ".ui-resizable-"+handle;
  6063. this.element.append(axis);
  6064. }
  6065. }
  6066. this._renderAxis = function(target) {
  6067. var i, axis, padPos, padWrapper;
  6068. target = target || this.element;
  6069. for(i in this.handles) {
  6070. if(this.handles[i].constructor === String) {
  6071. this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
  6072. }
  6073. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  6074. axis = $(this.handles[i], this.element);
  6075. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  6076. padPos = [ "padding",
  6077. /ne|nw|n/.test(i) ? "Top" :
  6078. /se|sw|s/.test(i) ? "Bottom" :
  6079. /^e$/.test(i) ? "Right" : "Left" ].join("");
  6080. target.css(padPos, padWrapper);
  6081. this._proportionallyResize();
  6082. }
  6083. // TODO: What's that good for? There's not anything to be executed left
  6084. if(!$(this.handles[i]).length) {
  6085. continue;
  6086. }
  6087. }
  6088. };
  6089. // TODO: make renderAxis a prototype function
  6090. this._renderAxis(this.element);
  6091. this._handles = $(".ui-resizable-handle", this.element)
  6092. .disableSelection();
  6093. this._handles.mouseover(function() {
  6094. if (!that.resizing) {
  6095. if (this.className) {
  6096. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  6097. }
  6098. that.axis = axis && axis[1] ? axis[1] : "se";
  6099. }
  6100. });
  6101. if (o.autoHide) {
  6102. this._handles.hide();
  6103. $(this.element)
  6104. .addClass("ui-resizable-autohide")
  6105. .mouseenter(function() {
  6106. if (o.disabled) {
  6107. return;
  6108. }
  6109. $(this).removeClass("ui-resizable-autohide");
  6110. that._handles.show();
  6111. })
  6112. .mouseleave(function(){
  6113. if (o.disabled) {
  6114. return;
  6115. }
  6116. if (!that.resizing) {
  6117. $(this).addClass("ui-resizable-autohide");
  6118. that._handles.hide();
  6119. }
  6120. });
  6121. }
  6122. this._mouseInit();
  6123. },
  6124. _destroy: function() {
  6125. this._mouseDestroy();
  6126. var wrapper,
  6127. _destroy = function(exp) {
  6128. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  6129. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
  6130. };
  6131. // TODO: Unwrap at same DOM position
  6132. if (this.elementIsWrapper) {
  6133. _destroy(this.element);
  6134. wrapper = this.element;
  6135. this.originalElement.css({
  6136. position: wrapper.css("position"),
  6137. width: wrapper.outerWidth(),
  6138. height: wrapper.outerHeight(),
  6139. top: wrapper.css("top"),
  6140. left: wrapper.css("left")
  6141. }).insertAfter( wrapper );
  6142. wrapper.remove();
  6143. }
  6144. this.originalElement.css("resize", this.originalResizeStyle);
  6145. _destroy(this.originalElement);
  6146. return this;
  6147. },
  6148. _mouseCapture: function(event) {
  6149. var i, handle,
  6150. capture = false;
  6151. for (i in this.handles) {
  6152. handle = $(this.handles[i])[0];
  6153. if (handle === event.target || $.contains(handle, event.target)) {
  6154. capture = true;
  6155. }
  6156. }
  6157. return !this.options.disabled && capture;
  6158. },
  6159. _mouseStart: function(event) {
  6160. var curleft, curtop, cursor,
  6161. o = this.options,
  6162. el = this.element;
  6163. this.resizing = true;
  6164. this._renderProxy();
  6165. curleft = this._num(this.helper.css("left"));
  6166. curtop = this._num(this.helper.css("top"));
  6167. if (o.containment) {
  6168. curleft += $(o.containment).scrollLeft() || 0;
  6169. curtop += $(o.containment).scrollTop() || 0;
  6170. }
  6171. this.offset = this.helper.offset();
  6172. this.position = { left: curleft, top: curtop };
  6173. this.size = this._helper ? { width: this.helper.width(), height: this.helper.height() } : { width: el.width(), height: el.height() };
  6174. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  6175. this.originalPosition = { left: curleft, top: curtop };
  6176. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  6177. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  6178. this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  6179. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  6180. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  6181. el.addClass("ui-resizable-resizing");
  6182. this._propagate("start", event);
  6183. return true;
  6184. },
  6185. _mouseDrag: function(event) {
  6186. var data,
  6187. el = this.helper, props = {},
  6188. smp = this.originalMousePosition,
  6189. a = this.axis,
  6190. dx = (event.pageX-smp.left)||0,
  6191. dy = (event.pageY-smp.top)||0,
  6192. trigger = this._change[a];
  6193. this.prevPosition = {
  6194. top: this.position.top,
  6195. left: this.position.left
  6196. };
  6197. this.prevSize = {
  6198. width: this.size.width,
  6199. height: this.size.height
  6200. };
  6201. if (!trigger) {
  6202. return false;
  6203. }
  6204. data = trigger.apply(this, [event, dx, dy]);
  6205. this._updateVirtualBoundaries(event.shiftKey);
  6206. if (this._aspectRatio || event.shiftKey) {
  6207. data = this._updateRatio(data, event);
  6208. }
  6209. data = this._respectSize(data, event);
  6210. this._updateCache(data);
  6211. this._propagate("resize", event);
  6212. if ( this.position.top !== this.prevPosition.top ) {
  6213. props.top = this.position.top + "px";
  6214. }
  6215. if ( this.position.left !== this.prevPosition.left ) {
  6216. props.left = this.position.left + "px";
  6217. }
  6218. if ( this.size.width !== this.prevSize.width ) {
  6219. props.width = this.size.width + "px";
  6220. }
  6221. if ( this.size.height !== this.prevSize.height ) {
  6222. props.height = this.size.height + "px";
  6223. }
  6224. el.css( props );
  6225. if ( !this._helper && this._proportionallyResizeElements.length ) {
  6226. this._proportionallyResize();
  6227. }
  6228. if ( !$.isEmptyObject( props ) ) {
  6229. this._trigger( "resize", event, this.ui() );
  6230. }
  6231. return false;
  6232. },
  6233. _mouseStop: function(event) {
  6234. this.resizing = false;
  6235. var pr, ista, soffseth, soffsetw, s, left, top,
  6236. o = this.options, that = this;
  6237. if(this._helper) {
  6238. pr = this._proportionallyResizeElements;
  6239. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  6240. soffseth = ista && this._hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
  6241. soffsetw = ista ? 0 : that.sizeDiff.width;
  6242. s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
  6243. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
  6244. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  6245. if (!o.animate) {
  6246. this.element.css($.extend(s, { top: top, left: left }));
  6247. }
  6248. that.helper.height(that.size.height);
  6249. that.helper.width(that.size.width);
  6250. if (this._helper && !o.animate) {
  6251. this._proportionallyResize();
  6252. }
  6253. }
  6254. $("body").css("cursor", "auto");
  6255. this.element.removeClass("ui-resizable-resizing");
  6256. this._propagate("stop", event);
  6257. if (this._helper) {
  6258. this.helper.remove();
  6259. }
  6260. return false;
  6261. },
  6262. _updateVirtualBoundaries: function(forceAspectRatio) {
  6263. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  6264. o = this.options;
  6265. b = {
  6266. minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
  6267. maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  6268. minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
  6269. maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
  6270. };
  6271. if(this._aspectRatio || forceAspectRatio) {
  6272. pMinWidth = b.minHeight * this.aspectRatio;
  6273. pMinHeight = b.minWidth / this.aspectRatio;
  6274. pMaxWidth = b.maxHeight * this.aspectRatio;
  6275. pMaxHeight = b.maxWidth / this.aspectRatio;
  6276. if(pMinWidth > b.minWidth) {
  6277. b.minWidth = pMinWidth;
  6278. }
  6279. if(pMinHeight > b.minHeight) {
  6280. b.minHeight = pMinHeight;
  6281. }
  6282. if(pMaxWidth < b.maxWidth) {
  6283. b.maxWidth = pMaxWidth;
  6284. }
  6285. if(pMaxHeight < b.maxHeight) {
  6286. b.maxHeight = pMaxHeight;
  6287. }
  6288. }
  6289. this._vBoundaries = b;
  6290. },
  6291. _updateCache: function(data) {
  6292. this.offset = this.helper.offset();
  6293. if (this._isNumber(data.left)) {
  6294. this.position.left = data.left;
  6295. }
  6296. if (this._isNumber(data.top)) {
  6297. this.position.top = data.top;
  6298. }
  6299. if (this._isNumber(data.height)) {
  6300. this.size.height = data.height;
  6301. }
  6302. if (this._isNumber(data.width)) {
  6303. this.size.width = data.width;
  6304. }
  6305. },
  6306. _updateRatio: function( data ) {
  6307. var cpos = this.position,
  6308. csize = this.size,
  6309. a = this.axis;
  6310. if (this._isNumber(data.height)) {
  6311. data.width = (data.height * this.aspectRatio);
  6312. } else if (this._isNumber(data.width)) {
  6313. data.height = (data.width / this.aspectRatio);
  6314. }
  6315. if (a === "sw") {
  6316. data.left = cpos.left + (csize.width - data.width);
  6317. data.top = null;
  6318. }
  6319. if (a === "nw") {
  6320. data.top = cpos.top + (csize.height - data.height);
  6321. data.left = cpos.left + (csize.width - data.width);
  6322. }
  6323. return data;
  6324. },
  6325. _respectSize: function( data ) {
  6326. var o = this._vBoundaries,
  6327. a = this.axis,
  6328. ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  6329. isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  6330. dw = this.originalPosition.left + this.originalSize.width,
  6331. dh = this.position.top + this.size.height,
  6332. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  6333. if (isminw) {
  6334. data.width = o.minWidth;
  6335. }
  6336. if (isminh) {
  6337. data.height = o.minHeight;
  6338. }
  6339. if (ismaxw) {
  6340. data.width = o.maxWidth;
  6341. }
  6342. if (ismaxh) {
  6343. data.height = o.maxHeight;
  6344. }
  6345. if (isminw && cw) {
  6346. data.left = dw - o.minWidth;
  6347. }
  6348. if (ismaxw && cw) {
  6349. data.left = dw - o.maxWidth;
  6350. }
  6351. if (isminh && ch) {
  6352. data.top = dh - o.minHeight;
  6353. }
  6354. if (ismaxh && ch) {
  6355. data.top = dh - o.maxHeight;
  6356. }
  6357. // Fixing jump error on top/left - bug #2330
  6358. if (!data.width && !data.height && !data.left && data.top) {
  6359. data.top = null;
  6360. } else if (!data.width && !data.height && !data.top && data.left) {
  6361. data.left = null;
  6362. }
  6363. return data;
  6364. },
  6365. _proportionallyResize: function() {
  6366. if (!this._proportionallyResizeElements.length) {
  6367. return;
  6368. }
  6369. var i, j, borders, paddings, prel,
  6370. element = this.helper || this.element;
  6371. for ( i=0; i < this._proportionallyResizeElements.length; i++) {
  6372. prel = this._proportionallyResizeElements[i];
  6373. if (!this.borderDif) {
  6374. this.borderDif = [];
  6375. borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
  6376. paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
  6377. for ( j = 0; j < borders.length; j++ ) {
  6378. this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
  6379. }
  6380. }
  6381. prel.css({
  6382. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  6383. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  6384. });
  6385. }
  6386. },
  6387. _renderProxy: function() {
  6388. var el = this.element, o = this.options;
  6389. this.elementOffset = el.offset();
  6390. if(this._helper) {
  6391. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  6392. this.helper.addClass(this._helper).css({
  6393. width: this.element.outerWidth() - 1,
  6394. height: this.element.outerHeight() - 1,
  6395. position: "absolute",
  6396. left: this.elementOffset.left +"px",
  6397. top: this.elementOffset.top +"px",
  6398. zIndex: ++o.zIndex //TODO: Don't modify option
  6399. });
  6400. this.helper
  6401. .appendTo("body")
  6402. .disableSelection();
  6403. } else {
  6404. this.helper = this.element;
  6405. }
  6406. },
  6407. _change: {
  6408. e: function(event, dx) {
  6409. return { width: this.originalSize.width + dx };
  6410. },
  6411. w: function(event, dx) {
  6412. var cs = this.originalSize, sp = this.originalPosition;
  6413. return { left: sp.left + dx, width: cs.width - dx };
  6414. },
  6415. n: function(event, dx, dy) {
  6416. var cs = this.originalSize, sp = this.originalPosition;
  6417. return { top: sp.top + dy, height: cs.height - dy };
  6418. },
  6419. s: function(event, dx, dy) {
  6420. return { height: this.originalSize.height + dy };
  6421. },
  6422. se: function(event, dx, dy) {
  6423. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  6424. },
  6425. sw: function(event, dx, dy) {
  6426. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  6427. },
  6428. ne: function(event, dx, dy) {
  6429. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  6430. },
  6431. nw: function(event, dx, dy) {
  6432. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  6433. }
  6434. },
  6435. _propagate: function(n, event) {
  6436. $.ui.plugin.call(this, n, [event, this.ui()]);
  6437. (n !== "resize" && this._trigger(n, event, this.ui()));
  6438. },
  6439. plugins: {},
  6440. ui: function() {
  6441. return {
  6442. originalElement: this.originalElement,
  6443. element: this.element,
  6444. helper: this.helper,
  6445. position: this.position,
  6446. size: this.size,
  6447. originalSize: this.originalSize,
  6448. originalPosition: this.originalPosition,
  6449. prevSize: this.prevSize,
  6450. prevPosition: this.prevPosition
  6451. };
  6452. }
  6453. });
  6454. /*
  6455. * Resizable Extensions
  6456. */
  6457. $.ui.plugin.add("resizable", "animate", {
  6458. stop: function( event ) {
  6459. var that = $(this).resizable( "instance" ),
  6460. o = that.options,
  6461. pr = that._proportionallyResizeElements,
  6462. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  6463. soffseth = ista && that._hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  6464. soffsetw = ista ? 0 : that.sizeDiff.width,
  6465. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  6466. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
  6467. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  6468. that.element.animate(
  6469. $.extend(style, top && left ? { top: top, left: left } : {}), {
  6470. duration: o.animateDuration,
  6471. easing: o.animateEasing,
  6472. step: function() {
  6473. var data = {
  6474. width: parseInt(that.element.css("width"), 10),
  6475. height: parseInt(that.element.css("height"), 10),
  6476. top: parseInt(that.element.css("top"), 10),
  6477. left: parseInt(that.element.css("left"), 10)
  6478. };
  6479. if (pr && pr.length) {
  6480. $(pr[0]).css({ width: data.width, height: data.height });
  6481. }
  6482. // propagating resize, and updating values for each animation step
  6483. that._updateCache(data);
  6484. that._propagate("resize", event);
  6485. }
  6486. }
  6487. );
  6488. }
  6489. });
  6490. $.ui.plugin.add( "resizable", "containment", {
  6491. start: function() {
  6492. var element, p, co, ch, cw, width, height,
  6493. that = $( this ).resizable( "instance" ),
  6494. o = that.options,
  6495. el = that.element,
  6496. oc = o.containment,
  6497. ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  6498. if ( !ce ) {
  6499. return;
  6500. }
  6501. that.containerElement = $( ce );
  6502. if ( /document/.test( oc ) || oc === document ) {
  6503. that.containerOffset = {
  6504. left: 0,
  6505. top: 0
  6506. };
  6507. that.containerPosition = {
  6508. left: 0,
  6509. top: 0
  6510. };
  6511. that.parentData = {
  6512. element: $( document ),
  6513. left: 0,
  6514. top: 0,
  6515. width: $( document ).width(),
  6516. height: $( document ).height() || document.body.parentNode.scrollHeight
  6517. };
  6518. } else {
  6519. element = $( ce );
  6520. p = [];
  6521. $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {
  6522. p[ i ] = that._num( element.css( "padding" + name ) );
  6523. });
  6524. that.containerOffset = element.offset();
  6525. that.containerPosition = element.position();
  6526. that.containerSize = {
  6527. height: ( element.innerHeight() - p[ 3 ] ),
  6528. width: ( element.innerWidth() - p[ 1 ] )
  6529. };
  6530. co = that.containerOffset;
  6531. ch = that.containerSize.height;
  6532. cw = that.containerSize.width;
  6533. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  6534. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  6535. that.parentData = {
  6536. element: ce,
  6537. left: co.left,
  6538. top: co.top,
  6539. width: width,
  6540. height: height
  6541. };
  6542. }
  6543. },
  6544. resize: function( event, ui ) {
  6545. var woset, hoset, isParent, isOffsetRelative,
  6546. that = $( this ).resizable( "instance" ),
  6547. o = that.options,
  6548. co = that.containerOffset,
  6549. cp = that.position,
  6550. pRatio = that._aspectRatio || event.shiftKey,
  6551. cop = {
  6552. top: 0,
  6553. left: 0
  6554. },
  6555. ce = that.containerElement,
  6556. continueResize = true;
  6557. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  6558. cop = co;
  6559. }
  6560. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  6561. that.size.width = that.size.width + ( that._helper ? ( that.position.left - co.left ) : ( that.position.left - cop.left ) );
  6562. if ( pRatio ) {
  6563. that.size.height = that.size.width / that.aspectRatio;
  6564. continueResize = false;
  6565. }
  6566. that.position.left = o.helper ? co.left : 0;
  6567. }
  6568. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  6569. that.size.height = that.size.height + ( that._helper ? ( that.position.top - co.top ) : that.position.top );
  6570. if ( pRatio ) {
  6571. that.size.width = that.size.height * that.aspectRatio;
  6572. continueResize = false;
  6573. }
  6574. that.position.top = that._helper ? co.top : 0;
  6575. }
  6576. that.offset.left = that.parentData.left + that.position.left;
  6577. that.offset.top = that.parentData.top + that.position.top;
  6578. woset = Math.abs( ( that._helper ? that.offset.left - cop.left : ( that.offset.left - co.left ) ) + that.sizeDiff.width );
  6579. hoset = Math.abs( ( that._helper ? that.offset.top - cop.top : ( that.offset.top - co.top ) ) + that.sizeDiff.height );
  6580. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  6581. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  6582. if ( isParent && isOffsetRelative ) {
  6583. woset -= Math.abs( that.parentData.left );
  6584. }
  6585. if ( woset + that.size.width >= that.parentData.width ) {
  6586. that.size.width = that.parentData.width - woset;
  6587. if ( pRatio ) {
  6588. that.size.height = that.size.width / that.aspectRatio;
  6589. continueResize = false;
  6590. }
  6591. }
  6592. if ( hoset + that.size.height >= that.parentData.height ) {
  6593. that.size.height = that.parentData.height - hoset;
  6594. if ( pRatio ) {
  6595. that.size.width = that.size.height * that.aspectRatio;
  6596. continueResize = false;
  6597. }
  6598. }
  6599. if ( !continueResize ){
  6600. that.position.left = ui.prevPosition.left;
  6601. that.position.top = ui.prevPosition.top;
  6602. that.size.width = ui.prevSize.width;
  6603. that.size.height = ui.prevSize.height;
  6604. }
  6605. },
  6606. stop: function(){
  6607. var that = $( this ).resizable( "instance" ),
  6608. o = that.options,
  6609. co = that.containerOffset,
  6610. cop = that.containerPosition,
  6611. ce = that.containerElement,
  6612. helper = $( that.helper ),
  6613. ho = helper.offset(),
  6614. w = helper.outerWidth() - that.sizeDiff.width,
  6615. h = helper.outerHeight() - that.sizeDiff.height;
  6616. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  6617. $( this ).css({
  6618. left: ho.left - cop.left - co.left,
  6619. width: w,
  6620. height: h
  6621. });
  6622. }
  6623. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  6624. $( this ).css({
  6625. left: ho.left - cop.left - co.left,
  6626. width: w,
  6627. height: h
  6628. });
  6629. }
  6630. }
  6631. });
  6632. $.ui.plugin.add("resizable", "alsoResize", {
  6633. start: function () {
  6634. var that = $(this).resizable( "instance" ),
  6635. o = that.options,
  6636. _store = function (exp) {
  6637. $(exp).each(function() {
  6638. var el = $(this);
  6639. el.data("ui-resizable-alsoresize", {
  6640. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  6641. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  6642. });
  6643. });
  6644. };
  6645. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  6646. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  6647. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  6648. }else{
  6649. _store(o.alsoResize);
  6650. }
  6651. },
  6652. resize: function (event, ui) {
  6653. var that = $(this).resizable( "instance" ),
  6654. o = that.options,
  6655. os = that.originalSize,
  6656. op = that.originalPosition,
  6657. delta = {
  6658. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  6659. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  6660. },
  6661. _alsoResize = function (exp, c) {
  6662. $(exp).each(function() {
  6663. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  6664. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
  6665. $.each(css, function (i, prop) {
  6666. var sum = (start[prop]||0) + (delta[prop]||0);
  6667. if (sum && sum >= 0) {
  6668. style[prop] = sum || null;
  6669. }
  6670. });
  6671. el.css(style);
  6672. });
  6673. };
  6674. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  6675. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  6676. }else{
  6677. _alsoResize(o.alsoResize);
  6678. }
  6679. },
  6680. stop: function () {
  6681. $(this).removeData("resizable-alsoresize");
  6682. }
  6683. });
  6684. $.ui.plugin.add("resizable", "ghost", {
  6685. start: function() {
  6686. var that = $(this).resizable( "instance" ), o = that.options, cs = that.size;
  6687. that.ghost = that.originalElement.clone();
  6688. that.ghost
  6689. .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  6690. .addClass("ui-resizable-ghost")
  6691. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  6692. that.ghost.appendTo(that.helper);
  6693. },
  6694. resize: function(){
  6695. var that = $(this).resizable( "instance" );
  6696. if (that.ghost) {
  6697. that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
  6698. }
  6699. },
  6700. stop: function() {
  6701. var that = $(this).resizable( "instance" );
  6702. if (that.ghost && that.helper) {
  6703. that.helper.get(0).removeChild(that.ghost.get(0));
  6704. }
  6705. }
  6706. });
  6707. $.ui.plugin.add("resizable", "grid", {
  6708. resize: function() {
  6709. var that = $(this).resizable( "instance" ),
  6710. o = that.options,
  6711. cs = that.size,
  6712. os = that.originalSize,
  6713. op = that.originalPosition,
  6714. a = that.axis,
  6715. grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
  6716. gridX = (grid[0]||1),
  6717. gridY = (grid[1]||1),
  6718. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  6719. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  6720. newWidth = os.width + ox,
  6721. newHeight = os.height + oy,
  6722. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  6723. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  6724. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  6725. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  6726. o.grid = grid;
  6727. if (isMinWidth) {
  6728. newWidth = newWidth + gridX;
  6729. }
  6730. if (isMinHeight) {
  6731. newHeight = newHeight + gridY;
  6732. }
  6733. if (isMaxWidth) {
  6734. newWidth = newWidth - gridX;
  6735. }
  6736. if (isMaxHeight) {
  6737. newHeight = newHeight - gridY;
  6738. }
  6739. if (/^(se|s|e)$/.test(a)) {
  6740. that.size.width = newWidth;
  6741. that.size.height = newHeight;
  6742. } else if (/^(ne)$/.test(a)) {
  6743. that.size.width = newWidth;
  6744. that.size.height = newHeight;
  6745. that.position.top = op.top - oy;
  6746. } else if (/^(sw)$/.test(a)) {
  6747. that.size.width = newWidth;
  6748. that.size.height = newHeight;
  6749. that.position.left = op.left - ox;
  6750. } else {
  6751. if ( newHeight - gridY > 0 ) {
  6752. that.size.height = newHeight;
  6753. that.position.top = op.top - oy;
  6754. } else {
  6755. that.size.height = gridY;
  6756. that.position.top = op.top + os.height - gridY;
  6757. }
  6758. if ( newWidth - gridX > 0 ) {
  6759. that.size.width = newWidth;
  6760. that.position.left = op.left - ox;
  6761. } else {
  6762. that.size.width = gridX;
  6763. that.position.left = op.left + os.width - gridX;
  6764. }
  6765. }
  6766. }
  6767. });
  6768. var resizable = $.ui.resizable;
  6769. /*!
  6770. * jQuery UI Dialog 1.11.0
  6771. * http://jqueryui.com
  6772. *
  6773. * Copyright 2014 jQuery Foundation and other contributors
  6774. * Released under the MIT license.
  6775. * http://jquery.org/license
  6776. *
  6777. * http://api.jqueryui.com/dialog/
  6778. */
  6779. var dialog = $.widget( "ui.dialog", {
  6780. version: "1.11.0",
  6781. options: {
  6782. appendTo: "body",
  6783. autoOpen: true,
  6784. buttons: [],
  6785. closeOnEscape: true,
  6786. closeText: "Close",
  6787. dialogClass: "",
  6788. draggable: true,
  6789. hide: null,
  6790. height: "auto",
  6791. maxHeight: null,
  6792. maxWidth: null,
  6793. minHeight: 150,
  6794. minWidth: 150,
  6795. modal: false,
  6796. position: {
  6797. my: "center",
  6798. at: "center",
  6799. of: window,
  6800. collision: "fit",
  6801. // Ensure the titlebar is always visible
  6802. using: function( pos ) {
  6803. var topOffset = $( this ).css( pos ).offset().top;
  6804. if ( topOffset < 0 ) {
  6805. $( this ).css( "top", pos.top - topOffset );
  6806. }
  6807. }
  6808. },
  6809. resizable: true,
  6810. show: null,
  6811. title: null,
  6812. width: 300,
  6813. // callbacks
  6814. beforeClose: null,
  6815. close: null,
  6816. drag: null,
  6817. dragStart: null,
  6818. dragStop: null,
  6819. focus: null,
  6820. open: null,
  6821. resize: null,
  6822. resizeStart: null,
  6823. resizeStop: null
  6824. },
  6825. sizeRelatedOptions: {
  6826. buttons: true,
  6827. height: true,
  6828. maxHeight: true,
  6829. maxWidth: true,
  6830. minHeight: true,
  6831. minWidth: true,
  6832. width: true
  6833. },
  6834. resizableRelatedOptions: {
  6835. maxHeight: true,
  6836. maxWidth: true,
  6837. minHeight: true,
  6838. minWidth: true
  6839. },
  6840. _create: function() {
  6841. this.originalCss = {
  6842. display: this.element[ 0 ].style.display,
  6843. width: this.element[ 0 ].style.width,
  6844. minHeight: this.element[ 0 ].style.minHeight,
  6845. maxHeight: this.element[ 0 ].style.maxHeight,
  6846. height: this.element[ 0 ].style.height
  6847. };
  6848. this.originalPosition = {
  6849. parent: this.element.parent(),
  6850. index: this.element.parent().children().index( this.element )
  6851. };
  6852. this.originalTitle = this.element.attr( "title" );
  6853. this.options.title = this.options.title || this.originalTitle;
  6854. this._createWrapper();
  6855. this.element
  6856. .show()
  6857. .removeAttr( "title" )
  6858. .addClass( "ui-dialog-content ui-widget-content" )
  6859. .appendTo( this.uiDialog );
  6860. this._createTitlebar();
  6861. this._createButtonPane();
  6862. if ( this.options.draggable && $.fn.draggable ) {
  6863. this._makeDraggable();
  6864. }
  6865. if ( this.options.resizable && $.fn.resizable ) {
  6866. this._makeResizable();
  6867. }
  6868. this._isOpen = false;
  6869. this._trackFocus();
  6870. },
  6871. _init: function() {
  6872. if ( this.options.autoOpen ) {
  6873. this.open();
  6874. }
  6875. },
  6876. _appendTo: function() {
  6877. var element = this.options.appendTo;
  6878. if ( element && (element.jquery || element.nodeType) ) {
  6879. return $( element );
  6880. }
  6881. return this.document.find( element || "body" ).eq( 0 );
  6882. },
  6883. _destroy: function() {
  6884. var next,
  6885. originalPosition = this.originalPosition;
  6886. this._destroyOverlay();
  6887. this.element
  6888. .removeUniqueId()
  6889. .removeClass( "ui-dialog-content ui-widget-content" )
  6890. .css( this.originalCss )
  6891. // Without detaching first, the following becomes really slow
  6892. .detach();
  6893. this.uiDialog.stop( true, true ).remove();
  6894. if ( this.originalTitle ) {
  6895. this.element.attr( "title", this.originalTitle );
  6896. }
  6897. next = originalPosition.parent.children().eq( originalPosition.index );
  6898. // Don't try to place the dialog next to itself (#8613)
  6899. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  6900. next.before( this.element );
  6901. } else {
  6902. originalPosition.parent.append( this.element );
  6903. }
  6904. },
  6905. widget: function() {
  6906. return this.uiDialog;
  6907. },
  6908. disable: $.noop,
  6909. enable: $.noop,
  6910. close: function( event ) {
  6911. var activeElement,
  6912. that = this;
  6913. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  6914. return;
  6915. }
  6916. this._isOpen = false;
  6917. this._focusedElement = null;
  6918. this._destroyOverlay();
  6919. this._untrackInstance();
  6920. if ( !this.opener.filter( ":focusable" ).focus().length ) {
  6921. // support: IE9
  6922. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  6923. try {
  6924. activeElement = this.document[ 0 ].activeElement;
  6925. // Support: IE9, IE10
  6926. // If the <body> is blurred, IE will switch windows, see #4520
  6927. if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {
  6928. // Hiding a focused element doesn't trigger blur in WebKit
  6929. // so in case we have nothing to focus on, explicitly blur the active element
  6930. // https://bugs.webkit.org/show_bug.cgi?id=47182
  6931. $( activeElement ).blur();
  6932. }
  6933. } catch ( error ) {}
  6934. }
  6935. this._hide( this.uiDialog, this.options.hide, function() {
  6936. that._trigger( "close", event );
  6937. });
  6938. },
  6939. isOpen: function() {
  6940. return this._isOpen;
  6941. },
  6942. moveToTop: function() {
  6943. this._moveToTop();
  6944. },
  6945. _moveToTop: function( event, silent ) {
  6946. var moved = false,
  6947. zIndicies = this.uiDialog.siblings( ".ui-front:visible" ).map(function() {
  6948. return +$( this ).css( "z-index" );
  6949. }).get(),
  6950. zIndexMax = Math.max.apply( null, zIndicies );
  6951. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  6952. this.uiDialog.css( "z-index", zIndexMax + 1 );
  6953. moved = true;
  6954. }
  6955. if ( moved && !silent ) {
  6956. this._trigger( "focus", event );
  6957. }
  6958. return moved;
  6959. },
  6960. open: function() {
  6961. var that = this;
  6962. if ( this._isOpen ) {
  6963. if ( this._moveToTop() ) {
  6964. this._focusTabbable();
  6965. }
  6966. return;
  6967. }
  6968. this._isOpen = true;
  6969. this.opener = $( this.document[ 0 ].activeElement );
  6970. this._size();
  6971. this._position();
  6972. this._createOverlay();
  6973. this._moveToTop( null, true );
  6974. this._show( this.uiDialog, this.options.show, function() {
  6975. that._focusTabbable();
  6976. that._trigger( "focus" );
  6977. });
  6978. this._trigger( "open" );
  6979. },
  6980. _focusTabbable: function() {
  6981. // Set focus to the first match:
  6982. // 1. An element that was focused previously
  6983. // 2. First element inside the dialog matching [autofocus]
  6984. // 3. Tabbable element inside the content element
  6985. // 4. Tabbable element inside the buttonpane
  6986. // 5. The close button
  6987. // 6. The dialog itself
  6988. var hasFocus = this._focusedElement;
  6989. if ( !hasFocus ) {
  6990. hasFocus = this.element.find( "[autofocus]" );
  6991. }
  6992. if ( !hasFocus.length ) {
  6993. hasFocus = this.element.find( ":tabbable" );
  6994. }
  6995. if ( !hasFocus.length ) {
  6996. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  6997. }
  6998. if ( !hasFocus.length ) {
  6999. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  7000. }
  7001. if ( !hasFocus.length ) {
  7002. hasFocus = this.uiDialog;
  7003. }
  7004. hasFocus.eq( 0 ).focus();
  7005. },
  7006. _keepFocus: function( event ) {
  7007. function checkFocus() {
  7008. var activeElement = this.document[0].activeElement,
  7009. isActive = this.uiDialog[0] === activeElement ||
  7010. $.contains( this.uiDialog[0], activeElement );
  7011. if ( !isActive ) {
  7012. this._focusTabbable();
  7013. }
  7014. }
  7015. event.preventDefault();
  7016. checkFocus.call( this );
  7017. // support: IE
  7018. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  7019. // so we check again later
  7020. this._delay( checkFocus );
  7021. },
  7022. _createWrapper: function() {
  7023. this.uiDialog = $("<div>")
  7024. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  7025. this.options.dialogClass )
  7026. .hide()
  7027. .attr({
  7028. // Setting tabIndex makes the div focusable
  7029. tabIndex: -1,
  7030. role: "dialog"
  7031. })
  7032. .appendTo( this._appendTo() );
  7033. this._on( this.uiDialog, {
  7034. keydown: function( event ) {
  7035. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  7036. event.keyCode === $.ui.keyCode.ESCAPE ) {
  7037. event.preventDefault();
  7038. this.close( event );
  7039. return;
  7040. }
  7041. // prevent tabbing out of dialogs
  7042. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  7043. return;
  7044. }
  7045. var tabbables = this.uiDialog.find( ":tabbable" ),
  7046. first = tabbables.filter( ":first" ),
  7047. last = tabbables.filter( ":last" );
  7048. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  7049. this._delay(function() {
  7050. first.focus();
  7051. });
  7052. event.preventDefault();
  7053. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  7054. this._delay(function() {
  7055. last.focus();
  7056. });
  7057. event.preventDefault();
  7058. }
  7059. },
  7060. mousedown: function( event ) {
  7061. if ( this._moveToTop( event ) ) {
  7062. this._focusTabbable();
  7063. }
  7064. }
  7065. });
  7066. // We assume that any existing aria-describedby attribute means
  7067. // that the dialog content is marked up properly
  7068. // otherwise we brute force the content as the description
  7069. if ( !this.element.find( "[aria-describedby]" ).length ) {
  7070. this.uiDialog.attr({
  7071. "aria-describedby": this.element.uniqueId().attr( "id" )
  7072. });
  7073. }
  7074. },
  7075. _createTitlebar: function() {
  7076. var uiDialogTitle;
  7077. this.uiDialogTitlebar = $( "<div>" )
  7078. .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" )
  7079. .prependTo( this.uiDialog );
  7080. this._on( this.uiDialogTitlebar, {
  7081. mousedown: function( event ) {
  7082. // Don't prevent click on close button (#8838)
  7083. // Focusing a dialog that is partially scrolled out of view
  7084. // causes the browser to scroll it into view, preventing the click event
  7085. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  7086. // Dialog isn't getting focus when dragging (#8063)
  7087. this.uiDialog.focus();
  7088. }
  7089. }
  7090. });
  7091. // support: IE
  7092. // Use type="button" to prevent enter keypresses in textboxes from closing the
  7093. // dialog in IE (#9312)
  7094. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  7095. .button({
  7096. label: this.options.closeText,
  7097. icons: {
  7098. primary: "ui-icon-closethick"
  7099. },
  7100. text: false
  7101. })
  7102. .addClass( "ui-dialog-titlebar-close" )
  7103. .appendTo( this.uiDialogTitlebar );
  7104. this._on( this.uiDialogTitlebarClose, {
  7105. click: function( event ) {
  7106. event.preventDefault();
  7107. this.close( event );
  7108. }
  7109. });
  7110. uiDialogTitle = $( "<span>" )
  7111. .uniqueId()
  7112. .addClass( "ui-dialog-title" )
  7113. .prependTo( this.uiDialogTitlebar );
  7114. this._title( uiDialogTitle );
  7115. this.uiDialog.attr({
  7116. "aria-labelledby": uiDialogTitle.attr( "id" )
  7117. });
  7118. },
  7119. _title: function( title ) {
  7120. if ( !this.options.title ) {
  7121. title.html( "&#160;" );
  7122. }
  7123. title.text( this.options.title );
  7124. },
  7125. _createButtonPane: function() {
  7126. this.uiDialogButtonPane = $( "<div>" )
  7127. .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
  7128. this.uiButtonSet = $( "<div>" )
  7129. .addClass( "ui-dialog-buttonset" )
  7130. .appendTo( this.uiDialogButtonPane );
  7131. this._createButtons();
  7132. },
  7133. _createButtons: function() {
  7134. var that = this,
  7135. buttons = this.options.buttons;
  7136. // if we already have a button pane, remove it
  7137. this.uiDialogButtonPane.remove();
  7138. this.uiButtonSet.empty();
  7139. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  7140. this.uiDialog.removeClass( "ui-dialog-buttons" );
  7141. return;
  7142. }
  7143. $.each( buttons, function( name, props ) {
  7144. var click, buttonOptions;
  7145. props = $.isFunction( props ) ?
  7146. { click: props, text: name } :
  7147. props;
  7148. // Default to a non-submitting button
  7149. props = $.extend( { type: "button" }, props );
  7150. // Change the context for the click callback to be the main element
  7151. click = props.click;
  7152. props.click = function() {
  7153. click.apply( that.element[ 0 ], arguments );
  7154. };
  7155. buttonOptions = {
  7156. icons: props.icons,
  7157. text: props.showText
  7158. };
  7159. delete props.icons;
  7160. delete props.showText;
  7161. $( "<button></button>", props )
  7162. .button( buttonOptions )
  7163. .appendTo( that.uiButtonSet );
  7164. });
  7165. this.uiDialog.addClass( "ui-dialog-buttons" );
  7166. this.uiDialogButtonPane.appendTo( this.uiDialog );
  7167. },
  7168. _makeDraggable: function() {
  7169. var that = this,
  7170. options = this.options;
  7171. function filteredUi( ui ) {
  7172. return {
  7173. position: ui.position,
  7174. offset: ui.offset
  7175. };
  7176. }
  7177. this.uiDialog.draggable({
  7178. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  7179. handle: ".ui-dialog-titlebar",
  7180. containment: "document",
  7181. start: function( event, ui ) {
  7182. $( this ).addClass( "ui-dialog-dragging" );
  7183. that._blockFrames();
  7184. that._trigger( "dragStart", event, filteredUi( ui ) );
  7185. },
  7186. drag: function( event, ui ) {
  7187. that._trigger( "drag", event, filteredUi( ui ) );
  7188. },
  7189. stop: function( event, ui ) {
  7190. var left = ui.offset.left - that.document.scrollLeft(),
  7191. top = ui.offset.top - that.document.scrollTop();
  7192. options.position = {
  7193. my: "left top",
  7194. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  7195. "top" + (top >= 0 ? "+" : "") + top,
  7196. of: that.window
  7197. };
  7198. $( this ).removeClass( "ui-dialog-dragging" );
  7199. that._unblockFrames();
  7200. that._trigger( "dragStop", event, filteredUi( ui ) );
  7201. }
  7202. });
  7203. },
  7204. _makeResizable: function() {
  7205. var that = this,
  7206. options = this.options,
  7207. handles = options.resizable,
  7208. // .ui-resizable has position: relative defined in the stylesheet
  7209. // but dialogs have to use absolute or fixed positioning
  7210. position = this.uiDialog.css("position"),
  7211. resizeHandles = typeof handles === "string" ?
  7212. handles :
  7213. "n,e,s,w,se,sw,ne,nw";
  7214. function filteredUi( ui ) {
  7215. return {
  7216. originalPosition: ui.originalPosition,
  7217. originalSize: ui.originalSize,
  7218. position: ui.position,
  7219. size: ui.size
  7220. };
  7221. }
  7222. this.uiDialog.resizable({
  7223. cancel: ".ui-dialog-content",
  7224. containment: "document",
  7225. alsoResize: this.element,
  7226. maxWidth: options.maxWidth,
  7227. maxHeight: options.maxHeight,
  7228. minWidth: options.minWidth,
  7229. minHeight: this._minHeight(),
  7230. handles: resizeHandles,
  7231. start: function( event, ui ) {
  7232. $( this ).addClass( "ui-dialog-resizing" );
  7233. that._blockFrames();
  7234. that._trigger( "resizeStart", event, filteredUi( ui ) );
  7235. },
  7236. resize: function( event, ui ) {
  7237. that._trigger( "resize", event, filteredUi( ui ) );
  7238. },
  7239. stop: function( event, ui ) {
  7240. var offset = that.uiDialog.offset(),
  7241. left = offset.left - that.document.scrollLeft(),
  7242. top = offset.top - that.document.scrollTop();
  7243. options.height = that.uiDialog.height();
  7244. options.width = that.uiDialog.width();
  7245. options.position = {
  7246. my: "left top",
  7247. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  7248. "top" + (top >= 0 ? "+" : "") + top,
  7249. of: that.window
  7250. };
  7251. $( this ).removeClass( "ui-dialog-resizing" );
  7252. that._unblockFrames();
  7253. that._trigger( "resizeStop", event, filteredUi( ui ) );
  7254. }
  7255. })
  7256. .css( "position", position );
  7257. },
  7258. _trackFocus: function() {
  7259. this._on( this.widget(), {
  7260. "focusin": function( event ) {
  7261. this._untrackInstance();
  7262. this._trackingInstances().unshift( this );
  7263. this._focusedElement = $( event.target );
  7264. }
  7265. });
  7266. },
  7267. _untrackInstance: function() {
  7268. var instances = this._trackingInstances(),
  7269. exists = $.inArray( this, instances );
  7270. if ( exists !== -1 ) {
  7271. instances.splice( exists, 1 );
  7272. }
  7273. },
  7274. _trackingInstances: function() {
  7275. var instances = this.document.data( "ui-dialog-instances" );
  7276. if ( !instances ) {
  7277. instances = [];
  7278. this.document.data( "ui-dialog-instances", instances );
  7279. }
  7280. return instances;
  7281. },
  7282. _minHeight: function() {
  7283. var options = this.options;
  7284. return options.height === "auto" ?
  7285. options.minHeight :
  7286. Math.min( options.minHeight, options.height );
  7287. },
  7288. _position: function() {
  7289. // Need to show the dialog to get the actual offset in the position plugin
  7290. var isVisible = this.uiDialog.is( ":visible" );
  7291. if ( !isVisible ) {
  7292. this.uiDialog.show();
  7293. }
  7294. this.uiDialog.position( this.options.position );
  7295. if ( !isVisible ) {
  7296. this.uiDialog.hide();
  7297. }
  7298. },
  7299. _setOptions: function( options ) {
  7300. var that = this,
  7301. resize = false,
  7302. resizableOptions = {};
  7303. $.each( options, function( key, value ) {
  7304. that._setOption( key, value );
  7305. if ( key in that.sizeRelatedOptions ) {
  7306. resize = true;
  7307. }
  7308. if ( key in that.resizableRelatedOptions ) {
  7309. resizableOptions[ key ] = value;
  7310. }
  7311. });
  7312. if ( resize ) {
  7313. this._size();
  7314. this._position();
  7315. }
  7316. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  7317. this.uiDialog.resizable( "option", resizableOptions );
  7318. }
  7319. },
  7320. _setOption: function( key, value ) {
  7321. var isDraggable, isResizable,
  7322. uiDialog = this.uiDialog;
  7323. if ( key === "dialogClass" ) {
  7324. uiDialog
  7325. .removeClass( this.options.dialogClass )
  7326. .addClass( value );
  7327. }
  7328. if ( key === "disabled" ) {
  7329. return;
  7330. }
  7331. this._super( key, value );
  7332. if ( key === "appendTo" ) {
  7333. this.uiDialog.appendTo( this._appendTo() );
  7334. }
  7335. if ( key === "buttons" ) {
  7336. this._createButtons();
  7337. }
  7338. if ( key === "closeText" ) {
  7339. this.uiDialogTitlebarClose.button({
  7340. // Ensure that we always pass a string
  7341. label: "" + value
  7342. });
  7343. }
  7344. if ( key === "draggable" ) {
  7345. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  7346. if ( isDraggable && !value ) {
  7347. uiDialog.draggable( "destroy" );
  7348. }
  7349. if ( !isDraggable && value ) {
  7350. this._makeDraggable();
  7351. }
  7352. }
  7353. if ( key === "position" ) {
  7354. this._position();
  7355. }
  7356. if ( key === "resizable" ) {
  7357. // currently resizable, becoming non-resizable
  7358. isResizable = uiDialog.is( ":data(ui-resizable)" );
  7359. if ( isResizable && !value ) {
  7360. uiDialog.resizable( "destroy" );
  7361. }
  7362. // currently resizable, changing handles
  7363. if ( isResizable && typeof value === "string" ) {
  7364. uiDialog.resizable( "option", "handles", value );
  7365. }
  7366. // currently non-resizable, becoming resizable
  7367. if ( !isResizable && value !== false ) {
  7368. this._makeResizable();
  7369. }
  7370. }
  7371. if ( key === "title" ) {
  7372. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  7373. }
  7374. },
  7375. _size: function() {
  7376. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  7377. // divs will both have width and height set, so we need to reset them
  7378. var nonContentHeight, minContentHeight, maxContentHeight,
  7379. options = this.options;
  7380. // Reset content sizing
  7381. this.element.show().css({
  7382. width: "auto",
  7383. minHeight: 0,
  7384. maxHeight: "none",
  7385. height: 0
  7386. });
  7387. if ( options.minWidth > options.width ) {
  7388. options.width = options.minWidth;
  7389. }
  7390. // reset wrapper sizing
  7391. // determine the height of all the non-content elements
  7392. nonContentHeight = this.uiDialog.css({
  7393. height: "auto",
  7394. width: options.width
  7395. })
  7396. .outerHeight();
  7397. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  7398. maxContentHeight = typeof options.maxHeight === "number" ?
  7399. Math.max( 0, options.maxHeight - nonContentHeight ) :
  7400. "none";
  7401. if ( options.height === "auto" ) {
  7402. this.element.css({
  7403. minHeight: minContentHeight,
  7404. maxHeight: maxContentHeight,
  7405. height: "auto"
  7406. });
  7407. } else {
  7408. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  7409. }
  7410. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  7411. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  7412. }
  7413. },
  7414. _blockFrames: function() {
  7415. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  7416. var iframe = $( this );
  7417. return $( "<div>" )
  7418. .css({
  7419. position: "absolute",
  7420. width: iframe.outerWidth(),
  7421. height: iframe.outerHeight()
  7422. })
  7423. .appendTo( iframe.parent() )
  7424. .offset( iframe.offset() )[0];
  7425. });
  7426. },
  7427. _unblockFrames: function() {
  7428. if ( this.iframeBlocks ) {
  7429. this.iframeBlocks.remove();
  7430. delete this.iframeBlocks;
  7431. }
  7432. },
  7433. _allowInteraction: function( event ) {
  7434. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  7435. return true;
  7436. }
  7437. // TODO: Remove hack when datepicker implements
  7438. // the .ui-front logic (#8989)
  7439. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  7440. },
  7441. _createOverlay: function() {
  7442. if ( !this.options.modal ) {
  7443. return;
  7444. }
  7445. // We use a delay in case the overlay is created from an
  7446. // event that we're going to be cancelling (#2804)
  7447. var isOpening = true;
  7448. this._delay(function() {
  7449. isOpening = false;
  7450. });
  7451. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  7452. // Prevent use of anchors and inputs
  7453. // Using _on() for an event handler shared across many instances is
  7454. // safe because the dialogs stack and must be closed in reverse order
  7455. this._on( this.document, {
  7456. focusin: function( event ) {
  7457. if ( isOpening ) {
  7458. return;
  7459. }
  7460. if ( !this._allowInteraction( event ) ) {
  7461. event.preventDefault();
  7462. this._trackingInstances()[ 0 ]._focusTabbable();
  7463. }
  7464. }
  7465. });
  7466. }
  7467. this.overlay = $( "<div>" )
  7468. .addClass( "ui-widget-overlay ui-front" )
  7469. .appendTo( this._appendTo() );
  7470. this._on( this.overlay, {
  7471. mousedown: "_keepFocus"
  7472. });
  7473. this.document.data( "ui-dialog-overlays",
  7474. (this.document.data( "ui-dialog-overlays" ) || 0) + 1 );
  7475. },
  7476. _destroyOverlay: function() {
  7477. if ( !this.options.modal ) {
  7478. return;
  7479. }
  7480. if ( this.overlay ) {
  7481. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  7482. if ( !overlays ) {
  7483. this.document
  7484. .unbind( "focusin" )
  7485. .removeData( "ui-dialog-overlays" );
  7486. } else {
  7487. this.document.data( "ui-dialog-overlays", overlays );
  7488. }
  7489. this.overlay.remove();
  7490. this.overlay = null;
  7491. }
  7492. }
  7493. });
  7494. /*!
  7495. * jQuery UI Droppable 1.11.0
  7496. * http://jqueryui.com
  7497. *
  7498. * Copyright 2014 jQuery Foundation and other contributors
  7499. * Released under the MIT license.
  7500. * http://jquery.org/license
  7501. *
  7502. * http://api.jqueryui.com/droppable/
  7503. */
  7504. $.widget( "ui.droppable", {
  7505. version: "1.11.0",
  7506. widgetEventPrefix: "drop",
  7507. options: {
  7508. accept: "*",
  7509. activeClass: false,
  7510. addClasses: true,
  7511. greedy: false,
  7512. hoverClass: false,
  7513. scope: "default",
  7514. tolerance: "intersect",
  7515. // callbacks
  7516. activate: null,
  7517. deactivate: null,
  7518. drop: null,
  7519. out: null,
  7520. over: null
  7521. },
  7522. _create: function() {
  7523. var proportions,
  7524. o = this.options,
  7525. accept = o.accept;
  7526. this.isover = false;
  7527. this.isout = true;
  7528. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  7529. return d.is( accept );
  7530. };
  7531. this.proportions = function( /* valueToWrite */ ) {
  7532. if ( arguments.length ) {
  7533. // Store the droppable's proportions
  7534. proportions = arguments[ 0 ];
  7535. } else {
  7536. // Retrieve or derive the droppable's proportions
  7537. return proportions ?
  7538. proportions :
  7539. proportions = {
  7540. width: this.element[ 0 ].offsetWidth,
  7541. height: this.element[ 0 ].offsetHeight
  7542. };
  7543. }
  7544. };
  7545. this._addToManager( o.scope );
  7546. o.addClasses && this.element.addClass( "ui-droppable" );
  7547. },
  7548. _addToManager: function( scope ) {
  7549. // Add the reference and positions to the manager
  7550. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  7551. $.ui.ddmanager.droppables[ scope ].push( this );
  7552. },
  7553. _splice: function( drop ) {
  7554. var i = 0;
  7555. for ( ; i < drop.length; i++ ) {
  7556. if ( drop[ i ] === this ) {
  7557. drop.splice( i, 1 );
  7558. }
  7559. }
  7560. },
  7561. _destroy: function() {
  7562. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  7563. this._splice( drop );
  7564. this.element.removeClass( "ui-droppable ui-droppable-disabled" );
  7565. },
  7566. _setOption: function( key, value ) {
  7567. if ( key === "accept" ) {
  7568. this.accept = $.isFunction( value ) ? value : function( d ) {
  7569. return d.is( value );
  7570. };
  7571. } else if ( key === "scope" ) {
  7572. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  7573. this._splice( drop );
  7574. this._addToManager( value );
  7575. }
  7576. this._super( key, value );
  7577. },
  7578. _activate: function( event ) {
  7579. var draggable = $.ui.ddmanager.current;
  7580. if ( this.options.activeClass ) {
  7581. this.element.addClass( this.options.activeClass );
  7582. }
  7583. if ( draggable ){
  7584. this._trigger( "activate", event, this.ui( draggable ) );
  7585. }
  7586. },
  7587. _deactivate: function( event ) {
  7588. var draggable = $.ui.ddmanager.current;
  7589. if ( this.options.activeClass ) {
  7590. this.element.removeClass( this.options.activeClass );
  7591. }
  7592. if ( draggable ){
  7593. this._trigger( "deactivate", event, this.ui( draggable ) );
  7594. }
  7595. },
  7596. _over: function( event ) {
  7597. var draggable = $.ui.ddmanager.current;
  7598. // Bail if draggable and droppable are same element
  7599. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  7600. return;
  7601. }
  7602. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7603. if ( this.options.hoverClass ) {
  7604. this.element.addClass( this.options.hoverClass );
  7605. }
  7606. this._trigger( "over", event, this.ui( draggable ) );
  7607. }
  7608. },
  7609. _out: function( event ) {
  7610. var draggable = $.ui.ddmanager.current;
  7611. // Bail if draggable and droppable are same element
  7612. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  7613. return;
  7614. }
  7615. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7616. if ( this.options.hoverClass ) {
  7617. this.element.removeClass( this.options.hoverClass );
  7618. }
  7619. this._trigger( "out", event, this.ui( draggable ) );
  7620. }
  7621. },
  7622. _drop: function( event, custom ) {
  7623. var draggable = custom || $.ui.ddmanager.current,
  7624. childrenIntersection = false;
  7625. // Bail if draggable and droppable are same element
  7626. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  7627. return false;
  7628. }
  7629. this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
  7630. var inst = $( this ).droppable( "instance" );
  7631. if (
  7632. inst.options.greedy &&
  7633. !inst.options.disabled &&
  7634. inst.options.scope === draggable.options.scope &&
  7635. inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
  7636. $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance )
  7637. ) { childrenIntersection = true; return false; }
  7638. });
  7639. if ( childrenIntersection ) {
  7640. return false;
  7641. }
  7642. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7643. if ( this.options.activeClass ) {
  7644. this.element.removeClass( this.options.activeClass );
  7645. }
  7646. if ( this.options.hoverClass ) {
  7647. this.element.removeClass( this.options.hoverClass );
  7648. }
  7649. this._trigger( "drop", event, this.ui( draggable ) );
  7650. return this.element;
  7651. }
  7652. return false;
  7653. },
  7654. ui: function( c ) {
  7655. return {
  7656. draggable: ( c.currentItem || c.element ),
  7657. helper: c.helper,
  7658. position: c.position,
  7659. offset: c.positionAbs
  7660. };
  7661. }
  7662. });
  7663. $.ui.intersect = (function() {
  7664. function isOverAxis( x, reference, size ) {
  7665. return ( x >= reference ) && ( x < ( reference + size ) );
  7666. }
  7667. return function( draggable, droppable, toleranceMode ) {
  7668. if ( !droppable.offset ) {
  7669. return false;
  7670. }
  7671. var draggableLeft, draggableTop,
  7672. x1 = ( draggable.positionAbs || draggable.position.absolute ).left,
  7673. y1 = ( draggable.positionAbs || draggable.position.absolute ).top,
  7674. x2 = x1 + draggable.helperProportions.width,
  7675. y2 = y1 + draggable.helperProportions.height,
  7676. l = droppable.offset.left,
  7677. t = droppable.offset.top,
  7678. r = l + droppable.proportions().width,
  7679. b = t + droppable.proportions().height;
  7680. switch ( toleranceMode ) {
  7681. case "fit":
  7682. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  7683. case "intersect":
  7684. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  7685. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  7686. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  7687. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  7688. case "pointer":
  7689. draggableLeft = ( ( draggable.positionAbs || draggable.position.absolute ).left + ( draggable.clickOffset || draggable.offset.click ).left );
  7690. draggableTop = ( ( draggable.positionAbs || draggable.position.absolute ).top + ( draggable.clickOffset || draggable.offset.click ).top );
  7691. return isOverAxis( draggableTop, t, droppable.proportions().height ) && isOverAxis( draggableLeft, l, droppable.proportions().width );
  7692. case "touch":
  7693. return (
  7694. ( y1 >= t && y1 <= b ) || // Top edge touching
  7695. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  7696. ( y1 < t && y2 > b ) // Surrounded vertically
  7697. ) && (
  7698. ( x1 >= l && x1 <= r ) || // Left edge touching
  7699. ( x2 >= l && x2 <= r ) || // Right edge touching
  7700. ( x1 < l && x2 > r ) // Surrounded horizontally
  7701. );
  7702. default:
  7703. return false;
  7704. }
  7705. };
  7706. })();
  7707. /*
  7708. This manager tracks offsets of draggables and droppables
  7709. */
  7710. $.ui.ddmanager = {
  7711. current: null,
  7712. droppables: { "default": [] },
  7713. prepareOffsets: function( t, event ) {
  7714. var i, j,
  7715. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  7716. type = event ? event.type : null, // workaround for #2317
  7717. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  7718. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  7719. // No disabled and non-accepted
  7720. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
  7721. continue;
  7722. }
  7723. // Filter out elements in the current dragged item
  7724. for ( j = 0; j < list.length; j++ ) {
  7725. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  7726. m[ i ].proportions().height = 0;
  7727. continue droppablesLoop;
  7728. }
  7729. }
  7730. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  7731. if ( !m[ i ].visible ) {
  7732. continue;
  7733. }
  7734. // Activate the droppable if used directly from draggables
  7735. if ( type === "mousedown" ) {
  7736. m[ i ]._activate.call( m[ i ], event );
  7737. }
  7738. m[ i ].offset = m[ i ].element.offset();
  7739. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  7740. }
  7741. },
  7742. drop: function( draggable, event ) {
  7743. var dropped = false;
  7744. // Create a copy of the droppables in case the list changes during the drop (#9116)
  7745. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  7746. if ( !this.options ) {
  7747. return;
  7748. }
  7749. if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance ) ) {
  7750. dropped = this._drop.call( this, event ) || dropped;
  7751. }
  7752. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7753. this.isout = true;
  7754. this.isover = false;
  7755. this._deactivate.call( this, event );
  7756. }
  7757. });
  7758. return dropped;
  7759. },
  7760. dragStart: function( draggable, event ) {
  7761. // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  7762. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  7763. if ( !draggable.options.refreshPositions ) {
  7764. $.ui.ddmanager.prepareOffsets( draggable, event );
  7765. }
  7766. });
  7767. },
  7768. drag: function( draggable, event ) {
  7769. // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  7770. if ( draggable.options.refreshPositions ) {
  7771. $.ui.ddmanager.prepareOffsets( draggable, event );
  7772. }
  7773. // Run through all droppables and check their positions based on specific tolerance options
  7774. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  7775. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  7776. return;
  7777. }
  7778. var parentInstance, scope, parent,
  7779. intersects = $.ui.intersect( draggable, this, this.options.tolerance ),
  7780. c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
  7781. if ( !c ) {
  7782. return;
  7783. }
  7784. if ( this.options.greedy ) {
  7785. // find droppable parents with same scope
  7786. scope = this.options.scope;
  7787. parent = this.element.parents( ":data(ui-droppable)" ).filter(function() {
  7788. return $( this ).droppable( "instance" ).options.scope === scope;
  7789. });
  7790. if ( parent.length ) {
  7791. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  7792. parentInstance.greedyChild = ( c === "isover" );
  7793. }
  7794. }
  7795. // we just moved into a greedy child
  7796. if ( parentInstance && c === "isover" ) {
  7797. parentInstance.isover = false;
  7798. parentInstance.isout = true;
  7799. parentInstance._out.call( parentInstance, event );
  7800. }
  7801. this[ c ] = true;
  7802. this[c === "isout" ? "isover" : "isout"] = false;
  7803. this[c === "isover" ? "_over" : "_out"].call( this, event );
  7804. // we just moved out of a greedy child
  7805. if ( parentInstance && c === "isout" ) {
  7806. parentInstance.isout = false;
  7807. parentInstance.isover = true;
  7808. parentInstance._over.call( parentInstance, event );
  7809. }
  7810. });
  7811. },
  7812. dragStop: function( draggable, event ) {
  7813. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  7814. // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  7815. if ( !draggable.options.refreshPositions ) {
  7816. $.ui.ddmanager.prepareOffsets( draggable, event );
  7817. }
  7818. }
  7819. };
  7820. var droppable = $.ui.droppable;
  7821. /*!
  7822. * jQuery UI Effects 1.11.0
  7823. * http://jqueryui.com
  7824. *
  7825. * Copyright 2014 jQuery Foundation and other contributors
  7826. * Released under the MIT license.
  7827. * http://jquery.org/license
  7828. *
  7829. * http://api.jqueryui.com/category/effects-core/
  7830. */
  7831. var dataSpace = "ui-effects-";
  7832. $.effects = {
  7833. effect: {}
  7834. };
  7835. /*!
  7836. * jQuery Color Animations v2.1.2
  7837. * https://github.com/jquery/jquery-color
  7838. *
  7839. * Copyright 2014 jQuery Foundation and other contributors
  7840. * Released under the MIT license.
  7841. * http://jquery.org/license
  7842. *
  7843. * Date: Wed Jan 16 08:47:09 2013 -0600
  7844. */
  7845. (function( jQuery, undefined ) {
  7846. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  7847. // plusequals test for += 100 -= 100
  7848. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  7849. // a set of RE's that can match strings and generate color tuples.
  7850. stringParsers = [ {
  7851. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  7852. parse: function( execResult ) {
  7853. return [
  7854. execResult[ 1 ],
  7855. execResult[ 2 ],
  7856. execResult[ 3 ],
  7857. execResult[ 4 ]
  7858. ];
  7859. }
  7860. }, {
  7861. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  7862. parse: function( execResult ) {
  7863. return [
  7864. execResult[ 1 ] * 2.55,
  7865. execResult[ 2 ] * 2.55,
  7866. execResult[ 3 ] * 2.55,
  7867. execResult[ 4 ]
  7868. ];
  7869. }
  7870. }, {
  7871. // this regex ignores A-F because it's compared against an already lowercased string
  7872. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  7873. parse: function( execResult ) {
  7874. return [
  7875. parseInt( execResult[ 1 ], 16 ),
  7876. parseInt( execResult[ 2 ], 16 ),
  7877. parseInt( execResult[ 3 ], 16 )
  7878. ];
  7879. }
  7880. }, {
  7881. // this regex ignores A-F because it's compared against an already lowercased string
  7882. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  7883. parse: function( execResult ) {
  7884. return [
  7885. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  7886. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  7887. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  7888. ];
  7889. }
  7890. }, {
  7891. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  7892. space: "hsla",
  7893. parse: function( execResult ) {
  7894. return [
  7895. execResult[ 1 ],
  7896. execResult[ 2 ] / 100,
  7897. execResult[ 3 ] / 100,
  7898. execResult[ 4 ]
  7899. ];
  7900. }
  7901. } ],
  7902. // jQuery.Color( )
  7903. color = jQuery.Color = function( color, green, blue, alpha ) {
  7904. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  7905. },
  7906. spaces = {
  7907. rgba: {
  7908. props: {
  7909. red: {
  7910. idx: 0,
  7911. type: "byte"
  7912. },
  7913. green: {
  7914. idx: 1,
  7915. type: "byte"
  7916. },
  7917. blue: {
  7918. idx: 2,
  7919. type: "byte"
  7920. }
  7921. }
  7922. },
  7923. hsla: {
  7924. props: {
  7925. hue: {
  7926. idx: 0,
  7927. type: "degrees"
  7928. },
  7929. saturation: {
  7930. idx: 1,
  7931. type: "percent"
  7932. },
  7933. lightness: {
  7934. idx: 2,
  7935. type: "percent"
  7936. }
  7937. }
  7938. }
  7939. },
  7940. propTypes = {
  7941. "byte": {
  7942. floor: true,
  7943. max: 255
  7944. },
  7945. "percent": {
  7946. max: 1
  7947. },
  7948. "degrees": {
  7949. mod: 360,
  7950. floor: true
  7951. }
  7952. },
  7953. support = color.support = {},
  7954. // element for support tests
  7955. supportElem = jQuery( "<p>" )[ 0 ],
  7956. // colors = jQuery.Color.names
  7957. colors,
  7958. // local aliases of functions called often
  7959. each = jQuery.each;
  7960. // determine rgba support immediately
  7961. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  7962. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  7963. // define cache name and alpha properties
  7964. // for rgba and hsla spaces
  7965. each( spaces, function( spaceName, space ) {
  7966. space.cache = "_" + spaceName;
  7967. space.props.alpha = {
  7968. idx: 3,
  7969. type: "percent",
  7970. def: 1
  7971. };
  7972. });
  7973. function clamp( value, prop, allowEmpty ) {
  7974. var type = propTypes[ prop.type ] || {};
  7975. if ( value == null ) {
  7976. return (allowEmpty || !prop.def) ? null : prop.def;
  7977. }
  7978. // ~~ is an short way of doing floor for positive numbers
  7979. value = type.floor ? ~~value : parseFloat( value );
  7980. // IE will pass in empty strings as value for alpha,
  7981. // which will hit this case
  7982. if ( isNaN( value ) ) {
  7983. return prop.def;
  7984. }
  7985. if ( type.mod ) {
  7986. // we add mod before modding to make sure that negatives values
  7987. // get converted properly: -10 -> 350
  7988. return (value + type.mod) % type.mod;
  7989. }
  7990. // for now all property types without mod have min and max
  7991. return 0 > value ? 0 : type.max < value ? type.max : value;
  7992. }
  7993. function stringParse( string ) {
  7994. var inst = color(),
  7995. rgba = inst._rgba = [];
  7996. string = string.toLowerCase();
  7997. each( stringParsers, function( i, parser ) {
  7998. var parsed,
  7999. match = parser.re.exec( string ),
  8000. values = match && parser.parse( match ),
  8001. spaceName = parser.space || "rgba";
  8002. if ( values ) {
  8003. parsed = inst[ spaceName ]( values );
  8004. // if this was an rgba parse the assignment might happen twice
  8005. // oh well....
  8006. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  8007. rgba = inst._rgba = parsed._rgba;
  8008. // exit each( stringParsers ) here because we matched
  8009. return false;
  8010. }
  8011. });
  8012. // Found a stringParser that handled it
  8013. if ( rgba.length ) {
  8014. // if this came from a parsed string, force "transparent" when alpha is 0
  8015. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  8016. if ( rgba.join() === "0,0,0,0" ) {
  8017. jQuery.extend( rgba, colors.transparent );
  8018. }
  8019. return inst;
  8020. }
  8021. // named colors
  8022. return colors[ string ];
  8023. }
  8024. color.fn = jQuery.extend( color.prototype, {
  8025. parse: function( red, green, blue, alpha ) {
  8026. if ( red === undefined ) {
  8027. this._rgba = [ null, null, null, null ];
  8028. return this;
  8029. }
  8030. if ( red.jquery || red.nodeType ) {
  8031. red = jQuery( red ).css( green );
  8032. green = undefined;
  8033. }
  8034. var inst = this,
  8035. type = jQuery.type( red ),
  8036. rgba = this._rgba = [];
  8037. // more than 1 argument specified - assume ( red, green, blue, alpha )
  8038. if ( green !== undefined ) {
  8039. red = [ red, green, blue, alpha ];
  8040. type = "array";
  8041. }
  8042. if ( type === "string" ) {
  8043. return this.parse( stringParse( red ) || colors._default );
  8044. }
  8045. if ( type === "array" ) {
  8046. each( spaces.rgba.props, function( key, prop ) {
  8047. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  8048. });
  8049. return this;
  8050. }
  8051. if ( type === "object" ) {
  8052. if ( red instanceof color ) {
  8053. each( spaces, function( spaceName, space ) {
  8054. if ( red[ space.cache ] ) {
  8055. inst[ space.cache ] = red[ space.cache ].slice();
  8056. }
  8057. });
  8058. } else {
  8059. each( spaces, function( spaceName, space ) {
  8060. var cache = space.cache;
  8061. each( space.props, function( key, prop ) {
  8062. // if the cache doesn't exist, and we know how to convert
  8063. if ( !inst[ cache ] && space.to ) {
  8064. // if the value was null, we don't need to copy it
  8065. // if the key was alpha, we don't need to copy it either
  8066. if ( key === "alpha" || red[ key ] == null ) {
  8067. return;
  8068. }
  8069. inst[ cache ] = space.to( inst._rgba );
  8070. }
  8071. // this is the only case where we allow nulls for ALL properties.
  8072. // call clamp with alwaysAllowEmpty
  8073. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  8074. });
  8075. // everything defined but alpha?
  8076. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  8077. // use the default of 1
  8078. inst[ cache ][ 3 ] = 1;
  8079. if ( space.from ) {
  8080. inst._rgba = space.from( inst[ cache ] );
  8081. }
  8082. }
  8083. });
  8084. }
  8085. return this;
  8086. }
  8087. },
  8088. is: function( compare ) {
  8089. var is = color( compare ),
  8090. same = true,
  8091. inst = this;
  8092. each( spaces, function( _, space ) {
  8093. var localCache,
  8094. isCache = is[ space.cache ];
  8095. if (isCache) {
  8096. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  8097. each( space.props, function( _, prop ) {
  8098. if ( isCache[ prop.idx ] != null ) {
  8099. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  8100. return same;
  8101. }
  8102. });
  8103. }
  8104. return same;
  8105. });
  8106. return same;
  8107. },
  8108. _space: function() {
  8109. var used = [],
  8110. inst = this;
  8111. each( spaces, function( spaceName, space ) {
  8112. if ( inst[ space.cache ] ) {
  8113. used.push( spaceName );
  8114. }
  8115. });
  8116. return used.pop();
  8117. },
  8118. transition: function( other, distance ) {
  8119. var end = color( other ),
  8120. spaceName = end._space(),
  8121. space = spaces[ spaceName ],
  8122. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  8123. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  8124. result = start.slice();
  8125. end = end[ space.cache ];
  8126. each( space.props, function( key, prop ) {
  8127. var index = prop.idx,
  8128. startValue = start[ index ],
  8129. endValue = end[ index ],
  8130. type = propTypes[ prop.type ] || {};
  8131. // if null, don't override start value
  8132. if ( endValue === null ) {
  8133. return;
  8134. }
  8135. // if null - use end
  8136. if ( startValue === null ) {
  8137. result[ index ] = endValue;
  8138. } else {
  8139. if ( type.mod ) {
  8140. if ( endValue - startValue > type.mod / 2 ) {
  8141. startValue += type.mod;
  8142. } else if ( startValue - endValue > type.mod / 2 ) {
  8143. startValue -= type.mod;
  8144. }
  8145. }
  8146. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  8147. }
  8148. });
  8149. return this[ spaceName ]( result );
  8150. },
  8151. blend: function( opaque ) {
  8152. // if we are already opaque - return ourself
  8153. if ( this._rgba[ 3 ] === 1 ) {
  8154. return this;
  8155. }
  8156. var rgb = this._rgba.slice(),
  8157. a = rgb.pop(),
  8158. blend = color( opaque )._rgba;
  8159. return color( jQuery.map( rgb, function( v, i ) {
  8160. return ( 1 - a ) * blend[ i ] + a * v;
  8161. }));
  8162. },
  8163. toRgbaString: function() {
  8164. var prefix = "rgba(",
  8165. rgba = jQuery.map( this._rgba, function( v, i ) {
  8166. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  8167. });
  8168. if ( rgba[ 3 ] === 1 ) {
  8169. rgba.pop();
  8170. prefix = "rgb(";
  8171. }
  8172. return prefix + rgba.join() + ")";
  8173. },
  8174. toHslaString: function() {
  8175. var prefix = "hsla(",
  8176. hsla = jQuery.map( this.hsla(), function( v, i ) {
  8177. if ( v == null ) {
  8178. v = i > 2 ? 1 : 0;
  8179. }
  8180. // catch 1 and 2
  8181. if ( i && i < 3 ) {
  8182. v = Math.round( v * 100 ) + "%";
  8183. }
  8184. return v;
  8185. });
  8186. if ( hsla[ 3 ] === 1 ) {
  8187. hsla.pop();
  8188. prefix = "hsl(";
  8189. }
  8190. return prefix + hsla.join() + ")";
  8191. },
  8192. toHexString: function( includeAlpha ) {
  8193. var rgba = this._rgba.slice(),
  8194. alpha = rgba.pop();
  8195. if ( includeAlpha ) {
  8196. rgba.push( ~~( alpha * 255 ) );
  8197. }
  8198. return "#" + jQuery.map( rgba, function( v ) {
  8199. // default to 0 when nulls exist
  8200. v = ( v || 0 ).toString( 16 );
  8201. return v.length === 1 ? "0" + v : v;
  8202. }).join("");
  8203. },
  8204. toString: function() {
  8205. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  8206. }
  8207. });
  8208. color.fn.parse.prototype = color.fn;
  8209. // hsla conversions adapted from:
  8210. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  8211. function hue2rgb( p, q, h ) {
  8212. h = ( h + 1 ) % 1;
  8213. if ( h * 6 < 1 ) {
  8214. return p + ( q - p ) * h * 6;
  8215. }
  8216. if ( h * 2 < 1) {
  8217. return q;
  8218. }
  8219. if ( h * 3 < 2 ) {
  8220. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  8221. }
  8222. return p;
  8223. }
  8224. spaces.hsla.to = function( rgba ) {
  8225. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  8226. return [ null, null, null, rgba[ 3 ] ];
  8227. }
  8228. var r = rgba[ 0 ] / 255,
  8229. g = rgba[ 1 ] / 255,
  8230. b = rgba[ 2 ] / 255,
  8231. a = rgba[ 3 ],
  8232. max = Math.max( r, g, b ),
  8233. min = Math.min( r, g, b ),
  8234. diff = max - min,
  8235. add = max + min,
  8236. l = add * 0.5,
  8237. h, s;
  8238. if ( min === max ) {
  8239. h = 0;
  8240. } else if ( r === max ) {
  8241. h = ( 60 * ( g - b ) / diff ) + 360;
  8242. } else if ( g === max ) {
  8243. h = ( 60 * ( b - r ) / diff ) + 120;
  8244. } else {
  8245. h = ( 60 * ( r - g ) / diff ) + 240;
  8246. }
  8247. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  8248. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  8249. if ( diff === 0 ) {
  8250. s = 0;
  8251. } else if ( l <= 0.5 ) {
  8252. s = diff / add;
  8253. } else {
  8254. s = diff / ( 2 - add );
  8255. }
  8256. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  8257. };
  8258. spaces.hsla.from = function( hsla ) {
  8259. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  8260. return [ null, null, null, hsla[ 3 ] ];
  8261. }
  8262. var h = hsla[ 0 ] / 360,
  8263. s = hsla[ 1 ],
  8264. l = hsla[ 2 ],
  8265. a = hsla[ 3 ],
  8266. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  8267. p = 2 * l - q;
  8268. return [
  8269. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  8270. Math.round( hue2rgb( p, q, h ) * 255 ),
  8271. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  8272. a
  8273. ];
  8274. };
  8275. each( spaces, function( spaceName, space ) {
  8276. var props = space.props,
  8277. cache = space.cache,
  8278. to = space.to,
  8279. from = space.from;
  8280. // makes rgba() and hsla()
  8281. color.fn[ spaceName ] = function( value ) {
  8282. // generate a cache for this space if it doesn't exist
  8283. if ( to && !this[ cache ] ) {
  8284. this[ cache ] = to( this._rgba );
  8285. }
  8286. if ( value === undefined ) {
  8287. return this[ cache ].slice();
  8288. }
  8289. var ret,
  8290. type = jQuery.type( value ),
  8291. arr = ( type === "array" || type === "object" ) ? value : arguments,
  8292. local = this[ cache ].slice();
  8293. each( props, function( key, prop ) {
  8294. var val = arr[ type === "object" ? key : prop.idx ];
  8295. if ( val == null ) {
  8296. val = local[ prop.idx ];
  8297. }
  8298. local[ prop.idx ] = clamp( val, prop );
  8299. });
  8300. if ( from ) {
  8301. ret = color( from( local ) );
  8302. ret[ cache ] = local;
  8303. return ret;
  8304. } else {
  8305. return color( local );
  8306. }
  8307. };
  8308. // makes red() green() blue() alpha() hue() saturation() lightness()
  8309. each( props, function( key, prop ) {
  8310. // alpha is included in more than one space
  8311. if ( color.fn[ key ] ) {
  8312. return;
  8313. }
  8314. color.fn[ key ] = function( value ) {
  8315. var vtype = jQuery.type( value ),
  8316. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  8317. local = this[ fn ](),
  8318. cur = local[ prop.idx ],
  8319. match;
  8320. if ( vtype === "undefined" ) {
  8321. return cur;
  8322. }
  8323. if ( vtype === "function" ) {
  8324. value = value.call( this, cur );
  8325. vtype = jQuery.type( value );
  8326. }
  8327. if ( value == null && prop.empty ) {
  8328. return this;
  8329. }
  8330. if ( vtype === "string" ) {
  8331. match = rplusequals.exec( value );
  8332. if ( match ) {
  8333. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  8334. }
  8335. }
  8336. local[ prop.idx ] = value;
  8337. return this[ fn ]( local );
  8338. };
  8339. });
  8340. });
  8341. // add cssHook and .fx.step function for each named hook.
  8342. // accept a space separated string of properties
  8343. color.hook = function( hook ) {
  8344. var hooks = hook.split( " " );
  8345. each( hooks, function( i, hook ) {
  8346. jQuery.cssHooks[ hook ] = {
  8347. set: function( elem, value ) {
  8348. var parsed, curElem,
  8349. backgroundColor = "";
  8350. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  8351. value = color( parsed || value );
  8352. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  8353. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  8354. while (
  8355. (backgroundColor === "" || backgroundColor === "transparent") &&
  8356. curElem && curElem.style
  8357. ) {
  8358. try {
  8359. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  8360. curElem = curElem.parentNode;
  8361. } catch ( e ) {
  8362. }
  8363. }
  8364. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  8365. backgroundColor :
  8366. "_default" );
  8367. }
  8368. value = value.toRgbaString();
  8369. }
  8370. try {
  8371. elem.style[ hook ] = value;
  8372. } catch( e ) {
  8373. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  8374. }
  8375. }
  8376. };
  8377. jQuery.fx.step[ hook ] = function( fx ) {
  8378. if ( !fx.colorInit ) {
  8379. fx.start = color( fx.elem, hook );
  8380. fx.end = color( fx.end );
  8381. fx.colorInit = true;
  8382. }
  8383. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  8384. };
  8385. });
  8386. };
  8387. color.hook( stepHooks );
  8388. jQuery.cssHooks.borderColor = {
  8389. expand: function( value ) {
  8390. var expanded = {};
  8391. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  8392. expanded[ "border" + part + "Color" ] = value;
  8393. });
  8394. return expanded;
  8395. }
  8396. };
  8397. // Basic color names only.
  8398. // Usage of any of the other color names requires adding yourself or including
  8399. // jquery.color.svg-names.js.
  8400. colors = jQuery.Color.names = {
  8401. // 4.1. Basic color keywords
  8402. aqua: "#00ffff",
  8403. black: "#000000",
  8404. blue: "#0000ff",
  8405. fuchsia: "#ff00ff",
  8406. gray: "#808080",
  8407. green: "#008000",
  8408. lime: "#00ff00",
  8409. maroon: "#800000",
  8410. navy: "#000080",
  8411. olive: "#808000",
  8412. purple: "#800080",
  8413. red: "#ff0000",
  8414. silver: "#c0c0c0",
  8415. teal: "#008080",
  8416. white: "#ffffff",
  8417. yellow: "#ffff00",
  8418. // 4.2.3. "transparent" color keyword
  8419. transparent: [ null, null, null, 0 ],
  8420. _default: "#ffffff"
  8421. };
  8422. })( jQuery );
  8423. /******************************************************************************/
  8424. /****************************** CLASS ANIMATIONS ******************************/
  8425. /******************************************************************************/
  8426. (function() {
  8427. var classAnimationActions = [ "add", "remove", "toggle" ],
  8428. shorthandStyles = {
  8429. border: 1,
  8430. borderBottom: 1,
  8431. borderColor: 1,
  8432. borderLeft: 1,
  8433. borderRight: 1,
  8434. borderTop: 1,
  8435. borderWidth: 1,
  8436. margin: 1,
  8437. padding: 1
  8438. };
  8439. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  8440. $.fx.step[ prop ] = function( fx ) {
  8441. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  8442. jQuery.style( fx.elem, prop, fx.end );
  8443. fx.setAttr = true;
  8444. }
  8445. };
  8446. });
  8447. function getElementStyles( elem ) {
  8448. var key, len,
  8449. style = elem.ownerDocument.defaultView ?
  8450. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  8451. elem.currentStyle,
  8452. styles = {};
  8453. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  8454. len = style.length;
  8455. while ( len-- ) {
  8456. key = style[ len ];
  8457. if ( typeof style[ key ] === "string" ) {
  8458. styles[ $.camelCase( key ) ] = style[ key ];
  8459. }
  8460. }
  8461. // support: Opera, IE <9
  8462. } else {
  8463. for ( key in style ) {
  8464. if ( typeof style[ key ] === "string" ) {
  8465. styles[ key ] = style[ key ];
  8466. }
  8467. }
  8468. }
  8469. return styles;
  8470. }
  8471. function styleDifference( oldStyle, newStyle ) {
  8472. var diff = {},
  8473. name, value;
  8474. for ( name in newStyle ) {
  8475. value = newStyle[ name ];
  8476. if ( oldStyle[ name ] !== value ) {
  8477. if ( !shorthandStyles[ name ] ) {
  8478. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  8479. diff[ name ] = value;
  8480. }
  8481. }
  8482. }
  8483. }
  8484. return diff;
  8485. }
  8486. // support: jQuery <1.8
  8487. if ( !$.fn.addBack ) {
  8488. $.fn.addBack = function( selector ) {
  8489. return this.add( selector == null ?
  8490. this.prevObject : this.prevObject.filter( selector )
  8491. );
  8492. };
  8493. }
  8494. $.effects.animateClass = function( value, duration, easing, callback ) {
  8495. var o = $.speed( duration, easing, callback );
  8496. return this.queue( function() {
  8497. var animated = $( this ),
  8498. baseClass = animated.attr( "class" ) || "",
  8499. applyClassChange,
  8500. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  8501. // map the animated objects to store the original styles.
  8502. allAnimations = allAnimations.map(function() {
  8503. var el = $( this );
  8504. return {
  8505. el: el,
  8506. start: getElementStyles( this )
  8507. };
  8508. });
  8509. // apply class change
  8510. applyClassChange = function() {
  8511. $.each( classAnimationActions, function(i, action) {
  8512. if ( value[ action ] ) {
  8513. animated[ action + "Class" ]( value[ action ] );
  8514. }
  8515. });
  8516. };
  8517. applyClassChange();
  8518. // map all animated objects again - calculate new styles and diff
  8519. allAnimations = allAnimations.map(function() {
  8520. this.end = getElementStyles( this.el[ 0 ] );
  8521. this.diff = styleDifference( this.start, this.end );
  8522. return this;
  8523. });
  8524. // apply original class
  8525. animated.attr( "class", baseClass );
  8526. // map all animated objects again - this time collecting a promise
  8527. allAnimations = allAnimations.map(function() {
  8528. var styleInfo = this,
  8529. dfd = $.Deferred(),
  8530. opts = $.extend({}, o, {
  8531. queue: false,
  8532. complete: function() {
  8533. dfd.resolve( styleInfo );
  8534. }
  8535. });
  8536. this.el.animate( this.diff, opts );
  8537. return dfd.promise();
  8538. });
  8539. // once all animations have completed:
  8540. $.when.apply( $, allAnimations.get() ).done(function() {
  8541. // set the final class
  8542. applyClassChange();
  8543. // for each animated element,
  8544. // clear all css properties that were animated
  8545. $.each( arguments, function() {
  8546. var el = this.el;
  8547. $.each( this.diff, function(key) {
  8548. el.css( key, "" );
  8549. });
  8550. });
  8551. // this is guarnteed to be there if you use jQuery.speed()
  8552. // it also handles dequeuing the next anim...
  8553. o.complete.call( animated[ 0 ] );
  8554. });
  8555. });
  8556. };
  8557. $.fn.extend({
  8558. addClass: (function( orig ) {
  8559. return function( classNames, speed, easing, callback ) {
  8560. return speed ?
  8561. $.effects.animateClass.call( this,
  8562. { add: classNames }, speed, easing, callback ) :
  8563. orig.apply( this, arguments );
  8564. };
  8565. })( $.fn.addClass ),
  8566. removeClass: (function( orig ) {
  8567. return function( classNames, speed, easing, callback ) {
  8568. return arguments.length > 1 ?
  8569. $.effects.animateClass.call( this,
  8570. { remove: classNames }, speed, easing, callback ) :
  8571. orig.apply( this, arguments );
  8572. };
  8573. })( $.fn.removeClass ),
  8574. toggleClass: (function( orig ) {
  8575. return function( classNames, force, speed, easing, callback ) {
  8576. if ( typeof force === "boolean" || force === undefined ) {
  8577. if ( !speed ) {
  8578. // without speed parameter
  8579. return orig.apply( this, arguments );
  8580. } else {
  8581. return $.effects.animateClass.call( this,
  8582. (force ? { add: classNames } : { remove: classNames }),
  8583. speed, easing, callback );
  8584. }
  8585. } else {
  8586. // without force parameter
  8587. return $.effects.animateClass.call( this,
  8588. { toggle: classNames }, force, speed, easing );
  8589. }
  8590. };
  8591. })( $.fn.toggleClass ),
  8592. switchClass: function( remove, add, speed, easing, callback) {
  8593. return $.effects.animateClass.call( this, {
  8594. add: add,
  8595. remove: remove
  8596. }, speed, easing, callback );
  8597. }
  8598. });
  8599. })();
  8600. /******************************************************************************/
  8601. /*********************************** EFFECTS **********************************/
  8602. /******************************************************************************/
  8603. (function() {
  8604. $.extend( $.effects, {
  8605. version: "1.11.0",
  8606. // Saves a set of properties in a data storage
  8607. save: function( element, set ) {
  8608. for ( var i = 0; i < set.length; i++ ) {
  8609. if ( set[ i ] !== null ) {
  8610. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  8611. }
  8612. }
  8613. },
  8614. // Restores a set of previously saved properties from a data storage
  8615. restore: function( element, set ) {
  8616. var val, i;
  8617. for ( i = 0; i < set.length; i++ ) {
  8618. if ( set[ i ] !== null ) {
  8619. val = element.data( dataSpace + set[ i ] );
  8620. // support: jQuery 1.6.2
  8621. // http://bugs.jquery.com/ticket/9917
  8622. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  8623. // We can't differentiate between "" and 0 here, so we just assume
  8624. // empty string since it's likely to be a more common value...
  8625. if ( val === undefined ) {
  8626. val = "";
  8627. }
  8628. element.css( set[ i ], val );
  8629. }
  8630. }
  8631. },
  8632. setMode: function( el, mode ) {
  8633. if (mode === "toggle") {
  8634. mode = el.is( ":hidden" ) ? "show" : "hide";
  8635. }
  8636. return mode;
  8637. },
  8638. // Translates a [top,left] array into a baseline value
  8639. // this should be a little more flexible in the future to handle a string & hash
  8640. getBaseline: function( origin, original ) {
  8641. var y, x;
  8642. switch ( origin[ 0 ] ) {
  8643. case "top": y = 0; break;
  8644. case "middle": y = 0.5; break;
  8645. case "bottom": y = 1; break;
  8646. default: y = origin[ 0 ] / original.height;
  8647. }
  8648. switch ( origin[ 1 ] ) {
  8649. case "left": x = 0; break;
  8650. case "center": x = 0.5; break;
  8651. case "right": x = 1; break;
  8652. default: x = origin[ 1 ] / original.width;
  8653. }
  8654. return {
  8655. x: x,
  8656. y: y
  8657. };
  8658. },
  8659. // Wraps the element around a wrapper that copies position properties
  8660. createWrapper: function( element ) {
  8661. // if the element is already wrapped, return it
  8662. if ( element.parent().is( ".ui-effects-wrapper" )) {
  8663. return element.parent();
  8664. }
  8665. // wrap the element
  8666. var props = {
  8667. width: element.outerWidth(true),
  8668. height: element.outerHeight(true),
  8669. "float": element.css( "float" )
  8670. },
  8671. wrapper = $( "<div></div>" )
  8672. .addClass( "ui-effects-wrapper" )
  8673. .css({
  8674. fontSize: "100%",
  8675. background: "transparent",
  8676. border: "none",
  8677. margin: 0,
  8678. padding: 0
  8679. }),
  8680. // Store the size in case width/height are defined in % - Fixes #5245
  8681. size = {
  8682. width: element.width(),
  8683. height: element.height()
  8684. },
  8685. active = document.activeElement;
  8686. // support: Firefox
  8687. // Firefox incorrectly exposes anonymous content
  8688. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  8689. try {
  8690. active.id;
  8691. } catch( e ) {
  8692. active = document.body;
  8693. }
  8694. element.wrap( wrapper );
  8695. // Fixes #7595 - Elements lose focus when wrapped.
  8696. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  8697. $( active ).focus();
  8698. }
  8699. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  8700. // transfer positioning properties to the wrapper
  8701. if ( element.css( "position" ) === "static" ) {
  8702. wrapper.css({ position: "relative" });
  8703. element.css({ position: "relative" });
  8704. } else {
  8705. $.extend( props, {
  8706. position: element.css( "position" ),
  8707. zIndex: element.css( "z-index" )
  8708. });
  8709. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  8710. props[ pos ] = element.css( pos );
  8711. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  8712. props[ pos ] = "auto";
  8713. }
  8714. });
  8715. element.css({
  8716. position: "relative",
  8717. top: 0,
  8718. left: 0,
  8719. right: "auto",
  8720. bottom: "auto"
  8721. });
  8722. }
  8723. element.css(size);
  8724. return wrapper.css( props ).show();
  8725. },
  8726. removeWrapper: function( element ) {
  8727. var active = document.activeElement;
  8728. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  8729. element.parent().replaceWith( element );
  8730. // Fixes #7595 - Elements lose focus when wrapped.
  8731. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  8732. $( active ).focus();
  8733. }
  8734. }
  8735. return element;
  8736. },
  8737. setTransition: function( element, list, factor, value ) {
  8738. value = value || {};
  8739. $.each( list, function( i, x ) {
  8740. var unit = element.cssUnit( x );
  8741. if ( unit[ 0 ] > 0 ) {
  8742. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  8743. }
  8744. });
  8745. return value;
  8746. }
  8747. });
  8748. // return an effect options object for the given parameters:
  8749. function _normalizeArguments( effect, options, speed, callback ) {
  8750. // allow passing all options as the first parameter
  8751. if ( $.isPlainObject( effect ) ) {
  8752. options = effect;
  8753. effect = effect.effect;
  8754. }
  8755. // convert to an object
  8756. effect = { effect: effect };
  8757. // catch (effect, null, ...)
  8758. if ( options == null ) {
  8759. options = {};
  8760. }
  8761. // catch (effect, callback)
  8762. if ( $.isFunction( options ) ) {
  8763. callback = options;
  8764. speed = null;
  8765. options = {};
  8766. }
  8767. // catch (effect, speed, ?)
  8768. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  8769. callback = speed;
  8770. speed = options;
  8771. options = {};
  8772. }
  8773. // catch (effect, options, callback)
  8774. if ( $.isFunction( speed ) ) {
  8775. callback = speed;
  8776. speed = null;
  8777. }
  8778. // add options to effect
  8779. if ( options ) {
  8780. $.extend( effect, options );
  8781. }
  8782. speed = speed || options.duration;
  8783. effect.duration = $.fx.off ? 0 :
  8784. typeof speed === "number" ? speed :
  8785. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  8786. $.fx.speeds._default;
  8787. effect.complete = callback || options.complete;
  8788. return effect;
  8789. }
  8790. function standardAnimationOption( option ) {
  8791. // Valid standard speeds (nothing, number, named speed)
  8792. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  8793. return true;
  8794. }
  8795. // Invalid strings - treat as "normal" speed
  8796. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  8797. return true;
  8798. }
  8799. // Complete callback
  8800. if ( $.isFunction( option ) ) {
  8801. return true;
  8802. }
  8803. // Options hash (but not naming an effect)
  8804. if ( typeof option === "object" && !option.effect ) {
  8805. return true;
  8806. }
  8807. // Didn't match any standard API
  8808. return false;
  8809. }
  8810. $.fn.extend({
  8811. effect: function( /* effect, options, speed, callback */ ) {
  8812. var args = _normalizeArguments.apply( this, arguments ),
  8813. mode = args.mode,
  8814. queue = args.queue,
  8815. effectMethod = $.effects.effect[ args.effect ];
  8816. if ( $.fx.off || !effectMethod ) {
  8817. // delegate to the original method (e.g., .show()) if possible
  8818. if ( mode ) {
  8819. return this[ mode ]( args.duration, args.complete );
  8820. } else {
  8821. return this.each( function() {
  8822. if ( args.complete ) {
  8823. args.complete.call( this );
  8824. }
  8825. });
  8826. }
  8827. }
  8828. function run( next ) {
  8829. var elem = $( this ),
  8830. complete = args.complete,
  8831. mode = args.mode;
  8832. function done() {
  8833. if ( $.isFunction( complete ) ) {
  8834. complete.call( elem[0] );
  8835. }
  8836. if ( $.isFunction( next ) ) {
  8837. next();
  8838. }
  8839. }
  8840. // If the element already has the correct final state, delegate to
  8841. // the core methods so the internal tracking of "olddisplay" works.
  8842. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  8843. elem[ mode ]();
  8844. done();
  8845. } else {
  8846. effectMethod.call( elem[0], args, done );
  8847. }
  8848. }
  8849. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  8850. },
  8851. show: (function( orig ) {
  8852. return function( option ) {
  8853. if ( standardAnimationOption( option ) ) {
  8854. return orig.apply( this, arguments );
  8855. } else {
  8856. var args = _normalizeArguments.apply( this, arguments );
  8857. args.mode = "show";
  8858. return this.effect.call( this, args );
  8859. }
  8860. };
  8861. })( $.fn.show ),
  8862. hide: (function( orig ) {
  8863. return function( option ) {
  8864. if ( standardAnimationOption( option ) ) {
  8865. return orig.apply( this, arguments );
  8866. } else {
  8867. var args = _normalizeArguments.apply( this, arguments );
  8868. args.mode = "hide";
  8869. return this.effect.call( this, args );
  8870. }
  8871. };
  8872. })( $.fn.hide ),
  8873. toggle: (function( orig ) {
  8874. return function( option ) {
  8875. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  8876. return orig.apply( this, arguments );
  8877. } else {
  8878. var args = _normalizeArguments.apply( this, arguments );
  8879. args.mode = "toggle";
  8880. return this.effect.call( this, args );
  8881. }
  8882. };
  8883. })( $.fn.toggle ),
  8884. // helper functions
  8885. cssUnit: function(key) {
  8886. var style = this.css( key ),
  8887. val = [];
  8888. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  8889. if ( style.indexOf( unit ) > 0 ) {
  8890. val = [ parseFloat( style ), unit ];
  8891. }
  8892. });
  8893. return val;
  8894. }
  8895. });
  8896. })();
  8897. /******************************************************************************/
  8898. /*********************************** EASING ***********************************/
  8899. /******************************************************************************/
  8900. (function() {
  8901. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  8902. var baseEasings = {};
  8903. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  8904. baseEasings[ name ] = function( p ) {
  8905. return Math.pow( p, i + 2 );
  8906. };
  8907. });
  8908. $.extend( baseEasings, {
  8909. Sine: function( p ) {
  8910. return 1 - Math.cos( p * Math.PI / 2 );
  8911. },
  8912. Circ: function( p ) {
  8913. return 1 - Math.sqrt( 1 - p * p );
  8914. },
  8915. Elastic: function( p ) {
  8916. return p === 0 || p === 1 ? p :
  8917. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  8918. },
  8919. Back: function( p ) {
  8920. return p * p * ( 3 * p - 2 );
  8921. },
  8922. Bounce: function( p ) {
  8923. var pow2,
  8924. bounce = 4;
  8925. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  8926. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  8927. }
  8928. });
  8929. $.each( baseEasings, function( name, easeIn ) {
  8930. $.easing[ "easeIn" + name ] = easeIn;
  8931. $.easing[ "easeOut" + name ] = function( p ) {
  8932. return 1 - easeIn( 1 - p );
  8933. };
  8934. $.easing[ "easeInOut" + name ] = function( p ) {
  8935. return p < 0.5 ?
  8936. easeIn( p * 2 ) / 2 :
  8937. 1 - easeIn( p * -2 + 2 ) / 2;
  8938. };
  8939. });
  8940. })();
  8941. var effect = $.effects;
  8942. /*!
  8943. * jQuery UI Effects Blind 1.11.0
  8944. * http://jqueryui.com
  8945. *
  8946. * Copyright 2014 jQuery Foundation and other contributors
  8947. * Released under the MIT license.
  8948. * http://jquery.org/license
  8949. *
  8950. * http://api.jqueryui.com/blind-effect/
  8951. */
  8952. var effectBlind = $.effects.effect.blind = function( o, done ) {
  8953. // Create element
  8954. var el = $( this ),
  8955. rvertical = /up|down|vertical/,
  8956. rpositivemotion = /up|left|vertical|horizontal/,
  8957. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  8958. mode = $.effects.setMode( el, o.mode || "hide" ),
  8959. direction = o.direction || "up",
  8960. vertical = rvertical.test( direction ),
  8961. ref = vertical ? "height" : "width",
  8962. ref2 = vertical ? "top" : "left",
  8963. motion = rpositivemotion.test( direction ),
  8964. animation = {},
  8965. show = mode === "show",
  8966. wrapper, distance, margin;
  8967. // if already wrapped, the wrapper's properties are my property. #6245
  8968. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  8969. $.effects.save( el.parent(), props );
  8970. } else {
  8971. $.effects.save( el, props );
  8972. }
  8973. el.show();
  8974. wrapper = $.effects.createWrapper( el ).css({
  8975. overflow: "hidden"
  8976. });
  8977. distance = wrapper[ ref ]();
  8978. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  8979. animation[ ref ] = show ? distance : 0;
  8980. if ( !motion ) {
  8981. el
  8982. .css( vertical ? "bottom" : "right", 0 )
  8983. .css( vertical ? "top" : "left", "auto" )
  8984. .css({ position: "absolute" });
  8985. animation[ ref2 ] = show ? margin : distance + margin;
  8986. }
  8987. // start at 0 if we are showing
  8988. if ( show ) {
  8989. wrapper.css( ref, 0 );
  8990. if ( !motion ) {
  8991. wrapper.css( ref2, margin + distance );
  8992. }
  8993. }
  8994. // Animate
  8995. wrapper.animate( animation, {
  8996. duration: o.duration,
  8997. easing: o.easing,
  8998. queue: false,
  8999. complete: function() {
  9000. if ( mode === "hide" ) {
  9001. el.hide();
  9002. }
  9003. $.effects.restore( el, props );
  9004. $.effects.removeWrapper( el );
  9005. done();
  9006. }
  9007. });
  9008. };
  9009. /*!
  9010. * jQuery UI Effects Bounce 1.11.0
  9011. * http://jqueryui.com
  9012. *
  9013. * Copyright 2014 jQuery Foundation and other contributors
  9014. * Released under the MIT license.
  9015. * http://jquery.org/license
  9016. *
  9017. * http://api.jqueryui.com/bounce-effect/
  9018. */
  9019. var effectBounce = $.effects.effect.bounce = function( o, done ) {
  9020. var el = $( this ),
  9021. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9022. // defaults:
  9023. mode = $.effects.setMode( el, o.mode || "effect" ),
  9024. hide = mode === "hide",
  9025. show = mode === "show",
  9026. direction = o.direction || "up",
  9027. distance = o.distance,
  9028. times = o.times || 5,
  9029. // number of internal animations
  9030. anims = times * 2 + ( show || hide ? 1 : 0 ),
  9031. speed = o.duration / anims,
  9032. easing = o.easing,
  9033. // utility:
  9034. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9035. motion = ( direction === "up" || direction === "left" ),
  9036. i,
  9037. upAnim,
  9038. downAnim,
  9039. // we will need to re-assemble the queue to stack our animations in place
  9040. queue = el.queue(),
  9041. queuelen = queue.length;
  9042. // Avoid touching opacity to prevent clearType and PNG issues in IE
  9043. if ( show || hide ) {
  9044. props.push( "opacity" );
  9045. }
  9046. $.effects.save( el, props );
  9047. el.show();
  9048. $.effects.createWrapper( el ); // Create Wrapper
  9049. // default distance for the BIGGEST bounce is the outer Distance / 3
  9050. if ( !distance ) {
  9051. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  9052. }
  9053. if ( show ) {
  9054. downAnim = { opacity: 1 };
  9055. downAnim[ ref ] = 0;
  9056. // if we are showing, force opacity 0 and set the initial position
  9057. // then do the "first" animation
  9058. el.css( "opacity", 0 )
  9059. .css( ref, motion ? -distance * 2 : distance * 2 )
  9060. .animate( downAnim, speed, easing );
  9061. }
  9062. // start at the smallest distance if we are hiding
  9063. if ( hide ) {
  9064. distance = distance / Math.pow( 2, times - 1 );
  9065. }
  9066. downAnim = {};
  9067. downAnim[ ref ] = 0;
  9068. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  9069. for ( i = 0; i < times; i++ ) {
  9070. upAnim = {};
  9071. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9072. el.animate( upAnim, speed, easing )
  9073. .animate( downAnim, speed, easing );
  9074. distance = hide ? distance * 2 : distance / 2;
  9075. }
  9076. // Last Bounce when Hiding
  9077. if ( hide ) {
  9078. upAnim = { opacity: 0 };
  9079. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9080. el.animate( upAnim, speed, easing );
  9081. }
  9082. el.queue(function() {
  9083. if ( hide ) {
  9084. el.hide();
  9085. }
  9086. $.effects.restore( el, props );
  9087. $.effects.removeWrapper( el );
  9088. done();
  9089. });
  9090. // inject all the animations we just queued to be first in line (after "inprogress")
  9091. if ( queuelen > 1) {
  9092. queue.splice.apply( queue,
  9093. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9094. }
  9095. el.dequeue();
  9096. };
  9097. /*!
  9098. * jQuery UI Effects Clip 1.11.0
  9099. * http://jqueryui.com
  9100. *
  9101. * Copyright 2014 jQuery Foundation and other contributors
  9102. * Released under the MIT license.
  9103. * http://jquery.org/license
  9104. *
  9105. * http://api.jqueryui.com/clip-effect/
  9106. */
  9107. var effectClip = $.effects.effect.clip = function( o, done ) {
  9108. // Create element
  9109. var el = $( this ),
  9110. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9111. mode = $.effects.setMode( el, o.mode || "hide" ),
  9112. show = mode === "show",
  9113. direction = o.direction || "vertical",
  9114. vert = direction === "vertical",
  9115. size = vert ? "height" : "width",
  9116. position = vert ? "top" : "left",
  9117. animation = {},
  9118. wrapper, animate, distance;
  9119. // Save & Show
  9120. $.effects.save( el, props );
  9121. el.show();
  9122. // Create Wrapper
  9123. wrapper = $.effects.createWrapper( el ).css({
  9124. overflow: "hidden"
  9125. });
  9126. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  9127. distance = animate[ size ]();
  9128. // Shift
  9129. if ( show ) {
  9130. animate.css( size, 0 );
  9131. animate.css( position, distance / 2 );
  9132. }
  9133. // Create Animation Object:
  9134. animation[ size ] = show ? distance : 0;
  9135. animation[ position ] = show ? 0 : distance / 2;
  9136. // Animate
  9137. animate.animate( animation, {
  9138. queue: false,
  9139. duration: o.duration,
  9140. easing: o.easing,
  9141. complete: function() {
  9142. if ( !show ) {
  9143. el.hide();
  9144. }
  9145. $.effects.restore( el, props );
  9146. $.effects.removeWrapper( el );
  9147. done();
  9148. }
  9149. });
  9150. };
  9151. /*!
  9152. * jQuery UI Effects Drop 1.11.0
  9153. * http://jqueryui.com
  9154. *
  9155. * Copyright 2014 jQuery Foundation and other contributors
  9156. * Released under the MIT license.
  9157. * http://jquery.org/license
  9158. *
  9159. * http://api.jqueryui.com/drop-effect/
  9160. */
  9161. var effectDrop = $.effects.effect.drop = function( o, done ) {
  9162. var el = $( this ),
  9163. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  9164. mode = $.effects.setMode( el, o.mode || "hide" ),
  9165. show = mode === "show",
  9166. direction = o.direction || "left",
  9167. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9168. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  9169. animation = {
  9170. opacity: show ? 1 : 0
  9171. },
  9172. distance;
  9173. // Adjust
  9174. $.effects.save( el, props );
  9175. el.show();
  9176. $.effects.createWrapper( el );
  9177. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  9178. if ( show ) {
  9179. el
  9180. .css( "opacity", 0 )
  9181. .css( ref, motion === "pos" ? -distance : distance );
  9182. }
  9183. // Animation
  9184. animation[ ref ] = ( show ?
  9185. ( motion === "pos" ? "+=" : "-=" ) :
  9186. ( motion === "pos" ? "-=" : "+=" ) ) +
  9187. distance;
  9188. // Animate
  9189. el.animate( animation, {
  9190. queue: false,
  9191. duration: o.duration,
  9192. easing: o.easing,
  9193. complete: function() {
  9194. if ( mode === "hide" ) {
  9195. el.hide();
  9196. }
  9197. $.effects.restore( el, props );
  9198. $.effects.removeWrapper( el );
  9199. done();
  9200. }
  9201. });
  9202. };
  9203. /*!
  9204. * jQuery UI Effects Explode 1.11.0
  9205. * http://jqueryui.com
  9206. *
  9207. * Copyright 2014 jQuery Foundation and other contributors
  9208. * Released under the MIT license.
  9209. * http://jquery.org/license
  9210. *
  9211. * http://api.jqueryui.com/explode-effect/
  9212. */
  9213. var effectExplode = $.effects.effect.explode = function( o, done ) {
  9214. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  9215. cells = rows,
  9216. el = $( this ),
  9217. mode = $.effects.setMode( el, o.mode || "hide" ),
  9218. show = mode === "show",
  9219. // show and then visibility:hidden the element before calculating offset
  9220. offset = el.show().css( "visibility", "hidden" ).offset(),
  9221. // width and height of a piece
  9222. width = Math.ceil( el.outerWidth() / cells ),
  9223. height = Math.ceil( el.outerHeight() / rows ),
  9224. pieces = [],
  9225. // loop
  9226. i, j, left, top, mx, my;
  9227. // children animate complete:
  9228. function childComplete() {
  9229. pieces.push( this );
  9230. if ( pieces.length === rows * cells ) {
  9231. animComplete();
  9232. }
  9233. }
  9234. // clone the element for each row and cell.
  9235. for ( i = 0; i < rows ; i++ ) { // ===>
  9236. top = offset.top + i * height;
  9237. my = i - ( rows - 1 ) / 2 ;
  9238. for ( j = 0; j < cells ; j++ ) { // |||
  9239. left = offset.left + j * width;
  9240. mx = j - ( cells - 1 ) / 2 ;
  9241. // Create a clone of the now hidden main element that will be absolute positioned
  9242. // within a wrapper div off the -left and -top equal to size of our pieces
  9243. el
  9244. .clone()
  9245. .appendTo( "body" )
  9246. .wrap( "<div></div>" )
  9247. .css({
  9248. position: "absolute",
  9249. visibility: "visible",
  9250. left: -j * width,
  9251. top: -i * height
  9252. })
  9253. // select the wrapper - make it overflow: hidden and absolute positioned based on
  9254. // where the original was located +left and +top equal to the size of pieces
  9255. .parent()
  9256. .addClass( "ui-effects-explode" )
  9257. .css({
  9258. position: "absolute",
  9259. overflow: "hidden",
  9260. width: width,
  9261. height: height,
  9262. left: left + ( show ? mx * width : 0 ),
  9263. top: top + ( show ? my * height : 0 ),
  9264. opacity: show ? 0 : 1
  9265. }).animate({
  9266. left: left + ( show ? 0 : mx * width ),
  9267. top: top + ( show ? 0 : my * height ),
  9268. opacity: show ? 1 : 0
  9269. }, o.duration || 500, o.easing, childComplete );
  9270. }
  9271. }
  9272. function animComplete() {
  9273. el.css({
  9274. visibility: "visible"
  9275. });
  9276. $( pieces ).remove();
  9277. if ( !show ) {
  9278. el.hide();
  9279. }
  9280. done();
  9281. }
  9282. };
  9283. /*!
  9284. * jQuery UI Effects Fade 1.11.0
  9285. * http://jqueryui.com
  9286. *
  9287. * Copyright 2014 jQuery Foundation and other contributors
  9288. * Released under the MIT license.
  9289. * http://jquery.org/license
  9290. *
  9291. * http://api.jqueryui.com/fade-effect/
  9292. */
  9293. var effectFade = $.effects.effect.fade = function( o, done ) {
  9294. var el = $( this ),
  9295. mode = $.effects.setMode( el, o.mode || "toggle" );
  9296. el.animate({
  9297. opacity: mode
  9298. }, {
  9299. queue: false,
  9300. duration: o.duration,
  9301. easing: o.easing,
  9302. complete: done
  9303. });
  9304. };
  9305. /*!
  9306. * jQuery UI Effects Fold 1.11.0
  9307. * http://jqueryui.com
  9308. *
  9309. * Copyright 2014 jQuery Foundation and other contributors
  9310. * Released under the MIT license.
  9311. * http://jquery.org/license
  9312. *
  9313. * http://api.jqueryui.com/fold-effect/
  9314. */
  9315. var effectFold = $.effects.effect.fold = function( o, done ) {
  9316. // Create element
  9317. var el = $( this ),
  9318. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9319. mode = $.effects.setMode( el, o.mode || "hide" ),
  9320. show = mode === "show",
  9321. hide = mode === "hide",
  9322. size = o.size || 15,
  9323. percent = /([0-9]+)%/.exec( size ),
  9324. horizFirst = !!o.horizFirst,
  9325. widthFirst = show !== horizFirst,
  9326. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  9327. duration = o.duration / 2,
  9328. wrapper, distance,
  9329. animation1 = {},
  9330. animation2 = {};
  9331. $.effects.save( el, props );
  9332. el.show();
  9333. // Create Wrapper
  9334. wrapper = $.effects.createWrapper( el ).css({
  9335. overflow: "hidden"
  9336. });
  9337. distance = widthFirst ?
  9338. [ wrapper.width(), wrapper.height() ] :
  9339. [ wrapper.height(), wrapper.width() ];
  9340. if ( percent ) {
  9341. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  9342. }
  9343. if ( show ) {
  9344. wrapper.css( horizFirst ? {
  9345. height: 0,
  9346. width: size
  9347. } : {
  9348. height: size,
  9349. width: 0
  9350. });
  9351. }
  9352. // Animation
  9353. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  9354. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  9355. // Animate
  9356. wrapper
  9357. .animate( animation1, duration, o.easing )
  9358. .animate( animation2, duration, o.easing, function() {
  9359. if ( hide ) {
  9360. el.hide();
  9361. }
  9362. $.effects.restore( el, props );
  9363. $.effects.removeWrapper( el );
  9364. done();
  9365. });
  9366. };
  9367. /*!
  9368. * jQuery UI Effects Highlight 1.11.0
  9369. * http://jqueryui.com
  9370. *
  9371. * Copyright 2014 jQuery Foundation and other contributors
  9372. * Released under the MIT license.
  9373. * http://jquery.org/license
  9374. *
  9375. * http://api.jqueryui.com/highlight-effect/
  9376. */
  9377. var effectHighlight = $.effects.effect.highlight = function( o, done ) {
  9378. var elem = $( this ),
  9379. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  9380. mode = $.effects.setMode( elem, o.mode || "show" ),
  9381. animation = {
  9382. backgroundColor: elem.css( "backgroundColor" )
  9383. };
  9384. if (mode === "hide") {
  9385. animation.opacity = 0;
  9386. }
  9387. $.effects.save( elem, props );
  9388. elem
  9389. .show()
  9390. .css({
  9391. backgroundImage: "none",
  9392. backgroundColor: o.color || "#ffff99"
  9393. })
  9394. .animate( animation, {
  9395. queue: false,
  9396. duration: o.duration,
  9397. easing: o.easing,
  9398. complete: function() {
  9399. if ( mode === "hide" ) {
  9400. elem.hide();
  9401. }
  9402. $.effects.restore( elem, props );
  9403. done();
  9404. }
  9405. });
  9406. };
  9407. /*!
  9408. * jQuery UI Effects Size 1.11.0
  9409. * http://jqueryui.com
  9410. *
  9411. * Copyright 2014 jQuery Foundation and other contributors
  9412. * Released under the MIT license.
  9413. * http://jquery.org/license
  9414. *
  9415. * http://api.jqueryui.com/size-effect/
  9416. */
  9417. var effectSize = $.effects.effect.size = function( o, done ) {
  9418. // Create element
  9419. var original, baseline, factor,
  9420. el = $( this ),
  9421. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  9422. // Always restore
  9423. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  9424. // Copy for children
  9425. props2 = [ "width", "height", "overflow" ],
  9426. cProps = [ "fontSize" ],
  9427. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  9428. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  9429. // Set options
  9430. mode = $.effects.setMode( el, o.mode || "effect" ),
  9431. restore = o.restore || mode !== "effect",
  9432. scale = o.scale || "both",
  9433. origin = o.origin || [ "middle", "center" ],
  9434. position = el.css( "position" ),
  9435. props = restore ? props0 : props1,
  9436. zero = {
  9437. height: 0,
  9438. width: 0,
  9439. outerHeight: 0,
  9440. outerWidth: 0
  9441. };
  9442. if ( mode === "show" ) {
  9443. el.show();
  9444. }
  9445. original = {
  9446. height: el.height(),
  9447. width: el.width(),
  9448. outerHeight: el.outerHeight(),
  9449. outerWidth: el.outerWidth()
  9450. };
  9451. if ( o.mode === "toggle" && mode === "show" ) {
  9452. el.from = o.to || zero;
  9453. el.to = o.from || original;
  9454. } else {
  9455. el.from = o.from || ( mode === "show" ? zero : original );
  9456. el.to = o.to || ( mode === "hide" ? zero : original );
  9457. }
  9458. // Set scaling factor
  9459. factor = {
  9460. from: {
  9461. y: el.from.height / original.height,
  9462. x: el.from.width / original.width
  9463. },
  9464. to: {
  9465. y: el.to.height / original.height,
  9466. x: el.to.width / original.width
  9467. }
  9468. };
  9469. // Scale the css box
  9470. if ( scale === "box" || scale === "both" ) {
  9471. // Vertical props scaling
  9472. if ( factor.from.y !== factor.to.y ) {
  9473. props = props.concat( vProps );
  9474. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  9475. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  9476. }
  9477. // Horizontal props scaling
  9478. if ( factor.from.x !== factor.to.x ) {
  9479. props = props.concat( hProps );
  9480. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  9481. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  9482. }
  9483. }
  9484. // Scale the content
  9485. if ( scale === "content" || scale === "both" ) {
  9486. // Vertical props scaling
  9487. if ( factor.from.y !== factor.to.y ) {
  9488. props = props.concat( cProps ).concat( props2 );
  9489. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  9490. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  9491. }
  9492. }
  9493. $.effects.save( el, props );
  9494. el.show();
  9495. $.effects.createWrapper( el );
  9496. el.css( "overflow", "hidden" ).css( el.from );
  9497. // Adjust
  9498. if (origin) { // Calculate baseline shifts
  9499. baseline = $.effects.getBaseline( origin, original );
  9500. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  9501. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  9502. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  9503. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  9504. }
  9505. el.css( el.from ); // set top & left
  9506. // Animate
  9507. if ( scale === "content" || scale === "both" ) { // Scale the children
  9508. // Add margins/font-size
  9509. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  9510. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  9511. props2 = props0.concat(vProps).concat(hProps);
  9512. el.find( "*[width]" ).each( function() {
  9513. var child = $( this ),
  9514. c_original = {
  9515. height: child.height(),
  9516. width: child.width(),
  9517. outerHeight: child.outerHeight(),
  9518. outerWidth: child.outerWidth()
  9519. };
  9520. if (restore) {
  9521. $.effects.save(child, props2);
  9522. }
  9523. child.from = {
  9524. height: c_original.height * factor.from.y,
  9525. width: c_original.width * factor.from.x,
  9526. outerHeight: c_original.outerHeight * factor.from.y,
  9527. outerWidth: c_original.outerWidth * factor.from.x
  9528. };
  9529. child.to = {
  9530. height: c_original.height * factor.to.y,
  9531. width: c_original.width * factor.to.x,
  9532. outerHeight: c_original.height * factor.to.y,
  9533. outerWidth: c_original.width * factor.to.x
  9534. };
  9535. // Vertical props scaling
  9536. if ( factor.from.y !== factor.to.y ) {
  9537. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  9538. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  9539. }
  9540. // Horizontal props scaling
  9541. if ( factor.from.x !== factor.to.x ) {
  9542. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  9543. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  9544. }
  9545. // Animate children
  9546. child.css( child.from );
  9547. child.animate( child.to, o.duration, o.easing, function() {
  9548. // Restore children
  9549. if ( restore ) {
  9550. $.effects.restore( child, props2 );
  9551. }
  9552. });
  9553. });
  9554. }
  9555. // Animate
  9556. el.animate( el.to, {
  9557. queue: false,
  9558. duration: o.duration,
  9559. easing: o.easing,
  9560. complete: function() {
  9561. if ( el.to.opacity === 0 ) {
  9562. el.css( "opacity", el.from.opacity );
  9563. }
  9564. if ( mode === "hide" ) {
  9565. el.hide();
  9566. }
  9567. $.effects.restore( el, props );
  9568. if ( !restore ) {
  9569. // we need to calculate our new positioning based on the scaling
  9570. if ( position === "static" ) {
  9571. el.css({
  9572. position: "relative",
  9573. top: el.to.top,
  9574. left: el.to.left
  9575. });
  9576. } else {
  9577. $.each([ "top", "left" ], function( idx, pos ) {
  9578. el.css( pos, function( _, str ) {
  9579. var val = parseInt( str, 10 ),
  9580. toRef = idx ? el.to.left : el.to.top;
  9581. // if original was "auto", recalculate the new value from wrapper
  9582. if ( str === "auto" ) {
  9583. return toRef + "px";
  9584. }
  9585. return val + toRef + "px";
  9586. });
  9587. });
  9588. }
  9589. }
  9590. $.effects.removeWrapper( el );
  9591. done();
  9592. }
  9593. });
  9594. };
  9595. /*!
  9596. * jQuery UI Effects Scale 1.11.0
  9597. * http://jqueryui.com
  9598. *
  9599. * Copyright 2014 jQuery Foundation and other contributors
  9600. * Released under the MIT license.
  9601. * http://jquery.org/license
  9602. *
  9603. * http://api.jqueryui.com/scale-effect/
  9604. */
  9605. var effectScale = $.effects.effect.scale = function( o, done ) {
  9606. // Create element
  9607. var el = $( this ),
  9608. options = $.extend( true, {}, o ),
  9609. mode = $.effects.setMode( el, o.mode || "effect" ),
  9610. percent = parseInt( o.percent, 10 ) ||
  9611. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  9612. direction = o.direction || "both",
  9613. origin = o.origin,
  9614. original = {
  9615. height: el.height(),
  9616. width: el.width(),
  9617. outerHeight: el.outerHeight(),
  9618. outerWidth: el.outerWidth()
  9619. },
  9620. factor = {
  9621. y: direction !== "horizontal" ? (percent / 100) : 1,
  9622. x: direction !== "vertical" ? (percent / 100) : 1
  9623. };
  9624. // We are going to pass this effect to the size effect:
  9625. options.effect = "size";
  9626. options.queue = false;
  9627. options.complete = done;
  9628. // Set default origin and restore for show/hide
  9629. if ( mode !== "effect" ) {
  9630. options.origin = origin || [ "middle", "center" ];
  9631. options.restore = true;
  9632. }
  9633. options.from = o.from || ( mode === "show" ? {
  9634. height: 0,
  9635. width: 0,
  9636. outerHeight: 0,
  9637. outerWidth: 0
  9638. } : original );
  9639. options.to = {
  9640. height: original.height * factor.y,
  9641. width: original.width * factor.x,
  9642. outerHeight: original.outerHeight * factor.y,
  9643. outerWidth: original.outerWidth * factor.x
  9644. };
  9645. // Fade option to support puff
  9646. if ( options.fade ) {
  9647. if ( mode === "show" ) {
  9648. options.from.opacity = 0;
  9649. options.to.opacity = 1;
  9650. }
  9651. if ( mode === "hide" ) {
  9652. options.from.opacity = 1;
  9653. options.to.opacity = 0;
  9654. }
  9655. }
  9656. // Animate
  9657. el.effect( options );
  9658. };
  9659. /*!
  9660. * jQuery UI Effects Puff 1.11.0
  9661. * http://jqueryui.com
  9662. *
  9663. * Copyright 2014 jQuery Foundation and other contributors
  9664. * Released under the MIT license.
  9665. * http://jquery.org/license
  9666. *
  9667. * http://api.jqueryui.com/puff-effect/
  9668. */
  9669. var effectPuff = $.effects.effect.puff = function( o, done ) {
  9670. var elem = $( this ),
  9671. mode = $.effects.setMode( elem, o.mode || "hide" ),
  9672. hide = mode === "hide",
  9673. percent = parseInt( o.percent, 10 ) || 150,
  9674. factor = percent / 100,
  9675. original = {
  9676. height: elem.height(),
  9677. width: elem.width(),
  9678. outerHeight: elem.outerHeight(),
  9679. outerWidth: elem.outerWidth()
  9680. };
  9681. $.extend( o, {
  9682. effect: "scale",
  9683. queue: false,
  9684. fade: true,
  9685. mode: mode,
  9686. complete: done,
  9687. percent: hide ? percent : 100,
  9688. from: hide ?
  9689. original :
  9690. {
  9691. height: original.height * factor,
  9692. width: original.width * factor,
  9693. outerHeight: original.outerHeight * factor,
  9694. outerWidth: original.outerWidth * factor
  9695. }
  9696. });
  9697. elem.effect( o );
  9698. };
  9699. /*!
  9700. * jQuery UI Effects Pulsate 1.11.0
  9701. * http://jqueryui.com
  9702. *
  9703. * Copyright 2014 jQuery Foundation and other contributors
  9704. * Released under the MIT license.
  9705. * http://jquery.org/license
  9706. *
  9707. * http://api.jqueryui.com/pulsate-effect/
  9708. */
  9709. var effectPulsate = $.effects.effect.pulsate = function( o, done ) {
  9710. var elem = $( this ),
  9711. mode = $.effects.setMode( elem, o.mode || "show" ),
  9712. show = mode === "show",
  9713. hide = mode === "hide",
  9714. showhide = ( show || mode === "hide" ),
  9715. // showing or hiding leaves of the "last" animation
  9716. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  9717. duration = o.duration / anims,
  9718. animateTo = 0,
  9719. queue = elem.queue(),
  9720. queuelen = queue.length,
  9721. i;
  9722. if ( show || !elem.is(":visible")) {
  9723. elem.css( "opacity", 0 ).show();
  9724. animateTo = 1;
  9725. }
  9726. // anims - 1 opacity "toggles"
  9727. for ( i = 1; i < anims; i++ ) {
  9728. elem.animate({
  9729. opacity: animateTo
  9730. }, duration, o.easing );
  9731. animateTo = 1 - animateTo;
  9732. }
  9733. elem.animate({
  9734. opacity: animateTo
  9735. }, duration, o.easing);
  9736. elem.queue(function() {
  9737. if ( hide ) {
  9738. elem.hide();
  9739. }
  9740. done();
  9741. });
  9742. // We just queued up "anims" animations, we need to put them next in the queue
  9743. if ( queuelen > 1 ) {
  9744. queue.splice.apply( queue,
  9745. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9746. }
  9747. elem.dequeue();
  9748. };
  9749. /*!
  9750. * jQuery UI Effects Shake 1.11.0
  9751. * http://jqueryui.com
  9752. *
  9753. * Copyright 2014 jQuery Foundation and other contributors
  9754. * Released under the MIT license.
  9755. * http://jquery.org/license
  9756. *
  9757. * http://api.jqueryui.com/shake-effect/
  9758. */
  9759. var effectShake = $.effects.effect.shake = function( o, done ) {
  9760. var el = $( this ),
  9761. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9762. mode = $.effects.setMode( el, o.mode || "effect" ),
  9763. direction = o.direction || "left",
  9764. distance = o.distance || 20,
  9765. times = o.times || 3,
  9766. anims = times * 2 + 1,
  9767. speed = Math.round( o.duration / anims ),
  9768. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9769. positiveMotion = (direction === "up" || direction === "left"),
  9770. animation = {},
  9771. animation1 = {},
  9772. animation2 = {},
  9773. i,
  9774. // we will need to re-assemble the queue to stack our animations in place
  9775. queue = el.queue(),
  9776. queuelen = queue.length;
  9777. $.effects.save( el, props );
  9778. el.show();
  9779. $.effects.createWrapper( el );
  9780. // Animation
  9781. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  9782. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  9783. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  9784. // Animate
  9785. el.animate( animation, speed, o.easing );
  9786. // Shakes
  9787. for ( i = 1; i < times; i++ ) {
  9788. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  9789. }
  9790. el
  9791. .animate( animation1, speed, o.easing )
  9792. .animate( animation, speed / 2, o.easing )
  9793. .queue(function() {
  9794. if ( mode === "hide" ) {
  9795. el.hide();
  9796. }
  9797. $.effects.restore( el, props );
  9798. $.effects.removeWrapper( el );
  9799. done();
  9800. });
  9801. // inject all the animations we just queued to be first in line (after "inprogress")
  9802. if ( queuelen > 1) {
  9803. queue.splice.apply( queue,
  9804. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9805. }
  9806. el.dequeue();
  9807. };
  9808. /*!
  9809. * jQuery UI Effects Slide 1.11.0
  9810. * http://jqueryui.com
  9811. *
  9812. * Copyright 2014 jQuery Foundation and other contributors
  9813. * Released under the MIT license.
  9814. * http://jquery.org/license
  9815. *
  9816. * http://api.jqueryui.com/slide-effect/
  9817. */
  9818. var effectSlide = $.effects.effect.slide = function( o, done ) {
  9819. // Create element
  9820. var el = $( this ),
  9821. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  9822. mode = $.effects.setMode( el, o.mode || "show" ),
  9823. show = mode === "show",
  9824. direction = o.direction || "left",
  9825. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9826. positiveMotion = (direction === "up" || direction === "left"),
  9827. distance,
  9828. animation = {};
  9829. // Adjust
  9830. $.effects.save( el, props );
  9831. el.show();
  9832. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  9833. $.effects.createWrapper( el ).css({
  9834. overflow: "hidden"
  9835. });
  9836. if ( show ) {
  9837. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  9838. }
  9839. // Animation
  9840. animation[ ref ] = ( show ?
  9841. ( positiveMotion ? "+=" : "-=") :
  9842. ( positiveMotion ? "-=" : "+=")) +
  9843. distance;
  9844. // Animate
  9845. el.animate( animation, {
  9846. queue: false,
  9847. duration: o.duration,
  9848. easing: o.easing,
  9849. complete: function() {
  9850. if ( mode === "hide" ) {
  9851. el.hide();
  9852. }
  9853. $.effects.restore( el, props );
  9854. $.effects.removeWrapper( el );
  9855. done();
  9856. }
  9857. });
  9858. };
  9859. /*!
  9860. * jQuery UI Effects Transfer 1.11.0
  9861. * http://jqueryui.com
  9862. *
  9863. * Copyright 2014 jQuery Foundation and other contributors
  9864. * Released under the MIT license.
  9865. * http://jquery.org/license
  9866. *
  9867. * http://api.jqueryui.com/transfer-effect/
  9868. */
  9869. var effectTransfer = $.effects.effect.transfer = function( o, done ) {
  9870. var elem = $( this ),
  9871. target = $( o.to ),
  9872. targetFixed = target.css( "position" ) === "fixed",
  9873. body = $("body"),
  9874. fixTop = targetFixed ? body.scrollTop() : 0,
  9875. fixLeft = targetFixed ? body.scrollLeft() : 0,
  9876. endPosition = target.offset(),
  9877. animation = {
  9878. top: endPosition.top - fixTop,
  9879. left: endPosition.left - fixLeft,
  9880. height: target.innerHeight(),
  9881. width: target.innerWidth()
  9882. },
  9883. startPosition = elem.offset(),
  9884. transfer = $( "<div class='ui-effects-transfer'></div>" )
  9885. .appendTo( document.body )
  9886. .addClass( o.className )
  9887. .css({
  9888. top: startPosition.top - fixTop,
  9889. left: startPosition.left - fixLeft,
  9890. height: elem.innerHeight(),
  9891. width: elem.innerWidth(),
  9892. position: targetFixed ? "fixed" : "absolute"
  9893. })
  9894. .animate( animation, o.duration, o.easing, function() {
  9895. transfer.remove();
  9896. done();
  9897. });
  9898. };
  9899. /*!
  9900. * jQuery UI Progressbar 1.11.0
  9901. * http://jqueryui.com
  9902. *
  9903. * Copyright 2014 jQuery Foundation and other contributors
  9904. * Released under the MIT license.
  9905. * http://jquery.org/license
  9906. *
  9907. * http://api.jqueryui.com/progressbar/
  9908. */
  9909. var progressbar = $.widget( "ui.progressbar", {
  9910. version: "1.11.0",
  9911. options: {
  9912. max: 100,
  9913. value: 0,
  9914. change: null,
  9915. complete: null
  9916. },
  9917. min: 0,
  9918. _create: function() {
  9919. // Constrain initial value
  9920. this.oldValue = this.options.value = this._constrainedValue();
  9921. this.element
  9922. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  9923. .attr({
  9924. // Only set static values, aria-valuenow and aria-valuemax are
  9925. // set inside _refreshValue()
  9926. role: "progressbar",
  9927. "aria-valuemin": this.min
  9928. });
  9929. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  9930. .appendTo( this.element );
  9931. this._refreshValue();
  9932. },
  9933. _destroy: function() {
  9934. this.element
  9935. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  9936. .removeAttr( "role" )
  9937. .removeAttr( "aria-valuemin" )
  9938. .removeAttr( "aria-valuemax" )
  9939. .removeAttr( "aria-valuenow" );
  9940. this.valueDiv.remove();
  9941. },
  9942. value: function( newValue ) {
  9943. if ( newValue === undefined ) {
  9944. return this.options.value;
  9945. }
  9946. this.options.value = this._constrainedValue( newValue );
  9947. this._refreshValue();
  9948. },
  9949. _constrainedValue: function( newValue ) {
  9950. if ( newValue === undefined ) {
  9951. newValue = this.options.value;
  9952. }
  9953. this.indeterminate = newValue === false;
  9954. // sanitize value
  9955. if ( typeof newValue !== "number" ) {
  9956. newValue = 0;
  9957. }
  9958. return this.indeterminate ? false :
  9959. Math.min( this.options.max, Math.max( this.min, newValue ) );
  9960. },
  9961. _setOptions: function( options ) {
  9962. // Ensure "value" option is set after other values (like max)
  9963. var value = options.value;
  9964. delete options.value;
  9965. this._super( options );
  9966. this.options.value = this._constrainedValue( value );
  9967. this._refreshValue();
  9968. },
  9969. _setOption: function( key, value ) {
  9970. if ( key === "max" ) {
  9971. // Don't allow a max less than min
  9972. value = Math.max( this.min, value );
  9973. }
  9974. if ( key === "disabled" ) {
  9975. this.element
  9976. .toggleClass( "ui-state-disabled", !!value )
  9977. .attr( "aria-disabled", value );
  9978. }
  9979. this._super( key, value );
  9980. },
  9981. _percentage: function() {
  9982. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  9983. },
  9984. _refreshValue: function() {
  9985. var value = this.options.value,
  9986. percentage = this._percentage();
  9987. this.valueDiv
  9988. .toggle( this.indeterminate || value > this.min )
  9989. .toggleClass( "ui-corner-right", value === this.options.max )
  9990. .width( percentage.toFixed(0) + "%" );
  9991. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  9992. if ( this.indeterminate ) {
  9993. this.element.removeAttr( "aria-valuenow" );
  9994. if ( !this.overlayDiv ) {
  9995. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  9996. }
  9997. } else {
  9998. this.element.attr({
  9999. "aria-valuemax": this.options.max,
  10000. "aria-valuenow": value
  10001. });
  10002. if ( this.overlayDiv ) {
  10003. this.overlayDiv.remove();
  10004. this.overlayDiv = null;
  10005. }
  10006. }
  10007. if ( this.oldValue !== value ) {
  10008. this.oldValue = value;
  10009. this._trigger( "change" );
  10010. }
  10011. if ( value === this.options.max ) {
  10012. this._trigger( "complete" );
  10013. }
  10014. }
  10015. });
  10016. /*!
  10017. * jQuery UI Selectable 1.11.0
  10018. * http://jqueryui.com
  10019. *
  10020. * Copyright 2014 jQuery Foundation and other contributors
  10021. * Released under the MIT license.
  10022. * http://jquery.org/license
  10023. *
  10024. * http://api.jqueryui.com/selectable/
  10025. */
  10026. var selectable = $.widget("ui.selectable", $.ui.mouse, {
  10027. version: "1.11.0",
  10028. options: {
  10029. appendTo: "body",
  10030. autoRefresh: true,
  10031. distance: 0,
  10032. filter: "*",
  10033. tolerance: "touch",
  10034. // callbacks
  10035. selected: null,
  10036. selecting: null,
  10037. start: null,
  10038. stop: null,
  10039. unselected: null,
  10040. unselecting: null
  10041. },
  10042. _create: function() {
  10043. var selectees,
  10044. that = this;
  10045. this.element.addClass("ui-selectable");
  10046. this.dragged = false;
  10047. // cache selectee children based on filter
  10048. this.refresh = function() {
  10049. selectees = $(that.options.filter, that.element[0]);
  10050. selectees.addClass("ui-selectee");
  10051. selectees.each(function() {
  10052. var $this = $(this),
  10053. pos = $this.offset();
  10054. $.data(this, "selectable-item", {
  10055. element: this,
  10056. $element: $this,
  10057. left: pos.left,
  10058. top: pos.top,
  10059. right: pos.left + $this.outerWidth(),
  10060. bottom: pos.top + $this.outerHeight(),
  10061. startselected: false,
  10062. selected: $this.hasClass("ui-selected"),
  10063. selecting: $this.hasClass("ui-selecting"),
  10064. unselecting: $this.hasClass("ui-unselecting")
  10065. });
  10066. });
  10067. };
  10068. this.refresh();
  10069. this.selectees = selectees.addClass("ui-selectee");
  10070. this._mouseInit();
  10071. this.helper = $("<div class='ui-selectable-helper'></div>");
  10072. },
  10073. _destroy: function() {
  10074. this.selectees
  10075. .removeClass("ui-selectee")
  10076. .removeData("selectable-item");
  10077. this.element
  10078. .removeClass("ui-selectable ui-selectable-disabled");
  10079. this._mouseDestroy();
  10080. },
  10081. _mouseStart: function(event) {
  10082. var that = this,
  10083. options = this.options;
  10084. this.opos = [ event.pageX, event.pageY ];
  10085. if (this.options.disabled) {
  10086. return;
  10087. }
  10088. this.selectees = $(options.filter, this.element[0]);
  10089. this._trigger("start", event);
  10090. $(options.appendTo).append(this.helper);
  10091. // position helper (lasso)
  10092. this.helper.css({
  10093. "left": event.pageX,
  10094. "top": event.pageY,
  10095. "width": 0,
  10096. "height": 0
  10097. });
  10098. if (options.autoRefresh) {
  10099. this.refresh();
  10100. }
  10101. this.selectees.filter(".ui-selected").each(function() {
  10102. var selectee = $.data(this, "selectable-item");
  10103. selectee.startselected = true;
  10104. if (!event.metaKey && !event.ctrlKey) {
  10105. selectee.$element.removeClass("ui-selected");
  10106. selectee.selected = false;
  10107. selectee.$element.addClass("ui-unselecting");
  10108. selectee.unselecting = true;
  10109. // selectable UNSELECTING callback
  10110. that._trigger("unselecting", event, {
  10111. unselecting: selectee.element
  10112. });
  10113. }
  10114. });
  10115. $(event.target).parents().addBack().each(function() {
  10116. var doSelect,
  10117. selectee = $.data(this, "selectable-item");
  10118. if (selectee) {
  10119. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  10120. selectee.$element
  10121. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  10122. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  10123. selectee.unselecting = !doSelect;
  10124. selectee.selecting = doSelect;
  10125. selectee.selected = doSelect;
  10126. // selectable (UN)SELECTING callback
  10127. if (doSelect) {
  10128. that._trigger("selecting", event, {
  10129. selecting: selectee.element
  10130. });
  10131. } else {
  10132. that._trigger("unselecting", event, {
  10133. unselecting: selectee.element
  10134. });
  10135. }
  10136. return false;
  10137. }
  10138. });
  10139. },
  10140. _mouseDrag: function(event) {
  10141. this.dragged = true;
  10142. if (this.options.disabled) {
  10143. return;
  10144. }
  10145. var tmp,
  10146. that = this,
  10147. options = this.options,
  10148. x1 = this.opos[0],
  10149. y1 = this.opos[1],
  10150. x2 = event.pageX,
  10151. y2 = event.pageY;
  10152. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  10153. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  10154. this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });
  10155. this.selectees.each(function() {
  10156. var selectee = $.data(this, "selectable-item"),
  10157. hit = false;
  10158. //prevent helper from being selected if appendTo: selectable
  10159. if (!selectee || selectee.element === that.element[0]) {
  10160. return;
  10161. }
  10162. if (options.tolerance === "touch") {
  10163. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  10164. } else if (options.tolerance === "fit") {
  10165. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  10166. }
  10167. if (hit) {
  10168. // SELECT
  10169. if (selectee.selected) {
  10170. selectee.$element.removeClass("ui-selected");
  10171. selectee.selected = false;
  10172. }
  10173. if (selectee.unselecting) {
  10174. selectee.$element.removeClass("ui-unselecting");
  10175. selectee.unselecting = false;
  10176. }
  10177. if (!selectee.selecting) {
  10178. selectee.$element.addClass("ui-selecting");
  10179. selectee.selecting = true;
  10180. // selectable SELECTING callback
  10181. that._trigger("selecting", event, {
  10182. selecting: selectee.element
  10183. });
  10184. }
  10185. } else {
  10186. // UNSELECT
  10187. if (selectee.selecting) {
  10188. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  10189. selectee.$element.removeClass("ui-selecting");
  10190. selectee.selecting = false;
  10191. selectee.$element.addClass("ui-selected");
  10192. selectee.selected = true;
  10193. } else {
  10194. selectee.$element.removeClass("ui-selecting");
  10195. selectee.selecting = false;
  10196. if (selectee.startselected) {
  10197. selectee.$element.addClass("ui-unselecting");
  10198. selectee.unselecting = true;
  10199. }
  10200. // selectable UNSELECTING callback
  10201. that._trigger("unselecting", event, {
  10202. unselecting: selectee.element
  10203. });
  10204. }
  10205. }
  10206. if (selectee.selected) {
  10207. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  10208. selectee.$element.removeClass("ui-selected");
  10209. selectee.selected = false;
  10210. selectee.$element.addClass("ui-unselecting");
  10211. selectee.unselecting = true;
  10212. // selectable UNSELECTING callback
  10213. that._trigger("unselecting", event, {
  10214. unselecting: selectee.element
  10215. });
  10216. }
  10217. }
  10218. }
  10219. });
  10220. return false;
  10221. },
  10222. _mouseStop: function(event) {
  10223. var that = this;
  10224. this.dragged = false;
  10225. $(".ui-unselecting", this.element[0]).each(function() {
  10226. var selectee = $.data(this, "selectable-item");
  10227. selectee.$element.removeClass("ui-unselecting");
  10228. selectee.unselecting = false;
  10229. selectee.startselected = false;
  10230. that._trigger("unselected", event, {
  10231. unselected: selectee.element
  10232. });
  10233. });
  10234. $(".ui-selecting", this.element[0]).each(function() {
  10235. var selectee = $.data(this, "selectable-item");
  10236. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  10237. selectee.selecting = false;
  10238. selectee.selected = true;
  10239. selectee.startselected = true;
  10240. that._trigger("selected", event, {
  10241. selected: selectee.element
  10242. });
  10243. });
  10244. this._trigger("stop", event);
  10245. this.helper.remove();
  10246. return false;
  10247. }
  10248. });
  10249. /*!
  10250. * jQuery UI Selectmenu 1.11.0
  10251. * http://jqueryui.com
  10252. *
  10253. * Copyright 2014 jQuery Foundation and other contributors
  10254. * Released under the MIT license.
  10255. * http://jquery.org/license
  10256. *
  10257. * http://api.jqueryui.com/selectmenu
  10258. */
  10259. var selectmenu = $.widget( "ui.selectmenu", {
  10260. version: "1.11.0",
  10261. defaultElement: "<select>",
  10262. options: {
  10263. appendTo: null,
  10264. disabled: null,
  10265. icons: {
  10266. button: "ui-icon-triangle-1-s"
  10267. },
  10268. position: {
  10269. my: "left top",
  10270. at: "left bottom",
  10271. collision: "none"
  10272. },
  10273. width: null,
  10274. // callbacks
  10275. change: null,
  10276. close: null,
  10277. focus: null,
  10278. open: null,
  10279. select: null
  10280. },
  10281. _create: function() {
  10282. var selectmenuId = this.element.uniqueId().attr( "id" );
  10283. this.ids = {
  10284. element: selectmenuId,
  10285. button: selectmenuId + "-button",
  10286. menu: selectmenuId + "-menu"
  10287. };
  10288. this._drawButton();
  10289. this._drawMenu();
  10290. if ( this.options.disabled ) {
  10291. this.disable();
  10292. }
  10293. },
  10294. _drawButton: function() {
  10295. var that = this,
  10296. tabindex = this.element.attr( "tabindex" );
  10297. // Associate existing label with the new button
  10298. this.label = $( "label[for='" + this.ids.element + "']" ).attr( "for", this.ids.button );
  10299. this._on( this.label, {
  10300. click: function( event ) {
  10301. this.button.focus();
  10302. event.preventDefault();
  10303. }
  10304. });
  10305. // Hide original select element
  10306. this.element.hide();
  10307. // Create button
  10308. this.button = $( "<span>", {
  10309. "class": "ui-selectmenu-button ui-widget ui-state-default ui-corner-all",
  10310. tabindex: tabindex || this.options.disabled ? -1 : 0,
  10311. id: this.ids.button,
  10312. role: "combobox",
  10313. "aria-expanded": "false",
  10314. "aria-autocomplete": "list",
  10315. "aria-owns": this.ids.menu,
  10316. "aria-haspopup": "true"
  10317. })
  10318. .insertAfter( this.element );
  10319. $( "<span>", {
  10320. "class": "ui-icon " + this.options.icons.button
  10321. })
  10322. .prependTo( this.button );
  10323. this.buttonText = $( "<span>", {
  10324. "class": "ui-selectmenu-text"
  10325. })
  10326. .appendTo( this.button );
  10327. this._setText( this.buttonText, this.element.find( "option:selected" ).text() );
  10328. this._setOption( "width", this.options.width );
  10329. this._on( this.button, this._buttonEvents );
  10330. this.button.one( "focusin", function() {
  10331. // Delay rendering the menu items until the button receives focus.
  10332. // The menu may have already been rendered via a programmatic open.
  10333. if ( !that.menuItems ) {
  10334. that._refreshMenu();
  10335. }
  10336. });
  10337. this._hoverable( this.button );
  10338. this._focusable( this.button );
  10339. },
  10340. _drawMenu: function() {
  10341. var that = this;
  10342. // Create menu
  10343. this.menu = $( "<ul>", {
  10344. "aria-hidden": "true",
  10345. "aria-labelledby": this.ids.button,
  10346. id: this.ids.menu
  10347. });
  10348. // Wrap menu
  10349. this.menuWrap = $( "<div>", {
  10350. "class": "ui-selectmenu-menu ui-front"
  10351. })
  10352. .append( this.menu )
  10353. .appendTo( this._appendTo() );
  10354. // Initialize menu widget
  10355. this.menuInstance = this.menu
  10356. .menu({
  10357. role: "listbox",
  10358. select: function( event, ui ) {
  10359. event.preventDefault();
  10360. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  10361. },
  10362. focus: function( event, ui ) {
  10363. var item = ui.item.data( "ui-selectmenu-item" );
  10364. // Prevent inital focus from firing and check if its a newly focused item
  10365. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  10366. that._trigger( "focus", event, { item: item } );
  10367. if ( !that.isOpen ) {
  10368. that._select( item, event );
  10369. }
  10370. }
  10371. that.focusIndex = item.index;
  10372. that.button.attr( "aria-activedescendant",
  10373. that.menuItems.eq( item.index ).attr( "id" ) );
  10374. }
  10375. })
  10376. .menu( "instance" );
  10377. // Adjust menu styles to dropdown
  10378. this.menu
  10379. .addClass( "ui-corner-bottom" )
  10380. .removeClass( "ui-corner-all" );
  10381. // Don't close the menu on mouseleave
  10382. this.menuInstance._off( this.menu, "mouseleave" );
  10383. // Cancel the menu's collapseAll on document click
  10384. this.menuInstance._closeOnDocumentClick = function() {
  10385. return false;
  10386. };
  10387. // Selects often contain empty items, but never contain dividers
  10388. this.menuInstance._isDivider = function() {
  10389. return false;
  10390. };
  10391. },
  10392. refresh: function() {
  10393. this._refreshMenu();
  10394. this._setText( this.buttonText, this._getSelectedItem().text() );
  10395. this._setOption( "width", this.options.width );
  10396. },
  10397. _refreshMenu: function() {
  10398. this.menu.empty();
  10399. var item,
  10400. options = this.element.find( "option" );
  10401. if ( !options.length ) {
  10402. return;
  10403. }
  10404. this._parseOptions( options );
  10405. this._renderMenu( this.menu, this.items );
  10406. this.menuInstance.refresh();
  10407. this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" );
  10408. item = this._getSelectedItem();
  10409. // Update the menu to have the correct item focused
  10410. this.menuInstance.focus( null, item );
  10411. this._setAria( item.data( "ui-selectmenu-item" ) );
  10412. // Set disabled state
  10413. this._setOption( "disabled", this.element.prop( "disabled" ) );
  10414. },
  10415. open: function( event ) {
  10416. if ( this.options.disabled ) {
  10417. return;
  10418. }
  10419. // If this is the first time the menu is being opened, render the items
  10420. if ( !this.menuItems ) {
  10421. this._refreshMenu();
  10422. } else {
  10423. // Menu clears focus on close, reset focus to selected item
  10424. this.menu.find( ".ui-state-focus" ).removeClass( "ui-state-focus" );
  10425. this.menuInstance.focus( null, this._getSelectedItem() );
  10426. }
  10427. this.isOpen = true;
  10428. this._toggleAttr();
  10429. this._resizeMenu();
  10430. this._position();
  10431. this._on( this.document, this._documentClick );
  10432. this._trigger( "open", event );
  10433. },
  10434. _position: function() {
  10435. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  10436. },
  10437. close: function( event ) {
  10438. if ( !this.isOpen ) {
  10439. return;
  10440. }
  10441. this.isOpen = false;
  10442. this._toggleAttr();
  10443. this._off( this.document );
  10444. this._trigger( "close", event );
  10445. },
  10446. widget: function() {
  10447. return this.button;
  10448. },
  10449. menuWidget: function() {
  10450. return this.menu;
  10451. },
  10452. _renderMenu: function( ul, items ) {
  10453. var that = this,
  10454. currentOptgroup = "";
  10455. $.each( items, function( index, item ) {
  10456. if ( item.optgroup !== currentOptgroup ) {
  10457. $( "<li>", {
  10458. "class": "ui-selectmenu-optgroup ui-menu-divider" +
  10459. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  10460. " ui-state-disabled" :
  10461. "" ),
  10462. text: item.optgroup
  10463. })
  10464. .appendTo( ul );
  10465. currentOptgroup = item.optgroup;
  10466. }
  10467. that._renderItemData( ul, item );
  10468. });
  10469. },
  10470. _renderItemData: function( ul, item ) {
  10471. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  10472. },
  10473. _renderItem: function( ul, item ) {
  10474. var li = $( "<li>" );
  10475. if ( item.disabled ) {
  10476. li.addClass( "ui-state-disabled" );
  10477. }
  10478. this._setText( li, item.label );
  10479. return li.appendTo( ul );
  10480. },
  10481. _setText: function( element, value ) {
  10482. if ( value ) {
  10483. element.text( value );
  10484. } else {
  10485. element.html( "&#160;" );
  10486. }
  10487. },
  10488. _move: function( direction, event ) {
  10489. var item, next,
  10490. filter = ".ui-menu-item";
  10491. if ( this.isOpen ) {
  10492. item = this.menuItems.eq( this.focusIndex );
  10493. } else {
  10494. item = this.menuItems.eq( this.element[ 0 ].selectedIndex );
  10495. filter += ":not(.ui-state-disabled)";
  10496. }
  10497. if ( direction === "first" || direction === "last" ) {
  10498. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  10499. } else {
  10500. next = item[ direction + "All" ]( filter ).eq( 0 );
  10501. }
  10502. if ( next.length ) {
  10503. this.menuInstance.focus( event, next );
  10504. }
  10505. },
  10506. _getSelectedItem: function() {
  10507. return this.menuItems.eq( this.element[ 0 ].selectedIndex );
  10508. },
  10509. _toggle: function( event ) {
  10510. this[ this.isOpen ? "close" : "open" ]( event );
  10511. },
  10512. _documentClick: {
  10513. mousedown: function( event ) {
  10514. if ( !this.isOpen ) {
  10515. return;
  10516. }
  10517. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + this.ids.button ).length ) {
  10518. this.close( event );
  10519. }
  10520. }
  10521. },
  10522. _buttonEvents: {
  10523. click: "_toggle",
  10524. keydown: function( event ) {
  10525. var preventDefault = true;
  10526. switch ( event.keyCode ) {
  10527. case $.ui.keyCode.TAB:
  10528. case $.ui.keyCode.ESCAPE:
  10529. this.close( event );
  10530. preventDefault = false;
  10531. break;
  10532. case $.ui.keyCode.ENTER:
  10533. if ( this.isOpen ) {
  10534. this._selectFocusedItem( event );
  10535. }
  10536. break;
  10537. case $.ui.keyCode.UP:
  10538. if ( event.altKey ) {
  10539. this._toggle( event );
  10540. } else {
  10541. this._move( "prev", event );
  10542. }
  10543. break;
  10544. case $.ui.keyCode.DOWN:
  10545. if ( event.altKey ) {
  10546. this._toggle( event );
  10547. } else {
  10548. this._move( "next", event );
  10549. }
  10550. break;
  10551. case $.ui.keyCode.SPACE:
  10552. if ( this.isOpen ) {
  10553. this._selectFocusedItem( event );
  10554. } else {
  10555. this._toggle( event );
  10556. }
  10557. break;
  10558. case $.ui.keyCode.LEFT:
  10559. this._move( "prev", event );
  10560. break;
  10561. case $.ui.keyCode.RIGHT:
  10562. this._move( "next", event );
  10563. break;
  10564. case $.ui.keyCode.HOME:
  10565. case $.ui.keyCode.PAGE_UP:
  10566. this._move( "first", event );
  10567. break;
  10568. case $.ui.keyCode.END:
  10569. case $.ui.keyCode.PAGE_DOWN:
  10570. this._move( "last", event );
  10571. break;
  10572. default:
  10573. this.menu.trigger( event );
  10574. preventDefault = false;
  10575. }
  10576. if ( preventDefault ) {
  10577. event.preventDefault();
  10578. }
  10579. }
  10580. },
  10581. _selectFocusedItem: function( event ) {
  10582. var item = this.menuItems.eq( this.focusIndex );
  10583. if ( !item.hasClass( "ui-state-disabled" ) ) {
  10584. this._select( item.data( "ui-selectmenu-item" ), event );
  10585. }
  10586. },
  10587. _select: function( item, event ) {
  10588. var oldIndex = this.element[ 0 ].selectedIndex;
  10589. // Change native select element
  10590. this.element[ 0 ].selectedIndex = item.index;
  10591. this._setText( this.buttonText, item.label );
  10592. this._setAria( item );
  10593. this._trigger( "select", event, { item: item } );
  10594. if ( item.index !== oldIndex ) {
  10595. this._trigger( "change", event, { item: item } );
  10596. }
  10597. this.close( event );
  10598. },
  10599. _setAria: function( item ) {
  10600. var id = this.menuItems.eq( item.index ).attr( "id" );
  10601. this.button.attr({
  10602. "aria-labelledby": id,
  10603. "aria-activedescendant": id
  10604. });
  10605. this.menu.attr( "aria-activedescendant", id );
  10606. },
  10607. _setOption: function( key, value ) {
  10608. if ( key === "icons" ) {
  10609. this.button.find( "span.ui-icon" )
  10610. .removeClass( this.options.icons.button )
  10611. .addClass( value.button );
  10612. }
  10613. this._super( key, value );
  10614. if ( key === "appendTo" ) {
  10615. this.menuWrap.appendTo( this._appendTo() );
  10616. }
  10617. if ( key === "disabled" ) {
  10618. this.menuInstance.option( "disabled", value );
  10619. this.button
  10620. .toggleClass( "ui-state-disabled", value )
  10621. .attr( "aria-disabled", value );
  10622. this.element.prop( "disabled", value );
  10623. if ( value ) {
  10624. this.button.attr( "tabindex", -1 );
  10625. this.close();
  10626. } else {
  10627. this.button.attr( "tabindex", 0 );
  10628. }
  10629. }
  10630. if ( key === "width" ) {
  10631. if ( !value ) {
  10632. value = this.element.outerWidth();
  10633. }
  10634. this.button.outerWidth( value );
  10635. }
  10636. },
  10637. _appendTo: function() {
  10638. var element = this.options.appendTo;
  10639. if ( element ) {
  10640. element = element.jquery || element.nodeType ?
  10641. $( element ) :
  10642. this.document.find( element ).eq( 0 );
  10643. }
  10644. if ( !element || !element[ 0 ] ) {
  10645. element = this.element.closest( ".ui-front" );
  10646. }
  10647. if ( !element.length ) {
  10648. element = this.document[ 0 ].body;
  10649. }
  10650. return element;
  10651. },
  10652. _toggleAttr: function() {
  10653. this.button
  10654. .toggleClass( "ui-corner-top", this.isOpen )
  10655. .toggleClass( "ui-corner-all", !this.isOpen )
  10656. .attr( "aria-expanded", this.isOpen );
  10657. this.menuWrap.toggleClass( "ui-selectmenu-open", this.isOpen );
  10658. this.menu.attr( "aria-hidden", !this.isOpen );
  10659. },
  10660. _resizeMenu: function() {
  10661. this.menu.outerWidth( Math.max(
  10662. this.button.outerWidth(),
  10663. // support: IE10
  10664. // IE10 wraps long text (possibly a rounding bug)
  10665. // so we add 1px to avoid the wrapping
  10666. this.menu.width( "" ).outerWidth() + 1
  10667. ) );
  10668. },
  10669. _getCreateOptions: function() {
  10670. return { disabled: this.element.prop( "disabled" ) };
  10671. },
  10672. _parseOptions: function( options ) {
  10673. var data = [];
  10674. options.each(function( index, item ) {
  10675. var option = $( item ),
  10676. optgroup = option.parent( "optgroup" );
  10677. data.push({
  10678. element: option,
  10679. index: index,
  10680. value: option.attr( "value" ),
  10681. label: option.text(),
  10682. optgroup: optgroup.attr( "label" ) || "",
  10683. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  10684. });
  10685. });
  10686. this.items = data;
  10687. },
  10688. _destroy: function() {
  10689. this.menuWrap.remove();
  10690. this.button.remove();
  10691. this.element.show();
  10692. this.element.removeUniqueId();
  10693. this.label.attr( "for", this.ids.element );
  10694. }
  10695. });
  10696. /*!
  10697. * jQuery UI Slider 1.11.0
  10698. * http://jqueryui.com
  10699. *
  10700. * Copyright 2014 jQuery Foundation and other contributors
  10701. * Released under the MIT license.
  10702. * http://jquery.org/license
  10703. *
  10704. * http://api.jqueryui.com/slider/
  10705. */
  10706. var slider = $.widget( "ui.slider", $.ui.mouse, {
  10707. version: "1.11.0",
  10708. widgetEventPrefix: "slide",
  10709. options: {
  10710. animate: false,
  10711. distance: 0,
  10712. max: 100,
  10713. min: 0,
  10714. orientation: "horizontal",
  10715. range: false,
  10716. step: 1,
  10717. value: 0,
  10718. values: null,
  10719. // callbacks
  10720. change: null,
  10721. slide: null,
  10722. start: null,
  10723. stop: null
  10724. },
  10725. // number of pages in a slider
  10726. // (how many times can you page up/down to go through the whole range)
  10727. numPages: 5,
  10728. _create: function() {
  10729. this._keySliding = false;
  10730. this._mouseSliding = false;
  10731. this._animateOff = true;
  10732. this._handleIndex = null;
  10733. this._detectOrientation();
  10734. this._mouseInit();
  10735. this.element
  10736. .addClass( "ui-slider" +
  10737. " ui-slider-" + this.orientation +
  10738. " ui-widget" +
  10739. " ui-widget-content" +
  10740. " ui-corner-all");
  10741. this._refresh();
  10742. this._setOption( "disabled", this.options.disabled );
  10743. this._animateOff = false;
  10744. },
  10745. _refresh: function() {
  10746. this._createRange();
  10747. this._createHandles();
  10748. this._setupEvents();
  10749. this._refreshValue();
  10750. },
  10751. _createHandles: function() {
  10752. var i, handleCount,
  10753. options = this.options,
  10754. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  10755. handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",
  10756. handles = [];
  10757. handleCount = ( options.values && options.values.length ) || 1;
  10758. if ( existingHandles.length > handleCount ) {
  10759. existingHandles.slice( handleCount ).remove();
  10760. existingHandles = existingHandles.slice( 0, handleCount );
  10761. }
  10762. for ( i = existingHandles.length; i < handleCount; i++ ) {
  10763. handles.push( handle );
  10764. }
  10765. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  10766. this.handle = this.handles.eq( 0 );
  10767. this.handles.each(function( i ) {
  10768. $( this ).data( "ui-slider-handle-index", i );
  10769. });
  10770. },
  10771. _createRange: function() {
  10772. var options = this.options,
  10773. classes = "";
  10774. if ( options.range ) {
  10775. if ( options.range === true ) {
  10776. if ( !options.values ) {
  10777. options.values = [ this._valueMin(), this._valueMin() ];
  10778. } else if ( options.values.length && options.values.length !== 2 ) {
  10779. options.values = [ options.values[0], options.values[0] ];
  10780. } else if ( $.isArray( options.values ) ) {
  10781. options.values = options.values.slice(0);
  10782. }
  10783. }
  10784. if ( !this.range || !this.range.length ) {
  10785. this.range = $( "<div></div>" )
  10786. .appendTo( this.element );
  10787. classes = "ui-slider-range" +
  10788. // note: this isn't the most fittingly semantic framework class for this element,
  10789. // but worked best visually with a variety of themes
  10790. " ui-widget-header ui-corner-all";
  10791. } else {
  10792. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  10793. // Handle range switching from true to min/max
  10794. .css({
  10795. "left": "",
  10796. "bottom": ""
  10797. });
  10798. }
  10799. this.range.addClass( classes +
  10800. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  10801. } else {
  10802. if ( this.range ) {
  10803. this.range.remove();
  10804. }
  10805. this.range = null;
  10806. }
  10807. },
  10808. _setupEvents: function() {
  10809. this._off( this.handles );
  10810. this._on( this.handles, this._handleEvents );
  10811. this._hoverable( this.handles );
  10812. this._focusable( this.handles );
  10813. },
  10814. _destroy: function() {
  10815. this.handles.remove();
  10816. if ( this.range ) {
  10817. this.range.remove();
  10818. }
  10819. this.element
  10820. .removeClass( "ui-slider" +
  10821. " ui-slider-horizontal" +
  10822. " ui-slider-vertical" +
  10823. " ui-widget" +
  10824. " ui-widget-content" +
  10825. " ui-corner-all" );
  10826. this._mouseDestroy();
  10827. },
  10828. _mouseCapture: function( event ) {
  10829. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  10830. that = this,
  10831. o = this.options;
  10832. if ( o.disabled ) {
  10833. return false;
  10834. }
  10835. this.elementSize = {
  10836. width: this.element.outerWidth(),
  10837. height: this.element.outerHeight()
  10838. };
  10839. this.elementOffset = this.element.offset();
  10840. position = { x: event.pageX, y: event.pageY };
  10841. normValue = this._normValueFromMouse( position );
  10842. distance = this._valueMax() - this._valueMin() + 1;
  10843. this.handles.each(function( i ) {
  10844. var thisDistance = Math.abs( normValue - that.values(i) );
  10845. if (( distance > thisDistance ) ||
  10846. ( distance === thisDistance &&
  10847. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  10848. distance = thisDistance;
  10849. closestHandle = $( this );
  10850. index = i;
  10851. }
  10852. });
  10853. allowed = this._start( event, index );
  10854. if ( allowed === false ) {
  10855. return false;
  10856. }
  10857. this._mouseSliding = true;
  10858. this._handleIndex = index;
  10859. closestHandle
  10860. .addClass( "ui-state-active" )
  10861. .focus();
  10862. offset = closestHandle.offset();
  10863. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  10864. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  10865. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  10866. top: event.pageY - offset.top -
  10867. ( closestHandle.height() / 2 ) -
  10868. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  10869. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  10870. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  10871. };
  10872. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  10873. this._slide( event, index, normValue );
  10874. }
  10875. this._animateOff = true;
  10876. return true;
  10877. },
  10878. _mouseStart: function() {
  10879. return true;
  10880. },
  10881. _mouseDrag: function( event ) {
  10882. var position = { x: event.pageX, y: event.pageY },
  10883. normValue = this._normValueFromMouse( position );
  10884. this._slide( event, this._handleIndex, normValue );
  10885. return false;
  10886. },
  10887. _mouseStop: function( event ) {
  10888. this.handles.removeClass( "ui-state-active" );
  10889. this._mouseSliding = false;
  10890. this._stop( event, this._handleIndex );
  10891. this._change( event, this._handleIndex );
  10892. this._handleIndex = null;
  10893. this._clickOffset = null;
  10894. this._animateOff = false;
  10895. return false;
  10896. },
  10897. _detectOrientation: function() {
  10898. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  10899. },
  10900. _normValueFromMouse: function( position ) {
  10901. var pixelTotal,
  10902. pixelMouse,
  10903. percentMouse,
  10904. valueTotal,
  10905. valueMouse;
  10906. if ( this.orientation === "horizontal" ) {
  10907. pixelTotal = this.elementSize.width;
  10908. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  10909. } else {
  10910. pixelTotal = this.elementSize.height;
  10911. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  10912. }
  10913. percentMouse = ( pixelMouse / pixelTotal );
  10914. if ( percentMouse > 1 ) {
  10915. percentMouse = 1;
  10916. }
  10917. if ( percentMouse < 0 ) {
  10918. percentMouse = 0;
  10919. }
  10920. if ( this.orientation === "vertical" ) {
  10921. percentMouse = 1 - percentMouse;
  10922. }
  10923. valueTotal = this._valueMax() - this._valueMin();
  10924. valueMouse = this._valueMin() + percentMouse * valueTotal;
  10925. return this._trimAlignValue( valueMouse );
  10926. },
  10927. _start: function( event, index ) {
  10928. var uiHash = {
  10929. handle: this.handles[ index ],
  10930. value: this.value()
  10931. };
  10932. if ( this.options.values && this.options.values.length ) {
  10933. uiHash.value = this.values( index );
  10934. uiHash.values = this.values();
  10935. }
  10936. return this._trigger( "start", event, uiHash );
  10937. },
  10938. _slide: function( event, index, newVal ) {
  10939. var otherVal,
  10940. newValues,
  10941. allowed;
  10942. if ( this.options.values && this.options.values.length ) {
  10943. otherVal = this.values( index ? 0 : 1 );
  10944. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  10945. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  10946. ) {
  10947. newVal = otherVal;
  10948. }
  10949. if ( newVal !== this.values( index ) ) {
  10950. newValues = this.values();
  10951. newValues[ index ] = newVal;
  10952. // A slide can be canceled by returning false from the slide callback
  10953. allowed = this._trigger( "slide", event, {
  10954. handle: this.handles[ index ],
  10955. value: newVal,
  10956. values: newValues
  10957. } );
  10958. otherVal = this.values( index ? 0 : 1 );
  10959. if ( allowed !== false ) {
  10960. this.values( index, newVal );
  10961. }
  10962. }
  10963. } else {
  10964. if ( newVal !== this.value() ) {
  10965. // A slide can be canceled by returning false from the slide callback
  10966. allowed = this._trigger( "slide", event, {
  10967. handle: this.handles[ index ],
  10968. value: newVal
  10969. } );
  10970. if ( allowed !== false ) {
  10971. this.value( newVal );
  10972. }
  10973. }
  10974. }
  10975. },
  10976. _stop: function( event, index ) {
  10977. var uiHash = {
  10978. handle: this.handles[ index ],
  10979. value: this.value()
  10980. };
  10981. if ( this.options.values && this.options.values.length ) {
  10982. uiHash.value = this.values( index );
  10983. uiHash.values = this.values();
  10984. }
  10985. this._trigger( "stop", event, uiHash );
  10986. },
  10987. _change: function( event, index ) {
  10988. if ( !this._keySliding && !this._mouseSliding ) {
  10989. var uiHash = {
  10990. handle: this.handles[ index ],
  10991. value: this.value()
  10992. };
  10993. if ( this.options.values && this.options.values.length ) {
  10994. uiHash.value = this.values( index );
  10995. uiHash.values = this.values();
  10996. }
  10997. //store the last changed value index for reference when handles overlap
  10998. this._lastChangedValue = index;
  10999. this._trigger( "change", event, uiHash );
  11000. }
  11001. },
  11002. value: function( newValue ) {
  11003. if ( arguments.length ) {
  11004. this.options.value = this._trimAlignValue( newValue );
  11005. this._refreshValue();
  11006. this._change( null, 0 );
  11007. return;
  11008. }
  11009. return this._value();
  11010. },
  11011. values: function( index, newValue ) {
  11012. var vals,
  11013. newValues,
  11014. i;
  11015. if ( arguments.length > 1 ) {
  11016. this.options.values[ index ] = this._trimAlignValue( newValue );
  11017. this._refreshValue();
  11018. this._change( null, index );
  11019. return;
  11020. }
  11021. if ( arguments.length ) {
  11022. if ( $.isArray( arguments[ 0 ] ) ) {
  11023. vals = this.options.values;
  11024. newValues = arguments[ 0 ];
  11025. for ( i = 0; i < vals.length; i += 1 ) {
  11026. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  11027. this._change( null, i );
  11028. }
  11029. this._refreshValue();
  11030. } else {
  11031. if ( this.options.values && this.options.values.length ) {
  11032. return this._values( index );
  11033. } else {
  11034. return this.value();
  11035. }
  11036. }
  11037. } else {
  11038. return this._values();
  11039. }
  11040. },
  11041. _setOption: function( key, value ) {
  11042. var i,
  11043. valsLength = 0;
  11044. if ( key === "range" && this.options.range === true ) {
  11045. if ( value === "min" ) {
  11046. this.options.value = this._values( 0 );
  11047. this.options.values = null;
  11048. } else if ( value === "max" ) {
  11049. this.options.value = this._values( this.options.values.length - 1 );
  11050. this.options.values = null;
  11051. }
  11052. }
  11053. if ( $.isArray( this.options.values ) ) {
  11054. valsLength = this.options.values.length;
  11055. }
  11056. if ( key === "disabled" ) {
  11057. this.element.toggleClass( "ui-state-disabled", !!value );
  11058. }
  11059. this._super( key, value );
  11060. switch ( key ) {
  11061. case "orientation":
  11062. this._detectOrientation();
  11063. this.element
  11064. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  11065. .addClass( "ui-slider-" + this.orientation );
  11066. this._refreshValue();
  11067. break;
  11068. case "value":
  11069. this._animateOff = true;
  11070. this._refreshValue();
  11071. this._change( null, 0 );
  11072. this._animateOff = false;
  11073. break;
  11074. case "values":
  11075. this._animateOff = true;
  11076. this._refreshValue();
  11077. for ( i = 0; i < valsLength; i += 1 ) {
  11078. this._change( null, i );
  11079. }
  11080. this._animateOff = false;
  11081. break;
  11082. case "min":
  11083. case "max":
  11084. this._animateOff = true;
  11085. this._refreshValue();
  11086. this._animateOff = false;
  11087. break;
  11088. case "range":
  11089. this._animateOff = true;
  11090. this._refresh();
  11091. this._animateOff = false;
  11092. break;
  11093. }
  11094. },
  11095. //internal value getter
  11096. // _value() returns value trimmed by min and max, aligned by step
  11097. _value: function() {
  11098. var val = this.options.value;
  11099. val = this._trimAlignValue( val );
  11100. return val;
  11101. },
  11102. //internal values getter
  11103. // _values() returns array of values trimmed by min and max, aligned by step
  11104. // _values( index ) returns single value trimmed by min and max, aligned by step
  11105. _values: function( index ) {
  11106. var val,
  11107. vals,
  11108. i;
  11109. if ( arguments.length ) {
  11110. val = this.options.values[ index ];
  11111. val = this._trimAlignValue( val );
  11112. return val;
  11113. } else if ( this.options.values && this.options.values.length ) {
  11114. // .slice() creates a copy of the array
  11115. // this copy gets trimmed by min and max and then returned
  11116. vals = this.options.values.slice();
  11117. for ( i = 0; i < vals.length; i+= 1) {
  11118. vals[ i ] = this._trimAlignValue( vals[ i ] );
  11119. }
  11120. return vals;
  11121. } else {
  11122. return [];
  11123. }
  11124. },
  11125. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  11126. _trimAlignValue: function( val ) {
  11127. if ( val <= this._valueMin() ) {
  11128. return this._valueMin();
  11129. }
  11130. if ( val >= this._valueMax() ) {
  11131. return this._valueMax();
  11132. }
  11133. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  11134. valModStep = (val - this._valueMin()) % step,
  11135. alignValue = val - valModStep;
  11136. if ( Math.abs(valModStep) * 2 >= step ) {
  11137. alignValue += ( valModStep > 0 ) ? step : ( -step );
  11138. }
  11139. // Since JavaScript has problems with large floats, round
  11140. // the final value to 5 digits after the decimal point (see #4124)
  11141. return parseFloat( alignValue.toFixed(5) );
  11142. },
  11143. _valueMin: function() {
  11144. return this.options.min;
  11145. },
  11146. _valueMax: function() {
  11147. return this.options.max;
  11148. },
  11149. _refreshValue: function() {
  11150. var lastValPercent, valPercent, value, valueMin, valueMax,
  11151. oRange = this.options.range,
  11152. o = this.options,
  11153. that = this,
  11154. animate = ( !this._animateOff ) ? o.animate : false,
  11155. _set = {};
  11156. if ( this.options.values && this.options.values.length ) {
  11157. this.handles.each(function( i ) {
  11158. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  11159. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11160. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11161. if ( that.options.range === true ) {
  11162. if ( that.orientation === "horizontal" ) {
  11163. if ( i === 0 ) {
  11164. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  11165. }
  11166. if ( i === 1 ) {
  11167. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11168. }
  11169. } else {
  11170. if ( i === 0 ) {
  11171. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  11172. }
  11173. if ( i === 1 ) {
  11174. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11175. }
  11176. }
  11177. }
  11178. lastValPercent = valPercent;
  11179. });
  11180. } else {
  11181. value = this.value();
  11182. valueMin = this._valueMin();
  11183. valueMax = this._valueMax();
  11184. valPercent = ( valueMax !== valueMin ) ?
  11185. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  11186. 0;
  11187. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11188. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11189. if ( oRange === "min" && this.orientation === "horizontal" ) {
  11190. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  11191. }
  11192. if ( oRange === "max" && this.orientation === "horizontal" ) {
  11193. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11194. }
  11195. if ( oRange === "min" && this.orientation === "vertical" ) {
  11196. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  11197. }
  11198. if ( oRange === "max" && this.orientation === "vertical" ) {
  11199. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11200. }
  11201. }
  11202. },
  11203. _handleEvents: {
  11204. keydown: function( event ) {
  11205. var allowed, curVal, newVal, step,
  11206. index = $( event.target ).data( "ui-slider-handle-index" );
  11207. switch ( event.keyCode ) {
  11208. case $.ui.keyCode.HOME:
  11209. case $.ui.keyCode.END:
  11210. case $.ui.keyCode.PAGE_UP:
  11211. case $.ui.keyCode.PAGE_DOWN:
  11212. case $.ui.keyCode.UP:
  11213. case $.ui.keyCode.RIGHT:
  11214. case $.ui.keyCode.DOWN:
  11215. case $.ui.keyCode.LEFT:
  11216. event.preventDefault();
  11217. if ( !this._keySliding ) {
  11218. this._keySliding = true;
  11219. $( event.target ).addClass( "ui-state-active" );
  11220. allowed = this._start( event, index );
  11221. if ( allowed === false ) {
  11222. return;
  11223. }
  11224. }
  11225. break;
  11226. }
  11227. step = this.options.step;
  11228. if ( this.options.values && this.options.values.length ) {
  11229. curVal = newVal = this.values( index );
  11230. } else {
  11231. curVal = newVal = this.value();
  11232. }
  11233. switch ( event.keyCode ) {
  11234. case $.ui.keyCode.HOME:
  11235. newVal = this._valueMin();
  11236. break;
  11237. case $.ui.keyCode.END:
  11238. newVal = this._valueMax();
  11239. break;
  11240. case $.ui.keyCode.PAGE_UP:
  11241. newVal = this._trimAlignValue(
  11242. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  11243. );
  11244. break;
  11245. case $.ui.keyCode.PAGE_DOWN:
  11246. newVal = this._trimAlignValue(
  11247. curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
  11248. break;
  11249. case $.ui.keyCode.UP:
  11250. case $.ui.keyCode.RIGHT:
  11251. if ( curVal === this._valueMax() ) {
  11252. return;
  11253. }
  11254. newVal = this._trimAlignValue( curVal + step );
  11255. break;
  11256. case $.ui.keyCode.DOWN:
  11257. case $.ui.keyCode.LEFT:
  11258. if ( curVal === this._valueMin() ) {
  11259. return;
  11260. }
  11261. newVal = this._trimAlignValue( curVal - step );
  11262. break;
  11263. }
  11264. this._slide( event, index, newVal );
  11265. },
  11266. keyup: function( event ) {
  11267. var index = $( event.target ).data( "ui-slider-handle-index" );
  11268. if ( this._keySliding ) {
  11269. this._keySliding = false;
  11270. this._stop( event, index );
  11271. this._change( event, index );
  11272. $( event.target ).removeClass( "ui-state-active" );
  11273. }
  11274. }
  11275. }
  11276. });
  11277. /*!
  11278. * jQuery UI Sortable 1.11.0
  11279. * http://jqueryui.com
  11280. *
  11281. * Copyright 2014 jQuery Foundation and other contributors
  11282. * Released under the MIT license.
  11283. * http://jquery.org/license
  11284. *
  11285. * http://api.jqueryui.com/sortable/
  11286. */
  11287. var sortable = $.widget("ui.sortable", $.ui.mouse, {
  11288. version: "1.11.0",
  11289. widgetEventPrefix: "sort",
  11290. ready: false,
  11291. options: {
  11292. appendTo: "parent",
  11293. axis: false,
  11294. connectWith: false,
  11295. containment: false,
  11296. cursor: "auto",
  11297. cursorAt: false,
  11298. dropOnEmpty: true,
  11299. forcePlaceholderSize: false,
  11300. forceHelperSize: false,
  11301. grid: false,
  11302. handle: false,
  11303. helper: "original",
  11304. items: "> *",
  11305. opacity: false,
  11306. placeholder: false,
  11307. revert: false,
  11308. scroll: true,
  11309. scrollSensitivity: 20,
  11310. scrollSpeed: 20,
  11311. scope: "default",
  11312. tolerance: "intersect",
  11313. zIndex: 1000,
  11314. // callbacks
  11315. activate: null,
  11316. beforeStop: null,
  11317. change: null,
  11318. deactivate: null,
  11319. out: null,
  11320. over: null,
  11321. receive: null,
  11322. remove: null,
  11323. sort: null,
  11324. start: null,
  11325. stop: null,
  11326. update: null
  11327. },
  11328. _isOverAxis: function( x, reference, size ) {
  11329. return ( x >= reference ) && ( x < ( reference + size ) );
  11330. },
  11331. _isFloating: function( item ) {
  11332. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  11333. },
  11334. _create: function() {
  11335. var o = this.options;
  11336. this.containerCache = {};
  11337. this.element.addClass("ui-sortable");
  11338. //Get the items
  11339. this.refresh();
  11340. //Let's determine if the items are being displayed horizontally
  11341. this.floating = this.items.length ? o.axis === "x" || this._isFloating(this.items[0].item) : false;
  11342. //Let's determine the parent's offset
  11343. this.offset = this.element.offset();
  11344. //Initialize mouse events for interaction
  11345. this._mouseInit();
  11346. this._setHandleClassName();
  11347. //We're ready to go
  11348. this.ready = true;
  11349. },
  11350. _setOption: function( key, value ) {
  11351. this._super( key, value );
  11352. if ( key === "handle" ) {
  11353. this._setHandleClassName();
  11354. }
  11355. },
  11356. _setHandleClassName: function() {
  11357. this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" );
  11358. $.each( this.items, function() {
  11359. ( this.instance.options.handle ?
  11360. this.item.find( this.instance.options.handle ) : this.item )
  11361. .addClass( "ui-sortable-handle" );
  11362. });
  11363. },
  11364. _destroy: function() {
  11365. this.element
  11366. .removeClass( "ui-sortable ui-sortable-disabled" )
  11367. .find( ".ui-sortable-handle" )
  11368. .removeClass( "ui-sortable-handle" );
  11369. this._mouseDestroy();
  11370. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  11371. this.items[i].item.removeData(this.widgetName + "-item");
  11372. }
  11373. return this;
  11374. },
  11375. _mouseCapture: function(event, overrideHandle) {
  11376. var currentItem = null,
  11377. validHandle = false,
  11378. that = this;
  11379. if (this.reverting) {
  11380. return false;
  11381. }
  11382. if(this.options.disabled || this.options.type === "static") {
  11383. return false;
  11384. }
  11385. //We have to refresh the items data once first
  11386. this._refreshItems(event);
  11387. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  11388. $(event.target).parents().each(function() {
  11389. if($.data(this, that.widgetName + "-item") === that) {
  11390. currentItem = $(this);
  11391. return false;
  11392. }
  11393. });
  11394. if($.data(event.target, that.widgetName + "-item") === that) {
  11395. currentItem = $(event.target);
  11396. }
  11397. if(!currentItem) {
  11398. return false;
  11399. }
  11400. if(this.options.handle && !overrideHandle) {
  11401. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  11402. if(this === event.target) {
  11403. validHandle = true;
  11404. }
  11405. });
  11406. if(!validHandle) {
  11407. return false;
  11408. }
  11409. }
  11410. this.currentItem = currentItem;
  11411. this._removeCurrentsFromItems();
  11412. return true;
  11413. },
  11414. _mouseStart: function(event, overrideHandle, noActivation) {
  11415. var i, body,
  11416. o = this.options;
  11417. this.currentContainer = this;
  11418. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  11419. this.refreshPositions();
  11420. //Create and append the visible helper
  11421. this.helper = this._createHelper(event);
  11422. //Cache the helper size
  11423. this._cacheHelperProportions();
  11424. /*
  11425. * - Position generation -
  11426. * This block generates everything position related - it's the core of draggables.
  11427. */
  11428. //Cache the margins of the original element
  11429. this._cacheMargins();
  11430. //Get the next scrolling parent
  11431. this.scrollParent = this.helper.scrollParent();
  11432. //The element's absolute position on the page minus margins
  11433. this.offset = this.currentItem.offset();
  11434. this.offset = {
  11435. top: this.offset.top - this.margins.top,
  11436. left: this.offset.left - this.margins.left
  11437. };
  11438. $.extend(this.offset, {
  11439. click: { //Where the click happened, relative to the element
  11440. left: event.pageX - this.offset.left,
  11441. top: event.pageY - this.offset.top
  11442. },
  11443. parent: this._getParentOffset(),
  11444. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  11445. });
  11446. // Only after we got the offset, we can change the helper's position to absolute
  11447. // TODO: Still need to figure out a way to make relative sorting possible
  11448. this.helper.css("position", "absolute");
  11449. this.cssPosition = this.helper.css("position");
  11450. //Generate the original position
  11451. this.originalPosition = this._generatePosition(event);
  11452. this.originalPageX = event.pageX;
  11453. this.originalPageY = event.pageY;
  11454. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  11455. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  11456. //Cache the former DOM position
  11457. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  11458. //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
  11459. if(this.helper[0] !== this.currentItem[0]) {
  11460. this.currentItem.hide();
  11461. }
  11462. //Create the placeholder
  11463. this._createPlaceholder();
  11464. //Set a containment if given in the options
  11465. if(o.containment) {
  11466. this._setContainment();
  11467. }
  11468. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  11469. body = this.document.find( "body" );
  11470. // support: IE
  11471. this.storedCursor = body.css( "cursor" );
  11472. body.css( "cursor", o.cursor );
  11473. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  11474. }
  11475. if(o.opacity) { // opacity option
  11476. if (this.helper.css("opacity")) {
  11477. this._storedOpacity = this.helper.css("opacity");
  11478. }
  11479. this.helper.css("opacity", o.opacity);
  11480. }
  11481. if(o.zIndex) { // zIndex option
  11482. if (this.helper.css("zIndex")) {
  11483. this._storedZIndex = this.helper.css("zIndex");
  11484. }
  11485. this.helper.css("zIndex", o.zIndex);
  11486. }
  11487. //Prepare scrolling
  11488. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  11489. this.overflowOffset = this.scrollParent.offset();
  11490. }
  11491. //Call callbacks
  11492. this._trigger("start", event, this._uiHash());
  11493. //Recache the helper size
  11494. if(!this._preserveHelperProportions) {
  11495. this._cacheHelperProportions();
  11496. }
  11497. //Post "activate" events to possible containers
  11498. if( !noActivation ) {
  11499. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  11500. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  11501. }
  11502. }
  11503. //Prepare possible droppables
  11504. if($.ui.ddmanager) {
  11505. $.ui.ddmanager.current = this;
  11506. }
  11507. if ($.ui.ddmanager && !o.dropBehaviour) {
  11508. $.ui.ddmanager.prepareOffsets(this, event);
  11509. }
  11510. this.dragging = true;
  11511. this.helper.addClass("ui-sortable-helper");
  11512. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  11513. return true;
  11514. },
  11515. _mouseDrag: function(event) {
  11516. var i, item, itemElement, intersection,
  11517. o = this.options,
  11518. scrolled = false;
  11519. //Compute the helpers position
  11520. this.position = this._generatePosition(event);
  11521. this.positionAbs = this._convertPositionTo("absolute");
  11522. if (!this.lastPositionAbs) {
  11523. this.lastPositionAbs = this.positionAbs;
  11524. }
  11525. //Do scrolling
  11526. if(this.options.scroll) {
  11527. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  11528. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  11529. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  11530. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  11531. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  11532. }
  11533. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  11534. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  11535. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  11536. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  11537. }
  11538. } else {
  11539. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  11540. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  11541. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  11542. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  11543. }
  11544. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  11545. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  11546. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  11547. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  11548. }
  11549. }
  11550. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  11551. $.ui.ddmanager.prepareOffsets(this, event);
  11552. }
  11553. }
  11554. //Regenerate the absolute position used for position checks
  11555. this.positionAbs = this._convertPositionTo("absolute");
  11556. //Set the helper position
  11557. if(!this.options.axis || this.options.axis !== "y") {
  11558. this.helper[0].style.left = this.position.left+"px";
  11559. }
  11560. if(!this.options.axis || this.options.axis !== "x") {
  11561. this.helper[0].style.top = this.position.top+"px";
  11562. }
  11563. //Rearrange
  11564. for (i = this.items.length - 1; i >= 0; i--) {
  11565. //Cache variables and intersection, continue if no intersection
  11566. item = this.items[i];
  11567. itemElement = item.item[0];
  11568. intersection = this._intersectsWithPointer(item);
  11569. if (!intersection) {
  11570. continue;
  11571. }
  11572. // Only put the placeholder inside the current Container, skip all
  11573. // items from other containers. This works because when moving
  11574. // an item from one container to another the
  11575. // currentContainer is switched before the placeholder is moved.
  11576. //
  11577. // Without this, moving items in "sub-sortables" can cause
  11578. // the placeholder to jitter between the outer and inner container.
  11579. if (item.instance !== this.currentContainer) {
  11580. continue;
  11581. }
  11582. // cannot intersect with itself
  11583. // no useless actions that have been done before
  11584. // no action if the item moved is the parent of the item checked
  11585. if (itemElement !== this.currentItem[0] &&
  11586. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  11587. !$.contains(this.placeholder[0], itemElement) &&
  11588. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  11589. ) {
  11590. this.direction = intersection === 1 ? "down" : "up";
  11591. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  11592. this._rearrange(event, item);
  11593. } else {
  11594. break;
  11595. }
  11596. this._trigger("change", event, this._uiHash());
  11597. break;
  11598. }
  11599. }
  11600. //Post events to containers
  11601. this._contactContainers(event);
  11602. //Interconnect with droppables
  11603. if($.ui.ddmanager) {
  11604. $.ui.ddmanager.drag(this, event);
  11605. }
  11606. //Call callbacks
  11607. this._trigger("sort", event, this._uiHash());
  11608. this.lastPositionAbs = this.positionAbs;
  11609. return false;
  11610. },
  11611. _mouseStop: function(event, noPropagation) {
  11612. if(!event) {
  11613. return;
  11614. }
  11615. //If we are using droppables, inform the manager about the drop
  11616. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  11617. $.ui.ddmanager.drop(this, event);
  11618. }
  11619. if(this.options.revert) {
  11620. var that = this,
  11621. cur = this.placeholder.offset(),
  11622. axis = this.options.axis,
  11623. animation = {};
  11624. if ( !axis || axis === "x" ) {
  11625. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  11626. }
  11627. if ( !axis || axis === "y" ) {
  11628. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  11629. }
  11630. this.reverting = true;
  11631. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  11632. that._clear(event);
  11633. });
  11634. } else {
  11635. this._clear(event, noPropagation);
  11636. }
  11637. return false;
  11638. },
  11639. cancel: function() {
  11640. if(this.dragging) {
  11641. this._mouseUp({ target: null });
  11642. if(this.options.helper === "original") {
  11643. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  11644. } else {
  11645. this.currentItem.show();
  11646. }
  11647. //Post deactivating events to containers
  11648. for (var i = this.containers.length - 1; i >= 0; i--){
  11649. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  11650. if(this.containers[i].containerCache.over) {
  11651. this.containers[i]._trigger("out", null, this._uiHash(this));
  11652. this.containers[i].containerCache.over = 0;
  11653. }
  11654. }
  11655. }
  11656. if (this.placeholder) {
  11657. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  11658. if(this.placeholder[0].parentNode) {
  11659. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  11660. }
  11661. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  11662. this.helper.remove();
  11663. }
  11664. $.extend(this, {
  11665. helper: null,
  11666. dragging: false,
  11667. reverting: false,
  11668. _noFinalSort: null
  11669. });
  11670. if(this.domPosition.prev) {
  11671. $(this.domPosition.prev).after(this.currentItem);
  11672. } else {
  11673. $(this.domPosition.parent).prepend(this.currentItem);
  11674. }
  11675. }
  11676. return this;
  11677. },
  11678. serialize: function(o) {
  11679. var items = this._getItemsAsjQuery(o && o.connected),
  11680. str = [];
  11681. o = o || {};
  11682. $(items).each(function() {
  11683. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  11684. if (res) {
  11685. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  11686. }
  11687. });
  11688. if(!str.length && o.key) {
  11689. str.push(o.key + "=");
  11690. }
  11691. return str.join("&");
  11692. },
  11693. toArray: function(o) {
  11694. var items = this._getItemsAsjQuery(o && o.connected),
  11695. ret = [];
  11696. o = o || {};
  11697. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  11698. return ret;
  11699. },
  11700. /* Be careful with the following core functions */
  11701. _intersectsWith: function(item) {
  11702. var x1 = this.positionAbs.left,
  11703. x2 = x1 + this.helperProportions.width,
  11704. y1 = this.positionAbs.top,
  11705. y2 = y1 + this.helperProportions.height,
  11706. l = item.left,
  11707. r = l + item.width,
  11708. t = item.top,
  11709. b = t + item.height,
  11710. dyClick = this.offset.click.top,
  11711. dxClick = this.offset.click.left,
  11712. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  11713. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  11714. isOverElement = isOverElementHeight && isOverElementWidth;
  11715. if ( this.options.tolerance === "pointer" ||
  11716. this.options.forcePointerForContainers ||
  11717. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  11718. ) {
  11719. return isOverElement;
  11720. } else {
  11721. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  11722. x2 - (this.helperProportions.width / 2) < r && // Left Half
  11723. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  11724. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  11725. }
  11726. },
  11727. _intersectsWithPointer: function(item) {
  11728. var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  11729. isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  11730. isOverElement = isOverElementHeight && isOverElementWidth,
  11731. verticalDirection = this._getDragVerticalDirection(),
  11732. horizontalDirection = this._getDragHorizontalDirection();
  11733. if (!isOverElement) {
  11734. return false;
  11735. }
  11736. return this.floating ?
  11737. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  11738. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  11739. },
  11740. _intersectsWithSides: function(item) {
  11741. var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  11742. isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  11743. verticalDirection = this._getDragVerticalDirection(),
  11744. horizontalDirection = this._getDragHorizontalDirection();
  11745. if (this.floating && horizontalDirection) {
  11746. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  11747. } else {
  11748. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  11749. }
  11750. },
  11751. _getDragVerticalDirection: function() {
  11752. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  11753. return delta !== 0 && (delta > 0 ? "down" : "up");
  11754. },
  11755. _getDragHorizontalDirection: function() {
  11756. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  11757. return delta !== 0 && (delta > 0 ? "right" : "left");
  11758. },
  11759. refresh: function(event) {
  11760. this._refreshItems(event);
  11761. this._setHandleClassName();
  11762. this.refreshPositions();
  11763. return this;
  11764. },
  11765. _connectWith: function() {
  11766. var options = this.options;
  11767. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  11768. },
  11769. _getItemsAsjQuery: function(connected) {
  11770. var i, j, cur, inst,
  11771. items = [],
  11772. queries = [],
  11773. connectWith = this._connectWith();
  11774. if(connectWith && connected) {
  11775. for (i = connectWith.length - 1; i >= 0; i--){
  11776. cur = $(connectWith[i]);
  11777. for ( j = cur.length - 1; j >= 0; j--){
  11778. inst = $.data(cur[j], this.widgetFullName);
  11779. if(inst && inst !== this && !inst.options.disabled) {
  11780. 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]);
  11781. }
  11782. }
  11783. }
  11784. }
  11785. 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]);
  11786. function addItems() {
  11787. items.push( this );
  11788. }
  11789. for (i = queries.length - 1; i >= 0; i--){
  11790. queries[i][0].each( addItems );
  11791. }
  11792. return $(items);
  11793. },
  11794. _removeCurrentsFromItems: function() {
  11795. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  11796. this.items = $.grep(this.items, function (item) {
  11797. for (var j=0; j < list.length; j++) {
  11798. if(list[j] === item.item[0]) {
  11799. return false;
  11800. }
  11801. }
  11802. return true;
  11803. });
  11804. },
  11805. _refreshItems: function(event) {
  11806. this.items = [];
  11807. this.containers = [this];
  11808. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  11809. items = this.items,
  11810. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  11811. connectWith = this._connectWith();
  11812. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  11813. for (i = connectWith.length - 1; i >= 0; i--){
  11814. cur = $(connectWith[i]);
  11815. for (j = cur.length - 1; j >= 0; j--){
  11816. inst = $.data(cur[j], this.widgetFullName);
  11817. if(inst && inst !== this && !inst.options.disabled) {
  11818. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  11819. this.containers.push(inst);
  11820. }
  11821. }
  11822. }
  11823. }
  11824. for (i = queries.length - 1; i >= 0; i--) {
  11825. targetData = queries[i][1];
  11826. _queries = queries[i][0];
  11827. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  11828. item = $(_queries[j]);
  11829. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  11830. items.push({
  11831. item: item,
  11832. instance: targetData,
  11833. width: 0, height: 0,
  11834. left: 0, top: 0
  11835. });
  11836. }
  11837. }
  11838. },
  11839. refreshPositions: function(fast) {
  11840. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  11841. if(this.offsetParent && this.helper) {
  11842. this.offset.parent = this._getParentOffset();
  11843. }
  11844. var i, item, t, p;
  11845. for (i = this.items.length - 1; i >= 0; i--){
  11846. item = this.items[i];
  11847. //We ignore calculating positions of all connected containers when we're not over them
  11848. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  11849. continue;
  11850. }
  11851. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  11852. if (!fast) {
  11853. item.width = t.outerWidth();
  11854. item.height = t.outerHeight();
  11855. }
  11856. p = t.offset();
  11857. item.left = p.left;
  11858. item.top = p.top;
  11859. }
  11860. if(this.options.custom && this.options.custom.refreshContainers) {
  11861. this.options.custom.refreshContainers.call(this);
  11862. } else {
  11863. for (i = this.containers.length - 1; i >= 0; i--){
  11864. p = this.containers[i].element.offset();
  11865. this.containers[i].containerCache.left = p.left;
  11866. this.containers[i].containerCache.top = p.top;
  11867. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  11868. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  11869. }
  11870. }
  11871. return this;
  11872. },
  11873. _createPlaceholder: function(that) {
  11874. that = that || this;
  11875. var className,
  11876. o = that.options;
  11877. if(!o.placeholder || o.placeholder.constructor === String) {
  11878. className = o.placeholder;
  11879. o.placeholder = {
  11880. element: function() {
  11881. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  11882. element = $( "<" + nodeName + ">", that.document[0] )
  11883. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  11884. .removeClass("ui-sortable-helper");
  11885. if ( nodeName === "tr" ) {
  11886. that.currentItem.children().each(function() {
  11887. $( "<td>&#160;</td>", that.document[0] )
  11888. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  11889. .appendTo( element );
  11890. });
  11891. } else if ( nodeName === "img" ) {
  11892. element.attr( "src", that.currentItem.attr( "src" ) );
  11893. }
  11894. if ( !className ) {
  11895. element.css( "visibility", "hidden" );
  11896. }
  11897. return element;
  11898. },
  11899. update: function(container, p) {
  11900. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  11901. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  11902. if(className && !o.forcePlaceholderSize) {
  11903. return;
  11904. }
  11905. //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
  11906. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  11907. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  11908. }
  11909. };
  11910. }
  11911. //Create the placeholder
  11912. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  11913. //Append it after the actual current item
  11914. that.currentItem.after(that.placeholder);
  11915. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  11916. o.placeholder.update(that, that.placeholder);
  11917. },
  11918. _contactContainers: function(event) {
  11919. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
  11920. innermostContainer = null,
  11921. innermostIndex = null;
  11922. // get innermost container that intersects with item
  11923. for (i = this.containers.length - 1; i >= 0; i--) {
  11924. // never consider a container that's located within the item itself
  11925. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  11926. continue;
  11927. }
  11928. if(this._intersectsWith(this.containers[i].containerCache)) {
  11929. // if we've already found a container and it's more "inner" than this, then continue
  11930. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  11931. continue;
  11932. }
  11933. innermostContainer = this.containers[i];
  11934. innermostIndex = i;
  11935. } else {
  11936. // container doesn't intersect. trigger "out" event if necessary
  11937. if(this.containers[i].containerCache.over) {
  11938. this.containers[i]._trigger("out", event, this._uiHash(this));
  11939. this.containers[i].containerCache.over = 0;
  11940. }
  11941. }
  11942. }
  11943. // if no intersecting containers found, return
  11944. if(!innermostContainer) {
  11945. return;
  11946. }
  11947. // move the item into the container if it's not there already
  11948. if(this.containers.length === 1) {
  11949. if (!this.containers[innermostIndex].containerCache.over) {
  11950. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  11951. this.containers[innermostIndex].containerCache.over = 1;
  11952. }
  11953. } else {
  11954. //When entering a new container, we will find the item with the least distance and append our item near it
  11955. dist = 10000;
  11956. itemWithLeastDistance = null;
  11957. floating = innermostContainer.floating || this._isFloating(this.currentItem);
  11958. posProperty = floating ? "left" : "top";
  11959. sizeProperty = floating ? "width" : "height";
  11960. axis = floating ? "clientX" : "clientY";
  11961. for (j = this.items.length - 1; j >= 0; j--) {
  11962. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  11963. continue;
  11964. }
  11965. if(this.items[j].item[0] === this.currentItem[0]) {
  11966. continue;
  11967. }
  11968. cur = this.items[j].item.offset()[posProperty];
  11969. nearBottom = false;
  11970. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  11971. nearBottom = true;
  11972. }
  11973. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  11974. dist = Math.abs( event[ axis ] - cur );
  11975. itemWithLeastDistance = this.items[ j ];
  11976. this.direction = nearBottom ? "up": "down";
  11977. }
  11978. }
  11979. //Check if dropOnEmpty is enabled
  11980. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  11981. return;
  11982. }
  11983. if(this.currentContainer === this.containers[innermostIndex]) {
  11984. return;
  11985. }
  11986. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  11987. this._trigger("change", event, this._uiHash());
  11988. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  11989. this.currentContainer = this.containers[innermostIndex];
  11990. //Update the placeholder
  11991. this.options.placeholder.update(this.currentContainer, this.placeholder);
  11992. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  11993. this.containers[innermostIndex].containerCache.over = 1;
  11994. }
  11995. },
  11996. _createHelper: function(event) {
  11997. var o = this.options,
  11998. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  11999. //Add the helper to the DOM if that didn't happen already
  12000. if(!helper.parents("body").length) {
  12001. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  12002. }
  12003. if(helper[0] === this.currentItem[0]) {
  12004. 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") };
  12005. }
  12006. if(!helper[0].style.width || o.forceHelperSize) {
  12007. helper.width(this.currentItem.width());
  12008. }
  12009. if(!helper[0].style.height || o.forceHelperSize) {
  12010. helper.height(this.currentItem.height());
  12011. }
  12012. return helper;
  12013. },
  12014. _adjustOffsetFromHelper: function(obj) {
  12015. if (typeof obj === "string") {
  12016. obj = obj.split(" ");
  12017. }
  12018. if ($.isArray(obj)) {
  12019. obj = {left: +obj[0], top: +obj[1] || 0};
  12020. }
  12021. if ("left" in obj) {
  12022. this.offset.click.left = obj.left + this.margins.left;
  12023. }
  12024. if ("right" in obj) {
  12025. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  12026. }
  12027. if ("top" in obj) {
  12028. this.offset.click.top = obj.top + this.margins.top;
  12029. }
  12030. if ("bottom" in obj) {
  12031. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  12032. }
  12033. },
  12034. _getParentOffset: function() {
  12035. //Get the offsetParent and cache its position
  12036. this.offsetParent = this.helper.offsetParent();
  12037. var po = this.offsetParent.offset();
  12038. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  12039. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  12040. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  12041. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  12042. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  12043. po.left += this.scrollParent.scrollLeft();
  12044. po.top += this.scrollParent.scrollTop();
  12045. }
  12046. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  12047. // with an ugly IE fix
  12048. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  12049. po = { top: 0, left: 0 };
  12050. }
  12051. return {
  12052. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  12053. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  12054. };
  12055. },
  12056. _getRelativeOffset: function() {
  12057. if(this.cssPosition === "relative") {
  12058. var p = this.currentItem.position();
  12059. return {
  12060. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  12061. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  12062. };
  12063. } else {
  12064. return { top: 0, left: 0 };
  12065. }
  12066. },
  12067. _cacheMargins: function() {
  12068. this.margins = {
  12069. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  12070. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  12071. };
  12072. },
  12073. _cacheHelperProportions: function() {
  12074. this.helperProportions = {
  12075. width: this.helper.outerWidth(),
  12076. height: this.helper.outerHeight()
  12077. };
  12078. },
  12079. _setContainment: function() {
  12080. var ce, co, over,
  12081. o = this.options;
  12082. if(o.containment === "parent") {
  12083. o.containment = this.helper[0].parentNode;
  12084. }
  12085. if(o.containment === "document" || o.containment === "window") {
  12086. this.containment = [
  12087. 0 - this.offset.relative.left - this.offset.parent.left,
  12088. 0 - this.offset.relative.top - this.offset.parent.top,
  12089. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  12090. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  12091. ];
  12092. }
  12093. if(!(/^(document|window|parent)$/).test(o.containment)) {
  12094. ce = $(o.containment)[0];
  12095. co = $(o.containment).offset();
  12096. over = ($(ce).css("overflow") !== "hidden");
  12097. this.containment = [
  12098. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  12099. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  12100. 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,
  12101. 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
  12102. ];
  12103. }
  12104. },
  12105. _convertPositionTo: function(d, pos) {
  12106. if(!pos) {
  12107. pos = this.position;
  12108. }
  12109. var mod = d === "absolute" ? 1 : -1,
  12110. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  12111. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  12112. return {
  12113. top: (
  12114. pos.top + // The absolute mouse position
  12115. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  12116. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  12117. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  12118. ),
  12119. left: (
  12120. pos.left + // The absolute mouse position
  12121. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  12122. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  12123. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  12124. )
  12125. };
  12126. },
  12127. _generatePosition: function(event) {
  12128. var top, left,
  12129. o = this.options,
  12130. pageX = event.pageX,
  12131. pageY = event.pageY,
  12132. 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);
  12133. // This is another very weird special case that only happens for relative elements:
  12134. // 1. If the css position is relative
  12135. // 2. and the scroll parent is the document or similar to the offset parent
  12136. // we have to refresh the relative offset during the scroll so there are no jumps
  12137. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  12138. this.offset.relative = this._getRelativeOffset();
  12139. }
  12140. /*
  12141. * - Position constraining -
  12142. * Constrain the position to a mix of grid, containment.
  12143. */
  12144. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  12145. if(this.containment) {
  12146. if(event.pageX - this.offset.click.left < this.containment[0]) {
  12147. pageX = this.containment[0] + this.offset.click.left;
  12148. }
  12149. if(event.pageY - this.offset.click.top < this.containment[1]) {
  12150. pageY = this.containment[1] + this.offset.click.top;
  12151. }
  12152. if(event.pageX - this.offset.click.left > this.containment[2]) {
  12153. pageX = this.containment[2] + this.offset.click.left;
  12154. }
  12155. if(event.pageY - this.offset.click.top > this.containment[3]) {
  12156. pageY = this.containment[3] + this.offset.click.top;
  12157. }
  12158. }
  12159. if(o.grid) {
  12160. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  12161. 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;
  12162. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  12163. 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;
  12164. }
  12165. }
  12166. return {
  12167. top: (
  12168. pageY - // The absolute mouse position
  12169. this.offset.click.top - // Click offset (relative to the element)
  12170. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  12171. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  12172. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  12173. ),
  12174. left: (
  12175. pageX - // The absolute mouse position
  12176. this.offset.click.left - // Click offset (relative to the element)
  12177. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  12178. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  12179. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  12180. )
  12181. };
  12182. },
  12183. _rearrange: function(event, i, a, hardRefresh) {
  12184. 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));
  12185. //Various things done here to improve the performance:
  12186. // 1. we create a setTimeout, that calls refreshPositions
  12187. // 2. on the instance, we have a counter variable, that get's higher after every append
  12188. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  12189. // 4. this lets only the last addition to the timeout stack through
  12190. this.counter = this.counter ? ++this.counter : 1;
  12191. var counter = this.counter;
  12192. this._delay(function() {
  12193. if(counter === this.counter) {
  12194. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  12195. }
  12196. });
  12197. },
  12198. _clear: function(event, noPropagation) {
  12199. this.reverting = false;
  12200. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  12201. // everything else normalized again
  12202. var i,
  12203. delayedTriggers = [];
  12204. // We first have to update the dom position of the actual currentItem
  12205. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  12206. if(!this._noFinalSort && this.currentItem.parent().length) {
  12207. this.placeholder.before(this.currentItem);
  12208. }
  12209. this._noFinalSort = null;
  12210. if(this.helper[0] === this.currentItem[0]) {
  12211. for(i in this._storedCSS) {
  12212. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  12213. this._storedCSS[i] = "";
  12214. }
  12215. }
  12216. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  12217. } else {
  12218. this.currentItem.show();
  12219. }
  12220. if(this.fromOutside && !noPropagation) {
  12221. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  12222. }
  12223. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  12224. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  12225. }
  12226. // Check if the items Container has Changed and trigger appropriate
  12227. // events.
  12228. if (this !== this.currentContainer) {
  12229. if(!noPropagation) {
  12230. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  12231. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  12232. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  12233. }
  12234. }
  12235. //Post events to containers
  12236. function delayEvent( type, instance, container ) {
  12237. return function( event ) {
  12238. container._trigger( type, event, instance._uiHash( instance ) );
  12239. };
  12240. }
  12241. for (i = this.containers.length - 1; i >= 0; i--){
  12242. if (!noPropagation) {
  12243. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  12244. }
  12245. if(this.containers[i].containerCache.over) {
  12246. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  12247. this.containers[i].containerCache.over = 0;
  12248. }
  12249. }
  12250. //Do what was originally in plugins
  12251. if ( this.storedCursor ) {
  12252. this.document.find( "body" ).css( "cursor", this.storedCursor );
  12253. this.storedStylesheet.remove();
  12254. }
  12255. if(this._storedOpacity) {
  12256. this.helper.css("opacity", this._storedOpacity);
  12257. }
  12258. if(this._storedZIndex) {
  12259. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  12260. }
  12261. this.dragging = false;
  12262. if(this.cancelHelperRemoval) {
  12263. if(!noPropagation) {
  12264. this._trigger("beforeStop", event, this._uiHash());
  12265. for (i=0; i < delayedTriggers.length; i++) {
  12266. delayedTriggers[i].call(this, event);
  12267. } //Trigger all delayed events
  12268. this._trigger("stop", event, this._uiHash());
  12269. }
  12270. this.fromOutside = false;
  12271. return false;
  12272. }
  12273. if(!noPropagation) {
  12274. this._trigger("beforeStop", event, this._uiHash());
  12275. }
  12276. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  12277. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  12278. if(this.helper[0] !== this.currentItem[0]) {
  12279. this.helper.remove();
  12280. }
  12281. this.helper = null;
  12282. if(!noPropagation) {
  12283. for (i=0; i < delayedTriggers.length; i++) {
  12284. delayedTriggers[i].call(this, event);
  12285. } //Trigger all delayed events
  12286. this._trigger("stop", event, this._uiHash());
  12287. }
  12288. this.fromOutside = false;
  12289. return true;
  12290. },
  12291. _trigger: function() {
  12292. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  12293. this.cancel();
  12294. }
  12295. },
  12296. _uiHash: function(_inst) {
  12297. var inst = _inst || this;
  12298. return {
  12299. helper: inst.helper,
  12300. placeholder: inst.placeholder || $([]),
  12301. position: inst.position,
  12302. originalPosition: inst.originalPosition,
  12303. offset: inst.positionAbs,
  12304. item: inst.currentItem,
  12305. sender: _inst ? _inst.element : null
  12306. };
  12307. }
  12308. });
  12309. /*!
  12310. * jQuery UI Spinner 1.11.0
  12311. * http://jqueryui.com
  12312. *
  12313. * Copyright 2014 jQuery Foundation and other contributors
  12314. * Released under the MIT license.
  12315. * http://jquery.org/license
  12316. *
  12317. * http://api.jqueryui.com/spinner/
  12318. */
  12319. function spinner_modifier( fn ) {
  12320. return function() {
  12321. var previous = this.element.val();
  12322. fn.apply( this, arguments );
  12323. this._refresh();
  12324. if ( previous !== this.element.val() ) {
  12325. this._trigger( "change" );
  12326. }
  12327. };
  12328. }
  12329. var spinner = $.widget( "ui.spinner", {
  12330. version: "1.11.0",
  12331. defaultElement: "<input>",
  12332. widgetEventPrefix: "spin",
  12333. options: {
  12334. culture: null,
  12335. icons: {
  12336. down: "ui-icon-triangle-1-s",
  12337. up: "ui-icon-triangle-1-n"
  12338. },
  12339. incremental: true,
  12340. max: null,
  12341. min: null,
  12342. numberFormat: null,
  12343. page: 10,
  12344. step: 1,
  12345. change: null,
  12346. spin: null,
  12347. start: null,
  12348. stop: null
  12349. },
  12350. _create: function() {
  12351. // handle string values that need to be parsed
  12352. this._setOption( "max", this.options.max );
  12353. this._setOption( "min", this.options.min );
  12354. this._setOption( "step", this.options.step );
  12355. // Only format if there is a value, prevents the field from being marked
  12356. // as invalid in Firefox, see #9573.
  12357. if ( this.value() !== "" ) {
  12358. // Format the value, but don't constrain.
  12359. this._value( this.element.val(), true );
  12360. }
  12361. this._draw();
  12362. this._on( this._events );
  12363. this._refresh();
  12364. // turning off autocomplete prevents the browser from remembering the
  12365. // value when navigating through history, so we re-enable autocomplete
  12366. // if the page is unloaded before the widget is destroyed. #7790
  12367. this._on( this.window, {
  12368. beforeunload: function() {
  12369. this.element.removeAttr( "autocomplete" );
  12370. }
  12371. });
  12372. },
  12373. _getCreateOptions: function() {
  12374. var options = {},
  12375. element = this.element;
  12376. $.each( [ "min", "max", "step" ], function( i, option ) {
  12377. var value = element.attr( option );
  12378. if ( value !== undefined && value.length ) {
  12379. options[ option ] = value;
  12380. }
  12381. });
  12382. return options;
  12383. },
  12384. _events: {
  12385. keydown: function( event ) {
  12386. if ( this._start( event ) && this._keydown( event ) ) {
  12387. event.preventDefault();
  12388. }
  12389. },
  12390. keyup: "_stop",
  12391. focus: function() {
  12392. this.previous = this.element.val();
  12393. },
  12394. blur: function( event ) {
  12395. if ( this.cancelBlur ) {
  12396. delete this.cancelBlur;
  12397. return;
  12398. }
  12399. this._stop();
  12400. this._refresh();
  12401. if ( this.previous !== this.element.val() ) {
  12402. this._trigger( "change", event );
  12403. }
  12404. },
  12405. mousewheel: function( event, delta ) {
  12406. if ( !delta ) {
  12407. return;
  12408. }
  12409. if ( !this.spinning && !this._start( event ) ) {
  12410. return false;
  12411. }
  12412. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  12413. clearTimeout( this.mousewheelTimer );
  12414. this.mousewheelTimer = this._delay(function() {
  12415. if ( this.spinning ) {
  12416. this._stop( event );
  12417. }
  12418. }, 100 );
  12419. event.preventDefault();
  12420. },
  12421. "mousedown .ui-spinner-button": function( event ) {
  12422. var previous;
  12423. // We never want the buttons to have focus; whenever the user is
  12424. // interacting with the spinner, the focus should be on the input.
  12425. // If the input is focused then this.previous is properly set from
  12426. // when the input first received focus. If the input is not focused
  12427. // then we need to set this.previous based on the value before spinning.
  12428. previous = this.element[0] === this.document[0].activeElement ?
  12429. this.previous : this.element.val();
  12430. function checkFocus() {
  12431. var isActive = this.element[0] === this.document[0].activeElement;
  12432. if ( !isActive ) {
  12433. this.element.focus();
  12434. this.previous = previous;
  12435. // support: IE
  12436. // IE sets focus asynchronously, so we need to check if focus
  12437. // moved off of the input because the user clicked on the button.
  12438. this._delay(function() {
  12439. this.previous = previous;
  12440. });
  12441. }
  12442. }
  12443. // ensure focus is on (or stays on) the text field
  12444. event.preventDefault();
  12445. checkFocus.call( this );
  12446. // support: IE
  12447. // IE doesn't prevent moving focus even with event.preventDefault()
  12448. // so we set a flag to know when we should ignore the blur event
  12449. // and check (again) if focus moved off of the input.
  12450. this.cancelBlur = true;
  12451. this._delay(function() {
  12452. delete this.cancelBlur;
  12453. checkFocus.call( this );
  12454. });
  12455. if ( this._start( event ) === false ) {
  12456. return;
  12457. }
  12458. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  12459. },
  12460. "mouseup .ui-spinner-button": "_stop",
  12461. "mouseenter .ui-spinner-button": function( event ) {
  12462. // button will add ui-state-active if mouse was down while mouseleave and kept down
  12463. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  12464. return;
  12465. }
  12466. if ( this._start( event ) === false ) {
  12467. return false;
  12468. }
  12469. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  12470. },
  12471. // TODO: do we really want to consider this a stop?
  12472. // shouldn't we just stop the repeater and wait until mouseup before
  12473. // we trigger the stop event?
  12474. "mouseleave .ui-spinner-button": "_stop"
  12475. },
  12476. _draw: function() {
  12477. var uiSpinner = this.uiSpinner = this.element
  12478. .addClass( "ui-spinner-input" )
  12479. .attr( "autocomplete", "off" )
  12480. .wrap( this._uiSpinnerHtml() )
  12481. .parent()
  12482. // add buttons
  12483. .append( this._buttonHtml() );
  12484. this.element.attr( "role", "spinbutton" );
  12485. // button bindings
  12486. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  12487. .attr( "tabIndex", -1 )
  12488. .button()
  12489. .removeClass( "ui-corner-all" );
  12490. // IE 6 doesn't understand height: 50% for the buttons
  12491. // unless the wrapper has an explicit height
  12492. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  12493. uiSpinner.height() > 0 ) {
  12494. uiSpinner.height( uiSpinner.height() );
  12495. }
  12496. // disable spinner if element was already disabled
  12497. if ( this.options.disabled ) {
  12498. this.disable();
  12499. }
  12500. },
  12501. _keydown: function( event ) {
  12502. var options = this.options,
  12503. keyCode = $.ui.keyCode;
  12504. switch ( event.keyCode ) {
  12505. case keyCode.UP:
  12506. this._repeat( null, 1, event );
  12507. return true;
  12508. case keyCode.DOWN:
  12509. this._repeat( null, -1, event );
  12510. return true;
  12511. case keyCode.PAGE_UP:
  12512. this._repeat( null, options.page, event );
  12513. return true;
  12514. case keyCode.PAGE_DOWN:
  12515. this._repeat( null, -options.page, event );
  12516. return true;
  12517. }
  12518. return false;
  12519. },
  12520. _uiSpinnerHtml: function() {
  12521. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  12522. },
  12523. _buttonHtml: function() {
  12524. return "" +
  12525. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  12526. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  12527. "</a>" +
  12528. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  12529. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  12530. "</a>";
  12531. },
  12532. _start: function( event ) {
  12533. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  12534. return false;
  12535. }
  12536. if ( !this.counter ) {
  12537. this.counter = 1;
  12538. }
  12539. this.spinning = true;
  12540. return true;
  12541. },
  12542. _repeat: function( i, steps, event ) {
  12543. i = i || 500;
  12544. clearTimeout( this.timer );
  12545. this.timer = this._delay(function() {
  12546. this._repeat( 40, steps, event );
  12547. }, i );
  12548. this._spin( steps * this.options.step, event );
  12549. },
  12550. _spin: function( step, event ) {
  12551. var value = this.value() || 0;
  12552. if ( !this.counter ) {
  12553. this.counter = 1;
  12554. }
  12555. value = this._adjustValue( value + step * this._increment( this.counter ) );
  12556. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  12557. this._value( value );
  12558. this.counter++;
  12559. }
  12560. },
  12561. _increment: function( i ) {
  12562. var incremental = this.options.incremental;
  12563. if ( incremental ) {
  12564. return $.isFunction( incremental ) ?
  12565. incremental( i ) :
  12566. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  12567. }
  12568. return 1;
  12569. },
  12570. _precision: function() {
  12571. var precision = this._precisionOf( this.options.step );
  12572. if ( this.options.min !== null ) {
  12573. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  12574. }
  12575. return precision;
  12576. },
  12577. _precisionOf: function( num ) {
  12578. var str = num.toString(),
  12579. decimal = str.indexOf( "." );
  12580. return decimal === -1 ? 0 : str.length - decimal - 1;
  12581. },
  12582. _adjustValue: function( value ) {
  12583. var base, aboveMin,
  12584. options = this.options;
  12585. // make sure we're at a valid step
  12586. // - find out where we are relative to the base (min or 0)
  12587. base = options.min !== null ? options.min : 0;
  12588. aboveMin = value - base;
  12589. // - round to the nearest step
  12590. aboveMin = Math.round(aboveMin / options.step) * options.step;
  12591. // - rounding is based on 0, so adjust back to our base
  12592. value = base + aboveMin;
  12593. // fix precision from bad JS floating point math
  12594. value = parseFloat( value.toFixed( this._precision() ) );
  12595. // clamp the value
  12596. if ( options.max !== null && value > options.max) {
  12597. return options.max;
  12598. }
  12599. if ( options.min !== null && value < options.min ) {
  12600. return options.min;
  12601. }
  12602. return value;
  12603. },
  12604. _stop: function( event ) {
  12605. if ( !this.spinning ) {
  12606. return;
  12607. }
  12608. clearTimeout( this.timer );
  12609. clearTimeout( this.mousewheelTimer );
  12610. this.counter = 0;
  12611. this.spinning = false;
  12612. this._trigger( "stop", event );
  12613. },
  12614. _setOption: function( key, value ) {
  12615. if ( key === "culture" || key === "numberFormat" ) {
  12616. var prevValue = this._parse( this.element.val() );
  12617. this.options[ key ] = value;
  12618. this.element.val( this._format( prevValue ) );
  12619. return;
  12620. }
  12621. if ( key === "max" || key === "min" || key === "step" ) {
  12622. if ( typeof value === "string" ) {
  12623. value = this._parse( value );
  12624. }
  12625. }
  12626. if ( key === "icons" ) {
  12627. this.buttons.first().find( ".ui-icon" )
  12628. .removeClass( this.options.icons.up )
  12629. .addClass( value.up );
  12630. this.buttons.last().find( ".ui-icon" )
  12631. .removeClass( this.options.icons.down )
  12632. .addClass( value.down );
  12633. }
  12634. this._super( key, value );
  12635. if ( key === "disabled" ) {
  12636. this.widget().toggleClass( "ui-state-disabled", !!value );
  12637. this.element.prop( "disabled", !!value );
  12638. this.buttons.button( value ? "disable" : "enable" );
  12639. }
  12640. },
  12641. _setOptions: spinner_modifier(function( options ) {
  12642. this._super( options );
  12643. }),
  12644. _parse: function( val ) {
  12645. if ( typeof val === "string" && val !== "" ) {
  12646. val = window.Globalize && this.options.numberFormat ?
  12647. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  12648. }
  12649. return val === "" || isNaN( val ) ? null : val;
  12650. },
  12651. _format: function( value ) {
  12652. if ( value === "" ) {
  12653. return "";
  12654. }
  12655. return window.Globalize && this.options.numberFormat ?
  12656. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  12657. value;
  12658. },
  12659. _refresh: function() {
  12660. this.element.attr({
  12661. "aria-valuemin": this.options.min,
  12662. "aria-valuemax": this.options.max,
  12663. // TODO: what should we do with values that can't be parsed?
  12664. "aria-valuenow": this._parse( this.element.val() )
  12665. });
  12666. },
  12667. isValid: function() {
  12668. var value = this.value();
  12669. // null is invalid
  12670. if ( value === null ) {
  12671. return false;
  12672. }
  12673. // if value gets adjusted, it's invalid
  12674. return value === this._adjustValue( value );
  12675. },
  12676. // update the value without triggering change
  12677. _value: function( value, allowAny ) {
  12678. var parsed;
  12679. if ( value !== "" ) {
  12680. parsed = this._parse( value );
  12681. if ( parsed !== null ) {
  12682. if ( !allowAny ) {
  12683. parsed = this._adjustValue( parsed );
  12684. }
  12685. value = this._format( parsed );
  12686. }
  12687. }
  12688. this.element.val( value );
  12689. this._refresh();
  12690. },
  12691. _destroy: function() {
  12692. this.element
  12693. .removeClass( "ui-spinner-input" )
  12694. .prop( "disabled", false )
  12695. .removeAttr( "autocomplete" )
  12696. .removeAttr( "role" )
  12697. .removeAttr( "aria-valuemin" )
  12698. .removeAttr( "aria-valuemax" )
  12699. .removeAttr( "aria-valuenow" );
  12700. this.uiSpinner.replaceWith( this.element );
  12701. },
  12702. stepUp: spinner_modifier(function( steps ) {
  12703. this._stepUp( steps );
  12704. }),
  12705. _stepUp: function( steps ) {
  12706. if ( this._start() ) {
  12707. this._spin( (steps || 1) * this.options.step );
  12708. this._stop();
  12709. }
  12710. },
  12711. stepDown: spinner_modifier(function( steps ) {
  12712. this._stepDown( steps );
  12713. }),
  12714. _stepDown: function( steps ) {
  12715. if ( this._start() ) {
  12716. this._spin( (steps || 1) * -this.options.step );
  12717. this._stop();
  12718. }
  12719. },
  12720. pageUp: spinner_modifier(function( pages ) {
  12721. this._stepUp( (pages || 1) * this.options.page );
  12722. }),
  12723. pageDown: spinner_modifier(function( pages ) {
  12724. this._stepDown( (pages || 1) * this.options.page );
  12725. }),
  12726. value: function( newVal ) {
  12727. if ( !arguments.length ) {
  12728. return this._parse( this.element.val() );
  12729. }
  12730. spinner_modifier( this._value ).call( this, newVal );
  12731. },
  12732. widget: function() {
  12733. return this.uiSpinner;
  12734. }
  12735. });
  12736. /*!
  12737. * jQuery UI Tabs 1.11.0
  12738. * http://jqueryui.com
  12739. *
  12740. * Copyright 2014 jQuery Foundation and other contributors
  12741. * Released under the MIT license.
  12742. * http://jquery.org/license
  12743. *
  12744. * http://api.jqueryui.com/tabs/
  12745. */
  12746. var tabs = $.widget( "ui.tabs", {
  12747. version: "1.11.0",
  12748. delay: 300,
  12749. options: {
  12750. active: null,
  12751. collapsible: false,
  12752. event: "click",
  12753. heightStyle: "content",
  12754. hide: null,
  12755. show: null,
  12756. // callbacks
  12757. activate: null,
  12758. beforeActivate: null,
  12759. beforeLoad: null,
  12760. load: null
  12761. },
  12762. _isLocal: (function() {
  12763. var rhash = /#.*$/;
  12764. return function( anchor ) {
  12765. var anchorUrl, locationUrl;
  12766. // support: IE7
  12767. // IE7 doesn't normalize the href property when set via script (#9317)
  12768. anchor = anchor.cloneNode( false );
  12769. anchorUrl = anchor.href.replace( rhash, "" );
  12770. locationUrl = location.href.replace( rhash, "" );
  12771. // decoding may throw an error if the URL isn't UTF-8 (#9518)
  12772. try {
  12773. anchorUrl = decodeURIComponent( anchorUrl );
  12774. } catch ( error ) {}
  12775. try {
  12776. locationUrl = decodeURIComponent( locationUrl );
  12777. } catch ( error ) {}
  12778. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  12779. };
  12780. })(),
  12781. _create: function() {
  12782. var that = this,
  12783. options = this.options;
  12784. this.running = false;
  12785. this.element
  12786. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  12787. .toggleClass( "ui-tabs-collapsible", options.collapsible )
  12788. // Prevent users from focusing disabled tabs via click
  12789. .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
  12790. if ( $( this ).is( ".ui-state-disabled" ) ) {
  12791. event.preventDefault();
  12792. }
  12793. })
  12794. // support: IE <9
  12795. // Preventing the default action in mousedown doesn't prevent IE
  12796. // from focusing the element, so if the anchor gets focused, blur.
  12797. // We don't have to worry about focusing the previously focused
  12798. // element since clicking on a non-focusable element should focus
  12799. // the body anyway.
  12800. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  12801. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  12802. this.blur();
  12803. }
  12804. });
  12805. this._processTabs();
  12806. options.active = this._initialActive();
  12807. // Take disabling tabs via class attribute from HTML
  12808. // into account and update option properly.
  12809. if ( $.isArray( options.disabled ) ) {
  12810. options.disabled = $.unique( options.disabled.concat(
  12811. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  12812. return that.tabs.index( li );
  12813. })
  12814. ) ).sort();
  12815. }
  12816. // check for length avoids error when initializing empty list
  12817. if ( this.options.active !== false && this.anchors.length ) {
  12818. this.active = this._findActive( options.active );
  12819. } else {
  12820. this.active = $();
  12821. }
  12822. this._refresh();
  12823. if ( this.active.length ) {
  12824. this.load( options.active );
  12825. }
  12826. },
  12827. _initialActive: function() {
  12828. var active = this.options.active,
  12829. collapsible = this.options.collapsible,
  12830. locationHash = location.hash.substring( 1 );
  12831. if ( active === null ) {
  12832. // check the fragment identifier in the URL
  12833. if ( locationHash ) {
  12834. this.tabs.each(function( i, tab ) {
  12835. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  12836. active = i;
  12837. return false;
  12838. }
  12839. });
  12840. }
  12841. // check for a tab marked active via a class
  12842. if ( active === null ) {
  12843. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  12844. }
  12845. // no active tab, set to false
  12846. if ( active === null || active === -1 ) {
  12847. active = this.tabs.length ? 0 : false;
  12848. }
  12849. }
  12850. // handle numbers: negative, out of range
  12851. if ( active !== false ) {
  12852. active = this.tabs.index( this.tabs.eq( active ) );
  12853. if ( active === -1 ) {
  12854. active = collapsible ? false : 0;
  12855. }
  12856. }
  12857. // don't allow collapsible: false and active: false
  12858. if ( !collapsible && active === false && this.anchors.length ) {
  12859. active = 0;
  12860. }
  12861. return active;
  12862. },
  12863. _getCreateEventData: function() {
  12864. return {
  12865. tab: this.active,
  12866. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  12867. };
  12868. },
  12869. _tabKeydown: function( event ) {
  12870. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  12871. selectedIndex = this.tabs.index( focusedTab ),
  12872. goingForward = true;
  12873. if ( this._handlePageNav( event ) ) {
  12874. return;
  12875. }
  12876. switch ( event.keyCode ) {
  12877. case $.ui.keyCode.RIGHT:
  12878. case $.ui.keyCode.DOWN:
  12879. selectedIndex++;
  12880. break;
  12881. case $.ui.keyCode.UP:
  12882. case $.ui.keyCode.LEFT:
  12883. goingForward = false;
  12884. selectedIndex--;
  12885. break;
  12886. case $.ui.keyCode.END:
  12887. selectedIndex = this.anchors.length - 1;
  12888. break;
  12889. case $.ui.keyCode.HOME:
  12890. selectedIndex = 0;
  12891. break;
  12892. case $.ui.keyCode.SPACE:
  12893. // Activate only, no collapsing
  12894. event.preventDefault();
  12895. clearTimeout( this.activating );
  12896. this._activate( selectedIndex );
  12897. return;
  12898. case $.ui.keyCode.ENTER:
  12899. // Toggle (cancel delayed activation, allow collapsing)
  12900. event.preventDefault();
  12901. clearTimeout( this.activating );
  12902. // Determine if we should collapse or activate
  12903. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  12904. return;
  12905. default:
  12906. return;
  12907. }
  12908. // Focus the appropriate tab, based on which key was pressed
  12909. event.preventDefault();
  12910. clearTimeout( this.activating );
  12911. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  12912. // Navigating with control key will prevent automatic activation
  12913. if ( !event.ctrlKey ) {
  12914. // Update aria-selected immediately so that AT think the tab is already selected.
  12915. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  12916. // but the tab will already be activated by the time the announcement finishes.
  12917. focusedTab.attr( "aria-selected", "false" );
  12918. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  12919. this.activating = this._delay(function() {
  12920. this.option( "active", selectedIndex );
  12921. }, this.delay );
  12922. }
  12923. },
  12924. _panelKeydown: function( event ) {
  12925. if ( this._handlePageNav( event ) ) {
  12926. return;
  12927. }
  12928. // Ctrl+up moves focus to the current tab
  12929. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  12930. event.preventDefault();
  12931. this.active.focus();
  12932. }
  12933. },
  12934. // Alt+page up/down moves focus to the previous/next tab (and activates)
  12935. _handlePageNav: function( event ) {
  12936. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  12937. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  12938. return true;
  12939. }
  12940. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  12941. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  12942. return true;
  12943. }
  12944. },
  12945. _findNextTab: function( index, goingForward ) {
  12946. var lastTabIndex = this.tabs.length - 1;
  12947. function constrain() {
  12948. if ( index > lastTabIndex ) {
  12949. index = 0;
  12950. }
  12951. if ( index < 0 ) {
  12952. index = lastTabIndex;
  12953. }
  12954. return index;
  12955. }
  12956. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  12957. index = goingForward ? index + 1 : index - 1;
  12958. }
  12959. return index;
  12960. },
  12961. _focusNextTab: function( index, goingForward ) {
  12962. index = this._findNextTab( index, goingForward );
  12963. this.tabs.eq( index ).focus();
  12964. return index;
  12965. },
  12966. _setOption: function( key, value ) {
  12967. if ( key === "active" ) {
  12968. // _activate() will handle invalid values and update this.options
  12969. this._activate( value );
  12970. return;
  12971. }
  12972. if ( key === "disabled" ) {
  12973. // don't use the widget factory's disabled handling
  12974. this._setupDisabled( value );
  12975. return;
  12976. }
  12977. this._super( key, value);
  12978. if ( key === "collapsible" ) {
  12979. this.element.toggleClass( "ui-tabs-collapsible", value );
  12980. // Setting collapsible: false while collapsed; open first panel
  12981. if ( !value && this.options.active === false ) {
  12982. this._activate( 0 );
  12983. }
  12984. }
  12985. if ( key === "event" ) {
  12986. this._setupEvents( value );
  12987. }
  12988. if ( key === "heightStyle" ) {
  12989. this._setupHeightStyle( value );
  12990. }
  12991. },
  12992. _sanitizeSelector: function( hash ) {
  12993. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  12994. },
  12995. refresh: function() {
  12996. var options = this.options,
  12997. lis = this.tablist.children( ":has(a[href])" );
  12998. // get disabled tabs from class attribute from HTML
  12999. // this will get converted to a boolean if needed in _refresh()
  13000. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  13001. return lis.index( tab );
  13002. });
  13003. this._processTabs();
  13004. // was collapsed or no tabs
  13005. if ( options.active === false || !this.anchors.length ) {
  13006. options.active = false;
  13007. this.active = $();
  13008. // was active, but active tab is gone
  13009. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  13010. // all remaining tabs are disabled
  13011. if ( this.tabs.length === options.disabled.length ) {
  13012. options.active = false;
  13013. this.active = $();
  13014. // activate previous tab
  13015. } else {
  13016. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  13017. }
  13018. // was active, active tab still exists
  13019. } else {
  13020. // make sure active index is correct
  13021. options.active = this.tabs.index( this.active );
  13022. }
  13023. this._refresh();
  13024. },
  13025. _refresh: function() {
  13026. this._setupDisabled( this.options.disabled );
  13027. this._setupEvents( this.options.event );
  13028. this._setupHeightStyle( this.options.heightStyle );
  13029. this.tabs.not( this.active ).attr({
  13030. "aria-selected": "false",
  13031. "aria-expanded": "false",
  13032. tabIndex: -1
  13033. });
  13034. this.panels.not( this._getPanelForTab( this.active ) )
  13035. .hide()
  13036. .attr({
  13037. "aria-hidden": "true"
  13038. });
  13039. // Make sure one tab is in the tab order
  13040. if ( !this.active.length ) {
  13041. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  13042. } else {
  13043. this.active
  13044. .addClass( "ui-tabs-active ui-state-active" )
  13045. .attr({
  13046. "aria-selected": "true",
  13047. "aria-expanded": "true",
  13048. tabIndex: 0
  13049. });
  13050. this._getPanelForTab( this.active )
  13051. .show()
  13052. .attr({
  13053. "aria-hidden": "false"
  13054. });
  13055. }
  13056. },
  13057. _processTabs: function() {
  13058. var that = this;
  13059. this.tablist = this._getList()
  13060. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  13061. .attr( "role", "tablist" );
  13062. this.tabs = this.tablist.find( "> li:has(a[href])" )
  13063. .addClass( "ui-state-default ui-corner-top" )
  13064. .attr({
  13065. role: "tab",
  13066. tabIndex: -1
  13067. });
  13068. this.anchors = this.tabs.map(function() {
  13069. return $( "a", this )[ 0 ];
  13070. })
  13071. .addClass( "ui-tabs-anchor" )
  13072. .attr({
  13073. role: "presentation",
  13074. tabIndex: -1
  13075. });
  13076. this.panels = $();
  13077. this.anchors.each(function( i, anchor ) {
  13078. var selector, panel, panelId,
  13079. anchorId = $( anchor ).uniqueId().attr( "id" ),
  13080. tab = $( anchor ).closest( "li" ),
  13081. originalAriaControls = tab.attr( "aria-controls" );
  13082. // inline tab
  13083. if ( that._isLocal( anchor ) ) {
  13084. selector = anchor.hash;
  13085. panelId = selector.substring( 1 );
  13086. panel = that.element.find( that._sanitizeSelector( selector ) );
  13087. // remote tab
  13088. } else {
  13089. // If the tab doesn't already have aria-controls,
  13090. // generate an id by using a throw-away element
  13091. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  13092. selector = "#" + panelId;
  13093. panel = that.element.find( selector );
  13094. if ( !panel.length ) {
  13095. panel = that._createPanel( panelId );
  13096. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  13097. }
  13098. panel.attr( "aria-live", "polite" );
  13099. }
  13100. if ( panel.length) {
  13101. that.panels = that.panels.add( panel );
  13102. }
  13103. if ( originalAriaControls ) {
  13104. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  13105. }
  13106. tab.attr({
  13107. "aria-controls": panelId,
  13108. "aria-labelledby": anchorId
  13109. });
  13110. panel.attr( "aria-labelledby", anchorId );
  13111. });
  13112. this.panels
  13113. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  13114. .attr( "role", "tabpanel" );
  13115. },
  13116. // allow overriding how to find the list for rare usage scenarios (#7715)
  13117. _getList: function() {
  13118. return this.tablist || this.element.find( "ol,ul" ).eq( 0 );
  13119. },
  13120. _createPanel: function( id ) {
  13121. return $( "<div>" )
  13122. .attr( "id", id )
  13123. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  13124. .data( "ui-tabs-destroy", true );
  13125. },
  13126. _setupDisabled: function( disabled ) {
  13127. if ( $.isArray( disabled ) ) {
  13128. if ( !disabled.length ) {
  13129. disabled = false;
  13130. } else if ( disabled.length === this.anchors.length ) {
  13131. disabled = true;
  13132. }
  13133. }
  13134. // disable tabs
  13135. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  13136. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  13137. $( li )
  13138. .addClass( "ui-state-disabled" )
  13139. .attr( "aria-disabled", "true" );
  13140. } else {
  13141. $( li )
  13142. .removeClass( "ui-state-disabled" )
  13143. .removeAttr( "aria-disabled" );
  13144. }
  13145. }
  13146. this.options.disabled = disabled;
  13147. },
  13148. _setupEvents: function( event ) {
  13149. var events = {};
  13150. if ( event ) {
  13151. $.each( event.split(" "), function( index, eventName ) {
  13152. events[ eventName ] = "_eventHandler";
  13153. });
  13154. }
  13155. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  13156. // Always prevent the default action, even when disabled
  13157. this._on( true, this.anchors, {
  13158. click: function( event ) {
  13159. event.preventDefault();
  13160. }
  13161. });
  13162. this._on( this.anchors, events );
  13163. this._on( this.tabs, { keydown: "_tabKeydown" } );
  13164. this._on( this.panels, { keydown: "_panelKeydown" } );
  13165. this._focusable( this.tabs );
  13166. this._hoverable( this.tabs );
  13167. },
  13168. _setupHeightStyle: function( heightStyle ) {
  13169. var maxHeight,
  13170. parent = this.element.parent();
  13171. if ( heightStyle === "fill" ) {
  13172. maxHeight = parent.height();
  13173. maxHeight -= this.element.outerHeight() - this.element.height();
  13174. this.element.siblings( ":visible" ).each(function() {
  13175. var elem = $( this ),
  13176. position = elem.css( "position" );
  13177. if ( position === "absolute" || position === "fixed" ) {
  13178. return;
  13179. }
  13180. maxHeight -= elem.outerHeight( true );
  13181. });
  13182. this.element.children().not( this.panels ).each(function() {
  13183. maxHeight -= $( this ).outerHeight( true );
  13184. });
  13185. this.panels.each(function() {
  13186. $( this ).height( Math.max( 0, maxHeight -
  13187. $( this ).innerHeight() + $( this ).height() ) );
  13188. })
  13189. .css( "overflow", "auto" );
  13190. } else if ( heightStyle === "auto" ) {
  13191. maxHeight = 0;
  13192. this.panels.each(function() {
  13193. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  13194. }).height( maxHeight );
  13195. }
  13196. },
  13197. _eventHandler: function( event ) {
  13198. var options = this.options,
  13199. active = this.active,
  13200. anchor = $( event.currentTarget ),
  13201. tab = anchor.closest( "li" ),
  13202. clickedIsActive = tab[ 0 ] === active[ 0 ],
  13203. collapsing = clickedIsActive && options.collapsible,
  13204. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  13205. toHide = !active.length ? $() : this._getPanelForTab( active ),
  13206. eventData = {
  13207. oldTab: active,
  13208. oldPanel: toHide,
  13209. newTab: collapsing ? $() : tab,
  13210. newPanel: toShow
  13211. };
  13212. event.preventDefault();
  13213. if ( tab.hasClass( "ui-state-disabled" ) ||
  13214. // tab is already loading
  13215. tab.hasClass( "ui-tabs-loading" ) ||
  13216. // can't switch durning an animation
  13217. this.running ||
  13218. // click on active header, but not collapsible
  13219. ( clickedIsActive && !options.collapsible ) ||
  13220. // allow canceling activation
  13221. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  13222. return;
  13223. }
  13224. options.active = collapsing ? false : this.tabs.index( tab );
  13225. this.active = clickedIsActive ? $() : tab;
  13226. if ( this.xhr ) {
  13227. this.xhr.abort();
  13228. }
  13229. if ( !toHide.length && !toShow.length ) {
  13230. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  13231. }
  13232. if ( toShow.length ) {
  13233. this.load( this.tabs.index( tab ), event );
  13234. }
  13235. this._toggle( event, eventData );
  13236. },
  13237. // handles show/hide for selecting tabs
  13238. _toggle: function( event, eventData ) {
  13239. var that = this,
  13240. toShow = eventData.newPanel,
  13241. toHide = eventData.oldPanel;
  13242. this.running = true;
  13243. function complete() {
  13244. that.running = false;
  13245. that._trigger( "activate", event, eventData );
  13246. }
  13247. function show() {
  13248. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  13249. if ( toShow.length && that.options.show ) {
  13250. that._show( toShow, that.options.show, complete );
  13251. } else {
  13252. toShow.show();
  13253. complete();
  13254. }
  13255. }
  13256. // start out by hiding, then showing, then completing
  13257. if ( toHide.length && this.options.hide ) {
  13258. this._hide( toHide, this.options.hide, function() {
  13259. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  13260. show();
  13261. });
  13262. } else {
  13263. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  13264. toHide.hide();
  13265. show();
  13266. }
  13267. toHide.attr( "aria-hidden", "true" );
  13268. eventData.oldTab.attr({
  13269. "aria-selected": "false",
  13270. "aria-expanded": "false"
  13271. });
  13272. // If we're switching tabs, remove the old tab from the tab order.
  13273. // If we're opening from collapsed state, remove the previous tab from the tab order.
  13274. // If we're collapsing, then keep the collapsing tab in the tab order.
  13275. if ( toShow.length && toHide.length ) {
  13276. eventData.oldTab.attr( "tabIndex", -1 );
  13277. } else if ( toShow.length ) {
  13278. this.tabs.filter(function() {
  13279. return $( this ).attr( "tabIndex" ) === 0;
  13280. })
  13281. .attr( "tabIndex", -1 );
  13282. }
  13283. toShow.attr( "aria-hidden", "false" );
  13284. eventData.newTab.attr({
  13285. "aria-selected": "true",
  13286. "aria-expanded": "true",
  13287. tabIndex: 0
  13288. });
  13289. },
  13290. _activate: function( index ) {
  13291. var anchor,
  13292. active = this._findActive( index );
  13293. // trying to activate the already active panel
  13294. if ( active[ 0 ] === this.active[ 0 ] ) {
  13295. return;
  13296. }
  13297. // trying to collapse, simulate a click on the current active header
  13298. if ( !active.length ) {
  13299. active = this.active;
  13300. }
  13301. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  13302. this._eventHandler({
  13303. target: anchor,
  13304. currentTarget: anchor,
  13305. preventDefault: $.noop
  13306. });
  13307. },
  13308. _findActive: function( index ) {
  13309. return index === false ? $() : this.tabs.eq( index );
  13310. },
  13311. _getIndex: function( index ) {
  13312. // meta-function to give users option to provide a href string instead of a numerical index.
  13313. if ( typeof index === "string" ) {
  13314. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  13315. }
  13316. return index;
  13317. },
  13318. _destroy: function() {
  13319. if ( this.xhr ) {
  13320. this.xhr.abort();
  13321. }
  13322. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  13323. this.tablist
  13324. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  13325. .removeAttr( "role" );
  13326. this.anchors
  13327. .removeClass( "ui-tabs-anchor" )
  13328. .removeAttr( "role" )
  13329. .removeAttr( "tabIndex" )
  13330. .removeUniqueId();
  13331. this.tabs.add( this.panels ).each(function() {
  13332. if ( $.data( this, "ui-tabs-destroy" ) ) {
  13333. $( this ).remove();
  13334. } else {
  13335. $( this )
  13336. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  13337. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  13338. .removeAttr( "tabIndex" )
  13339. .removeAttr( "aria-live" )
  13340. .removeAttr( "aria-busy" )
  13341. .removeAttr( "aria-selected" )
  13342. .removeAttr( "aria-labelledby" )
  13343. .removeAttr( "aria-hidden" )
  13344. .removeAttr( "aria-expanded" )
  13345. .removeAttr( "role" );
  13346. }
  13347. });
  13348. this.tabs.each(function() {
  13349. var li = $( this ),
  13350. prev = li.data( "ui-tabs-aria-controls" );
  13351. if ( prev ) {
  13352. li
  13353. .attr( "aria-controls", prev )
  13354. .removeData( "ui-tabs-aria-controls" );
  13355. } else {
  13356. li.removeAttr( "aria-controls" );
  13357. }
  13358. });
  13359. this.panels.show();
  13360. if ( this.options.heightStyle !== "content" ) {
  13361. this.panels.css( "height", "" );
  13362. }
  13363. },
  13364. enable: function( index ) {
  13365. var disabled = this.options.disabled;
  13366. if ( disabled === false ) {
  13367. return;
  13368. }
  13369. if ( index === undefined ) {
  13370. disabled = false;
  13371. } else {
  13372. index = this._getIndex( index );
  13373. if ( $.isArray( disabled ) ) {
  13374. disabled = $.map( disabled, function( num ) {
  13375. return num !== index ? num : null;
  13376. });
  13377. } else {
  13378. disabled = $.map( this.tabs, function( li, num ) {
  13379. return num !== index ? num : null;
  13380. });
  13381. }
  13382. }
  13383. this._setupDisabled( disabled );
  13384. },
  13385. disable: function( index ) {
  13386. var disabled = this.options.disabled;
  13387. if ( disabled === true ) {
  13388. return;
  13389. }
  13390. if ( index === undefined ) {
  13391. disabled = true;
  13392. } else {
  13393. index = this._getIndex( index );
  13394. if ( $.inArray( index, disabled ) !== -1 ) {
  13395. return;
  13396. }
  13397. if ( $.isArray( disabled ) ) {
  13398. disabled = $.merge( [ index ], disabled ).sort();
  13399. } else {
  13400. disabled = [ index ];
  13401. }
  13402. }
  13403. this._setupDisabled( disabled );
  13404. },
  13405. load: function( index, event ) {
  13406. index = this._getIndex( index );
  13407. var that = this,
  13408. tab = this.tabs.eq( index ),
  13409. anchor = tab.find( ".ui-tabs-anchor" ),
  13410. panel = this._getPanelForTab( tab ),
  13411. eventData = {
  13412. tab: tab,
  13413. panel: panel
  13414. };
  13415. // not remote
  13416. if ( this._isLocal( anchor[ 0 ] ) ) {
  13417. return;
  13418. }
  13419. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  13420. // support: jQuery <1.8
  13421. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  13422. // but as of 1.8, $.ajax() always returns a jqXHR object.
  13423. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  13424. tab.addClass( "ui-tabs-loading" );
  13425. panel.attr( "aria-busy", "true" );
  13426. this.xhr
  13427. .success(function( response ) {
  13428. // support: jQuery <1.8
  13429. // http://bugs.jquery.com/ticket/11778
  13430. setTimeout(function() {
  13431. panel.html( response );
  13432. that._trigger( "load", event, eventData );
  13433. }, 1 );
  13434. })
  13435. .complete(function( jqXHR, status ) {
  13436. // support: jQuery <1.8
  13437. // http://bugs.jquery.com/ticket/11778
  13438. setTimeout(function() {
  13439. if ( status === "abort" ) {
  13440. that.panels.stop( false, true );
  13441. }
  13442. tab.removeClass( "ui-tabs-loading" );
  13443. panel.removeAttr( "aria-busy" );
  13444. if ( jqXHR === that.xhr ) {
  13445. delete that.xhr;
  13446. }
  13447. }, 1 );
  13448. });
  13449. }
  13450. },
  13451. _ajaxSettings: function( anchor, event, eventData ) {
  13452. var that = this;
  13453. return {
  13454. url: anchor.attr( "href" ),
  13455. beforeSend: function( jqXHR, settings ) {
  13456. return that._trigger( "beforeLoad", event,
  13457. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  13458. }
  13459. };
  13460. },
  13461. _getPanelForTab: function( tab ) {
  13462. var id = $( tab ).attr( "aria-controls" );
  13463. return this.element.find( this._sanitizeSelector( "#" + id ) );
  13464. }
  13465. });
  13466. /*!
  13467. * jQuery UI Tooltip 1.11.0
  13468. * http://jqueryui.com
  13469. *
  13470. * Copyright 2014 jQuery Foundation and other contributors
  13471. * Released under the MIT license.
  13472. * http://jquery.org/license
  13473. *
  13474. * http://api.jqueryui.com/tooltip/
  13475. */
  13476. var tooltip = $.widget( "ui.tooltip", {
  13477. version: "1.11.0",
  13478. options: {
  13479. content: function() {
  13480. // support: IE<9, Opera in jQuery <1.7
  13481. // .text() can't accept undefined, so coerce to a string
  13482. var title = $( this ).attr( "title" ) || "";
  13483. // Escape title, since we're going from an attribute to raw HTML
  13484. return $( "<a>" ).text( title ).html();
  13485. },
  13486. hide: true,
  13487. // Disabled elements have inconsistent behavior across browsers (#8661)
  13488. items: "[title]:not([disabled])",
  13489. position: {
  13490. my: "left top+15",
  13491. at: "left bottom",
  13492. collision: "flipfit flip"
  13493. },
  13494. show: true,
  13495. tooltipClass: null,
  13496. track: false,
  13497. // callbacks
  13498. close: null,
  13499. open: null
  13500. },
  13501. _addDescribedBy: function( elem, id ) {
  13502. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  13503. describedby.push( id );
  13504. elem
  13505. .data( "ui-tooltip-id", id )
  13506. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  13507. },
  13508. _removeDescribedBy: function( elem ) {
  13509. var id = elem.data( "ui-tooltip-id" ),
  13510. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  13511. index = $.inArray( id, describedby );
  13512. if ( index !== -1 ) {
  13513. describedby.splice( index, 1 );
  13514. }
  13515. elem.removeData( "ui-tooltip-id" );
  13516. describedby = $.trim( describedby.join( " " ) );
  13517. if ( describedby ) {
  13518. elem.attr( "aria-describedby", describedby );
  13519. } else {
  13520. elem.removeAttr( "aria-describedby" );
  13521. }
  13522. },
  13523. _create: function() {
  13524. this._on({
  13525. mouseover: "open",
  13526. focusin: "open"
  13527. });
  13528. // IDs of generated tooltips, needed for destroy
  13529. this.tooltips = {};
  13530. // IDs of parent tooltips where we removed the title attribute
  13531. this.parents = {};
  13532. if ( this.options.disabled ) {
  13533. this._disable();
  13534. }
  13535. // Append the aria-live region so tooltips announce correctly
  13536. this.liveRegion = $( "<div>" )
  13537. .attr({
  13538. role: "log",
  13539. "aria-live": "assertive",
  13540. "aria-relevant": "additions"
  13541. })
  13542. .addClass( "ui-helper-hidden-accessible" )
  13543. .appendTo( this.document[ 0 ].body );
  13544. },
  13545. _setOption: function( key, value ) {
  13546. var that = this;
  13547. if ( key === "disabled" ) {
  13548. this[ value ? "_disable" : "_enable" ]();
  13549. this.options[ key ] = value;
  13550. // disable element style changes
  13551. return;
  13552. }
  13553. this._super( key, value );
  13554. if ( key === "content" ) {
  13555. $.each( this.tooltips, function( id, element ) {
  13556. that._updateContent( element );
  13557. });
  13558. }
  13559. },
  13560. _disable: function() {
  13561. var that = this;
  13562. // close open tooltips
  13563. $.each( this.tooltips, function( id, element ) {
  13564. var event = $.Event( "blur" );
  13565. event.target = event.currentTarget = element[0];
  13566. that.close( event, true );
  13567. });
  13568. // remove title attributes to prevent native tooltips
  13569. this.element.find( this.options.items ).addBack().each(function() {
  13570. var element = $( this );
  13571. if ( element.is( "[title]" ) ) {
  13572. element
  13573. .data( "ui-tooltip-title", element.attr( "title" ) )
  13574. .removeAttr( "title" );
  13575. }
  13576. });
  13577. },
  13578. _enable: function() {
  13579. // restore title attributes
  13580. this.element.find( this.options.items ).addBack().each(function() {
  13581. var element = $( this );
  13582. if ( element.data( "ui-tooltip-title" ) ) {
  13583. element.attr( "title", element.data( "ui-tooltip-title" ) );
  13584. }
  13585. });
  13586. },
  13587. open: function( event ) {
  13588. var that = this,
  13589. target = $( event ? event.target : this.element )
  13590. // we need closest here due to mouseover bubbling,
  13591. // but always pointing at the same event target
  13592. .closest( this.options.items );
  13593. // No element to show a tooltip for or the tooltip is already open
  13594. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  13595. return;
  13596. }
  13597. if ( target.attr( "title" ) ) {
  13598. target.data( "ui-tooltip-title", target.attr( "title" ) );
  13599. }
  13600. target.data( "ui-tooltip-open", true );
  13601. // kill parent tooltips, custom or native, for hover
  13602. if ( event && event.type === "mouseover" ) {
  13603. target.parents().each(function() {
  13604. var parent = $( this ),
  13605. blurEvent;
  13606. if ( parent.data( "ui-tooltip-open" ) ) {
  13607. blurEvent = $.Event( "blur" );
  13608. blurEvent.target = blurEvent.currentTarget = this;
  13609. that.close( blurEvent, true );
  13610. }
  13611. if ( parent.attr( "title" ) ) {
  13612. parent.uniqueId();
  13613. that.parents[ this.id ] = {
  13614. element: this,
  13615. title: parent.attr( "title" )
  13616. };
  13617. parent.attr( "title", "" );
  13618. }
  13619. });
  13620. }
  13621. this._updateContent( target, event );
  13622. },
  13623. _updateContent: function( target, event ) {
  13624. var content,
  13625. contentOption = this.options.content,
  13626. that = this,
  13627. eventType = event ? event.type : null;
  13628. if ( typeof contentOption === "string" ) {
  13629. return this._open( event, target, contentOption );
  13630. }
  13631. content = contentOption.call( target[0], function( response ) {
  13632. // ignore async response if tooltip was closed already
  13633. if ( !target.data( "ui-tooltip-open" ) ) {
  13634. return;
  13635. }
  13636. // IE may instantly serve a cached response for ajax requests
  13637. // delay this call to _open so the other call to _open runs first
  13638. that._delay(function() {
  13639. // jQuery creates a special event for focusin when it doesn't
  13640. // exist natively. To improve performance, the native event
  13641. // object is reused and the type is changed. Therefore, we can't
  13642. // rely on the type being correct after the event finished
  13643. // bubbling, so we set it back to the previous value. (#8740)
  13644. if ( event ) {
  13645. event.type = eventType;
  13646. }
  13647. this._open( event, target, response );
  13648. });
  13649. });
  13650. if ( content ) {
  13651. this._open( event, target, content );
  13652. }
  13653. },
  13654. _open: function( event, target, content ) {
  13655. var tooltip, events, delayedShow, a11yContent,
  13656. positionOption = $.extend( {}, this.options.position );
  13657. if ( !content ) {
  13658. return;
  13659. }
  13660. // Content can be updated multiple times. If the tooltip already
  13661. // exists, then just update the content and bail.
  13662. tooltip = this._find( target );
  13663. if ( tooltip.length ) {
  13664. tooltip.find( ".ui-tooltip-content" ).html( content );
  13665. return;
  13666. }
  13667. // if we have a title, clear it to prevent the native tooltip
  13668. // we have to check first to avoid defining a title if none exists
  13669. // (we don't want to cause an element to start matching [title])
  13670. //
  13671. // We use removeAttr only for key events, to allow IE to export the correct
  13672. // accessible attributes. For mouse events, set to empty string to avoid
  13673. // native tooltip showing up (happens only when removing inside mouseover).
  13674. if ( target.is( "[title]" ) ) {
  13675. if ( event && event.type === "mouseover" ) {
  13676. target.attr( "title", "" );
  13677. } else {
  13678. target.removeAttr( "title" );
  13679. }
  13680. }
  13681. tooltip = this._tooltip( target );
  13682. this._addDescribedBy( target, tooltip.attr( "id" ) );
  13683. tooltip.find( ".ui-tooltip-content" ).html( content );
  13684. // Support: Voiceover on OS X, JAWS on IE <= 9
  13685. // JAWS announces deletions even when aria-relevant="additions"
  13686. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  13687. this.liveRegion.children().hide();
  13688. if ( content.clone ) {
  13689. a11yContent = content.clone();
  13690. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  13691. } else {
  13692. a11yContent = content;
  13693. }
  13694. $( "<div>" ).html( a11yContent ).appendTo( this.liveRegion );
  13695. function position( event ) {
  13696. positionOption.of = event;
  13697. if ( tooltip.is( ":hidden" ) ) {
  13698. return;
  13699. }
  13700. tooltip.position( positionOption );
  13701. }
  13702. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  13703. this._on( this.document, {
  13704. mousemove: position
  13705. });
  13706. // trigger once to override element-relative positioning
  13707. position( event );
  13708. } else {
  13709. tooltip.position( $.extend({
  13710. of: target
  13711. }, this.options.position ) );
  13712. }
  13713. tooltip.hide();
  13714. this._show( tooltip, this.options.show );
  13715. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  13716. // as the tooltip is visible, position the tooltip using the most recent
  13717. // event.
  13718. if ( this.options.show && this.options.show.delay ) {
  13719. delayedShow = this.delayedShow = setInterval(function() {
  13720. if ( tooltip.is( ":visible" ) ) {
  13721. position( positionOption.of );
  13722. clearInterval( delayedShow );
  13723. }
  13724. }, $.fx.interval );
  13725. }
  13726. this._trigger( "open", event, { tooltip: tooltip } );
  13727. events = {
  13728. keyup: function( event ) {
  13729. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  13730. var fakeEvent = $.Event(event);
  13731. fakeEvent.currentTarget = target[0];
  13732. this.close( fakeEvent, true );
  13733. }
  13734. }
  13735. };
  13736. // Only bind remove handler for delegated targets. Non-delegated
  13737. // tooltips will handle this in destroy.
  13738. if ( target[ 0 ] !== this.element[ 0 ] ) {
  13739. events.remove = function() {
  13740. this._removeTooltip( tooltip );
  13741. };
  13742. }
  13743. if ( !event || event.type === "mouseover" ) {
  13744. events.mouseleave = "close";
  13745. }
  13746. if ( !event || event.type === "focusin" ) {
  13747. events.focusout = "close";
  13748. }
  13749. this._on( true, target, events );
  13750. },
  13751. close: function( event ) {
  13752. var that = this,
  13753. target = $( event ? event.currentTarget : this.element ),
  13754. tooltip = this._find( target );
  13755. // disabling closes the tooltip, so we need to track when we're closing
  13756. // to avoid an infinite loop in case the tooltip becomes disabled on close
  13757. if ( this.closing ) {
  13758. return;
  13759. }
  13760. // Clear the interval for delayed tracking tooltips
  13761. clearInterval( this.delayedShow );
  13762. // only set title if we had one before (see comment in _open())
  13763. // If the title attribute has changed since open(), don't restore
  13764. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  13765. target.attr( "title", target.data( "ui-tooltip-title" ) );
  13766. }
  13767. this._removeDescribedBy( target );
  13768. tooltip.stop( true );
  13769. this._hide( tooltip, this.options.hide, function() {
  13770. that._removeTooltip( $( this ) );
  13771. });
  13772. target.removeData( "ui-tooltip-open" );
  13773. this._off( target, "mouseleave focusout keyup" );
  13774. // Remove 'remove' binding only on delegated targets
  13775. if ( target[ 0 ] !== this.element[ 0 ] ) {
  13776. this._off( target, "remove" );
  13777. }
  13778. this._off( this.document, "mousemove" );
  13779. if ( event && event.type === "mouseleave" ) {
  13780. $.each( this.parents, function( id, parent ) {
  13781. $( parent.element ).attr( "title", parent.title );
  13782. delete that.parents[ id ];
  13783. });
  13784. }
  13785. this.closing = true;
  13786. this._trigger( "close", event, { tooltip: tooltip } );
  13787. this.closing = false;
  13788. },
  13789. _tooltip: function( element ) {
  13790. var tooltip = $( "<div>" )
  13791. .attr( "role", "tooltip" )
  13792. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  13793. ( this.options.tooltipClass || "" ) ),
  13794. id = tooltip.uniqueId().attr( "id" );
  13795. $( "<div>" )
  13796. .addClass( "ui-tooltip-content" )
  13797. .appendTo( tooltip );
  13798. tooltip.appendTo( this.document[0].body );
  13799. this.tooltips[ id ] = element;
  13800. return tooltip;
  13801. },
  13802. _find: function( target ) {
  13803. var id = target.data( "ui-tooltip-id" );
  13804. return id ? $( "#" + id ) : $();
  13805. },
  13806. _removeTooltip: function( tooltip ) {
  13807. tooltip.remove();
  13808. delete this.tooltips[ tooltip.attr( "id" ) ];
  13809. },
  13810. _destroy: function() {
  13811. var that = this;
  13812. // close open tooltips
  13813. $.each( this.tooltips, function( id, element ) {
  13814. // Delegate to close method to handle common cleanup
  13815. var event = $.Event( "blur" );
  13816. event.target = event.currentTarget = element[0];
  13817. that.close( event, true );
  13818. // Remove immediately; destroying an open tooltip doesn't use the
  13819. // hide animation
  13820. $( "#" + id ).remove();
  13821. // Restore the title
  13822. if ( element.data( "ui-tooltip-title" ) ) {
  13823. // If the title attribute has changed since open(), don't restore
  13824. if ( !element.attr( "title" ) ) {
  13825. element.attr( "title", element.data( "ui-tooltip-title" ) );
  13826. }
  13827. element.removeData( "ui-tooltip-title" );
  13828. }
  13829. });
  13830. this.liveRegion.remove();
  13831. }
  13832. });
  13833. }));