jquery-ui.js 459 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607
  1. /*! jQuery UI - v1.11.3 - 2015-03-01
  2. * http://jqueryui.com
  3. * Includes: core.js, widget.js, mouse.js, position.js, draggable.js, droppable.js, resizable.js, selectable.js, sortable.js, accordion.js, autocomplete.js, button.js, datepicker.js, dialog.js, menu.js, progressbar.js, selectmenu.js, slider.js, spinner.js, tabs.js, tooltip.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
  4. * Copyright 2015 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.3
  16. * http://jqueryui.com
  17. *
  18. * Copyright 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.3",
  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( includeHidden ) {
  50. var position = this.css( "position" ),
  51. excludeStaticParent = position === "absolute",
  52. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  53. scrollParent = this.parents().filter( function() {
  54. var parent = $( this );
  55. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  56. return false;
  57. }
  58. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
  59. }).eq( 0 );
  60. return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
  61. },
  62. uniqueId: (function() {
  63. var uuid = 0;
  64. return function() {
  65. return this.each(function() {
  66. if ( !this.id ) {
  67. this.id = "ui-id-" + ( ++uuid );
  68. }
  69. });
  70. };
  71. })(),
  72. removeUniqueId: function() {
  73. return this.each(function() {
  74. if ( /^ui-id-\d+$/.test( this.id ) ) {
  75. $( this ).removeAttr( "id" );
  76. }
  77. });
  78. }
  79. });
  80. // selectors
  81. function focusable( element, isTabIndexNotNaN ) {
  82. var map, mapName, img,
  83. nodeName = element.nodeName.toLowerCase();
  84. if ( "area" === nodeName ) {
  85. map = element.parentNode;
  86. mapName = map.name;
  87. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  88. return false;
  89. }
  90. img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
  91. return !!img && visible( img );
  92. }
  93. return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ?
  94. !element.disabled :
  95. "a" === nodeName ?
  96. element.href || isTabIndexNotNaN :
  97. isTabIndexNotNaN) &&
  98. // the element and all of its ancestors must be visible
  99. visible( element );
  100. }
  101. function visible( element ) {
  102. return $.expr.filters.visible( element ) &&
  103. !$( element ).parents().addBack().filter(function() {
  104. return $.css( this, "visibility" ) === "hidden";
  105. }).length;
  106. }
  107. $.extend( $.expr[ ":" ], {
  108. data: $.expr.createPseudo ?
  109. $.expr.createPseudo(function( dataName ) {
  110. return function( elem ) {
  111. return !!$.data( elem, dataName );
  112. };
  113. }) :
  114. // support: jQuery <1.8
  115. function( elem, i, match ) {
  116. return !!$.data( elem, match[ 3 ] );
  117. },
  118. focusable: function( element ) {
  119. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  120. },
  121. tabbable: function( element ) {
  122. var tabIndex = $.attr( element, "tabindex" ),
  123. isTabIndexNaN = isNaN( tabIndex );
  124. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  125. }
  126. });
  127. // support: jQuery <1.8
  128. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  129. $.each( [ "Width", "Height" ], function( i, name ) {
  130. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  131. type = name.toLowerCase(),
  132. orig = {
  133. innerWidth: $.fn.innerWidth,
  134. innerHeight: $.fn.innerHeight,
  135. outerWidth: $.fn.outerWidth,
  136. outerHeight: $.fn.outerHeight
  137. };
  138. function reduce( elem, size, border, margin ) {
  139. $.each( side, function() {
  140. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  141. if ( border ) {
  142. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  143. }
  144. if ( margin ) {
  145. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  146. }
  147. });
  148. return size;
  149. }
  150. $.fn[ "inner" + name ] = function( size ) {
  151. if ( size === undefined ) {
  152. return orig[ "inner" + name ].call( this );
  153. }
  154. return this.each(function() {
  155. $( this ).css( type, reduce( this, size ) + "px" );
  156. });
  157. };
  158. $.fn[ "outer" + name] = function( size, margin ) {
  159. if ( typeof size !== "number" ) {
  160. return orig[ "outer" + name ].call( this, size );
  161. }
  162. return this.each(function() {
  163. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  164. });
  165. };
  166. });
  167. }
  168. // support: jQuery <1.8
  169. if ( !$.fn.addBack ) {
  170. $.fn.addBack = function( selector ) {
  171. return this.add( selector == null ?
  172. this.prevObject : this.prevObject.filter( selector )
  173. );
  174. };
  175. }
  176. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  177. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  178. $.fn.removeData = (function( removeData ) {
  179. return function( key ) {
  180. if ( arguments.length ) {
  181. return removeData.call( this, $.camelCase( key ) );
  182. } else {
  183. return removeData.call( this );
  184. }
  185. };
  186. })( $.fn.removeData );
  187. }
  188. // deprecated
  189. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  190. $.fn.extend({
  191. focus: (function( orig ) {
  192. return function( delay, fn ) {
  193. return typeof delay === "number" ?
  194. this.each(function() {
  195. var elem = this;
  196. setTimeout(function() {
  197. $( elem ).focus();
  198. if ( fn ) {
  199. fn.call( elem );
  200. }
  201. }, delay );
  202. }) :
  203. orig.apply( this, arguments );
  204. };
  205. })( $.fn.focus ),
  206. disableSelection: (function() {
  207. var eventType = "onselectstart" in document.createElement( "div" ) ?
  208. "selectstart" :
  209. "mousedown";
  210. return function() {
  211. return this.bind( eventType + ".ui-disableSelection", function( event ) {
  212. event.preventDefault();
  213. });
  214. };
  215. })(),
  216. enableSelection: function() {
  217. return this.unbind( ".ui-disableSelection" );
  218. },
  219. zIndex: function( zIndex ) {
  220. if ( zIndex !== undefined ) {
  221. return this.css( "zIndex", zIndex );
  222. }
  223. if ( this.length ) {
  224. var elem = $( this[ 0 ] ), position, value;
  225. while ( elem.length && elem[ 0 ] !== document ) {
  226. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  227. // This makes behavior of this function consistent across browsers
  228. // WebKit always returns auto if the element is positioned
  229. position = elem.css( "position" );
  230. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  231. // IE returns 0 when zIndex is not specified
  232. // other browsers return a string
  233. // we ignore the case of nested elements with an explicit value of 0
  234. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  235. value = parseInt( elem.css( "zIndex" ), 10 );
  236. if ( !isNaN( value ) && value !== 0 ) {
  237. return value;
  238. }
  239. }
  240. elem = elem.parent();
  241. }
  242. }
  243. return 0;
  244. }
  245. });
  246. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  247. $.ui.plugin = {
  248. add: function( module, option, set ) {
  249. var i,
  250. proto = $.ui[ module ].prototype;
  251. for ( i in set ) {
  252. proto.plugins[ i ] = proto.plugins[ i ] || [];
  253. proto.plugins[ i ].push( [ option, set[ i ] ] );
  254. }
  255. },
  256. call: function( instance, name, args, allowDisconnected ) {
  257. var i,
  258. set = instance.plugins[ name ];
  259. if ( !set ) {
  260. return;
  261. }
  262. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  263. return;
  264. }
  265. for ( i = 0; i < set.length; i++ ) {
  266. if ( instance.options[ set[ i ][ 0 ] ] ) {
  267. set[ i ][ 1 ].apply( instance.element, args );
  268. }
  269. }
  270. }
  271. };
  272. /*!
  273. * jQuery UI Widget 1.11.3
  274. * http://jqueryui.com
  275. *
  276. * Copyright jQuery Foundation and other contributors
  277. * Released under the MIT license.
  278. * http://jquery.org/license
  279. *
  280. * http://api.jqueryui.com/jQuery.widget/
  281. */
  282. var widget_uuid = 0,
  283. widget_slice = Array.prototype.slice;
  284. $.cleanData = (function( orig ) {
  285. return function( elems ) {
  286. var events, elem, i;
  287. for ( i = 0; (elem = elems[i]) != null; i++ ) {
  288. try {
  289. // Only trigger remove when necessary to save time
  290. events = $._data( elem, "events" );
  291. if ( events && events.remove ) {
  292. $( elem ).triggerHandler( "remove" );
  293. }
  294. // http://bugs.jquery.com/ticket/8235
  295. } catch ( e ) {}
  296. }
  297. orig( elems );
  298. };
  299. })( $.cleanData );
  300. $.widget = function( name, base, prototype ) {
  301. var fullName, existingConstructor, constructor, basePrototype,
  302. // proxiedPrototype allows the provided prototype to remain unmodified
  303. // so that it can be used as a mixin for multiple widgets (#8876)
  304. proxiedPrototype = {},
  305. namespace = name.split( "." )[ 0 ];
  306. name = name.split( "." )[ 1 ];
  307. fullName = namespace + "-" + name;
  308. if ( !prototype ) {
  309. prototype = base;
  310. base = $.Widget;
  311. }
  312. // create selector for plugin
  313. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  314. return !!$.data( elem, fullName );
  315. };
  316. $[ namespace ] = $[ namespace ] || {};
  317. existingConstructor = $[ namespace ][ name ];
  318. constructor = $[ namespace ][ name ] = function( options, element ) {
  319. // allow instantiation without "new" keyword
  320. if ( !this._createWidget ) {
  321. return new constructor( options, element );
  322. }
  323. // allow instantiation without initializing for simple inheritance
  324. // must use "new" keyword (the code above always passes args)
  325. if ( arguments.length ) {
  326. this._createWidget( options, element );
  327. }
  328. };
  329. // extend with the existing constructor to carry over any static properties
  330. $.extend( constructor, existingConstructor, {
  331. version: prototype.version,
  332. // copy the object used to create the prototype in case we need to
  333. // redefine the widget later
  334. _proto: $.extend( {}, prototype ),
  335. // track widgets that inherit from this widget in case this widget is
  336. // redefined after a widget inherits from it
  337. _childConstructors: []
  338. });
  339. basePrototype = new base();
  340. // we need to make the options hash a property directly on the new instance
  341. // otherwise we'll modify the options hash on the prototype that we're
  342. // inheriting from
  343. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  344. $.each( prototype, function( prop, value ) {
  345. if ( !$.isFunction( value ) ) {
  346. proxiedPrototype[ prop ] = value;
  347. return;
  348. }
  349. proxiedPrototype[ prop ] = (function() {
  350. var _super = function() {
  351. return base.prototype[ prop ].apply( this, arguments );
  352. },
  353. _superApply = function( args ) {
  354. return base.prototype[ prop ].apply( this, args );
  355. };
  356. return function() {
  357. var __super = this._super,
  358. __superApply = this._superApply,
  359. returnValue;
  360. this._super = _super;
  361. this._superApply = _superApply;
  362. returnValue = value.apply( this, arguments );
  363. this._super = __super;
  364. this._superApply = __superApply;
  365. return returnValue;
  366. };
  367. })();
  368. });
  369. constructor.prototype = $.widget.extend( basePrototype, {
  370. // TODO: remove support for widgetEventPrefix
  371. // always use the name + a colon as the prefix, e.g., draggable:start
  372. // don't prefix for widgets that aren't DOM-based
  373. widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
  374. }, proxiedPrototype, {
  375. constructor: constructor,
  376. namespace: namespace,
  377. widgetName: name,
  378. widgetFullName: fullName
  379. });
  380. // If this widget is being redefined then we need to find all widgets that
  381. // are inheriting from it and redefine all of them so that they inherit from
  382. // the new version of this widget. We're essentially trying to replace one
  383. // level in the prototype chain.
  384. if ( existingConstructor ) {
  385. $.each( existingConstructor._childConstructors, function( i, child ) {
  386. var childPrototype = child.prototype;
  387. // redefine the child widget using the same prototype that was
  388. // originally used, but inherit from the new version of the base
  389. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  390. });
  391. // remove the list of existing child constructors from the old constructor
  392. // so the old child constructors can be garbage collected
  393. delete existingConstructor._childConstructors;
  394. } else {
  395. base._childConstructors.push( constructor );
  396. }
  397. $.widget.bridge( name, constructor );
  398. return constructor;
  399. };
  400. $.widget.extend = function( target ) {
  401. var input = widget_slice.call( arguments, 1 ),
  402. inputIndex = 0,
  403. inputLength = input.length,
  404. key,
  405. value;
  406. for ( ; inputIndex < inputLength; inputIndex++ ) {
  407. for ( key in input[ inputIndex ] ) {
  408. value = input[ inputIndex ][ key ];
  409. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  410. // Clone objects
  411. if ( $.isPlainObject( value ) ) {
  412. target[ key ] = $.isPlainObject( target[ key ] ) ?
  413. $.widget.extend( {}, target[ key ], value ) :
  414. // Don't extend strings, arrays, etc. with objects
  415. $.widget.extend( {}, value );
  416. // Copy everything else by reference
  417. } else {
  418. target[ key ] = value;
  419. }
  420. }
  421. }
  422. }
  423. return target;
  424. };
  425. $.widget.bridge = function( name, object ) {
  426. var fullName = object.prototype.widgetFullName || name;
  427. $.fn[ name ] = function( options ) {
  428. var isMethodCall = typeof options === "string",
  429. args = widget_slice.call( arguments, 1 ),
  430. returnValue = this;
  431. if ( isMethodCall ) {
  432. this.each(function() {
  433. var methodValue,
  434. instance = $.data( this, fullName );
  435. if ( options === "instance" ) {
  436. returnValue = instance;
  437. return false;
  438. }
  439. if ( !instance ) {
  440. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  441. "attempted to call method '" + options + "'" );
  442. }
  443. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  444. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  445. }
  446. methodValue = instance[ options ].apply( instance, args );
  447. if ( methodValue !== instance && methodValue !== undefined ) {
  448. returnValue = methodValue && methodValue.jquery ?
  449. returnValue.pushStack( methodValue.get() ) :
  450. methodValue;
  451. return false;
  452. }
  453. });
  454. } else {
  455. // Allow multiple hashes to be passed on init
  456. if ( args.length ) {
  457. options = $.widget.extend.apply( null, [ options ].concat(args) );
  458. }
  459. this.each(function() {
  460. var instance = $.data( this, fullName );
  461. if ( instance ) {
  462. instance.option( options || {} );
  463. if ( instance._init ) {
  464. instance._init();
  465. }
  466. } else {
  467. $.data( this, fullName, new object( options, this ) );
  468. }
  469. });
  470. }
  471. return returnValue;
  472. };
  473. };
  474. $.Widget = function( /* options, element */ ) {};
  475. $.Widget._childConstructors = [];
  476. $.Widget.prototype = {
  477. widgetName: "widget",
  478. widgetEventPrefix: "",
  479. defaultElement: "<div>",
  480. options: {
  481. disabled: false,
  482. // callbacks
  483. create: null
  484. },
  485. _createWidget: function( options, element ) {
  486. element = $( element || this.defaultElement || this )[ 0 ];
  487. this.element = $( element );
  488. this.uuid = widget_uuid++;
  489. this.eventNamespace = "." + this.widgetName + this.uuid;
  490. this.bindings = $();
  491. this.hoverable = $();
  492. this.focusable = $();
  493. if ( element !== this ) {
  494. $.data( element, this.widgetFullName, this );
  495. this._on( true, this.element, {
  496. remove: function( event ) {
  497. if ( event.target === element ) {
  498. this.destroy();
  499. }
  500. }
  501. });
  502. this.document = $( element.style ?
  503. // element within the document
  504. element.ownerDocument :
  505. // element is window or document
  506. element.document || element );
  507. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  508. }
  509. this.options = $.widget.extend( {},
  510. this.options,
  511. this._getCreateOptions(),
  512. options );
  513. this._create();
  514. this._trigger( "create", null, this._getCreateEventData() );
  515. this._init();
  516. },
  517. _getCreateOptions: $.noop,
  518. _getCreateEventData: $.noop,
  519. _create: $.noop,
  520. _init: $.noop,
  521. destroy: function() {
  522. this._destroy();
  523. // we can probably remove the unbind calls in 2.0
  524. // all event bindings should go through this._on()
  525. this.element
  526. .unbind( this.eventNamespace )
  527. .removeData( this.widgetFullName )
  528. // support: jquery <1.6.3
  529. // http://bugs.jquery.com/ticket/9413
  530. .removeData( $.camelCase( this.widgetFullName ) );
  531. this.widget()
  532. .unbind( this.eventNamespace )
  533. .removeAttr( "aria-disabled" )
  534. .removeClass(
  535. this.widgetFullName + "-disabled " +
  536. "ui-state-disabled" );
  537. // clean up events and states
  538. this.bindings.unbind( this.eventNamespace );
  539. this.hoverable.removeClass( "ui-state-hover" );
  540. this.focusable.removeClass( "ui-state-focus" );
  541. },
  542. _destroy: $.noop,
  543. widget: function() {
  544. return this.element;
  545. },
  546. option: function( key, value ) {
  547. var options = key,
  548. parts,
  549. curOption,
  550. i;
  551. if ( arguments.length === 0 ) {
  552. // don't return a reference to the internal hash
  553. return $.widget.extend( {}, this.options );
  554. }
  555. if ( typeof key === "string" ) {
  556. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  557. options = {};
  558. parts = key.split( "." );
  559. key = parts.shift();
  560. if ( parts.length ) {
  561. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  562. for ( i = 0; i < parts.length - 1; i++ ) {
  563. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  564. curOption = curOption[ parts[ i ] ];
  565. }
  566. key = parts.pop();
  567. if ( arguments.length === 1 ) {
  568. return curOption[ key ] === undefined ? null : curOption[ key ];
  569. }
  570. curOption[ key ] = value;
  571. } else {
  572. if ( arguments.length === 1 ) {
  573. return this.options[ key ] === undefined ? null : this.options[ key ];
  574. }
  575. options[ key ] = value;
  576. }
  577. }
  578. this._setOptions( options );
  579. return this;
  580. },
  581. _setOptions: function( options ) {
  582. var key;
  583. for ( key in options ) {
  584. this._setOption( key, options[ key ] );
  585. }
  586. return this;
  587. },
  588. _setOption: function( key, value ) {
  589. this.options[ key ] = value;
  590. if ( key === "disabled" ) {
  591. this.widget()
  592. .toggleClass( this.widgetFullName + "-disabled", !!value );
  593. // If the widget is becoming disabled, then nothing is interactive
  594. if ( value ) {
  595. this.hoverable.removeClass( "ui-state-hover" );
  596. this.focusable.removeClass( "ui-state-focus" );
  597. }
  598. }
  599. return this;
  600. },
  601. enable: function() {
  602. return this._setOptions({ disabled: false });
  603. },
  604. disable: function() {
  605. return this._setOptions({ disabled: true });
  606. },
  607. _on: function( suppressDisabledCheck, element, handlers ) {
  608. var delegateElement,
  609. instance = this;
  610. // no suppressDisabledCheck flag, shuffle arguments
  611. if ( typeof suppressDisabledCheck !== "boolean" ) {
  612. handlers = element;
  613. element = suppressDisabledCheck;
  614. suppressDisabledCheck = false;
  615. }
  616. // no element argument, shuffle and use this.element
  617. if ( !handlers ) {
  618. handlers = element;
  619. element = this.element;
  620. delegateElement = this.widget();
  621. } else {
  622. element = delegateElement = $( element );
  623. this.bindings = this.bindings.add( element );
  624. }
  625. $.each( handlers, function( event, handler ) {
  626. function handlerProxy() {
  627. // allow widgets to customize the disabled handling
  628. // - disabled as an array instead of boolean
  629. // - disabled class as method for disabling individual parts
  630. if ( !suppressDisabledCheck &&
  631. ( instance.options.disabled === true ||
  632. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  633. return;
  634. }
  635. return ( typeof handler === "string" ? instance[ handler ] : handler )
  636. .apply( instance, arguments );
  637. }
  638. // copy the guid so direct unbinding works
  639. if ( typeof handler !== "string" ) {
  640. handlerProxy.guid = handler.guid =
  641. handler.guid || handlerProxy.guid || $.guid++;
  642. }
  643. var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
  644. eventName = match[1] + instance.eventNamespace,
  645. selector = match[2];
  646. if ( selector ) {
  647. delegateElement.delegate( selector, eventName, handlerProxy );
  648. } else {
  649. element.bind( eventName, handlerProxy );
  650. }
  651. });
  652. },
  653. _off: function( element, eventName ) {
  654. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) +
  655. this.eventNamespace;
  656. element.unbind( eventName ).undelegate( eventName );
  657. // Clear the stack to avoid memory leaks (#10056)
  658. this.bindings = $( this.bindings.not( element ).get() );
  659. this.focusable = $( this.focusable.not( element ).get() );
  660. this.hoverable = $( this.hoverable.not( element ).get() );
  661. },
  662. _delay: function( handler, delay ) {
  663. function handlerProxy() {
  664. return ( typeof handler === "string" ? instance[ handler ] : handler )
  665. .apply( instance, arguments );
  666. }
  667. var instance = this;
  668. return setTimeout( handlerProxy, delay || 0 );
  669. },
  670. _hoverable: function( element ) {
  671. this.hoverable = this.hoverable.add( element );
  672. this._on( element, {
  673. mouseenter: function( event ) {
  674. $( event.currentTarget ).addClass( "ui-state-hover" );
  675. },
  676. mouseleave: function( event ) {
  677. $( event.currentTarget ).removeClass( "ui-state-hover" );
  678. }
  679. });
  680. },
  681. _focusable: function( element ) {
  682. this.focusable = this.focusable.add( element );
  683. this._on( element, {
  684. focusin: function( event ) {
  685. $( event.currentTarget ).addClass( "ui-state-focus" );
  686. },
  687. focusout: function( event ) {
  688. $( event.currentTarget ).removeClass( "ui-state-focus" );
  689. }
  690. });
  691. },
  692. _trigger: function( type, event, data ) {
  693. var prop, orig,
  694. callback = this.options[ type ];
  695. data = data || {};
  696. event = $.Event( event );
  697. event.type = ( type === this.widgetEventPrefix ?
  698. type :
  699. this.widgetEventPrefix + type ).toLowerCase();
  700. // the original event may come from any element
  701. // so we need to reset the target on the new event
  702. event.target = this.element[ 0 ];
  703. // copy original event properties over to the new event
  704. orig = event.originalEvent;
  705. if ( orig ) {
  706. for ( prop in orig ) {
  707. if ( !( prop in event ) ) {
  708. event[ prop ] = orig[ prop ];
  709. }
  710. }
  711. }
  712. this.element.trigger( event, data );
  713. return !( $.isFunction( callback ) &&
  714. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  715. event.isDefaultPrevented() );
  716. }
  717. };
  718. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  719. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  720. if ( typeof options === "string" ) {
  721. options = { effect: options };
  722. }
  723. var hasOptions,
  724. effectName = !options ?
  725. method :
  726. options === true || typeof options === "number" ?
  727. defaultEffect :
  728. options.effect || defaultEffect;
  729. options = options || {};
  730. if ( typeof options === "number" ) {
  731. options = { duration: options };
  732. }
  733. hasOptions = !$.isEmptyObject( options );
  734. options.complete = callback;
  735. if ( options.delay ) {
  736. element.delay( options.delay );
  737. }
  738. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  739. element[ method ]( options );
  740. } else if ( effectName !== method && element[ effectName ] ) {
  741. element[ effectName ]( options.duration, options.easing, callback );
  742. } else {
  743. element.queue(function( next ) {
  744. $( this )[ method ]();
  745. if ( callback ) {
  746. callback.call( element[ 0 ] );
  747. }
  748. next();
  749. });
  750. }
  751. };
  752. });
  753. var widget = $.widget;
  754. /*!
  755. * jQuery UI Mouse 1.11.3
  756. * http://jqueryui.com
  757. *
  758. * Copyright jQuery Foundation and other contributors
  759. * Released under the MIT license.
  760. * http://jquery.org/license
  761. *
  762. * http://api.jqueryui.com/mouse/
  763. */
  764. var mouseHandled = false;
  765. $( document ).mouseup( function() {
  766. mouseHandled = false;
  767. });
  768. var mouse = $.widget("ui.mouse", {
  769. version: "1.11.3",
  770. options: {
  771. cancel: "input,textarea,button,select,option",
  772. distance: 1,
  773. delay: 0
  774. },
  775. _mouseInit: function() {
  776. var that = this;
  777. this.element
  778. .bind("mousedown." + this.widgetName, function(event) {
  779. return that._mouseDown(event);
  780. })
  781. .bind("click." + this.widgetName, function(event) {
  782. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  783. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  784. event.stopImmediatePropagation();
  785. return false;
  786. }
  787. });
  788. this.started = false;
  789. },
  790. // TODO: make sure destroying one instance of mouse doesn't mess with
  791. // other instances of mouse
  792. _mouseDestroy: function() {
  793. this.element.unbind("." + this.widgetName);
  794. if ( this._mouseMoveDelegate ) {
  795. this.document
  796. .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate)
  797. .unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
  798. }
  799. },
  800. _mouseDown: function(event) {
  801. // don't let more than one widget handle mouseStart
  802. if ( mouseHandled ) {
  803. return;
  804. }
  805. this._mouseMoved = false;
  806. // we may have missed mouseup (out of window)
  807. (this._mouseStarted && this._mouseUp(event));
  808. this._mouseDownEvent = event;
  809. var that = this,
  810. btnIsLeft = (event.which === 1),
  811. // event.target.nodeName works around a bug in IE 8 with
  812. // disabled inputs (#7620)
  813. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  814. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  815. return true;
  816. }
  817. this.mouseDelayMet = !this.options.delay;
  818. if (!this.mouseDelayMet) {
  819. this._mouseDelayTimer = setTimeout(function() {
  820. that.mouseDelayMet = true;
  821. }, this.options.delay);
  822. }
  823. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  824. this._mouseStarted = (this._mouseStart(event) !== false);
  825. if (!this._mouseStarted) {
  826. event.preventDefault();
  827. return true;
  828. }
  829. }
  830. // Click event may never have fired (Gecko & Opera)
  831. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  832. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  833. }
  834. // these delegates are required to keep context
  835. this._mouseMoveDelegate = function(event) {
  836. return that._mouseMove(event);
  837. };
  838. this._mouseUpDelegate = function(event) {
  839. return that._mouseUp(event);
  840. };
  841. this.document
  842. .bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  843. .bind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  844. event.preventDefault();
  845. mouseHandled = true;
  846. return true;
  847. },
  848. _mouseMove: function(event) {
  849. // Only check for mouseups outside the document if you've moved inside the document
  850. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  851. // fire a mousemove event if content is placed under the cursor. See #7778
  852. // Support: IE <9
  853. if ( this._mouseMoved ) {
  854. // IE mouseup check - mouseup happened when mouse was out of window
  855. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  856. return this._mouseUp(event);
  857. // Iframe mouseup check - mouseup occurred in another document
  858. } else if ( !event.which ) {
  859. return this._mouseUp( event );
  860. }
  861. }
  862. if ( event.which || event.button ) {
  863. this._mouseMoved = true;
  864. }
  865. if (this._mouseStarted) {
  866. this._mouseDrag(event);
  867. return event.preventDefault();
  868. }
  869. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  870. this._mouseStarted =
  871. (this._mouseStart(this._mouseDownEvent, event) !== false);
  872. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  873. }
  874. return !this._mouseStarted;
  875. },
  876. _mouseUp: function(event) {
  877. this.document
  878. .unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  879. .unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  880. if (this._mouseStarted) {
  881. this._mouseStarted = false;
  882. if (event.target === this._mouseDownEvent.target) {
  883. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  884. }
  885. this._mouseStop(event);
  886. }
  887. mouseHandled = false;
  888. return false;
  889. },
  890. _mouseDistanceMet: function(event) {
  891. return (Math.max(
  892. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  893. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  894. ) >= this.options.distance
  895. );
  896. },
  897. _mouseDelayMet: function(/* event */) {
  898. return this.mouseDelayMet;
  899. },
  900. // These are placeholder methods, to be overriden by extending plugin
  901. _mouseStart: function(/* event */) {},
  902. _mouseDrag: function(/* event */) {},
  903. _mouseStop: function(/* event */) {},
  904. _mouseCapture: function(/* event */) { return true; }
  905. });
  906. /*!
  907. * jQuery UI Position 1.11.3
  908. * http://jqueryui.com
  909. *
  910. * Copyright jQuery Foundation and other contributors
  911. * Released under the MIT license.
  912. * http://jquery.org/license
  913. *
  914. * http://api.jqueryui.com/position/
  915. */
  916. (function() {
  917. $.ui = $.ui || {};
  918. var cachedScrollbarWidth, supportsOffsetFractions,
  919. max = Math.max,
  920. abs = Math.abs,
  921. round = Math.round,
  922. rhorizontal = /left|center|right/,
  923. rvertical = /top|center|bottom/,
  924. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  925. rposition = /^\w+/,
  926. rpercent = /%$/,
  927. _position = $.fn.position;
  928. function getOffsets( offsets, width, height ) {
  929. return [
  930. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  931. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  932. ];
  933. }
  934. function parseCss( element, property ) {
  935. return parseInt( $.css( element, property ), 10 ) || 0;
  936. }
  937. function getDimensions( elem ) {
  938. var raw = elem[0];
  939. if ( raw.nodeType === 9 ) {
  940. return {
  941. width: elem.width(),
  942. height: elem.height(),
  943. offset: { top: 0, left: 0 }
  944. };
  945. }
  946. if ( $.isWindow( raw ) ) {
  947. return {
  948. width: elem.width(),
  949. height: elem.height(),
  950. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  951. };
  952. }
  953. if ( raw.preventDefault ) {
  954. return {
  955. width: 0,
  956. height: 0,
  957. offset: { top: raw.pageY, left: raw.pageX }
  958. };
  959. }
  960. return {
  961. width: elem.outerWidth(),
  962. height: elem.outerHeight(),
  963. offset: elem.offset()
  964. };
  965. }
  966. $.position = {
  967. scrollbarWidth: function() {
  968. if ( cachedScrollbarWidth !== undefined ) {
  969. return cachedScrollbarWidth;
  970. }
  971. var w1, w2,
  972. div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  973. innerDiv = div.children()[0];
  974. $( "body" ).append( div );
  975. w1 = innerDiv.offsetWidth;
  976. div.css( "overflow", "scroll" );
  977. w2 = innerDiv.offsetWidth;
  978. if ( w1 === w2 ) {
  979. w2 = div[0].clientWidth;
  980. }
  981. div.remove();
  982. return (cachedScrollbarWidth = w1 - w2);
  983. },
  984. getScrollInfo: function( within ) {
  985. var overflowX = within.isWindow || within.isDocument ? "" :
  986. within.element.css( "overflow-x" ),
  987. overflowY = within.isWindow || within.isDocument ? "" :
  988. within.element.css( "overflow-y" ),
  989. hasOverflowX = overflowX === "scroll" ||
  990. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  991. hasOverflowY = overflowY === "scroll" ||
  992. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  993. return {
  994. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  995. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  996. };
  997. },
  998. getWithinInfo: function( element ) {
  999. var withinElement = $( element || window ),
  1000. isWindow = $.isWindow( withinElement[0] ),
  1001. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
  1002. return {
  1003. element: withinElement,
  1004. isWindow: isWindow,
  1005. isDocument: isDocument,
  1006. offset: withinElement.offset() || { left: 0, top: 0 },
  1007. scrollLeft: withinElement.scrollLeft(),
  1008. scrollTop: withinElement.scrollTop(),
  1009. // support: jQuery 1.6.x
  1010. // jQuery 1.6 doesn't support .outerWidth/Height() on documents or windows
  1011. width: isWindow || isDocument ? withinElement.width() : withinElement.outerWidth(),
  1012. height: isWindow || isDocument ? withinElement.height() : withinElement.outerHeight()
  1013. };
  1014. }
  1015. };
  1016. $.fn.position = function( options ) {
  1017. if ( !options || !options.of ) {
  1018. return _position.apply( this, arguments );
  1019. }
  1020. // make a copy, we don't want to modify arguments
  1021. options = $.extend( {}, options );
  1022. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  1023. target = $( options.of ),
  1024. within = $.position.getWithinInfo( options.within ),
  1025. scrollInfo = $.position.getScrollInfo( within ),
  1026. collision = ( options.collision || "flip" ).split( " " ),
  1027. offsets = {};
  1028. dimensions = getDimensions( target );
  1029. if ( target[0].preventDefault ) {
  1030. // force left top to allow flipping
  1031. options.at = "left top";
  1032. }
  1033. targetWidth = dimensions.width;
  1034. targetHeight = dimensions.height;
  1035. targetOffset = dimensions.offset;
  1036. // clone to reuse original targetOffset later
  1037. basePosition = $.extend( {}, targetOffset );
  1038. // force my and at to have valid horizontal and vertical positions
  1039. // if a value is missing or invalid, it will be converted to center
  1040. $.each( [ "my", "at" ], function() {
  1041. var pos = ( options[ this ] || "" ).split( " " ),
  1042. horizontalOffset,
  1043. verticalOffset;
  1044. if ( pos.length === 1) {
  1045. pos = rhorizontal.test( pos[ 0 ] ) ?
  1046. pos.concat( [ "center" ] ) :
  1047. rvertical.test( pos[ 0 ] ) ?
  1048. [ "center" ].concat( pos ) :
  1049. [ "center", "center" ];
  1050. }
  1051. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  1052. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  1053. // calculate offsets
  1054. horizontalOffset = roffset.exec( pos[ 0 ] );
  1055. verticalOffset = roffset.exec( pos[ 1 ] );
  1056. offsets[ this ] = [
  1057. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  1058. verticalOffset ? verticalOffset[ 0 ] : 0
  1059. ];
  1060. // reduce to just the positions without the offsets
  1061. options[ this ] = [
  1062. rposition.exec( pos[ 0 ] )[ 0 ],
  1063. rposition.exec( pos[ 1 ] )[ 0 ]
  1064. ];
  1065. });
  1066. // normalize collision option
  1067. if ( collision.length === 1 ) {
  1068. collision[ 1 ] = collision[ 0 ];
  1069. }
  1070. if ( options.at[ 0 ] === "right" ) {
  1071. basePosition.left += targetWidth;
  1072. } else if ( options.at[ 0 ] === "center" ) {
  1073. basePosition.left += targetWidth / 2;
  1074. }
  1075. if ( options.at[ 1 ] === "bottom" ) {
  1076. basePosition.top += targetHeight;
  1077. } else if ( options.at[ 1 ] === "center" ) {
  1078. basePosition.top += targetHeight / 2;
  1079. }
  1080. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  1081. basePosition.left += atOffset[ 0 ];
  1082. basePosition.top += atOffset[ 1 ];
  1083. return this.each(function() {
  1084. var collisionPosition, using,
  1085. elem = $( this ),
  1086. elemWidth = elem.outerWidth(),
  1087. elemHeight = elem.outerHeight(),
  1088. marginLeft = parseCss( this, "marginLeft" ),
  1089. marginTop = parseCss( this, "marginTop" ),
  1090. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  1091. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  1092. position = $.extend( {}, basePosition ),
  1093. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  1094. if ( options.my[ 0 ] === "right" ) {
  1095. position.left -= elemWidth;
  1096. } else if ( options.my[ 0 ] === "center" ) {
  1097. position.left -= elemWidth / 2;
  1098. }
  1099. if ( options.my[ 1 ] === "bottom" ) {
  1100. position.top -= elemHeight;
  1101. } else if ( options.my[ 1 ] === "center" ) {
  1102. position.top -= elemHeight / 2;
  1103. }
  1104. position.left += myOffset[ 0 ];
  1105. position.top += myOffset[ 1 ];
  1106. // if the browser doesn't support fractions, then round for consistent results
  1107. if ( !supportsOffsetFractions ) {
  1108. position.left = round( position.left );
  1109. position.top = round( position.top );
  1110. }
  1111. collisionPosition = {
  1112. marginLeft: marginLeft,
  1113. marginTop: marginTop
  1114. };
  1115. $.each( [ "left", "top" ], function( i, dir ) {
  1116. if ( $.ui.position[ collision[ i ] ] ) {
  1117. $.ui.position[ collision[ i ] ][ dir ]( position, {
  1118. targetWidth: targetWidth,
  1119. targetHeight: targetHeight,
  1120. elemWidth: elemWidth,
  1121. elemHeight: elemHeight,
  1122. collisionPosition: collisionPosition,
  1123. collisionWidth: collisionWidth,
  1124. collisionHeight: collisionHeight,
  1125. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  1126. my: options.my,
  1127. at: options.at,
  1128. within: within,
  1129. elem: elem
  1130. });
  1131. }
  1132. });
  1133. if ( options.using ) {
  1134. // adds feedback as second argument to using callback, if present
  1135. using = function( props ) {
  1136. var left = targetOffset.left - position.left,
  1137. right = left + targetWidth - elemWidth,
  1138. top = targetOffset.top - position.top,
  1139. bottom = top + targetHeight - elemHeight,
  1140. feedback = {
  1141. target: {
  1142. element: target,
  1143. left: targetOffset.left,
  1144. top: targetOffset.top,
  1145. width: targetWidth,
  1146. height: targetHeight
  1147. },
  1148. element: {
  1149. element: elem,
  1150. left: position.left,
  1151. top: position.top,
  1152. width: elemWidth,
  1153. height: elemHeight
  1154. },
  1155. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1156. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1157. };
  1158. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1159. feedback.horizontal = "center";
  1160. }
  1161. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1162. feedback.vertical = "middle";
  1163. }
  1164. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1165. feedback.important = "horizontal";
  1166. } else {
  1167. feedback.important = "vertical";
  1168. }
  1169. options.using.call( this, props, feedback );
  1170. };
  1171. }
  1172. elem.offset( $.extend( position, { using: using } ) );
  1173. });
  1174. };
  1175. $.ui.position = {
  1176. fit: {
  1177. left: function( position, data ) {
  1178. var within = data.within,
  1179. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1180. outerWidth = within.width,
  1181. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1182. overLeft = withinOffset - collisionPosLeft,
  1183. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1184. newOverRight;
  1185. // element is wider than within
  1186. if ( data.collisionWidth > outerWidth ) {
  1187. // element is initially over the left side of within
  1188. if ( overLeft > 0 && overRight <= 0 ) {
  1189. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1190. position.left += overLeft - newOverRight;
  1191. // element is initially over right side of within
  1192. } else if ( overRight > 0 && overLeft <= 0 ) {
  1193. position.left = withinOffset;
  1194. // element is initially over both left and right sides of within
  1195. } else {
  1196. if ( overLeft > overRight ) {
  1197. position.left = withinOffset + outerWidth - data.collisionWidth;
  1198. } else {
  1199. position.left = withinOffset;
  1200. }
  1201. }
  1202. // too far left -> align with left edge
  1203. } else if ( overLeft > 0 ) {
  1204. position.left += overLeft;
  1205. // too far right -> align with right edge
  1206. } else if ( overRight > 0 ) {
  1207. position.left -= overRight;
  1208. // adjust based on position and margin
  1209. } else {
  1210. position.left = max( position.left - collisionPosLeft, position.left );
  1211. }
  1212. },
  1213. top: function( position, data ) {
  1214. var within = data.within,
  1215. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1216. outerHeight = data.within.height,
  1217. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1218. overTop = withinOffset - collisionPosTop,
  1219. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1220. newOverBottom;
  1221. // element is taller than within
  1222. if ( data.collisionHeight > outerHeight ) {
  1223. // element is initially over the top of within
  1224. if ( overTop > 0 && overBottom <= 0 ) {
  1225. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1226. position.top += overTop - newOverBottom;
  1227. // element is initially over bottom of within
  1228. } else if ( overBottom > 0 && overTop <= 0 ) {
  1229. position.top = withinOffset;
  1230. // element is initially over both top and bottom of within
  1231. } else {
  1232. if ( overTop > overBottom ) {
  1233. position.top = withinOffset + outerHeight - data.collisionHeight;
  1234. } else {
  1235. position.top = withinOffset;
  1236. }
  1237. }
  1238. // too far up -> align with top
  1239. } else if ( overTop > 0 ) {
  1240. position.top += overTop;
  1241. // too far down -> align with bottom edge
  1242. } else if ( overBottom > 0 ) {
  1243. position.top -= overBottom;
  1244. // adjust based on position and margin
  1245. } else {
  1246. position.top = max( position.top - collisionPosTop, position.top );
  1247. }
  1248. }
  1249. },
  1250. flip: {
  1251. left: function( position, data ) {
  1252. var within = data.within,
  1253. withinOffset = within.offset.left + within.scrollLeft,
  1254. outerWidth = within.width,
  1255. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1256. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1257. overLeft = collisionPosLeft - offsetLeft,
  1258. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1259. myOffset = data.my[ 0 ] === "left" ?
  1260. -data.elemWidth :
  1261. data.my[ 0 ] === "right" ?
  1262. data.elemWidth :
  1263. 0,
  1264. atOffset = data.at[ 0 ] === "left" ?
  1265. data.targetWidth :
  1266. data.at[ 0 ] === "right" ?
  1267. -data.targetWidth :
  1268. 0,
  1269. offset = -2 * data.offset[ 0 ],
  1270. newOverRight,
  1271. newOverLeft;
  1272. if ( overLeft < 0 ) {
  1273. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1274. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1275. position.left += myOffset + atOffset + offset;
  1276. }
  1277. } else if ( overRight > 0 ) {
  1278. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1279. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1280. position.left += myOffset + atOffset + offset;
  1281. }
  1282. }
  1283. },
  1284. top: function( position, data ) {
  1285. var within = data.within,
  1286. withinOffset = within.offset.top + within.scrollTop,
  1287. outerHeight = within.height,
  1288. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1289. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1290. overTop = collisionPosTop - offsetTop,
  1291. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1292. top = data.my[ 1 ] === "top",
  1293. myOffset = top ?
  1294. -data.elemHeight :
  1295. data.my[ 1 ] === "bottom" ?
  1296. data.elemHeight :
  1297. 0,
  1298. atOffset = data.at[ 1 ] === "top" ?
  1299. data.targetHeight :
  1300. data.at[ 1 ] === "bottom" ?
  1301. -data.targetHeight :
  1302. 0,
  1303. offset = -2 * data.offset[ 1 ],
  1304. newOverTop,
  1305. newOverBottom;
  1306. if ( overTop < 0 ) {
  1307. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1308. if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
  1309. position.top += myOffset + atOffset + offset;
  1310. }
  1311. } else if ( overBottom > 0 ) {
  1312. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1313. if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
  1314. position.top += myOffset + atOffset + offset;
  1315. }
  1316. }
  1317. }
  1318. },
  1319. flipfit: {
  1320. left: function() {
  1321. $.ui.position.flip.left.apply( this, arguments );
  1322. $.ui.position.fit.left.apply( this, arguments );
  1323. },
  1324. top: function() {
  1325. $.ui.position.flip.top.apply( this, arguments );
  1326. $.ui.position.fit.top.apply( this, arguments );
  1327. }
  1328. }
  1329. };
  1330. // fraction support test
  1331. (function() {
  1332. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1333. body = document.getElementsByTagName( "body" )[ 0 ],
  1334. div = document.createElement( "div" );
  1335. //Create a "fake body" for testing based on method used in jQuery.support
  1336. testElement = document.createElement( body ? "div" : "body" );
  1337. testElementStyle = {
  1338. visibility: "hidden",
  1339. width: 0,
  1340. height: 0,
  1341. border: 0,
  1342. margin: 0,
  1343. background: "none"
  1344. };
  1345. if ( body ) {
  1346. $.extend( testElementStyle, {
  1347. position: "absolute",
  1348. left: "-1000px",
  1349. top: "-1000px"
  1350. });
  1351. }
  1352. for ( i in testElementStyle ) {
  1353. testElement.style[ i ] = testElementStyle[ i ];
  1354. }
  1355. testElement.appendChild( div );
  1356. testElementParent = body || document.documentElement;
  1357. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1358. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1359. offsetLeft = $( div ).offset().left;
  1360. supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1361. testElement.innerHTML = "";
  1362. testElementParent.removeChild( testElement );
  1363. })();
  1364. })();
  1365. var position = $.ui.position;
  1366. /*!
  1367. * jQuery UI Draggable 1.11.3
  1368. * http://jqueryui.com
  1369. *
  1370. * Copyright jQuery Foundation and other contributors
  1371. * Released under the MIT license.
  1372. * http://jquery.org/license
  1373. *
  1374. * http://api.jqueryui.com/draggable/
  1375. */
  1376. $.widget("ui.draggable", $.ui.mouse, {
  1377. version: "1.11.3",
  1378. widgetEventPrefix: "drag",
  1379. options: {
  1380. addClasses: true,
  1381. appendTo: "parent",
  1382. axis: false,
  1383. connectToSortable: false,
  1384. containment: false,
  1385. cursor: "auto",
  1386. cursorAt: false,
  1387. grid: false,
  1388. handle: false,
  1389. helper: "original",
  1390. iframeFix: false,
  1391. opacity: false,
  1392. refreshPositions: false,
  1393. revert: false,
  1394. revertDuration: 500,
  1395. scope: "default",
  1396. scroll: true,
  1397. scrollSensitivity: 20,
  1398. scrollSpeed: 20,
  1399. snap: false,
  1400. snapMode: "both",
  1401. snapTolerance: 20,
  1402. stack: false,
  1403. zIndex: false,
  1404. // callbacks
  1405. drag: null,
  1406. start: null,
  1407. stop: null
  1408. },
  1409. _create: function() {
  1410. if ( this.options.helper === "original" ) {
  1411. this._setPositionRelative();
  1412. }
  1413. if (this.options.addClasses){
  1414. this.element.addClass("ui-draggable");
  1415. }
  1416. if (this.options.disabled){
  1417. this.element.addClass("ui-draggable-disabled");
  1418. }
  1419. this._setHandleClassName();
  1420. this._mouseInit();
  1421. },
  1422. _setOption: function( key, value ) {
  1423. this._super( key, value );
  1424. if ( key === "handle" ) {
  1425. this._removeHandleClassName();
  1426. this._setHandleClassName();
  1427. }
  1428. },
  1429. _destroy: function() {
  1430. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  1431. this.destroyOnClear = true;
  1432. return;
  1433. }
  1434. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  1435. this._removeHandleClassName();
  1436. this._mouseDestroy();
  1437. },
  1438. _mouseCapture: function(event) {
  1439. var o = this.options;
  1440. this._blurActiveElement( event );
  1441. // among others, prevent a drag on a resizable-handle
  1442. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  1443. return false;
  1444. }
  1445. //Quit if we're not on a valid handle
  1446. this.handle = this._getHandle(event);
  1447. if (!this.handle) {
  1448. return false;
  1449. }
  1450. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  1451. return true;
  1452. },
  1453. _blockFrames: function( selector ) {
  1454. this.iframeBlocks = this.document.find( selector ).map(function() {
  1455. var iframe = $( this );
  1456. return $( "<div>" )
  1457. .css( "position", "absolute" )
  1458. .appendTo( iframe.parent() )
  1459. .outerWidth( iframe.outerWidth() )
  1460. .outerHeight( iframe.outerHeight() )
  1461. .offset( iframe.offset() )[ 0 ];
  1462. });
  1463. },
  1464. _unblockFrames: function() {
  1465. if ( this.iframeBlocks ) {
  1466. this.iframeBlocks.remove();
  1467. delete this.iframeBlocks;
  1468. }
  1469. },
  1470. _blurActiveElement: function( event ) {
  1471. var document = this.document[ 0 ];
  1472. // Only need to blur if the event occurred on the draggable itself, see #10527
  1473. if ( !this.handleElement.is( event.target ) ) {
  1474. return;
  1475. }
  1476. // support: IE9
  1477. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  1478. try {
  1479. // Support: IE9, IE10
  1480. // If the <body> is blurred, IE will switch windows, see #9520
  1481. if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
  1482. // Blur any element that currently has focus, see #4261
  1483. $( document.activeElement ).blur();
  1484. }
  1485. } catch ( error ) {}
  1486. },
  1487. _mouseStart: function(event) {
  1488. var o = this.options;
  1489. //Create and append the visible helper
  1490. this.helper = this._createHelper(event);
  1491. this.helper.addClass("ui-draggable-dragging");
  1492. //Cache the helper size
  1493. this._cacheHelperProportions();
  1494. //If ddmanager is used for droppables, set the global draggable
  1495. if ($.ui.ddmanager) {
  1496. $.ui.ddmanager.current = this;
  1497. }
  1498. /*
  1499. * - Position generation -
  1500. * This block generates everything position related - it's the core of draggables.
  1501. */
  1502. //Cache the margins of the original element
  1503. this._cacheMargins();
  1504. //Store the helper's css position
  1505. this.cssPosition = this.helper.css( "position" );
  1506. this.scrollParent = this.helper.scrollParent( true );
  1507. this.offsetParent = this.helper.offsetParent();
  1508. this.hasFixedAncestor = this.helper.parents().filter(function() {
  1509. return $( this ).css( "position" ) === "fixed";
  1510. }).length > 0;
  1511. //The element's absolute position on the page minus margins
  1512. this.positionAbs = this.element.offset();
  1513. this._refreshOffsets( event );
  1514. //Generate the original position
  1515. this.originalPosition = this.position = this._generatePosition( event, false );
  1516. this.originalPageX = event.pageX;
  1517. this.originalPageY = event.pageY;
  1518. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1519. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  1520. //Set a containment if given in the options
  1521. this._setContainment();
  1522. //Trigger event + callbacks
  1523. if (this._trigger("start", event) === false) {
  1524. this._clear();
  1525. return false;
  1526. }
  1527. //Recache the helper size
  1528. this._cacheHelperProportions();
  1529. //Prepare the droppable offsets
  1530. if ($.ui.ddmanager && !o.dropBehaviour) {
  1531. $.ui.ddmanager.prepareOffsets(this, event);
  1532. }
  1533. // Reset helper's right/bottom css if they're set and set explicit width/height instead
  1534. // as this prevents resizing of elements with right/bottom set (see #7772)
  1535. this._normalizeRightBottom();
  1536. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  1537. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  1538. if ( $.ui.ddmanager ) {
  1539. $.ui.ddmanager.dragStart(this, event);
  1540. }
  1541. return true;
  1542. },
  1543. _refreshOffsets: function( event ) {
  1544. this.offset = {
  1545. top: this.positionAbs.top - this.margins.top,
  1546. left: this.positionAbs.left - this.margins.left,
  1547. scroll: false,
  1548. parent: this._getParentOffset(),
  1549. relative: this._getRelativeOffset()
  1550. };
  1551. this.offset.click = {
  1552. left: event.pageX - this.offset.left,
  1553. top: event.pageY - this.offset.top
  1554. };
  1555. },
  1556. _mouseDrag: function(event, noPropagation) {
  1557. // reset any necessary cached properties (see #5009)
  1558. if ( this.hasFixedAncestor ) {
  1559. this.offset.parent = this._getParentOffset();
  1560. }
  1561. //Compute the helpers position
  1562. this.position = this._generatePosition( event, true );
  1563. this.positionAbs = this._convertPositionTo("absolute");
  1564. //Call plugins and callbacks and use the resulting position if something is returned
  1565. if (!noPropagation) {
  1566. var ui = this._uiHash();
  1567. if (this._trigger("drag", event, ui) === false) {
  1568. this._mouseUp({});
  1569. return false;
  1570. }
  1571. this.position = ui.position;
  1572. }
  1573. this.helper[ 0 ].style.left = this.position.left + "px";
  1574. this.helper[ 0 ].style.top = this.position.top + "px";
  1575. if ($.ui.ddmanager) {
  1576. $.ui.ddmanager.drag(this, event);
  1577. }
  1578. return false;
  1579. },
  1580. _mouseStop: function(event) {
  1581. //If we are using droppables, inform the manager about the drop
  1582. var that = this,
  1583. dropped = false;
  1584. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1585. dropped = $.ui.ddmanager.drop(this, event);
  1586. }
  1587. //if a drop comes from outside (a sortable)
  1588. if (this.dropped) {
  1589. dropped = this.dropped;
  1590. this.dropped = false;
  1591. }
  1592. 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))) {
  1593. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1594. if (that._trigger("stop", event) !== false) {
  1595. that._clear();
  1596. }
  1597. });
  1598. } else {
  1599. if (this._trigger("stop", event) !== false) {
  1600. this._clear();
  1601. }
  1602. }
  1603. return false;
  1604. },
  1605. _mouseUp: function( event ) {
  1606. this._unblockFrames();
  1607. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1608. if ( $.ui.ddmanager ) {
  1609. $.ui.ddmanager.dragStop(this, event);
  1610. }
  1611. // Only need to focus if the event occurred on the draggable itself, see #10527
  1612. if ( this.handleElement.is( event.target ) ) {
  1613. // The interaction is over; whether or not the click resulted in a drag, focus the element
  1614. this.element.focus();
  1615. }
  1616. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1617. },
  1618. cancel: function() {
  1619. if (this.helper.is(".ui-draggable-dragging")) {
  1620. this._mouseUp({});
  1621. } else {
  1622. this._clear();
  1623. }
  1624. return this;
  1625. },
  1626. _getHandle: function(event) {
  1627. return this.options.handle ?
  1628. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1629. true;
  1630. },
  1631. _setHandleClassName: function() {
  1632. this.handleElement = this.options.handle ?
  1633. this.element.find( this.options.handle ) : this.element;
  1634. this.handleElement.addClass( "ui-draggable-handle" );
  1635. },
  1636. _removeHandleClassName: function() {
  1637. this.handleElement.removeClass( "ui-draggable-handle" );
  1638. },
  1639. _createHelper: function(event) {
  1640. var o = this.options,
  1641. helperIsFunction = $.isFunction( o.helper ),
  1642. helper = helperIsFunction ?
  1643. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  1644. ( o.helper === "clone" ?
  1645. this.element.clone().removeAttr( "id" ) :
  1646. this.element );
  1647. if (!helper.parents("body").length) {
  1648. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1649. }
  1650. // http://bugs.jqueryui.com/ticket/9446
  1651. // a helper function can return the original element
  1652. // which wouldn't have been set to relative in _create
  1653. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  1654. this._setPositionRelative();
  1655. }
  1656. if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1657. helper.css("position", "absolute");
  1658. }
  1659. return helper;
  1660. },
  1661. _setPositionRelative: function() {
  1662. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  1663. this.element[ 0 ].style.position = "relative";
  1664. }
  1665. },
  1666. _adjustOffsetFromHelper: function(obj) {
  1667. if (typeof obj === "string") {
  1668. obj = obj.split(" ");
  1669. }
  1670. if ($.isArray(obj)) {
  1671. obj = { left: +obj[0], top: +obj[1] || 0 };
  1672. }
  1673. if ("left" in obj) {
  1674. this.offset.click.left = obj.left + this.margins.left;
  1675. }
  1676. if ("right" in obj) {
  1677. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1678. }
  1679. if ("top" in obj) {
  1680. this.offset.click.top = obj.top + this.margins.top;
  1681. }
  1682. if ("bottom" in obj) {
  1683. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1684. }
  1685. },
  1686. _isRootNode: function( element ) {
  1687. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  1688. },
  1689. _getParentOffset: function() {
  1690. //Get the offsetParent and cache its position
  1691. var po = this.offsetParent.offset(),
  1692. document = this.document[ 0 ];
  1693. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1694. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1695. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1696. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1697. if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1698. po.left += this.scrollParent.scrollLeft();
  1699. po.top += this.scrollParent.scrollTop();
  1700. }
  1701. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  1702. po = { top: 0, left: 0 };
  1703. }
  1704. return {
  1705. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
  1706. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
  1707. };
  1708. },
  1709. _getRelativeOffset: function() {
  1710. if ( this.cssPosition !== "relative" ) {
  1711. return { top: 0, left: 0 };
  1712. }
  1713. var p = this.element.position(),
  1714. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  1715. return {
  1716. top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  1717. left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  1718. };
  1719. },
  1720. _cacheMargins: function() {
  1721. this.margins = {
  1722. left: (parseInt(this.element.css("marginLeft"), 10) || 0),
  1723. top: (parseInt(this.element.css("marginTop"), 10) || 0),
  1724. right: (parseInt(this.element.css("marginRight"), 10) || 0),
  1725. bottom: (parseInt(this.element.css("marginBottom"), 10) || 0)
  1726. };
  1727. },
  1728. _cacheHelperProportions: function() {
  1729. this.helperProportions = {
  1730. width: this.helper.outerWidth(),
  1731. height: this.helper.outerHeight()
  1732. };
  1733. },
  1734. _setContainment: function() {
  1735. var isUserScrollable, c, ce,
  1736. o = this.options,
  1737. document = this.document[ 0 ];
  1738. this.relativeContainer = null;
  1739. if ( !o.containment ) {
  1740. this.containment = null;
  1741. return;
  1742. }
  1743. if ( o.containment === "window" ) {
  1744. this.containment = [
  1745. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1746. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1747. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  1748. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1749. ];
  1750. return;
  1751. }
  1752. if ( o.containment === "document") {
  1753. this.containment = [
  1754. 0,
  1755. 0,
  1756. $( document ).width() - this.helperProportions.width - this.margins.left,
  1757. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1758. ];
  1759. return;
  1760. }
  1761. if ( o.containment.constructor === Array ) {
  1762. this.containment = o.containment;
  1763. return;
  1764. }
  1765. if ( o.containment === "parent" ) {
  1766. o.containment = this.helper[ 0 ].parentNode;
  1767. }
  1768. c = $( o.containment );
  1769. ce = c[ 0 ];
  1770. if ( !ce ) {
  1771. return;
  1772. }
  1773. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  1774. this.containment = [
  1775. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  1776. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  1777. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  1778. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  1779. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  1780. this.helperProportions.width -
  1781. this.margins.left -
  1782. this.margins.right,
  1783. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  1784. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  1785. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  1786. this.helperProportions.height -
  1787. this.margins.top -
  1788. this.margins.bottom
  1789. ];
  1790. this.relativeContainer = c;
  1791. },
  1792. _convertPositionTo: function(d, pos) {
  1793. if (!pos) {
  1794. pos = this.position;
  1795. }
  1796. var mod = d === "absolute" ? 1 : -1,
  1797. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  1798. return {
  1799. top: (
  1800. pos.top + // The absolute mouse position
  1801. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1802. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1803. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
  1804. ),
  1805. left: (
  1806. pos.left + // The absolute mouse position
  1807. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1808. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1809. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod)
  1810. )
  1811. };
  1812. },
  1813. _generatePosition: function( event, constrainPosition ) {
  1814. var containment, co, top, left,
  1815. o = this.options,
  1816. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  1817. pageX = event.pageX,
  1818. pageY = event.pageY;
  1819. // Cache the scroll
  1820. if ( !scrollIsRootNode || !this.offset.scroll ) {
  1821. this.offset.scroll = {
  1822. top: this.scrollParent.scrollTop(),
  1823. left: this.scrollParent.scrollLeft()
  1824. };
  1825. }
  1826. /*
  1827. * - Position constraining -
  1828. * Constrain the position to a mix of grid, containment.
  1829. */
  1830. // If we are not dragging yet, we won't check for options
  1831. if ( constrainPosition ) {
  1832. if ( this.containment ) {
  1833. if ( this.relativeContainer ){
  1834. co = this.relativeContainer.offset();
  1835. containment = [
  1836. this.containment[ 0 ] + co.left,
  1837. this.containment[ 1 ] + co.top,
  1838. this.containment[ 2 ] + co.left,
  1839. this.containment[ 3 ] + co.top
  1840. ];
  1841. } else {
  1842. containment = this.containment;
  1843. }
  1844. if (event.pageX - this.offset.click.left < containment[0]) {
  1845. pageX = containment[0] + this.offset.click.left;
  1846. }
  1847. if (event.pageY - this.offset.click.top < containment[1]) {
  1848. pageY = containment[1] + this.offset.click.top;
  1849. }
  1850. if (event.pageX - this.offset.click.left > containment[2]) {
  1851. pageX = containment[2] + this.offset.click.left;
  1852. }
  1853. if (event.pageY - this.offset.click.top > containment[3]) {
  1854. pageY = containment[3] + this.offset.click.top;
  1855. }
  1856. }
  1857. if (o.grid) {
  1858. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1859. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1860. 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;
  1861. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1862. 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;
  1863. }
  1864. if ( o.axis === "y" ) {
  1865. pageX = this.originalPageX;
  1866. }
  1867. if ( o.axis === "x" ) {
  1868. pageY = this.originalPageY;
  1869. }
  1870. }
  1871. return {
  1872. top: (
  1873. pageY - // The absolute mouse position
  1874. this.offset.click.top - // Click offset (relative to the element)
  1875. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1876. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1877. ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  1878. ),
  1879. left: (
  1880. pageX - // The absolute mouse position
  1881. this.offset.click.left - // Click offset (relative to the element)
  1882. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1883. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1884. ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  1885. )
  1886. };
  1887. },
  1888. _clear: function() {
  1889. this.helper.removeClass("ui-draggable-dragging");
  1890. if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1891. this.helper.remove();
  1892. }
  1893. this.helper = null;
  1894. this.cancelHelperRemoval = false;
  1895. if ( this.destroyOnClear ) {
  1896. this.destroy();
  1897. }
  1898. },
  1899. _normalizeRightBottom: function() {
  1900. if ( this.options.axis !== "y" && this.helper.css( "right" ) !== "auto" ) {
  1901. this.helper.width( this.helper.width() );
  1902. this.helper.css( "right", "auto" );
  1903. }
  1904. if ( this.options.axis !== "x" && this.helper.css( "bottom" ) !== "auto" ) {
  1905. this.helper.height( this.helper.height() );
  1906. this.helper.css( "bottom", "auto" );
  1907. }
  1908. },
  1909. // From now on bulk stuff - mainly helpers
  1910. _trigger: function( type, event, ui ) {
  1911. ui = ui || this._uiHash();
  1912. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  1913. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  1914. if ( /^(drag|start|stop)/.test( type ) ) {
  1915. this.positionAbs = this._convertPositionTo( "absolute" );
  1916. ui.offset = this.positionAbs;
  1917. }
  1918. return $.Widget.prototype._trigger.call( this, type, event, ui );
  1919. },
  1920. plugins: {},
  1921. _uiHash: function() {
  1922. return {
  1923. helper: this.helper,
  1924. position: this.position,
  1925. originalPosition: this.originalPosition,
  1926. offset: this.positionAbs
  1927. };
  1928. }
  1929. });
  1930. $.ui.plugin.add( "draggable", "connectToSortable", {
  1931. start: function( event, ui, draggable ) {
  1932. var uiSortable = $.extend( {}, ui, {
  1933. item: draggable.element
  1934. });
  1935. draggable.sortables = [];
  1936. $( draggable.options.connectToSortable ).each(function() {
  1937. var sortable = $( this ).sortable( "instance" );
  1938. if ( sortable && !sortable.options.disabled ) {
  1939. draggable.sortables.push( sortable );
  1940. // refreshPositions is called at drag start to refresh the containerCache
  1941. // which is used in drag. This ensures it's initialized and synchronized
  1942. // with any changes that might have happened on the page since initialization.
  1943. sortable.refreshPositions();
  1944. sortable._trigger("activate", event, uiSortable);
  1945. }
  1946. });
  1947. },
  1948. stop: function( event, ui, draggable ) {
  1949. var uiSortable = $.extend( {}, ui, {
  1950. item: draggable.element
  1951. });
  1952. draggable.cancelHelperRemoval = false;
  1953. $.each( draggable.sortables, function() {
  1954. var sortable = this;
  1955. if ( sortable.isOver ) {
  1956. sortable.isOver = 0;
  1957. // Allow this sortable to handle removing the helper
  1958. draggable.cancelHelperRemoval = true;
  1959. sortable.cancelHelperRemoval = false;
  1960. // Use _storedCSS To restore properties in the sortable,
  1961. // as this also handles revert (#9675) since the draggable
  1962. // may have modified them in unexpected ways (#8809)
  1963. sortable._storedCSS = {
  1964. position: sortable.placeholder.css( "position" ),
  1965. top: sortable.placeholder.css( "top" ),
  1966. left: sortable.placeholder.css( "left" )
  1967. };
  1968. sortable._mouseStop(event);
  1969. // Once drag has ended, the sortable should return to using
  1970. // its original helper, not the shared helper from draggable
  1971. sortable.options.helper = sortable.options._helper;
  1972. } else {
  1973. // Prevent this Sortable from removing the helper.
  1974. // However, don't set the draggable to remove the helper
  1975. // either as another connected Sortable may yet handle the removal.
  1976. sortable.cancelHelperRemoval = true;
  1977. sortable._trigger( "deactivate", event, uiSortable );
  1978. }
  1979. });
  1980. },
  1981. drag: function( event, ui, draggable ) {
  1982. $.each( draggable.sortables, function() {
  1983. var innermostIntersecting = false,
  1984. sortable = this;
  1985. // Copy over variables that sortable's _intersectsWith uses
  1986. sortable.positionAbs = draggable.positionAbs;
  1987. sortable.helperProportions = draggable.helperProportions;
  1988. sortable.offset.click = draggable.offset.click;
  1989. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  1990. innermostIntersecting = true;
  1991. $.each( draggable.sortables, function() {
  1992. // Copy over variables that sortable's _intersectsWith uses
  1993. this.positionAbs = draggable.positionAbs;
  1994. this.helperProportions = draggable.helperProportions;
  1995. this.offset.click = draggable.offset.click;
  1996. if ( this !== sortable &&
  1997. this._intersectsWith( this.containerCache ) &&
  1998. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  1999. innermostIntersecting = false;
  2000. }
  2001. return innermostIntersecting;
  2002. });
  2003. }
  2004. if ( innermostIntersecting ) {
  2005. // If it intersects, we use a little isOver variable and set it once,
  2006. // so that the move-in stuff gets fired only once.
  2007. if ( !sortable.isOver ) {
  2008. sortable.isOver = 1;
  2009. sortable.currentItem = ui.helper
  2010. .appendTo( sortable.element )
  2011. .data( "ui-sortable-item", true );
  2012. // Store helper option to later restore it
  2013. sortable.options._helper = sortable.options.helper;
  2014. sortable.options.helper = function() {
  2015. return ui.helper[ 0 ];
  2016. };
  2017. // Fire the start events of the sortable with our passed browser event,
  2018. // and our own helper (so it doesn't create a new one)
  2019. event.target = sortable.currentItem[ 0 ];
  2020. sortable._mouseCapture( event, true );
  2021. sortable._mouseStart( event, true, true );
  2022. // Because the browser event is way off the new appended portlet,
  2023. // modify necessary variables to reflect the changes
  2024. sortable.offset.click.top = draggable.offset.click.top;
  2025. sortable.offset.click.left = draggable.offset.click.left;
  2026. sortable.offset.parent.left -= draggable.offset.parent.left -
  2027. sortable.offset.parent.left;
  2028. sortable.offset.parent.top -= draggable.offset.parent.top -
  2029. sortable.offset.parent.top;
  2030. draggable._trigger( "toSortable", event );
  2031. // Inform draggable that the helper is in a valid drop zone,
  2032. // used solely in the revert option to handle "valid/invalid".
  2033. draggable.dropped = sortable.element;
  2034. // Need to refreshPositions of all sortables in the case that
  2035. // adding to one sortable changes the location of the other sortables (#9675)
  2036. $.each( draggable.sortables, function() {
  2037. this.refreshPositions();
  2038. });
  2039. // hack so receive/update callbacks work (mostly)
  2040. draggable.currentItem = draggable.element;
  2041. sortable.fromOutside = draggable;
  2042. }
  2043. if ( sortable.currentItem ) {
  2044. sortable._mouseDrag( event );
  2045. // Copy the sortable's position because the draggable's can potentially reflect
  2046. // a relative position, while sortable is always absolute, which the dragged
  2047. // element has now become. (#8809)
  2048. ui.position = sortable.position;
  2049. }
  2050. } else {
  2051. // If it doesn't intersect with the sortable, and it intersected before,
  2052. // we fake the drag stop of the sortable, but make sure it doesn't remove
  2053. // the helper by using cancelHelperRemoval.
  2054. if ( sortable.isOver ) {
  2055. sortable.isOver = 0;
  2056. sortable.cancelHelperRemoval = true;
  2057. // Calling sortable's mouseStop would trigger a revert,
  2058. // so revert must be temporarily false until after mouseStop is called.
  2059. sortable.options._revert = sortable.options.revert;
  2060. sortable.options.revert = false;
  2061. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  2062. sortable._mouseStop( event, true );
  2063. // restore sortable behaviors that were modfied
  2064. // when the draggable entered the sortable area (#9481)
  2065. sortable.options.revert = sortable.options._revert;
  2066. sortable.options.helper = sortable.options._helper;
  2067. if ( sortable.placeholder ) {
  2068. sortable.placeholder.remove();
  2069. }
  2070. // Recalculate the draggable's offset considering the sortable
  2071. // may have modified them in unexpected ways (#8809)
  2072. draggable._refreshOffsets( event );
  2073. ui.position = draggable._generatePosition( event, true );
  2074. draggable._trigger( "fromSortable", event );
  2075. // Inform draggable that the helper is no longer in a valid drop zone
  2076. draggable.dropped = false;
  2077. // Need to refreshPositions of all sortables just in case removing
  2078. // from one sortable changes the location of other sortables (#9675)
  2079. $.each( draggable.sortables, function() {
  2080. this.refreshPositions();
  2081. });
  2082. }
  2083. }
  2084. });
  2085. }
  2086. });
  2087. $.ui.plugin.add("draggable", "cursor", {
  2088. start: function( event, ui, instance ) {
  2089. var t = $( "body" ),
  2090. o = instance.options;
  2091. if (t.css("cursor")) {
  2092. o._cursor = t.css("cursor");
  2093. }
  2094. t.css("cursor", o.cursor);
  2095. },
  2096. stop: function( event, ui, instance ) {
  2097. var o = instance.options;
  2098. if (o._cursor) {
  2099. $("body").css("cursor", o._cursor);
  2100. }
  2101. }
  2102. });
  2103. $.ui.plugin.add("draggable", "opacity", {
  2104. start: function( event, ui, instance ) {
  2105. var t = $( ui.helper ),
  2106. o = instance.options;
  2107. if (t.css("opacity")) {
  2108. o._opacity = t.css("opacity");
  2109. }
  2110. t.css("opacity", o.opacity);
  2111. },
  2112. stop: function( event, ui, instance ) {
  2113. var o = instance.options;
  2114. if (o._opacity) {
  2115. $(ui.helper).css("opacity", o._opacity);
  2116. }
  2117. }
  2118. });
  2119. $.ui.plugin.add("draggable", "scroll", {
  2120. start: function( event, ui, i ) {
  2121. if ( !i.scrollParentNotHidden ) {
  2122. i.scrollParentNotHidden = i.helper.scrollParent( false );
  2123. }
  2124. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  2125. i.overflowOffset = i.scrollParentNotHidden.offset();
  2126. }
  2127. },
  2128. drag: function( event, ui, i ) {
  2129. var o = i.options,
  2130. scrolled = false,
  2131. scrollParent = i.scrollParentNotHidden[ 0 ],
  2132. document = i.document[ 0 ];
  2133. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  2134. if ( !o.axis || o.axis !== "x" ) {
  2135. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) {
  2136. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  2137. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  2138. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  2139. }
  2140. }
  2141. if ( !o.axis || o.axis !== "y" ) {
  2142. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) {
  2143. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  2144. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  2145. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  2146. }
  2147. }
  2148. } else {
  2149. if (!o.axis || o.axis !== "x") {
  2150. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  2151. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  2152. } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  2153. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  2154. }
  2155. }
  2156. if (!o.axis || o.axis !== "y") {
  2157. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  2158. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  2159. } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  2160. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  2161. }
  2162. }
  2163. }
  2164. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  2165. $.ui.ddmanager.prepareOffsets(i, event);
  2166. }
  2167. }
  2168. });
  2169. $.ui.plugin.add("draggable", "snap", {
  2170. start: function( event, ui, i ) {
  2171. var o = i.options;
  2172. i.snapElements = [];
  2173. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  2174. var $t = $(this),
  2175. $o = $t.offset();
  2176. if (this !== i.element[0]) {
  2177. i.snapElements.push({
  2178. item: this,
  2179. width: $t.outerWidth(), height: $t.outerHeight(),
  2180. top: $o.top, left: $o.left
  2181. });
  2182. }
  2183. });
  2184. },
  2185. drag: function( event, ui, inst ) {
  2186. var ts, bs, ls, rs, l, r, t, b, i, first,
  2187. o = inst.options,
  2188. d = o.snapTolerance,
  2189. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  2190. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  2191. for (i = inst.snapElements.length - 1; i >= 0; i--){
  2192. l = inst.snapElements[i].left - inst.margins.left;
  2193. r = l + inst.snapElements[i].width;
  2194. t = inst.snapElements[i].top - inst.margins.top;
  2195. b = t + inst.snapElements[i].height;
  2196. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  2197. if (inst.snapElements[i].snapping) {
  2198. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2199. }
  2200. inst.snapElements[i].snapping = false;
  2201. continue;
  2202. }
  2203. if (o.snapMode !== "inner") {
  2204. ts = Math.abs(t - y2) <= d;
  2205. bs = Math.abs(b - y1) <= d;
  2206. ls = Math.abs(l - x2) <= d;
  2207. rs = Math.abs(r - x1) <= d;
  2208. if (ts) {
  2209. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
  2210. }
  2211. if (bs) {
  2212. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
  2213. }
  2214. if (ls) {
  2215. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
  2216. }
  2217. if (rs) {
  2218. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
  2219. }
  2220. }
  2221. first = (ts || bs || ls || rs);
  2222. if (o.snapMode !== "outer") {
  2223. ts = Math.abs(t - y1) <= d;
  2224. bs = Math.abs(b - y2) <= d;
  2225. ls = Math.abs(l - x1) <= d;
  2226. rs = Math.abs(r - x2) <= d;
  2227. if (ts) {
  2228. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
  2229. }
  2230. if (bs) {
  2231. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
  2232. }
  2233. if (ls) {
  2234. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
  2235. }
  2236. if (rs) {
  2237. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
  2238. }
  2239. }
  2240. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  2241. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2242. }
  2243. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  2244. }
  2245. }
  2246. });
  2247. $.ui.plugin.add("draggable", "stack", {
  2248. start: function( event, ui, instance ) {
  2249. var min,
  2250. o = instance.options,
  2251. group = $.makeArray($(o.stack)).sort(function(a, b) {
  2252. return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
  2253. });
  2254. if (!group.length) { return; }
  2255. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  2256. $(group).each(function(i) {
  2257. $(this).css("zIndex", min + i);
  2258. });
  2259. this.css("zIndex", (min + group.length));
  2260. }
  2261. });
  2262. $.ui.plugin.add("draggable", "zIndex", {
  2263. start: function( event, ui, instance ) {
  2264. var t = $( ui.helper ),
  2265. o = instance.options;
  2266. if (t.css("zIndex")) {
  2267. o._zIndex = t.css("zIndex");
  2268. }
  2269. t.css("zIndex", o.zIndex);
  2270. },
  2271. stop: function( event, ui, instance ) {
  2272. var o = instance.options;
  2273. if (o._zIndex) {
  2274. $(ui.helper).css("zIndex", o._zIndex);
  2275. }
  2276. }
  2277. });
  2278. var draggable = $.ui.draggable;
  2279. /*!
  2280. * jQuery UI Droppable 1.11.3
  2281. * http://jqueryui.com
  2282. *
  2283. * Copyright jQuery Foundation and other contributors
  2284. * Released under the MIT license.
  2285. * http://jquery.org/license
  2286. *
  2287. * http://api.jqueryui.com/droppable/
  2288. */
  2289. $.widget( "ui.droppable", {
  2290. version: "1.11.3",
  2291. widgetEventPrefix: "drop",
  2292. options: {
  2293. accept: "*",
  2294. activeClass: false,
  2295. addClasses: true,
  2296. greedy: false,
  2297. hoverClass: false,
  2298. scope: "default",
  2299. tolerance: "intersect",
  2300. // callbacks
  2301. activate: null,
  2302. deactivate: null,
  2303. drop: null,
  2304. out: null,
  2305. over: null
  2306. },
  2307. _create: function() {
  2308. var proportions,
  2309. o = this.options,
  2310. accept = o.accept;
  2311. this.isover = false;
  2312. this.isout = true;
  2313. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  2314. return d.is( accept );
  2315. };
  2316. this.proportions = function( /* valueToWrite */ ) {
  2317. if ( arguments.length ) {
  2318. // Store the droppable's proportions
  2319. proportions = arguments[ 0 ];
  2320. } else {
  2321. // Retrieve or derive the droppable's proportions
  2322. return proportions ?
  2323. proportions :
  2324. proportions = {
  2325. width: this.element[ 0 ].offsetWidth,
  2326. height: this.element[ 0 ].offsetHeight
  2327. };
  2328. }
  2329. };
  2330. this._addToManager( o.scope );
  2331. o.addClasses && this.element.addClass( "ui-droppable" );
  2332. },
  2333. _addToManager: function( scope ) {
  2334. // Add the reference and positions to the manager
  2335. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  2336. $.ui.ddmanager.droppables[ scope ].push( this );
  2337. },
  2338. _splice: function( drop ) {
  2339. var i = 0;
  2340. for ( ; i < drop.length; i++ ) {
  2341. if ( drop[ i ] === this ) {
  2342. drop.splice( i, 1 );
  2343. }
  2344. }
  2345. },
  2346. _destroy: function() {
  2347. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2348. this._splice( drop );
  2349. this.element.removeClass( "ui-droppable ui-droppable-disabled" );
  2350. },
  2351. _setOption: function( key, value ) {
  2352. if ( key === "accept" ) {
  2353. this.accept = $.isFunction( value ) ? value : function( d ) {
  2354. return d.is( value );
  2355. };
  2356. } else if ( key === "scope" ) {
  2357. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2358. this._splice( drop );
  2359. this._addToManager( value );
  2360. }
  2361. this._super( key, value );
  2362. },
  2363. _activate: function( event ) {
  2364. var draggable = $.ui.ddmanager.current;
  2365. if ( this.options.activeClass ) {
  2366. this.element.addClass( this.options.activeClass );
  2367. }
  2368. if ( draggable ){
  2369. this._trigger( "activate", event, this.ui( draggable ) );
  2370. }
  2371. },
  2372. _deactivate: function( event ) {
  2373. var draggable = $.ui.ddmanager.current;
  2374. if ( this.options.activeClass ) {
  2375. this.element.removeClass( this.options.activeClass );
  2376. }
  2377. if ( draggable ){
  2378. this._trigger( "deactivate", event, this.ui( draggable ) );
  2379. }
  2380. },
  2381. _over: function( event ) {
  2382. var draggable = $.ui.ddmanager.current;
  2383. // Bail if draggable and droppable are same element
  2384. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2385. return;
  2386. }
  2387. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2388. if ( this.options.hoverClass ) {
  2389. this.element.addClass( this.options.hoverClass );
  2390. }
  2391. this._trigger( "over", event, this.ui( draggable ) );
  2392. }
  2393. },
  2394. _out: function( event ) {
  2395. var draggable = $.ui.ddmanager.current;
  2396. // Bail if draggable and droppable are same element
  2397. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2398. return;
  2399. }
  2400. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2401. if ( this.options.hoverClass ) {
  2402. this.element.removeClass( this.options.hoverClass );
  2403. }
  2404. this._trigger( "out", event, this.ui( draggable ) );
  2405. }
  2406. },
  2407. _drop: function( event, custom ) {
  2408. var draggable = custom || $.ui.ddmanager.current,
  2409. childrenIntersection = false;
  2410. // Bail if draggable and droppable are same element
  2411. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2412. return false;
  2413. }
  2414. this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
  2415. var inst = $( this ).droppable( "instance" );
  2416. if (
  2417. inst.options.greedy &&
  2418. !inst.options.disabled &&
  2419. inst.options.scope === draggable.options.scope &&
  2420. inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
  2421. $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
  2422. ) { childrenIntersection = true; return false; }
  2423. });
  2424. if ( childrenIntersection ) {
  2425. return false;
  2426. }
  2427. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2428. if ( this.options.activeClass ) {
  2429. this.element.removeClass( this.options.activeClass );
  2430. }
  2431. if ( this.options.hoverClass ) {
  2432. this.element.removeClass( this.options.hoverClass );
  2433. }
  2434. this._trigger( "drop", event, this.ui( draggable ) );
  2435. return this.element;
  2436. }
  2437. return false;
  2438. },
  2439. ui: function( c ) {
  2440. return {
  2441. draggable: ( c.currentItem || c.element ),
  2442. helper: c.helper,
  2443. position: c.position,
  2444. offset: c.positionAbs
  2445. };
  2446. }
  2447. });
  2448. $.ui.intersect = (function() {
  2449. function isOverAxis( x, reference, size ) {
  2450. return ( x >= reference ) && ( x < ( reference + size ) );
  2451. }
  2452. return function( draggable, droppable, toleranceMode, event ) {
  2453. if ( !droppable.offset ) {
  2454. return false;
  2455. }
  2456. var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left,
  2457. y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top,
  2458. x2 = x1 + draggable.helperProportions.width,
  2459. y2 = y1 + draggable.helperProportions.height,
  2460. l = droppable.offset.left,
  2461. t = droppable.offset.top,
  2462. r = l + droppable.proportions().width,
  2463. b = t + droppable.proportions().height;
  2464. switch ( toleranceMode ) {
  2465. case "fit":
  2466. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  2467. case "intersect":
  2468. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  2469. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  2470. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  2471. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  2472. case "pointer":
  2473. return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
  2474. case "touch":
  2475. return (
  2476. ( y1 >= t && y1 <= b ) || // Top edge touching
  2477. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  2478. ( y1 < t && y2 > b ) // Surrounded vertically
  2479. ) && (
  2480. ( x1 >= l && x1 <= r ) || // Left edge touching
  2481. ( x2 >= l && x2 <= r ) || // Right edge touching
  2482. ( x1 < l && x2 > r ) // Surrounded horizontally
  2483. );
  2484. default:
  2485. return false;
  2486. }
  2487. };
  2488. })();
  2489. /*
  2490. This manager tracks offsets of draggables and droppables
  2491. */
  2492. $.ui.ddmanager = {
  2493. current: null,
  2494. droppables: { "default": [] },
  2495. prepareOffsets: function( t, event ) {
  2496. var i, j,
  2497. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  2498. type = event ? event.type : null, // workaround for #2317
  2499. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  2500. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  2501. // No disabled and non-accepted
  2502. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
  2503. continue;
  2504. }
  2505. // Filter out elements in the current dragged item
  2506. for ( j = 0; j < list.length; j++ ) {
  2507. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  2508. m[ i ].proportions().height = 0;
  2509. continue droppablesLoop;
  2510. }
  2511. }
  2512. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  2513. if ( !m[ i ].visible ) {
  2514. continue;
  2515. }
  2516. // Activate the droppable if used directly from draggables
  2517. if ( type === "mousedown" ) {
  2518. m[ i ]._activate.call( m[ i ], event );
  2519. }
  2520. m[ i ].offset = m[ i ].element.offset();
  2521. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  2522. }
  2523. },
  2524. drop: function( draggable, event ) {
  2525. var dropped = false;
  2526. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2527. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  2528. if ( !this.options ) {
  2529. return;
  2530. }
  2531. if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
  2532. dropped = this._drop.call( this, event ) || dropped;
  2533. }
  2534. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2535. this.isout = true;
  2536. this.isover = false;
  2537. this._deactivate.call( this, event );
  2538. }
  2539. });
  2540. return dropped;
  2541. },
  2542. dragStart: function( draggable, event ) {
  2543. // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  2544. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  2545. if ( !draggable.options.refreshPositions ) {
  2546. $.ui.ddmanager.prepareOffsets( draggable, event );
  2547. }
  2548. });
  2549. },
  2550. drag: function( draggable, event ) {
  2551. // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  2552. if ( draggable.options.refreshPositions ) {
  2553. $.ui.ddmanager.prepareOffsets( draggable, event );
  2554. }
  2555. // Run through all droppables and check their positions based on specific tolerance options
  2556. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  2557. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  2558. return;
  2559. }
  2560. var parentInstance, scope, parent,
  2561. intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
  2562. c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
  2563. if ( !c ) {
  2564. return;
  2565. }
  2566. if ( this.options.greedy ) {
  2567. // find droppable parents with same scope
  2568. scope = this.options.scope;
  2569. parent = this.element.parents( ":data(ui-droppable)" ).filter(function() {
  2570. return $( this ).droppable( "instance" ).options.scope === scope;
  2571. });
  2572. if ( parent.length ) {
  2573. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  2574. parentInstance.greedyChild = ( c === "isover" );
  2575. }
  2576. }
  2577. // we just moved into a greedy child
  2578. if ( parentInstance && c === "isover" ) {
  2579. parentInstance.isover = false;
  2580. parentInstance.isout = true;
  2581. parentInstance._out.call( parentInstance, event );
  2582. }
  2583. this[ c ] = true;
  2584. this[c === "isout" ? "isover" : "isout"] = false;
  2585. this[c === "isover" ? "_over" : "_out"].call( this, event );
  2586. // we just moved out of a greedy child
  2587. if ( parentInstance && c === "isout" ) {
  2588. parentInstance.isout = false;
  2589. parentInstance.isover = true;
  2590. parentInstance._over.call( parentInstance, event );
  2591. }
  2592. });
  2593. },
  2594. dragStop: function( draggable, event ) {
  2595. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  2596. // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  2597. if ( !draggable.options.refreshPositions ) {
  2598. $.ui.ddmanager.prepareOffsets( draggable, event );
  2599. }
  2600. }
  2601. };
  2602. var droppable = $.ui.droppable;
  2603. /*!
  2604. * jQuery UI Resizable 1.11.3
  2605. * http://jqueryui.com
  2606. *
  2607. * Copyright jQuery Foundation and other contributors
  2608. * Released under the MIT license.
  2609. * http://jquery.org/license
  2610. *
  2611. * http://api.jqueryui.com/resizable/
  2612. */
  2613. $.widget("ui.resizable", $.ui.mouse, {
  2614. version: "1.11.3",
  2615. widgetEventPrefix: "resize",
  2616. options: {
  2617. alsoResize: false,
  2618. animate: false,
  2619. animateDuration: "slow",
  2620. animateEasing: "swing",
  2621. aspectRatio: false,
  2622. autoHide: false,
  2623. containment: false,
  2624. ghost: false,
  2625. grid: false,
  2626. handles: "e,s,se",
  2627. helper: false,
  2628. maxHeight: null,
  2629. maxWidth: null,
  2630. minHeight: 10,
  2631. minWidth: 10,
  2632. // See #7960
  2633. zIndex: 90,
  2634. // callbacks
  2635. resize: null,
  2636. start: null,
  2637. stop: null
  2638. },
  2639. _num: function( value ) {
  2640. return parseInt( value, 10 ) || 0;
  2641. },
  2642. _isNumber: function( value ) {
  2643. return !isNaN( parseInt( value, 10 ) );
  2644. },
  2645. _hasScroll: function( el, a ) {
  2646. if ( $( el ).css( "overflow" ) === "hidden") {
  2647. return false;
  2648. }
  2649. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  2650. has = false;
  2651. if ( el[ scroll ] > 0 ) {
  2652. return true;
  2653. }
  2654. // TODO: determine which cases actually cause this to happen
  2655. // if the element doesn't have the scroll set, see if it's possible to
  2656. // set the scroll
  2657. el[ scroll ] = 1;
  2658. has = ( el[ scroll ] > 0 );
  2659. el[ scroll ] = 0;
  2660. return has;
  2661. },
  2662. _create: function() {
  2663. var n, i, handle, axis, hname,
  2664. that = this,
  2665. o = this.options;
  2666. this.element.addClass("ui-resizable");
  2667. $.extend(this, {
  2668. _aspectRatio: !!(o.aspectRatio),
  2669. aspectRatio: o.aspectRatio,
  2670. originalElement: this.element,
  2671. _proportionallyResizeElements: [],
  2672. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  2673. });
  2674. // Wrap the element if it cannot hold child nodes
  2675. if (this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)) {
  2676. this.element.wrap(
  2677. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  2678. position: this.element.css("position"),
  2679. width: this.element.outerWidth(),
  2680. height: this.element.outerHeight(),
  2681. top: this.element.css("top"),
  2682. left: this.element.css("left")
  2683. })
  2684. );
  2685. this.element = this.element.parent().data(
  2686. "ui-resizable", this.element.resizable( "instance" )
  2687. );
  2688. this.elementIsWrapper = true;
  2689. this.element.css({
  2690. marginLeft: this.originalElement.css("marginLeft"),
  2691. marginTop: this.originalElement.css("marginTop"),
  2692. marginRight: this.originalElement.css("marginRight"),
  2693. marginBottom: this.originalElement.css("marginBottom")
  2694. });
  2695. this.originalElement.css({
  2696. marginLeft: 0,
  2697. marginTop: 0,
  2698. marginRight: 0,
  2699. marginBottom: 0
  2700. });
  2701. // support: Safari
  2702. // Prevent Safari textarea resize
  2703. this.originalResizeStyle = this.originalElement.css("resize");
  2704. this.originalElement.css("resize", "none");
  2705. this._proportionallyResizeElements.push( this.originalElement.css({
  2706. position: "static",
  2707. zoom: 1,
  2708. display: "block"
  2709. }) );
  2710. // support: IE9
  2711. // avoid IE jump (hard set the margin)
  2712. this.originalElement.css({ margin: this.originalElement.css("margin") });
  2713. this._proportionallyResize();
  2714. }
  2715. this.handles = o.handles ||
  2716. ( !$(".ui-resizable-handle", this.element).length ?
  2717. "e,s,se" : {
  2718. n: ".ui-resizable-n",
  2719. e: ".ui-resizable-e",
  2720. s: ".ui-resizable-s",
  2721. w: ".ui-resizable-w",
  2722. se: ".ui-resizable-se",
  2723. sw: ".ui-resizable-sw",
  2724. ne: ".ui-resizable-ne",
  2725. nw: ".ui-resizable-nw"
  2726. } );
  2727. if (this.handles.constructor === String) {
  2728. if ( this.handles === "all") {
  2729. this.handles = "n,e,s,w,se,sw,ne,nw";
  2730. }
  2731. n = this.handles.split(",");
  2732. this.handles = {};
  2733. for (i = 0; i < n.length; i++) {
  2734. handle = $.trim(n[i]);
  2735. hname = "ui-resizable-" + handle;
  2736. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  2737. axis.css({ zIndex: o.zIndex });
  2738. // TODO : What's going on here?
  2739. if ("se" === handle) {
  2740. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  2741. }
  2742. this.handles[handle] = ".ui-resizable-" + handle;
  2743. this.element.append(axis);
  2744. }
  2745. }
  2746. this._renderAxis = function(target) {
  2747. var i, axis, padPos, padWrapper;
  2748. target = target || this.element;
  2749. for (i in this.handles) {
  2750. if (this.handles[i].constructor === String) {
  2751. this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
  2752. }
  2753. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)) {
  2754. axis = $(this.handles[i], this.element);
  2755. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2756. padPos = [ "padding",
  2757. /ne|nw|n/.test(i) ? "Top" :
  2758. /se|sw|s/.test(i) ? "Bottom" :
  2759. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2760. target.css(padPos, padWrapper);
  2761. this._proportionallyResize();
  2762. }
  2763. // TODO: What's that good for? There's not anything to be executed left
  2764. if (!$(this.handles[i]).length) {
  2765. continue;
  2766. }
  2767. }
  2768. };
  2769. // TODO: make renderAxis a prototype function
  2770. this._renderAxis(this.element);
  2771. this._handles = $(".ui-resizable-handle", this.element)
  2772. .disableSelection();
  2773. this._handles.mouseover(function() {
  2774. if (!that.resizing) {
  2775. if (this.className) {
  2776. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2777. }
  2778. that.axis = axis && axis[1] ? axis[1] : "se";
  2779. }
  2780. });
  2781. if (o.autoHide) {
  2782. this._handles.hide();
  2783. $(this.element)
  2784. .addClass("ui-resizable-autohide")
  2785. .mouseenter(function() {
  2786. if (o.disabled) {
  2787. return;
  2788. }
  2789. $(this).removeClass("ui-resizable-autohide");
  2790. that._handles.show();
  2791. })
  2792. .mouseleave(function() {
  2793. if (o.disabled) {
  2794. return;
  2795. }
  2796. if (!that.resizing) {
  2797. $(this).addClass("ui-resizable-autohide");
  2798. that._handles.hide();
  2799. }
  2800. });
  2801. }
  2802. this._mouseInit();
  2803. },
  2804. _destroy: function() {
  2805. this._mouseDestroy();
  2806. var wrapper,
  2807. _destroy = function(exp) {
  2808. $(exp)
  2809. .removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2810. .removeData("resizable")
  2811. .removeData("ui-resizable")
  2812. .unbind(".resizable")
  2813. .find(".ui-resizable-handle")
  2814. .remove();
  2815. };
  2816. // TODO: Unwrap at same DOM position
  2817. if (this.elementIsWrapper) {
  2818. _destroy(this.element);
  2819. wrapper = this.element;
  2820. this.originalElement.css({
  2821. position: wrapper.css("position"),
  2822. width: wrapper.outerWidth(),
  2823. height: wrapper.outerHeight(),
  2824. top: wrapper.css("top"),
  2825. left: wrapper.css("left")
  2826. }).insertAfter( wrapper );
  2827. wrapper.remove();
  2828. }
  2829. this.originalElement.css("resize", this.originalResizeStyle);
  2830. _destroy(this.originalElement);
  2831. return this;
  2832. },
  2833. _mouseCapture: function(event) {
  2834. var i, handle,
  2835. capture = false;
  2836. for (i in this.handles) {
  2837. handle = $(this.handles[i])[0];
  2838. if (handle === event.target || $.contains(handle, event.target)) {
  2839. capture = true;
  2840. }
  2841. }
  2842. return !this.options.disabled && capture;
  2843. },
  2844. _mouseStart: function(event) {
  2845. var curleft, curtop, cursor,
  2846. o = this.options,
  2847. el = this.element;
  2848. this.resizing = true;
  2849. this._renderProxy();
  2850. curleft = this._num(this.helper.css("left"));
  2851. curtop = this._num(this.helper.css("top"));
  2852. if (o.containment) {
  2853. curleft += $(o.containment).scrollLeft() || 0;
  2854. curtop += $(o.containment).scrollTop() || 0;
  2855. }
  2856. this.offset = this.helper.offset();
  2857. this.position = { left: curleft, top: curtop };
  2858. this.size = this._helper ? {
  2859. width: this.helper.width(),
  2860. height: this.helper.height()
  2861. } : {
  2862. width: el.width(),
  2863. height: el.height()
  2864. };
  2865. this.originalSize = this._helper ? {
  2866. width: el.outerWidth(),
  2867. height: el.outerHeight()
  2868. } : {
  2869. width: el.width(),
  2870. height: el.height()
  2871. };
  2872. this.sizeDiff = {
  2873. width: el.outerWidth() - el.width(),
  2874. height: el.outerHeight() - el.height()
  2875. };
  2876. this.originalPosition = { left: curleft, top: curtop };
  2877. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2878. this.aspectRatio = (typeof o.aspectRatio === "number") ?
  2879. o.aspectRatio :
  2880. ((this.originalSize.width / this.originalSize.height) || 1);
  2881. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2882. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2883. el.addClass("ui-resizable-resizing");
  2884. this._propagate("start", event);
  2885. return true;
  2886. },
  2887. _mouseDrag: function(event) {
  2888. var data, props,
  2889. smp = this.originalMousePosition,
  2890. a = this.axis,
  2891. dx = (event.pageX - smp.left) || 0,
  2892. dy = (event.pageY - smp.top) || 0,
  2893. trigger = this._change[a];
  2894. this._updatePrevProperties();
  2895. if (!trigger) {
  2896. return false;
  2897. }
  2898. data = trigger.apply(this, [ event, dx, dy ]);
  2899. this._updateVirtualBoundaries(event.shiftKey);
  2900. if (this._aspectRatio || event.shiftKey) {
  2901. data = this._updateRatio(data, event);
  2902. }
  2903. data = this._respectSize(data, event);
  2904. this._updateCache(data);
  2905. this._propagate("resize", event);
  2906. props = this._applyChanges();
  2907. if ( !this._helper && this._proportionallyResizeElements.length ) {
  2908. this._proportionallyResize();
  2909. }
  2910. if ( !$.isEmptyObject( props ) ) {
  2911. this._updatePrevProperties();
  2912. this._trigger( "resize", event, this.ui() );
  2913. this._applyChanges();
  2914. }
  2915. return false;
  2916. },
  2917. _mouseStop: function(event) {
  2918. this.resizing = false;
  2919. var pr, ista, soffseth, soffsetw, s, left, top,
  2920. o = this.options, that = this;
  2921. if (this._helper) {
  2922. pr = this._proportionallyResizeElements;
  2923. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2924. soffseth = ista && this._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height;
  2925. soffsetw = ista ? 0 : that.sizeDiff.width;
  2926. s = {
  2927. width: (that.helper.width() - soffsetw),
  2928. height: (that.helper.height() - soffseth)
  2929. };
  2930. left = (parseInt(that.element.css("left"), 10) +
  2931. (that.position.left - that.originalPosition.left)) || null;
  2932. top = (parseInt(that.element.css("top"), 10) +
  2933. (that.position.top - that.originalPosition.top)) || null;
  2934. if (!o.animate) {
  2935. this.element.css($.extend(s, { top: top, left: left }));
  2936. }
  2937. that.helper.height(that.size.height);
  2938. that.helper.width(that.size.width);
  2939. if (this._helper && !o.animate) {
  2940. this._proportionallyResize();
  2941. }
  2942. }
  2943. $("body").css("cursor", "auto");
  2944. this.element.removeClass("ui-resizable-resizing");
  2945. this._propagate("stop", event);
  2946. if (this._helper) {
  2947. this.helper.remove();
  2948. }
  2949. return false;
  2950. },
  2951. _updatePrevProperties: function() {
  2952. this.prevPosition = {
  2953. top: this.position.top,
  2954. left: this.position.left
  2955. };
  2956. this.prevSize = {
  2957. width: this.size.width,
  2958. height: this.size.height
  2959. };
  2960. },
  2961. _applyChanges: function() {
  2962. var props = {};
  2963. if ( this.position.top !== this.prevPosition.top ) {
  2964. props.top = this.position.top + "px";
  2965. }
  2966. if ( this.position.left !== this.prevPosition.left ) {
  2967. props.left = this.position.left + "px";
  2968. }
  2969. if ( this.size.width !== this.prevSize.width ) {
  2970. props.width = this.size.width + "px";
  2971. }
  2972. if ( this.size.height !== this.prevSize.height ) {
  2973. props.height = this.size.height + "px";
  2974. }
  2975. this.helper.css( props );
  2976. return props;
  2977. },
  2978. _updateVirtualBoundaries: function(forceAspectRatio) {
  2979. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2980. o = this.options;
  2981. b = {
  2982. minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
  2983. maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2984. minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
  2985. maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2986. };
  2987. if (this._aspectRatio || forceAspectRatio) {
  2988. pMinWidth = b.minHeight * this.aspectRatio;
  2989. pMinHeight = b.minWidth / this.aspectRatio;
  2990. pMaxWidth = b.maxHeight * this.aspectRatio;
  2991. pMaxHeight = b.maxWidth / this.aspectRatio;
  2992. if (pMinWidth > b.minWidth) {
  2993. b.minWidth = pMinWidth;
  2994. }
  2995. if (pMinHeight > b.minHeight) {
  2996. b.minHeight = pMinHeight;
  2997. }
  2998. if (pMaxWidth < b.maxWidth) {
  2999. b.maxWidth = pMaxWidth;
  3000. }
  3001. if (pMaxHeight < b.maxHeight) {
  3002. b.maxHeight = pMaxHeight;
  3003. }
  3004. }
  3005. this._vBoundaries = b;
  3006. },
  3007. _updateCache: function(data) {
  3008. this.offset = this.helper.offset();
  3009. if (this._isNumber(data.left)) {
  3010. this.position.left = data.left;
  3011. }
  3012. if (this._isNumber(data.top)) {
  3013. this.position.top = data.top;
  3014. }
  3015. if (this._isNumber(data.height)) {
  3016. this.size.height = data.height;
  3017. }
  3018. if (this._isNumber(data.width)) {
  3019. this.size.width = data.width;
  3020. }
  3021. },
  3022. _updateRatio: function( data ) {
  3023. var cpos = this.position,
  3024. csize = this.size,
  3025. a = this.axis;
  3026. if (this._isNumber(data.height)) {
  3027. data.width = (data.height * this.aspectRatio);
  3028. } else if (this._isNumber(data.width)) {
  3029. data.height = (data.width / this.aspectRatio);
  3030. }
  3031. if (a === "sw") {
  3032. data.left = cpos.left + (csize.width - data.width);
  3033. data.top = null;
  3034. }
  3035. if (a === "nw") {
  3036. data.top = cpos.top + (csize.height - data.height);
  3037. data.left = cpos.left + (csize.width - data.width);
  3038. }
  3039. return data;
  3040. },
  3041. _respectSize: function( data ) {
  3042. var o = this._vBoundaries,
  3043. a = this.axis,
  3044. ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width),
  3045. ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  3046. isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width),
  3047. isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  3048. dw = this.originalPosition.left + this.originalSize.width,
  3049. dh = this.position.top + this.size.height,
  3050. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  3051. if (isminw) {
  3052. data.width = o.minWidth;
  3053. }
  3054. if (isminh) {
  3055. data.height = o.minHeight;
  3056. }
  3057. if (ismaxw) {
  3058. data.width = o.maxWidth;
  3059. }
  3060. if (ismaxh) {
  3061. data.height = o.maxHeight;
  3062. }
  3063. if (isminw && cw) {
  3064. data.left = dw - o.minWidth;
  3065. }
  3066. if (ismaxw && cw) {
  3067. data.left = dw - o.maxWidth;
  3068. }
  3069. if (isminh && ch) {
  3070. data.top = dh - o.minHeight;
  3071. }
  3072. if (ismaxh && ch) {
  3073. data.top = dh - o.maxHeight;
  3074. }
  3075. // Fixing jump error on top/left - bug #2330
  3076. if (!data.width && !data.height && !data.left && data.top) {
  3077. data.top = null;
  3078. } else if (!data.width && !data.height && !data.top && data.left) {
  3079. data.left = null;
  3080. }
  3081. return data;
  3082. },
  3083. _getPaddingPlusBorderDimensions: function( element ) {
  3084. var i = 0,
  3085. widths = [],
  3086. borders = [
  3087. element.css( "borderTopWidth" ),
  3088. element.css( "borderRightWidth" ),
  3089. element.css( "borderBottomWidth" ),
  3090. element.css( "borderLeftWidth" )
  3091. ],
  3092. paddings = [
  3093. element.css( "paddingTop" ),
  3094. element.css( "paddingRight" ),
  3095. element.css( "paddingBottom" ),
  3096. element.css( "paddingLeft" )
  3097. ];
  3098. for ( ; i < 4; i++ ) {
  3099. widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 );
  3100. widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 );
  3101. }
  3102. return {
  3103. height: widths[ 0 ] + widths[ 2 ],
  3104. width: widths[ 1 ] + widths[ 3 ]
  3105. };
  3106. },
  3107. _proportionallyResize: function() {
  3108. if (!this._proportionallyResizeElements.length) {
  3109. return;
  3110. }
  3111. var prel,
  3112. i = 0,
  3113. element = this.helper || this.element;
  3114. for ( ; i < this._proportionallyResizeElements.length; i++) {
  3115. prel = this._proportionallyResizeElements[i];
  3116. // TODO: Seems like a bug to cache this.outerDimensions
  3117. // considering that we are in a loop.
  3118. if (!this.outerDimensions) {
  3119. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  3120. }
  3121. prel.css({
  3122. height: (element.height() - this.outerDimensions.height) || 0,
  3123. width: (element.width() - this.outerDimensions.width) || 0
  3124. });
  3125. }
  3126. },
  3127. _renderProxy: function() {
  3128. var el = this.element, o = this.options;
  3129. this.elementOffset = el.offset();
  3130. if (this._helper) {
  3131. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  3132. this.helper.addClass(this._helper).css({
  3133. width: this.element.outerWidth() - 1,
  3134. height: this.element.outerHeight() - 1,
  3135. position: "absolute",
  3136. left: this.elementOffset.left + "px",
  3137. top: this.elementOffset.top + "px",
  3138. zIndex: ++o.zIndex //TODO: Don't modify option
  3139. });
  3140. this.helper
  3141. .appendTo("body")
  3142. .disableSelection();
  3143. } else {
  3144. this.helper = this.element;
  3145. }
  3146. },
  3147. _change: {
  3148. e: function(event, dx) {
  3149. return { width: this.originalSize.width + dx };
  3150. },
  3151. w: function(event, dx) {
  3152. var cs = this.originalSize, sp = this.originalPosition;
  3153. return { left: sp.left + dx, width: cs.width - dx };
  3154. },
  3155. n: function(event, dx, dy) {
  3156. var cs = this.originalSize, sp = this.originalPosition;
  3157. return { top: sp.top + dy, height: cs.height - dy };
  3158. },
  3159. s: function(event, dx, dy) {
  3160. return { height: this.originalSize.height + dy };
  3161. },
  3162. se: function(event, dx, dy) {
  3163. return $.extend(this._change.s.apply(this, arguments),
  3164. this._change.e.apply(this, [ event, dx, dy ]));
  3165. },
  3166. sw: function(event, dx, dy) {
  3167. return $.extend(this._change.s.apply(this, arguments),
  3168. this._change.w.apply(this, [ event, dx, dy ]));
  3169. },
  3170. ne: function(event, dx, dy) {
  3171. return $.extend(this._change.n.apply(this, arguments),
  3172. this._change.e.apply(this, [ event, dx, dy ]));
  3173. },
  3174. nw: function(event, dx, dy) {
  3175. return $.extend(this._change.n.apply(this, arguments),
  3176. this._change.w.apply(this, [ event, dx, dy ]));
  3177. }
  3178. },
  3179. _propagate: function(n, event) {
  3180. $.ui.plugin.call(this, n, [ event, this.ui() ]);
  3181. (n !== "resize" && this._trigger(n, event, this.ui()));
  3182. },
  3183. plugins: {},
  3184. ui: function() {
  3185. return {
  3186. originalElement: this.originalElement,
  3187. element: this.element,
  3188. helper: this.helper,
  3189. position: this.position,
  3190. size: this.size,
  3191. originalSize: this.originalSize,
  3192. originalPosition: this.originalPosition
  3193. };
  3194. }
  3195. });
  3196. /*
  3197. * Resizable Extensions
  3198. */
  3199. $.ui.plugin.add("resizable", "animate", {
  3200. stop: function( event ) {
  3201. var that = $(this).resizable( "instance" ),
  3202. o = that.options,
  3203. pr = that._proportionallyResizeElements,
  3204. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  3205. soffseth = ista && that._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height,
  3206. soffsetw = ista ? 0 : that.sizeDiff.width,
  3207. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  3208. left = (parseInt(that.element.css("left"), 10) +
  3209. (that.position.left - that.originalPosition.left)) || null,
  3210. top = (parseInt(that.element.css("top"), 10) +
  3211. (that.position.top - that.originalPosition.top)) || null;
  3212. that.element.animate(
  3213. $.extend(style, top && left ? { top: top, left: left } : {}), {
  3214. duration: o.animateDuration,
  3215. easing: o.animateEasing,
  3216. step: function() {
  3217. var data = {
  3218. width: parseInt(that.element.css("width"), 10),
  3219. height: parseInt(that.element.css("height"), 10),
  3220. top: parseInt(that.element.css("top"), 10),
  3221. left: parseInt(that.element.css("left"), 10)
  3222. };
  3223. if (pr && pr.length) {
  3224. $(pr[0]).css({ width: data.width, height: data.height });
  3225. }
  3226. // propagating resize, and updating values for each animation step
  3227. that._updateCache(data);
  3228. that._propagate("resize", event);
  3229. }
  3230. }
  3231. );
  3232. }
  3233. });
  3234. $.ui.plugin.add( "resizable", "containment", {
  3235. start: function() {
  3236. var element, p, co, ch, cw, width, height,
  3237. that = $( this ).resizable( "instance" ),
  3238. o = that.options,
  3239. el = that.element,
  3240. oc = o.containment,
  3241. ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  3242. if ( !ce ) {
  3243. return;
  3244. }
  3245. that.containerElement = $( ce );
  3246. if ( /document/.test( oc ) || oc === document ) {
  3247. that.containerOffset = {
  3248. left: 0,
  3249. top: 0
  3250. };
  3251. that.containerPosition = {
  3252. left: 0,
  3253. top: 0
  3254. };
  3255. that.parentData = {
  3256. element: $( document ),
  3257. left: 0,
  3258. top: 0,
  3259. width: $( document ).width(),
  3260. height: $( document ).height() || document.body.parentNode.scrollHeight
  3261. };
  3262. } else {
  3263. element = $( ce );
  3264. p = [];
  3265. $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {
  3266. p[ i ] = that._num( element.css( "padding" + name ) );
  3267. });
  3268. that.containerOffset = element.offset();
  3269. that.containerPosition = element.position();
  3270. that.containerSize = {
  3271. height: ( element.innerHeight() - p[ 3 ] ),
  3272. width: ( element.innerWidth() - p[ 1 ] )
  3273. };
  3274. co = that.containerOffset;
  3275. ch = that.containerSize.height;
  3276. cw = that.containerSize.width;
  3277. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  3278. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  3279. that.parentData = {
  3280. element: ce,
  3281. left: co.left,
  3282. top: co.top,
  3283. width: width,
  3284. height: height
  3285. };
  3286. }
  3287. },
  3288. resize: function( event ) {
  3289. var woset, hoset, isParent, isOffsetRelative,
  3290. that = $( this ).resizable( "instance" ),
  3291. o = that.options,
  3292. co = that.containerOffset,
  3293. cp = that.position,
  3294. pRatio = that._aspectRatio || event.shiftKey,
  3295. cop = {
  3296. top: 0,
  3297. left: 0
  3298. },
  3299. ce = that.containerElement,
  3300. continueResize = true;
  3301. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  3302. cop = co;
  3303. }
  3304. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  3305. that.size.width = that.size.width +
  3306. ( that._helper ?
  3307. ( that.position.left - co.left ) :
  3308. ( that.position.left - cop.left ) );
  3309. if ( pRatio ) {
  3310. that.size.height = that.size.width / that.aspectRatio;
  3311. continueResize = false;
  3312. }
  3313. that.position.left = o.helper ? co.left : 0;
  3314. }
  3315. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  3316. that.size.height = that.size.height +
  3317. ( that._helper ?
  3318. ( that.position.top - co.top ) :
  3319. that.position.top );
  3320. if ( pRatio ) {
  3321. that.size.width = that.size.height * that.aspectRatio;
  3322. continueResize = false;
  3323. }
  3324. that.position.top = that._helper ? co.top : 0;
  3325. }
  3326. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  3327. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  3328. if ( isParent && isOffsetRelative ) {
  3329. that.offset.left = that.parentData.left + that.position.left;
  3330. that.offset.top = that.parentData.top + that.position.top;
  3331. } else {
  3332. that.offset.left = that.element.offset().left;
  3333. that.offset.top = that.element.offset().top;
  3334. }
  3335. woset = Math.abs( that.sizeDiff.width +
  3336. (that._helper ?
  3337. that.offset.left - cop.left :
  3338. (that.offset.left - co.left)) );
  3339. hoset = Math.abs( that.sizeDiff.height +
  3340. (that._helper ?
  3341. that.offset.top - cop.top :
  3342. (that.offset.top - co.top)) );
  3343. if ( woset + that.size.width >= that.parentData.width ) {
  3344. that.size.width = that.parentData.width - woset;
  3345. if ( pRatio ) {
  3346. that.size.height = that.size.width / that.aspectRatio;
  3347. continueResize = false;
  3348. }
  3349. }
  3350. if ( hoset + that.size.height >= that.parentData.height ) {
  3351. that.size.height = that.parentData.height - hoset;
  3352. if ( pRatio ) {
  3353. that.size.width = that.size.height * that.aspectRatio;
  3354. continueResize = false;
  3355. }
  3356. }
  3357. if ( !continueResize ) {
  3358. that.position.left = that.prevPosition.left;
  3359. that.position.top = that.prevPosition.top;
  3360. that.size.width = that.prevSize.width;
  3361. that.size.height = that.prevSize.height;
  3362. }
  3363. },
  3364. stop: function() {
  3365. var that = $( this ).resizable( "instance" ),
  3366. o = that.options,
  3367. co = that.containerOffset,
  3368. cop = that.containerPosition,
  3369. ce = that.containerElement,
  3370. helper = $( that.helper ),
  3371. ho = helper.offset(),
  3372. w = helper.outerWidth() - that.sizeDiff.width,
  3373. h = helper.outerHeight() - that.sizeDiff.height;
  3374. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  3375. $( this ).css({
  3376. left: ho.left - cop.left - co.left,
  3377. width: w,
  3378. height: h
  3379. });
  3380. }
  3381. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  3382. $( this ).css({
  3383. left: ho.left - cop.left - co.left,
  3384. width: w,
  3385. height: h
  3386. });
  3387. }
  3388. }
  3389. });
  3390. $.ui.plugin.add("resizable", "alsoResize", {
  3391. start: function() {
  3392. var that = $(this).resizable( "instance" ),
  3393. o = that.options,
  3394. _store = function(exp) {
  3395. $(exp).each(function() {
  3396. var el = $(this);
  3397. el.data("ui-resizable-alsoresize", {
  3398. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  3399. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  3400. });
  3401. });
  3402. };
  3403. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  3404. if (o.alsoResize.length) {
  3405. o.alsoResize = o.alsoResize[0];
  3406. _store(o.alsoResize);
  3407. } else {
  3408. $.each(o.alsoResize, function(exp) {
  3409. _store(exp);
  3410. });
  3411. }
  3412. } else {
  3413. _store(o.alsoResize);
  3414. }
  3415. },
  3416. resize: function(event, ui) {
  3417. var that = $(this).resizable( "instance" ),
  3418. o = that.options,
  3419. os = that.originalSize,
  3420. op = that.originalPosition,
  3421. delta = {
  3422. height: (that.size.height - os.height) || 0,
  3423. width: (that.size.width - os.width) || 0,
  3424. top: (that.position.top - op.top) || 0,
  3425. left: (that.position.left - op.left) || 0
  3426. },
  3427. _alsoResize = function(exp, c) {
  3428. $(exp).each(function() {
  3429. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  3430. css = c && c.length ?
  3431. c :
  3432. el.parents(ui.originalElement[0]).length ?
  3433. [ "width", "height" ] :
  3434. [ "width", "height", "top", "left" ];
  3435. $.each(css, function(i, prop) {
  3436. var sum = (start[prop] || 0) + (delta[prop] || 0);
  3437. if (sum && sum >= 0) {
  3438. style[prop] = sum || null;
  3439. }
  3440. });
  3441. el.css(style);
  3442. });
  3443. };
  3444. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  3445. $.each(o.alsoResize, function(exp, c) {
  3446. _alsoResize(exp, c);
  3447. });
  3448. } else {
  3449. _alsoResize(o.alsoResize);
  3450. }
  3451. },
  3452. stop: function() {
  3453. $(this).removeData("resizable-alsoresize");
  3454. }
  3455. });
  3456. $.ui.plugin.add("resizable", "ghost", {
  3457. start: function() {
  3458. var that = $(this).resizable( "instance" ), o = that.options, cs = that.size;
  3459. that.ghost = that.originalElement.clone();
  3460. that.ghost
  3461. .css({
  3462. opacity: 0.25,
  3463. display: "block",
  3464. position: "relative",
  3465. height: cs.height,
  3466. width: cs.width,
  3467. margin: 0,
  3468. left: 0,
  3469. top: 0
  3470. })
  3471. .addClass("ui-resizable-ghost")
  3472. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  3473. that.ghost.appendTo(that.helper);
  3474. },
  3475. resize: function() {
  3476. var that = $(this).resizable( "instance" );
  3477. if (that.ghost) {
  3478. that.ghost.css({
  3479. position: "relative",
  3480. height: that.size.height,
  3481. width: that.size.width
  3482. });
  3483. }
  3484. },
  3485. stop: function() {
  3486. var that = $(this).resizable( "instance" );
  3487. if (that.ghost && that.helper) {
  3488. that.helper.get(0).removeChild(that.ghost.get(0));
  3489. }
  3490. }
  3491. });
  3492. $.ui.plugin.add("resizable", "grid", {
  3493. resize: function() {
  3494. var outerDimensions,
  3495. that = $(this).resizable( "instance" ),
  3496. o = that.options,
  3497. cs = that.size,
  3498. os = that.originalSize,
  3499. op = that.originalPosition,
  3500. a = that.axis,
  3501. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  3502. gridX = (grid[0] || 1),
  3503. gridY = (grid[1] || 1),
  3504. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  3505. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  3506. newWidth = os.width + ox,
  3507. newHeight = os.height + oy,
  3508. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  3509. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  3510. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  3511. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  3512. o.grid = grid;
  3513. if (isMinWidth) {
  3514. newWidth += gridX;
  3515. }
  3516. if (isMinHeight) {
  3517. newHeight += gridY;
  3518. }
  3519. if (isMaxWidth) {
  3520. newWidth -= gridX;
  3521. }
  3522. if (isMaxHeight) {
  3523. newHeight -= gridY;
  3524. }
  3525. if (/^(se|s|e)$/.test(a)) {
  3526. that.size.width = newWidth;
  3527. that.size.height = newHeight;
  3528. } else if (/^(ne)$/.test(a)) {
  3529. that.size.width = newWidth;
  3530. that.size.height = newHeight;
  3531. that.position.top = op.top - oy;
  3532. } else if (/^(sw)$/.test(a)) {
  3533. that.size.width = newWidth;
  3534. that.size.height = newHeight;
  3535. that.position.left = op.left - ox;
  3536. } else {
  3537. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) {
  3538. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  3539. }
  3540. if ( newHeight - gridY > 0 ) {
  3541. that.size.height = newHeight;
  3542. that.position.top = op.top - oy;
  3543. } else {
  3544. newHeight = gridY - outerDimensions.height;
  3545. that.size.height = newHeight;
  3546. that.position.top = op.top + os.height - newHeight;
  3547. }
  3548. if ( newWidth - gridX > 0 ) {
  3549. that.size.width = newWidth;
  3550. that.position.left = op.left - ox;
  3551. } else {
  3552. newWidth = gridX - outerDimensions.width;
  3553. that.size.width = newWidth;
  3554. that.position.left = op.left + os.width - newWidth;
  3555. }
  3556. }
  3557. }
  3558. });
  3559. var resizable = $.ui.resizable;
  3560. /*!
  3561. * jQuery UI Selectable 1.11.3
  3562. * http://jqueryui.com
  3563. *
  3564. * Copyright jQuery Foundation and other contributors
  3565. * Released under the MIT license.
  3566. * http://jquery.org/license
  3567. *
  3568. * http://api.jqueryui.com/selectable/
  3569. */
  3570. var selectable = $.widget("ui.selectable", $.ui.mouse, {
  3571. version: "1.11.3",
  3572. options: {
  3573. appendTo: "body",
  3574. autoRefresh: true,
  3575. distance: 0,
  3576. filter: "*",
  3577. tolerance: "touch",
  3578. // callbacks
  3579. selected: null,
  3580. selecting: null,
  3581. start: null,
  3582. stop: null,
  3583. unselected: null,
  3584. unselecting: null
  3585. },
  3586. _create: function() {
  3587. var selectees,
  3588. that = this;
  3589. this.element.addClass("ui-selectable");
  3590. this.dragged = false;
  3591. // cache selectee children based on filter
  3592. this.refresh = function() {
  3593. selectees = $(that.options.filter, that.element[0]);
  3594. selectees.addClass("ui-selectee");
  3595. selectees.each(function() {
  3596. var $this = $(this),
  3597. pos = $this.offset();
  3598. $.data(this, "selectable-item", {
  3599. element: this,
  3600. $element: $this,
  3601. left: pos.left,
  3602. top: pos.top,
  3603. right: pos.left + $this.outerWidth(),
  3604. bottom: pos.top + $this.outerHeight(),
  3605. startselected: false,
  3606. selected: $this.hasClass("ui-selected"),
  3607. selecting: $this.hasClass("ui-selecting"),
  3608. unselecting: $this.hasClass("ui-unselecting")
  3609. });
  3610. });
  3611. };
  3612. this.refresh();
  3613. this.selectees = selectees.addClass("ui-selectee");
  3614. this._mouseInit();
  3615. this.helper = $("<div class='ui-selectable-helper'></div>");
  3616. },
  3617. _destroy: function() {
  3618. this.selectees
  3619. .removeClass("ui-selectee")
  3620. .removeData("selectable-item");
  3621. this.element
  3622. .removeClass("ui-selectable ui-selectable-disabled");
  3623. this._mouseDestroy();
  3624. },
  3625. _mouseStart: function(event) {
  3626. var that = this,
  3627. options = this.options;
  3628. this.opos = [ event.pageX, event.pageY ];
  3629. if (this.options.disabled) {
  3630. return;
  3631. }
  3632. this.selectees = $(options.filter, this.element[0]);
  3633. this._trigger("start", event);
  3634. $(options.appendTo).append(this.helper);
  3635. // position helper (lasso)
  3636. this.helper.css({
  3637. "left": event.pageX,
  3638. "top": event.pageY,
  3639. "width": 0,
  3640. "height": 0
  3641. });
  3642. if (options.autoRefresh) {
  3643. this.refresh();
  3644. }
  3645. this.selectees.filter(".ui-selected").each(function() {
  3646. var selectee = $.data(this, "selectable-item");
  3647. selectee.startselected = true;
  3648. if (!event.metaKey && !event.ctrlKey) {
  3649. selectee.$element.removeClass("ui-selected");
  3650. selectee.selected = false;
  3651. selectee.$element.addClass("ui-unselecting");
  3652. selectee.unselecting = true;
  3653. // selectable UNSELECTING callback
  3654. that._trigger("unselecting", event, {
  3655. unselecting: selectee.element
  3656. });
  3657. }
  3658. });
  3659. $(event.target).parents().addBack().each(function() {
  3660. var doSelect,
  3661. selectee = $.data(this, "selectable-item");
  3662. if (selectee) {
  3663. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  3664. selectee.$element
  3665. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  3666. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  3667. selectee.unselecting = !doSelect;
  3668. selectee.selecting = doSelect;
  3669. selectee.selected = doSelect;
  3670. // selectable (UN)SELECTING callback
  3671. if (doSelect) {
  3672. that._trigger("selecting", event, {
  3673. selecting: selectee.element
  3674. });
  3675. } else {
  3676. that._trigger("unselecting", event, {
  3677. unselecting: selectee.element
  3678. });
  3679. }
  3680. return false;
  3681. }
  3682. });
  3683. },
  3684. _mouseDrag: function(event) {
  3685. this.dragged = true;
  3686. if (this.options.disabled) {
  3687. return;
  3688. }
  3689. var tmp,
  3690. that = this,
  3691. options = this.options,
  3692. x1 = this.opos[0],
  3693. y1 = this.opos[1],
  3694. x2 = event.pageX,
  3695. y2 = event.pageY;
  3696. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  3697. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  3698. this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });
  3699. this.selectees.each(function() {
  3700. var selectee = $.data(this, "selectable-item"),
  3701. hit = false;
  3702. //prevent helper from being selected if appendTo: selectable
  3703. if (!selectee || selectee.element === that.element[0]) {
  3704. return;
  3705. }
  3706. if (options.tolerance === "touch") {
  3707. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  3708. } else if (options.tolerance === "fit") {
  3709. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  3710. }
  3711. if (hit) {
  3712. // SELECT
  3713. if (selectee.selected) {
  3714. selectee.$element.removeClass("ui-selected");
  3715. selectee.selected = false;
  3716. }
  3717. if (selectee.unselecting) {
  3718. selectee.$element.removeClass("ui-unselecting");
  3719. selectee.unselecting = false;
  3720. }
  3721. if (!selectee.selecting) {
  3722. selectee.$element.addClass("ui-selecting");
  3723. selectee.selecting = true;
  3724. // selectable SELECTING callback
  3725. that._trigger("selecting", event, {
  3726. selecting: selectee.element
  3727. });
  3728. }
  3729. } else {
  3730. // UNSELECT
  3731. if (selectee.selecting) {
  3732. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  3733. selectee.$element.removeClass("ui-selecting");
  3734. selectee.selecting = false;
  3735. selectee.$element.addClass("ui-selected");
  3736. selectee.selected = true;
  3737. } else {
  3738. selectee.$element.removeClass("ui-selecting");
  3739. selectee.selecting = false;
  3740. if (selectee.startselected) {
  3741. selectee.$element.addClass("ui-unselecting");
  3742. selectee.unselecting = true;
  3743. }
  3744. // selectable UNSELECTING callback
  3745. that._trigger("unselecting", event, {
  3746. unselecting: selectee.element
  3747. });
  3748. }
  3749. }
  3750. if (selectee.selected) {
  3751. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  3752. selectee.$element.removeClass("ui-selected");
  3753. selectee.selected = false;
  3754. selectee.$element.addClass("ui-unselecting");
  3755. selectee.unselecting = true;
  3756. // selectable UNSELECTING callback
  3757. that._trigger("unselecting", event, {
  3758. unselecting: selectee.element
  3759. });
  3760. }
  3761. }
  3762. }
  3763. });
  3764. return false;
  3765. },
  3766. _mouseStop: function(event) {
  3767. var that = this;
  3768. this.dragged = false;
  3769. $(".ui-unselecting", this.element[0]).each(function() {
  3770. var selectee = $.data(this, "selectable-item");
  3771. selectee.$element.removeClass("ui-unselecting");
  3772. selectee.unselecting = false;
  3773. selectee.startselected = false;
  3774. that._trigger("unselected", event, {
  3775. unselected: selectee.element
  3776. });
  3777. });
  3778. $(".ui-selecting", this.element[0]).each(function() {
  3779. var selectee = $.data(this, "selectable-item");
  3780. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  3781. selectee.selecting = false;
  3782. selectee.selected = true;
  3783. selectee.startselected = true;
  3784. that._trigger("selected", event, {
  3785. selected: selectee.element
  3786. });
  3787. });
  3788. this._trigger("stop", event);
  3789. this.helper.remove();
  3790. return false;
  3791. }
  3792. });
  3793. /*!
  3794. * jQuery UI Sortable 1.11.3
  3795. * http://jqueryui.com
  3796. *
  3797. * Copyright jQuery Foundation and other contributors
  3798. * Released under the MIT license.
  3799. * http://jquery.org/license
  3800. *
  3801. * http://api.jqueryui.com/sortable/
  3802. */
  3803. var sortable = $.widget("ui.sortable", $.ui.mouse, {
  3804. version: "1.11.3",
  3805. widgetEventPrefix: "sort",
  3806. ready: false,
  3807. options: {
  3808. appendTo: "parent",
  3809. axis: false,
  3810. connectWith: false,
  3811. containment: false,
  3812. cursor: "auto",
  3813. cursorAt: false,
  3814. dropOnEmpty: true,
  3815. forcePlaceholderSize: false,
  3816. forceHelperSize: false,
  3817. grid: false,
  3818. handle: false,
  3819. helper: "original",
  3820. items: "> *",
  3821. opacity: false,
  3822. placeholder: false,
  3823. revert: false,
  3824. scroll: true,
  3825. scrollSensitivity: 20,
  3826. scrollSpeed: 20,
  3827. scope: "default",
  3828. tolerance: "intersect",
  3829. zIndex: 1000,
  3830. // callbacks
  3831. activate: null,
  3832. beforeStop: null,
  3833. change: null,
  3834. deactivate: null,
  3835. out: null,
  3836. over: null,
  3837. receive: null,
  3838. remove: null,
  3839. sort: null,
  3840. start: null,
  3841. stop: null,
  3842. update: null
  3843. },
  3844. _isOverAxis: function( x, reference, size ) {
  3845. return ( x >= reference ) && ( x < ( reference + size ) );
  3846. },
  3847. _isFloating: function( item ) {
  3848. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  3849. },
  3850. _create: function() {
  3851. var o = this.options;
  3852. this.containerCache = {};
  3853. this.element.addClass("ui-sortable");
  3854. //Get the items
  3855. this.refresh();
  3856. //Let's determine if the items are being displayed horizontally
  3857. this.floating = this.items.length ? o.axis === "x" || this._isFloating(this.items[0].item) : false;
  3858. //Let's determine the parent's offset
  3859. this.offset = this.element.offset();
  3860. //Initialize mouse events for interaction
  3861. this._mouseInit();
  3862. this._setHandleClassName();
  3863. //We're ready to go
  3864. this.ready = true;
  3865. },
  3866. _setOption: function( key, value ) {
  3867. this._super( key, value );
  3868. if ( key === "handle" ) {
  3869. this._setHandleClassName();
  3870. }
  3871. },
  3872. _setHandleClassName: function() {
  3873. this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" );
  3874. $.each( this.items, function() {
  3875. ( this.instance.options.handle ?
  3876. this.item.find( this.instance.options.handle ) : this.item )
  3877. .addClass( "ui-sortable-handle" );
  3878. });
  3879. },
  3880. _destroy: function() {
  3881. this.element
  3882. .removeClass( "ui-sortable ui-sortable-disabled" )
  3883. .find( ".ui-sortable-handle" )
  3884. .removeClass( "ui-sortable-handle" );
  3885. this._mouseDestroy();
  3886. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  3887. this.items[i].item.removeData(this.widgetName + "-item");
  3888. }
  3889. return this;
  3890. },
  3891. _mouseCapture: function(event, overrideHandle) {
  3892. var currentItem = null,
  3893. validHandle = false,
  3894. that = this;
  3895. if (this.reverting) {
  3896. return false;
  3897. }
  3898. if(this.options.disabled || this.options.type === "static") {
  3899. return false;
  3900. }
  3901. //We have to refresh the items data once first
  3902. this._refreshItems(event);
  3903. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  3904. $(event.target).parents().each(function() {
  3905. if($.data(this, that.widgetName + "-item") === that) {
  3906. currentItem = $(this);
  3907. return false;
  3908. }
  3909. });
  3910. if($.data(event.target, that.widgetName + "-item") === that) {
  3911. currentItem = $(event.target);
  3912. }
  3913. if(!currentItem) {
  3914. return false;
  3915. }
  3916. if(this.options.handle && !overrideHandle) {
  3917. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  3918. if(this === event.target) {
  3919. validHandle = true;
  3920. }
  3921. });
  3922. if(!validHandle) {
  3923. return false;
  3924. }
  3925. }
  3926. this.currentItem = currentItem;
  3927. this._removeCurrentsFromItems();
  3928. return true;
  3929. },
  3930. _mouseStart: function(event, overrideHandle, noActivation) {
  3931. var i, body,
  3932. o = this.options;
  3933. this.currentContainer = this;
  3934. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3935. this.refreshPositions();
  3936. //Create and append the visible helper
  3937. this.helper = this._createHelper(event);
  3938. //Cache the helper size
  3939. this._cacheHelperProportions();
  3940. /*
  3941. * - Position generation -
  3942. * This block generates everything position related - it's the core of draggables.
  3943. */
  3944. //Cache the margins of the original element
  3945. this._cacheMargins();
  3946. //Get the next scrolling parent
  3947. this.scrollParent = this.helper.scrollParent();
  3948. //The element's absolute position on the page minus margins
  3949. this.offset = this.currentItem.offset();
  3950. this.offset = {
  3951. top: this.offset.top - this.margins.top,
  3952. left: this.offset.left - this.margins.left
  3953. };
  3954. $.extend(this.offset, {
  3955. click: { //Where the click happened, relative to the element
  3956. left: event.pageX - this.offset.left,
  3957. top: event.pageY - this.offset.top
  3958. },
  3959. parent: this._getParentOffset(),
  3960. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3961. });
  3962. // Only after we got the offset, we can change the helper's position to absolute
  3963. // TODO: Still need to figure out a way to make relative sorting possible
  3964. this.helper.css("position", "absolute");
  3965. this.cssPosition = this.helper.css("position");
  3966. //Generate the original position
  3967. this.originalPosition = this._generatePosition(event);
  3968. this.originalPageX = event.pageX;
  3969. this.originalPageY = event.pageY;
  3970. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3971. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3972. //Cache the former DOM position
  3973. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3974. //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
  3975. if(this.helper[0] !== this.currentItem[0]) {
  3976. this.currentItem.hide();
  3977. }
  3978. //Create the placeholder
  3979. this._createPlaceholder();
  3980. //Set a containment if given in the options
  3981. if(o.containment) {
  3982. this._setContainment();
  3983. }
  3984. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  3985. body = this.document.find( "body" );
  3986. // support: IE
  3987. this.storedCursor = body.css( "cursor" );
  3988. body.css( "cursor", o.cursor );
  3989. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  3990. }
  3991. if(o.opacity) { // opacity option
  3992. if (this.helper.css("opacity")) {
  3993. this._storedOpacity = this.helper.css("opacity");
  3994. }
  3995. this.helper.css("opacity", o.opacity);
  3996. }
  3997. if(o.zIndex) { // zIndex option
  3998. if (this.helper.css("zIndex")) {
  3999. this._storedZIndex = this.helper.css("zIndex");
  4000. }
  4001. this.helper.css("zIndex", o.zIndex);
  4002. }
  4003. //Prepare scrolling
  4004. if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
  4005. this.overflowOffset = this.scrollParent.offset();
  4006. }
  4007. //Call callbacks
  4008. this._trigger("start", event, this._uiHash());
  4009. //Recache the helper size
  4010. if(!this._preserveHelperProportions) {
  4011. this._cacheHelperProportions();
  4012. }
  4013. //Post "activate" events to possible containers
  4014. if( !noActivation ) {
  4015. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  4016. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  4017. }
  4018. }
  4019. //Prepare possible droppables
  4020. if($.ui.ddmanager) {
  4021. $.ui.ddmanager.current = this;
  4022. }
  4023. if ($.ui.ddmanager && !o.dropBehaviour) {
  4024. $.ui.ddmanager.prepareOffsets(this, event);
  4025. }
  4026. this.dragging = true;
  4027. this.helper.addClass("ui-sortable-helper");
  4028. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  4029. return true;
  4030. },
  4031. _mouseDrag: function(event) {
  4032. var i, item, itemElement, intersection,
  4033. o = this.options,
  4034. scrolled = false;
  4035. //Compute the helpers position
  4036. this.position = this._generatePosition(event);
  4037. this.positionAbs = this._convertPositionTo("absolute");
  4038. if (!this.lastPositionAbs) {
  4039. this.lastPositionAbs = this.positionAbs;
  4040. }
  4041. //Do scrolling
  4042. if(this.options.scroll) {
  4043. if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
  4044. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  4045. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  4046. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  4047. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  4048. }
  4049. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  4050. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  4051. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  4052. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  4053. }
  4054. } else {
  4055. if(event.pageY - this.document.scrollTop() < o.scrollSensitivity) {
  4056. scrolled = this.document.scrollTop(this.document.scrollTop() - o.scrollSpeed);
  4057. } else if(this.window.height() - (event.pageY - this.document.scrollTop()) < o.scrollSensitivity) {
  4058. scrolled = this.document.scrollTop(this.document.scrollTop() + o.scrollSpeed);
  4059. }
  4060. if(event.pageX - this.document.scrollLeft() < o.scrollSensitivity) {
  4061. scrolled = this.document.scrollLeft(this.document.scrollLeft() - o.scrollSpeed);
  4062. } else if(this.window.width() - (event.pageX - this.document.scrollLeft()) < o.scrollSensitivity) {
  4063. scrolled = this.document.scrollLeft(this.document.scrollLeft() + o.scrollSpeed);
  4064. }
  4065. }
  4066. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  4067. $.ui.ddmanager.prepareOffsets(this, event);
  4068. }
  4069. }
  4070. //Regenerate the absolute position used for position checks
  4071. this.positionAbs = this._convertPositionTo("absolute");
  4072. //Set the helper position
  4073. if(!this.options.axis || this.options.axis !== "y") {
  4074. this.helper[0].style.left = this.position.left+"px";
  4075. }
  4076. if(!this.options.axis || this.options.axis !== "x") {
  4077. this.helper[0].style.top = this.position.top+"px";
  4078. }
  4079. //Rearrange
  4080. for (i = this.items.length - 1; i >= 0; i--) {
  4081. //Cache variables and intersection, continue if no intersection
  4082. item = this.items[i];
  4083. itemElement = item.item[0];
  4084. intersection = this._intersectsWithPointer(item);
  4085. if (!intersection) {
  4086. continue;
  4087. }
  4088. // Only put the placeholder inside the current Container, skip all
  4089. // items from other containers. This works because when moving
  4090. // an item from one container to another the
  4091. // currentContainer is switched before the placeholder is moved.
  4092. //
  4093. // Without this, moving items in "sub-sortables" can cause
  4094. // the placeholder to jitter between the outer and inner container.
  4095. if (item.instance !== this.currentContainer) {
  4096. continue;
  4097. }
  4098. // cannot intersect with itself
  4099. // no useless actions that have been done before
  4100. // no action if the item moved is the parent of the item checked
  4101. if (itemElement !== this.currentItem[0] &&
  4102. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  4103. !$.contains(this.placeholder[0], itemElement) &&
  4104. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  4105. ) {
  4106. this.direction = intersection === 1 ? "down" : "up";
  4107. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  4108. this._rearrange(event, item);
  4109. } else {
  4110. break;
  4111. }
  4112. this._trigger("change", event, this._uiHash());
  4113. break;
  4114. }
  4115. }
  4116. //Post events to containers
  4117. this._contactContainers(event);
  4118. //Interconnect with droppables
  4119. if($.ui.ddmanager) {
  4120. $.ui.ddmanager.drag(this, event);
  4121. }
  4122. //Call callbacks
  4123. this._trigger("sort", event, this._uiHash());
  4124. this.lastPositionAbs = this.positionAbs;
  4125. return false;
  4126. },
  4127. _mouseStop: function(event, noPropagation) {
  4128. if(!event) {
  4129. return;
  4130. }
  4131. //If we are using droppables, inform the manager about the drop
  4132. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  4133. $.ui.ddmanager.drop(this, event);
  4134. }
  4135. if(this.options.revert) {
  4136. var that = this,
  4137. cur = this.placeholder.offset(),
  4138. axis = this.options.axis,
  4139. animation = {};
  4140. if ( !axis || axis === "x" ) {
  4141. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollLeft);
  4142. }
  4143. if ( !axis || axis === "y" ) {
  4144. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollTop);
  4145. }
  4146. this.reverting = true;
  4147. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  4148. that._clear(event);
  4149. });
  4150. } else {
  4151. this._clear(event, noPropagation);
  4152. }
  4153. return false;
  4154. },
  4155. cancel: function() {
  4156. if(this.dragging) {
  4157. this._mouseUp({ target: null });
  4158. if(this.options.helper === "original") {
  4159. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  4160. } else {
  4161. this.currentItem.show();
  4162. }
  4163. //Post deactivating events to containers
  4164. for (var i = this.containers.length - 1; i >= 0; i--){
  4165. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  4166. if(this.containers[i].containerCache.over) {
  4167. this.containers[i]._trigger("out", null, this._uiHash(this));
  4168. this.containers[i].containerCache.over = 0;
  4169. }
  4170. }
  4171. }
  4172. if (this.placeholder) {
  4173. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  4174. if(this.placeholder[0].parentNode) {
  4175. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  4176. }
  4177. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  4178. this.helper.remove();
  4179. }
  4180. $.extend(this, {
  4181. helper: null,
  4182. dragging: false,
  4183. reverting: false,
  4184. _noFinalSort: null
  4185. });
  4186. if(this.domPosition.prev) {
  4187. $(this.domPosition.prev).after(this.currentItem);
  4188. } else {
  4189. $(this.domPosition.parent).prepend(this.currentItem);
  4190. }
  4191. }
  4192. return this;
  4193. },
  4194. serialize: function(o) {
  4195. var items = this._getItemsAsjQuery(o && o.connected),
  4196. str = [];
  4197. o = o || {};
  4198. $(items).each(function() {
  4199. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  4200. if (res) {
  4201. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  4202. }
  4203. });
  4204. if(!str.length && o.key) {
  4205. str.push(o.key + "=");
  4206. }
  4207. return str.join("&");
  4208. },
  4209. toArray: function(o) {
  4210. var items = this._getItemsAsjQuery(o && o.connected),
  4211. ret = [];
  4212. o = o || {};
  4213. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  4214. return ret;
  4215. },
  4216. /* Be careful with the following core functions */
  4217. _intersectsWith: function(item) {
  4218. var x1 = this.positionAbs.left,
  4219. x2 = x1 + this.helperProportions.width,
  4220. y1 = this.positionAbs.top,
  4221. y2 = y1 + this.helperProportions.height,
  4222. l = item.left,
  4223. r = l + item.width,
  4224. t = item.top,
  4225. b = t + item.height,
  4226. dyClick = this.offset.click.top,
  4227. dxClick = this.offset.click.left,
  4228. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  4229. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  4230. isOverElement = isOverElementHeight && isOverElementWidth;
  4231. if ( this.options.tolerance === "pointer" ||
  4232. this.options.forcePointerForContainers ||
  4233. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  4234. ) {
  4235. return isOverElement;
  4236. } else {
  4237. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  4238. x2 - (this.helperProportions.width / 2) < r && // Left Half
  4239. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  4240. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  4241. }
  4242. },
  4243. _intersectsWithPointer: function(item) {
  4244. var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  4245. isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  4246. isOverElement = isOverElementHeight && isOverElementWidth,
  4247. verticalDirection = this._getDragVerticalDirection(),
  4248. horizontalDirection = this._getDragHorizontalDirection();
  4249. if (!isOverElement) {
  4250. return false;
  4251. }
  4252. return this.floating ?
  4253. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  4254. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  4255. },
  4256. _intersectsWithSides: function(item) {
  4257. var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  4258. isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  4259. verticalDirection = this._getDragVerticalDirection(),
  4260. horizontalDirection = this._getDragHorizontalDirection();
  4261. if (this.floating && horizontalDirection) {
  4262. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  4263. } else {
  4264. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  4265. }
  4266. },
  4267. _getDragVerticalDirection: function() {
  4268. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  4269. return delta !== 0 && (delta > 0 ? "down" : "up");
  4270. },
  4271. _getDragHorizontalDirection: function() {
  4272. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  4273. return delta !== 0 && (delta > 0 ? "right" : "left");
  4274. },
  4275. refresh: function(event) {
  4276. this._refreshItems(event);
  4277. this._setHandleClassName();
  4278. this.refreshPositions();
  4279. return this;
  4280. },
  4281. _connectWith: function() {
  4282. var options = this.options;
  4283. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  4284. },
  4285. _getItemsAsjQuery: function(connected) {
  4286. var i, j, cur, inst,
  4287. items = [],
  4288. queries = [],
  4289. connectWith = this._connectWith();
  4290. if(connectWith && connected) {
  4291. for (i = connectWith.length - 1; i >= 0; i--){
  4292. cur = $(connectWith[i], this.document[0]);
  4293. for ( j = cur.length - 1; j >= 0; j--){
  4294. inst = $.data(cur[j], this.widgetFullName);
  4295. if(inst && inst !== this && !inst.options.disabled) {
  4296. 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]);
  4297. }
  4298. }
  4299. }
  4300. }
  4301. 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]);
  4302. function addItems() {
  4303. items.push( this );
  4304. }
  4305. for (i = queries.length - 1; i >= 0; i--){
  4306. queries[i][0].each( addItems );
  4307. }
  4308. return $(items);
  4309. },
  4310. _removeCurrentsFromItems: function() {
  4311. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  4312. this.items = $.grep(this.items, function (item) {
  4313. for (var j=0; j < list.length; j++) {
  4314. if(list[j] === item.item[0]) {
  4315. return false;
  4316. }
  4317. }
  4318. return true;
  4319. });
  4320. },
  4321. _refreshItems: function(event) {
  4322. this.items = [];
  4323. this.containers = [this];
  4324. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  4325. items = this.items,
  4326. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  4327. connectWith = this._connectWith();
  4328. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  4329. for (i = connectWith.length - 1; i >= 0; i--){
  4330. cur = $(connectWith[i], this.document[0]);
  4331. for (j = cur.length - 1; j >= 0; j--){
  4332. inst = $.data(cur[j], this.widgetFullName);
  4333. if(inst && inst !== this && !inst.options.disabled) {
  4334. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  4335. this.containers.push(inst);
  4336. }
  4337. }
  4338. }
  4339. }
  4340. for (i = queries.length - 1; i >= 0; i--) {
  4341. targetData = queries[i][1];
  4342. _queries = queries[i][0];
  4343. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  4344. item = $(_queries[j]);
  4345. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  4346. items.push({
  4347. item: item,
  4348. instance: targetData,
  4349. width: 0, height: 0,
  4350. left: 0, top: 0
  4351. });
  4352. }
  4353. }
  4354. },
  4355. refreshPositions: function(fast) {
  4356. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  4357. if(this.offsetParent && this.helper) {
  4358. this.offset.parent = this._getParentOffset();
  4359. }
  4360. var i, item, t, p;
  4361. for (i = this.items.length - 1; i >= 0; i--){
  4362. item = this.items[i];
  4363. //We ignore calculating positions of all connected containers when we're not over them
  4364. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  4365. continue;
  4366. }
  4367. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  4368. if (!fast) {
  4369. item.width = t.outerWidth();
  4370. item.height = t.outerHeight();
  4371. }
  4372. p = t.offset();
  4373. item.left = p.left;
  4374. item.top = p.top;
  4375. }
  4376. if(this.options.custom && this.options.custom.refreshContainers) {
  4377. this.options.custom.refreshContainers.call(this);
  4378. } else {
  4379. for (i = this.containers.length - 1; i >= 0; i--){
  4380. p = this.containers[i].element.offset();
  4381. this.containers[i].containerCache.left = p.left;
  4382. this.containers[i].containerCache.top = p.top;
  4383. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  4384. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  4385. }
  4386. }
  4387. return this;
  4388. },
  4389. _createPlaceholder: function(that) {
  4390. that = that || this;
  4391. var className,
  4392. o = that.options;
  4393. if(!o.placeholder || o.placeholder.constructor === String) {
  4394. className = o.placeholder;
  4395. o.placeholder = {
  4396. element: function() {
  4397. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  4398. element = $( "<" + nodeName + ">", that.document[0] )
  4399. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  4400. .removeClass("ui-sortable-helper");
  4401. if ( nodeName === "tr" ) {
  4402. that.currentItem.children().each(function() {
  4403. $( "<td>&#160;</td>", that.document[0] )
  4404. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  4405. .appendTo( element );
  4406. });
  4407. } else if ( nodeName === "img" ) {
  4408. element.attr( "src", that.currentItem.attr( "src" ) );
  4409. }
  4410. if ( !className ) {
  4411. element.css( "visibility", "hidden" );
  4412. }
  4413. return element;
  4414. },
  4415. update: function(container, p) {
  4416. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  4417. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  4418. if(className && !o.forcePlaceholderSize) {
  4419. return;
  4420. }
  4421. //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
  4422. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  4423. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  4424. }
  4425. };
  4426. }
  4427. //Create the placeholder
  4428. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  4429. //Append it after the actual current item
  4430. that.currentItem.after(that.placeholder);
  4431. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  4432. o.placeholder.update(that, that.placeholder);
  4433. },
  4434. _contactContainers: function(event) {
  4435. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
  4436. innermostContainer = null,
  4437. innermostIndex = null;
  4438. // get innermost container that intersects with item
  4439. for (i = this.containers.length - 1; i >= 0; i--) {
  4440. // never consider a container that's located within the item itself
  4441. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  4442. continue;
  4443. }
  4444. if(this._intersectsWith(this.containers[i].containerCache)) {
  4445. // if we've already found a container and it's more "inner" than this, then continue
  4446. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  4447. continue;
  4448. }
  4449. innermostContainer = this.containers[i];
  4450. innermostIndex = i;
  4451. } else {
  4452. // container doesn't intersect. trigger "out" event if necessary
  4453. if(this.containers[i].containerCache.over) {
  4454. this.containers[i]._trigger("out", event, this._uiHash(this));
  4455. this.containers[i].containerCache.over = 0;
  4456. }
  4457. }
  4458. }
  4459. // if no intersecting containers found, return
  4460. if(!innermostContainer) {
  4461. return;
  4462. }
  4463. // move the item into the container if it's not there already
  4464. if(this.containers.length === 1) {
  4465. if (!this.containers[innermostIndex].containerCache.over) {
  4466. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4467. this.containers[innermostIndex].containerCache.over = 1;
  4468. }
  4469. } else {
  4470. //When entering a new container, we will find the item with the least distance and append our item near it
  4471. dist = 10000;
  4472. itemWithLeastDistance = null;
  4473. floating = innermostContainer.floating || this._isFloating(this.currentItem);
  4474. posProperty = floating ? "left" : "top";
  4475. sizeProperty = floating ? "width" : "height";
  4476. axis = floating ? "clientX" : "clientY";
  4477. for (j = this.items.length - 1; j >= 0; j--) {
  4478. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  4479. continue;
  4480. }
  4481. if(this.items[j].item[0] === this.currentItem[0]) {
  4482. continue;
  4483. }
  4484. cur = this.items[j].item.offset()[posProperty];
  4485. nearBottom = false;
  4486. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  4487. nearBottom = true;
  4488. }
  4489. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  4490. dist = Math.abs( event[ axis ] - cur );
  4491. itemWithLeastDistance = this.items[ j ];
  4492. this.direction = nearBottom ? "up": "down";
  4493. }
  4494. }
  4495. //Check if dropOnEmpty is enabled
  4496. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  4497. return;
  4498. }
  4499. if(this.currentContainer === this.containers[innermostIndex]) {
  4500. if ( !this.currentContainer.containerCache.over ) {
  4501. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  4502. this.currentContainer.containerCache.over = 1;
  4503. }
  4504. return;
  4505. }
  4506. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  4507. this._trigger("change", event, this._uiHash());
  4508. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  4509. this.currentContainer = this.containers[innermostIndex];
  4510. //Update the placeholder
  4511. this.options.placeholder.update(this.currentContainer, this.placeholder);
  4512. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4513. this.containers[innermostIndex].containerCache.over = 1;
  4514. }
  4515. },
  4516. _createHelper: function(event) {
  4517. var o = this.options,
  4518. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  4519. //Add the helper to the DOM if that didn't happen already
  4520. if(!helper.parents("body").length) {
  4521. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  4522. }
  4523. if(helper[0] === this.currentItem[0]) {
  4524. 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") };
  4525. }
  4526. if(!helper[0].style.width || o.forceHelperSize) {
  4527. helper.width(this.currentItem.width());
  4528. }
  4529. if(!helper[0].style.height || o.forceHelperSize) {
  4530. helper.height(this.currentItem.height());
  4531. }
  4532. return helper;
  4533. },
  4534. _adjustOffsetFromHelper: function(obj) {
  4535. if (typeof obj === "string") {
  4536. obj = obj.split(" ");
  4537. }
  4538. if ($.isArray(obj)) {
  4539. obj = {left: +obj[0], top: +obj[1] || 0};
  4540. }
  4541. if ("left" in obj) {
  4542. this.offset.click.left = obj.left + this.margins.left;
  4543. }
  4544. if ("right" in obj) {
  4545. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  4546. }
  4547. if ("top" in obj) {
  4548. this.offset.click.top = obj.top + this.margins.top;
  4549. }
  4550. if ("bottom" in obj) {
  4551. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  4552. }
  4553. },
  4554. _getParentOffset: function() {
  4555. //Get the offsetParent and cache its position
  4556. this.offsetParent = this.helper.offsetParent();
  4557. var po = this.offsetParent.offset();
  4558. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  4559. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  4560. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  4561. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  4562. if(this.cssPosition === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  4563. po.left += this.scrollParent.scrollLeft();
  4564. po.top += this.scrollParent.scrollTop();
  4565. }
  4566. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  4567. // with an ugly IE fix
  4568. if( this.offsetParent[0] === this.document[0].body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  4569. po = { top: 0, left: 0 };
  4570. }
  4571. return {
  4572. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  4573. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  4574. };
  4575. },
  4576. _getRelativeOffset: function() {
  4577. if(this.cssPosition === "relative") {
  4578. var p = this.currentItem.position();
  4579. return {
  4580. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  4581. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  4582. };
  4583. } else {
  4584. return { top: 0, left: 0 };
  4585. }
  4586. },
  4587. _cacheMargins: function() {
  4588. this.margins = {
  4589. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  4590. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  4591. };
  4592. },
  4593. _cacheHelperProportions: function() {
  4594. this.helperProportions = {
  4595. width: this.helper.outerWidth(),
  4596. height: this.helper.outerHeight()
  4597. };
  4598. },
  4599. _setContainment: function() {
  4600. var ce, co, over,
  4601. o = this.options;
  4602. if(o.containment === "parent") {
  4603. o.containment = this.helper[0].parentNode;
  4604. }
  4605. if(o.containment === "document" || o.containment === "window") {
  4606. this.containment = [
  4607. 0 - this.offset.relative.left - this.offset.parent.left,
  4608. 0 - this.offset.relative.top - this.offset.parent.top,
  4609. o.containment === "document" ? this.document.width() : this.window.width() - this.helperProportions.width - this.margins.left,
  4610. (o.containment === "document" ? this.document.width() : this.window.height() || this.document[0].body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  4611. ];
  4612. }
  4613. if(!(/^(document|window|parent)$/).test(o.containment)) {
  4614. ce = $(o.containment)[0];
  4615. co = $(o.containment).offset();
  4616. over = ($(ce).css("overflow") !== "hidden");
  4617. this.containment = [
  4618. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  4619. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  4620. 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,
  4621. 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
  4622. ];
  4623. }
  4624. },
  4625. _convertPositionTo: function(d, pos) {
  4626. if(!pos) {
  4627. pos = this.position;
  4628. }
  4629. var mod = d === "absolute" ? 1 : -1,
  4630. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  4631. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  4632. return {
  4633. top: (
  4634. pos.top + // The absolute mouse position
  4635. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4636. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  4637. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  4638. ),
  4639. left: (
  4640. pos.left + // The absolute mouse position
  4641. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4642. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  4643. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  4644. )
  4645. };
  4646. },
  4647. _generatePosition: function(event) {
  4648. var top, left,
  4649. o = this.options,
  4650. pageX = event.pageX,
  4651. pageY = event.pageY,
  4652. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  4653. // This is another very weird special case that only happens for relative elements:
  4654. // 1. If the css position is relative
  4655. // 2. and the scroll parent is the document or similar to the offset parent
  4656. // we have to refresh the relative offset during the scroll so there are no jumps
  4657. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== this.document[0] && this.scrollParent[0] !== this.offsetParent[0])) {
  4658. this.offset.relative = this._getRelativeOffset();
  4659. }
  4660. /*
  4661. * - Position constraining -
  4662. * Constrain the position to a mix of grid, containment.
  4663. */
  4664. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  4665. if(this.containment) {
  4666. if(event.pageX - this.offset.click.left < this.containment[0]) {
  4667. pageX = this.containment[0] + this.offset.click.left;
  4668. }
  4669. if(event.pageY - this.offset.click.top < this.containment[1]) {
  4670. pageY = this.containment[1] + this.offset.click.top;
  4671. }
  4672. if(event.pageX - this.offset.click.left > this.containment[2]) {
  4673. pageX = this.containment[2] + this.offset.click.left;
  4674. }
  4675. if(event.pageY - this.offset.click.top > this.containment[3]) {
  4676. pageY = this.containment[3] + this.offset.click.top;
  4677. }
  4678. }
  4679. if(o.grid) {
  4680. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  4681. 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;
  4682. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  4683. 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;
  4684. }
  4685. }
  4686. return {
  4687. top: (
  4688. pageY - // The absolute mouse position
  4689. this.offset.click.top - // Click offset (relative to the element)
  4690. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  4691. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  4692. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  4693. ),
  4694. left: (
  4695. pageX - // The absolute mouse position
  4696. this.offset.click.left - // Click offset (relative to the element)
  4697. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  4698. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  4699. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  4700. )
  4701. };
  4702. },
  4703. _rearrange: function(event, i, a, hardRefresh) {
  4704. 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));
  4705. //Various things done here to improve the performance:
  4706. // 1. we create a setTimeout, that calls refreshPositions
  4707. // 2. on the instance, we have a counter variable, that get's higher after every append
  4708. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  4709. // 4. this lets only the last addition to the timeout stack through
  4710. this.counter = this.counter ? ++this.counter : 1;
  4711. var counter = this.counter;
  4712. this._delay(function() {
  4713. if(counter === this.counter) {
  4714. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  4715. }
  4716. });
  4717. },
  4718. _clear: function(event, noPropagation) {
  4719. this.reverting = false;
  4720. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  4721. // everything else normalized again
  4722. var i,
  4723. delayedTriggers = [];
  4724. // We first have to update the dom position of the actual currentItem
  4725. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  4726. if(!this._noFinalSort && this.currentItem.parent().length) {
  4727. this.placeholder.before(this.currentItem);
  4728. }
  4729. this._noFinalSort = null;
  4730. if(this.helper[0] === this.currentItem[0]) {
  4731. for(i in this._storedCSS) {
  4732. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  4733. this._storedCSS[i] = "";
  4734. }
  4735. }
  4736. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  4737. } else {
  4738. this.currentItem.show();
  4739. }
  4740. if(this.fromOutside && !noPropagation) {
  4741. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  4742. }
  4743. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  4744. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  4745. }
  4746. // Check if the items Container has Changed and trigger appropriate
  4747. // events.
  4748. if (this !== this.currentContainer) {
  4749. if(!noPropagation) {
  4750. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  4751. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4752. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4753. }
  4754. }
  4755. //Post events to containers
  4756. function delayEvent( type, instance, container ) {
  4757. return function( event ) {
  4758. container._trigger( type, event, instance._uiHash( instance ) );
  4759. };
  4760. }
  4761. for (i = this.containers.length - 1; i >= 0; i--){
  4762. if (!noPropagation) {
  4763. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  4764. }
  4765. if(this.containers[i].containerCache.over) {
  4766. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  4767. this.containers[i].containerCache.over = 0;
  4768. }
  4769. }
  4770. //Do what was originally in plugins
  4771. if ( this.storedCursor ) {
  4772. this.document.find( "body" ).css( "cursor", this.storedCursor );
  4773. this.storedStylesheet.remove();
  4774. }
  4775. if(this._storedOpacity) {
  4776. this.helper.css("opacity", this._storedOpacity);
  4777. }
  4778. if(this._storedZIndex) {
  4779. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  4780. }
  4781. this.dragging = false;
  4782. if(!noPropagation) {
  4783. this._trigger("beforeStop", event, this._uiHash());
  4784. }
  4785. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  4786. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  4787. if ( !this.cancelHelperRemoval ) {
  4788. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  4789. this.helper.remove();
  4790. }
  4791. this.helper = null;
  4792. }
  4793. if(!noPropagation) {
  4794. for (i=0; i < delayedTriggers.length; i++) {
  4795. delayedTriggers[i].call(this, event);
  4796. } //Trigger all delayed events
  4797. this._trigger("stop", event, this._uiHash());
  4798. }
  4799. this.fromOutside = false;
  4800. return !this.cancelHelperRemoval;
  4801. },
  4802. _trigger: function() {
  4803. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  4804. this.cancel();
  4805. }
  4806. },
  4807. _uiHash: function(_inst) {
  4808. var inst = _inst || this;
  4809. return {
  4810. helper: inst.helper,
  4811. placeholder: inst.placeholder || $([]),
  4812. position: inst.position,
  4813. originalPosition: inst.originalPosition,
  4814. offset: inst.positionAbs,
  4815. item: inst.currentItem,
  4816. sender: _inst ? _inst.element : null
  4817. };
  4818. }
  4819. });
  4820. /*!
  4821. * jQuery UI Accordion 1.11.3
  4822. * http://jqueryui.com
  4823. *
  4824. * Copyright jQuery Foundation and other contributors
  4825. * Released under the MIT license.
  4826. * http://jquery.org/license
  4827. *
  4828. * http://api.jqueryui.com/accordion/
  4829. */
  4830. var accordion = $.widget( "ui.accordion", {
  4831. version: "1.11.3",
  4832. options: {
  4833. active: 0,
  4834. animate: {},
  4835. collapsible: false,
  4836. event: "click",
  4837. header: "> li > :first-child,> :not(li):even",
  4838. heightStyle: "auto",
  4839. icons: {
  4840. activeHeader: "ui-icon-triangle-1-s",
  4841. header: "ui-icon-triangle-1-e"
  4842. },
  4843. // callbacks
  4844. activate: null,
  4845. beforeActivate: null
  4846. },
  4847. hideProps: {
  4848. borderTopWidth: "hide",
  4849. borderBottomWidth: "hide",
  4850. paddingTop: "hide",
  4851. paddingBottom: "hide",
  4852. height: "hide"
  4853. },
  4854. showProps: {
  4855. borderTopWidth: "show",
  4856. borderBottomWidth: "show",
  4857. paddingTop: "show",
  4858. paddingBottom: "show",
  4859. height: "show"
  4860. },
  4861. _create: function() {
  4862. var options = this.options;
  4863. this.prevShow = this.prevHide = $();
  4864. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  4865. // ARIA
  4866. .attr( "role", "tablist" );
  4867. // don't allow collapsible: false and active: false / null
  4868. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  4869. options.active = 0;
  4870. }
  4871. this._processPanels();
  4872. // handle negative values
  4873. if ( options.active < 0 ) {
  4874. options.active += this.headers.length;
  4875. }
  4876. this._refresh();
  4877. },
  4878. _getCreateEventData: function() {
  4879. return {
  4880. header: this.active,
  4881. panel: !this.active.length ? $() : this.active.next()
  4882. };
  4883. },
  4884. _createIcons: function() {
  4885. var icons = this.options.icons;
  4886. if ( icons ) {
  4887. $( "<span>" )
  4888. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  4889. .prependTo( this.headers );
  4890. this.active.children( ".ui-accordion-header-icon" )
  4891. .removeClass( icons.header )
  4892. .addClass( icons.activeHeader );
  4893. this.headers.addClass( "ui-accordion-icons" );
  4894. }
  4895. },
  4896. _destroyIcons: function() {
  4897. this.headers
  4898. .removeClass( "ui-accordion-icons" )
  4899. .children( ".ui-accordion-header-icon" )
  4900. .remove();
  4901. },
  4902. _destroy: function() {
  4903. var contents;
  4904. // clean up main element
  4905. this.element
  4906. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  4907. .removeAttr( "role" );
  4908. // clean up headers
  4909. this.headers
  4910. .removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " +
  4911. "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
  4912. .removeAttr( "role" )
  4913. .removeAttr( "aria-expanded" )
  4914. .removeAttr( "aria-selected" )
  4915. .removeAttr( "aria-controls" )
  4916. .removeAttr( "tabIndex" )
  4917. .removeUniqueId();
  4918. this._destroyIcons();
  4919. // clean up content panels
  4920. contents = this.headers.next()
  4921. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " +
  4922. "ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  4923. .css( "display", "" )
  4924. .removeAttr( "role" )
  4925. .removeAttr( "aria-hidden" )
  4926. .removeAttr( "aria-labelledby" )
  4927. .removeUniqueId();
  4928. if ( this.options.heightStyle !== "content" ) {
  4929. contents.css( "height", "" );
  4930. }
  4931. },
  4932. _setOption: function( key, value ) {
  4933. if ( key === "active" ) {
  4934. // _activate() will handle invalid values and update this.options
  4935. this._activate( value );
  4936. return;
  4937. }
  4938. if ( key === "event" ) {
  4939. if ( this.options.event ) {
  4940. this._off( this.headers, this.options.event );
  4941. }
  4942. this._setupEvents( value );
  4943. }
  4944. this._super( key, value );
  4945. // setting collapsible: false while collapsed; open first panel
  4946. if ( key === "collapsible" && !value && this.options.active === false ) {
  4947. this._activate( 0 );
  4948. }
  4949. if ( key === "icons" ) {
  4950. this._destroyIcons();
  4951. if ( value ) {
  4952. this._createIcons();
  4953. }
  4954. }
  4955. // #5332 - opacity doesn't cascade to positioned elements in IE
  4956. // so we need to add the disabled class to the headers and panels
  4957. if ( key === "disabled" ) {
  4958. this.element
  4959. .toggleClass( "ui-state-disabled", !!value )
  4960. .attr( "aria-disabled", value );
  4961. this.headers.add( this.headers.next() )
  4962. .toggleClass( "ui-state-disabled", !!value );
  4963. }
  4964. },
  4965. _keydown: function( event ) {
  4966. if ( event.altKey || event.ctrlKey ) {
  4967. return;
  4968. }
  4969. var keyCode = $.ui.keyCode,
  4970. length = this.headers.length,
  4971. currentIndex = this.headers.index( event.target ),
  4972. toFocus = false;
  4973. switch ( event.keyCode ) {
  4974. case keyCode.RIGHT:
  4975. case keyCode.DOWN:
  4976. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  4977. break;
  4978. case keyCode.LEFT:
  4979. case keyCode.UP:
  4980. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  4981. break;
  4982. case keyCode.SPACE:
  4983. case keyCode.ENTER:
  4984. this._eventHandler( event );
  4985. break;
  4986. case keyCode.HOME:
  4987. toFocus = this.headers[ 0 ];
  4988. break;
  4989. case keyCode.END:
  4990. toFocus = this.headers[ length - 1 ];
  4991. break;
  4992. }
  4993. if ( toFocus ) {
  4994. $( event.target ).attr( "tabIndex", -1 );
  4995. $( toFocus ).attr( "tabIndex", 0 );
  4996. toFocus.focus();
  4997. event.preventDefault();
  4998. }
  4999. },
  5000. _panelKeyDown: function( event ) {
  5001. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  5002. $( event.currentTarget ).prev().focus();
  5003. }
  5004. },
  5005. refresh: function() {
  5006. var options = this.options;
  5007. this._processPanels();
  5008. // was collapsed or no panel
  5009. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  5010. options.active = false;
  5011. this.active = $();
  5012. // active false only when collapsible is true
  5013. } else if ( options.active === false ) {
  5014. this._activate( 0 );
  5015. // was active, but active panel is gone
  5016. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5017. // all remaining panel are disabled
  5018. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  5019. options.active = false;
  5020. this.active = $();
  5021. // activate previous panel
  5022. } else {
  5023. this._activate( Math.max( 0, options.active - 1 ) );
  5024. }
  5025. // was active, active panel still exists
  5026. } else {
  5027. // make sure active index is correct
  5028. options.active = this.headers.index( this.active );
  5029. }
  5030. this._destroyIcons();
  5031. this._refresh();
  5032. },
  5033. _processPanels: function() {
  5034. var prevHeaders = this.headers,
  5035. prevPanels = this.panels;
  5036. this.headers = this.element.find( this.options.header )
  5037. .addClass( "ui-accordion-header ui-state-default ui-corner-all" );
  5038. this.panels = this.headers.next()
  5039. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  5040. .filter( ":not(.ui-accordion-content-active)" )
  5041. .hide();
  5042. // Avoid memory leaks (#10056)
  5043. if ( prevPanels ) {
  5044. this._off( prevHeaders.not( this.headers ) );
  5045. this._off( prevPanels.not( this.panels ) );
  5046. }
  5047. },
  5048. _refresh: function() {
  5049. var maxHeight,
  5050. options = this.options,
  5051. heightStyle = options.heightStyle,
  5052. parent = this.element.parent();
  5053. this.active = this._findActive( options.active )
  5054. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  5055. .removeClass( "ui-corner-all" );
  5056. this.active.next()
  5057. .addClass( "ui-accordion-content-active" )
  5058. .show();
  5059. this.headers
  5060. .attr( "role", "tab" )
  5061. .each(function() {
  5062. var header = $( this ),
  5063. headerId = header.uniqueId().attr( "id" ),
  5064. panel = header.next(),
  5065. panelId = panel.uniqueId().attr( "id" );
  5066. header.attr( "aria-controls", panelId );
  5067. panel.attr( "aria-labelledby", headerId );
  5068. })
  5069. .next()
  5070. .attr( "role", "tabpanel" );
  5071. this.headers
  5072. .not( this.active )
  5073. .attr({
  5074. "aria-selected": "false",
  5075. "aria-expanded": "false",
  5076. tabIndex: -1
  5077. })
  5078. .next()
  5079. .attr({
  5080. "aria-hidden": "true"
  5081. })
  5082. .hide();
  5083. // make sure at least one header is in the tab order
  5084. if ( !this.active.length ) {
  5085. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  5086. } else {
  5087. this.active.attr({
  5088. "aria-selected": "true",
  5089. "aria-expanded": "true",
  5090. tabIndex: 0
  5091. })
  5092. .next()
  5093. .attr({
  5094. "aria-hidden": "false"
  5095. });
  5096. }
  5097. this._createIcons();
  5098. this._setupEvents( options.event );
  5099. if ( heightStyle === "fill" ) {
  5100. maxHeight = parent.height();
  5101. this.element.siblings( ":visible" ).each(function() {
  5102. var elem = $( this ),
  5103. position = elem.css( "position" );
  5104. if ( position === "absolute" || position === "fixed" ) {
  5105. return;
  5106. }
  5107. maxHeight -= elem.outerHeight( true );
  5108. });
  5109. this.headers.each(function() {
  5110. maxHeight -= $( this ).outerHeight( true );
  5111. });
  5112. this.headers.next()
  5113. .each(function() {
  5114. $( this ).height( Math.max( 0, maxHeight -
  5115. $( this ).innerHeight() + $( this ).height() ) );
  5116. })
  5117. .css( "overflow", "auto" );
  5118. } else if ( heightStyle === "auto" ) {
  5119. maxHeight = 0;
  5120. this.headers.next()
  5121. .each(function() {
  5122. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  5123. })
  5124. .height( maxHeight );
  5125. }
  5126. },
  5127. _activate: function( index ) {
  5128. var active = this._findActive( index )[ 0 ];
  5129. // trying to activate the already active panel
  5130. if ( active === this.active[ 0 ] ) {
  5131. return;
  5132. }
  5133. // trying to collapse, simulate a click on the currently active header
  5134. active = active || this.active[ 0 ];
  5135. this._eventHandler({
  5136. target: active,
  5137. currentTarget: active,
  5138. preventDefault: $.noop
  5139. });
  5140. },
  5141. _findActive: function( selector ) {
  5142. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  5143. },
  5144. _setupEvents: function( event ) {
  5145. var events = {
  5146. keydown: "_keydown"
  5147. };
  5148. if ( event ) {
  5149. $.each( event.split( " " ), function( index, eventName ) {
  5150. events[ eventName ] = "_eventHandler";
  5151. });
  5152. }
  5153. this._off( this.headers.add( this.headers.next() ) );
  5154. this._on( this.headers, events );
  5155. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  5156. this._hoverable( this.headers );
  5157. this._focusable( this.headers );
  5158. },
  5159. _eventHandler: function( event ) {
  5160. var options = this.options,
  5161. active = this.active,
  5162. clicked = $( event.currentTarget ),
  5163. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  5164. collapsing = clickedIsActive && options.collapsible,
  5165. toShow = collapsing ? $() : clicked.next(),
  5166. toHide = active.next(),
  5167. eventData = {
  5168. oldHeader: active,
  5169. oldPanel: toHide,
  5170. newHeader: collapsing ? $() : clicked,
  5171. newPanel: toShow
  5172. };
  5173. event.preventDefault();
  5174. if (
  5175. // click on active header, but not collapsible
  5176. ( clickedIsActive && !options.collapsible ) ||
  5177. // allow canceling activation
  5178. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  5179. return;
  5180. }
  5181. options.active = collapsing ? false : this.headers.index( clicked );
  5182. // when the call to ._toggle() comes after the class changes
  5183. // it causes a very odd bug in IE 8 (see #6720)
  5184. this.active = clickedIsActive ? $() : clicked;
  5185. this._toggle( eventData );
  5186. // switch classes
  5187. // corner classes on the previously active header stay after the animation
  5188. active.removeClass( "ui-accordion-header-active ui-state-active" );
  5189. if ( options.icons ) {
  5190. active.children( ".ui-accordion-header-icon" )
  5191. .removeClass( options.icons.activeHeader )
  5192. .addClass( options.icons.header );
  5193. }
  5194. if ( !clickedIsActive ) {
  5195. clicked
  5196. .removeClass( "ui-corner-all" )
  5197. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  5198. if ( options.icons ) {
  5199. clicked.children( ".ui-accordion-header-icon" )
  5200. .removeClass( options.icons.header )
  5201. .addClass( options.icons.activeHeader );
  5202. }
  5203. clicked
  5204. .next()
  5205. .addClass( "ui-accordion-content-active" );
  5206. }
  5207. },
  5208. _toggle: function( data ) {
  5209. var toShow = data.newPanel,
  5210. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  5211. // handle activating a panel during the animation for another activation
  5212. this.prevShow.add( this.prevHide ).stop( true, true );
  5213. this.prevShow = toShow;
  5214. this.prevHide = toHide;
  5215. if ( this.options.animate ) {
  5216. this._animate( toShow, toHide, data );
  5217. } else {
  5218. toHide.hide();
  5219. toShow.show();
  5220. this._toggleComplete( data );
  5221. }
  5222. toHide.attr({
  5223. "aria-hidden": "true"
  5224. });
  5225. toHide.prev().attr({
  5226. "aria-selected": "false",
  5227. "aria-expanded": "false"
  5228. });
  5229. // if we're switching panels, remove the old header from the tab order
  5230. // if we're opening from collapsed state, remove the previous header from the tab order
  5231. // if we're collapsing, then keep the collapsing header in the tab order
  5232. if ( toShow.length && toHide.length ) {
  5233. toHide.prev().attr({
  5234. "tabIndex": -1,
  5235. "aria-expanded": "false"
  5236. });
  5237. } else if ( toShow.length ) {
  5238. this.headers.filter(function() {
  5239. return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0;
  5240. })
  5241. .attr( "tabIndex", -1 );
  5242. }
  5243. toShow
  5244. .attr( "aria-hidden", "false" )
  5245. .prev()
  5246. .attr({
  5247. "aria-selected": "true",
  5248. "aria-expanded": "true",
  5249. tabIndex: 0
  5250. });
  5251. },
  5252. _animate: function( toShow, toHide, data ) {
  5253. var total, easing, duration,
  5254. that = this,
  5255. adjust = 0,
  5256. down = toShow.length &&
  5257. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  5258. animate = this.options.animate || {},
  5259. options = down && animate.down || animate,
  5260. complete = function() {
  5261. that._toggleComplete( data );
  5262. };
  5263. if ( typeof options === "number" ) {
  5264. duration = options;
  5265. }
  5266. if ( typeof options === "string" ) {
  5267. easing = options;
  5268. }
  5269. // fall back from options to animation in case of partial down settings
  5270. easing = easing || options.easing || animate.easing;
  5271. duration = duration || options.duration || animate.duration;
  5272. if ( !toHide.length ) {
  5273. return toShow.animate( this.showProps, duration, easing, complete );
  5274. }
  5275. if ( !toShow.length ) {
  5276. return toHide.animate( this.hideProps, duration, easing, complete );
  5277. }
  5278. total = toShow.show().outerHeight();
  5279. toHide.animate( this.hideProps, {
  5280. duration: duration,
  5281. easing: easing,
  5282. step: function( now, fx ) {
  5283. fx.now = Math.round( now );
  5284. }
  5285. });
  5286. toShow
  5287. .hide()
  5288. .animate( this.showProps, {
  5289. duration: duration,
  5290. easing: easing,
  5291. complete: complete,
  5292. step: function( now, fx ) {
  5293. fx.now = Math.round( now );
  5294. if ( fx.prop !== "height" ) {
  5295. adjust += fx.now;
  5296. } else if ( that.options.heightStyle !== "content" ) {
  5297. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  5298. adjust = 0;
  5299. }
  5300. }
  5301. });
  5302. },
  5303. _toggleComplete: function( data ) {
  5304. var toHide = data.oldPanel;
  5305. toHide
  5306. .removeClass( "ui-accordion-content-active" )
  5307. .prev()
  5308. .removeClass( "ui-corner-top" )
  5309. .addClass( "ui-corner-all" );
  5310. // Work around for rendering bug in IE (#5421)
  5311. if ( toHide.length ) {
  5312. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  5313. }
  5314. this._trigger( "activate", null, data );
  5315. }
  5316. });
  5317. /*!
  5318. * jQuery UI Menu 1.11.3
  5319. * http://jqueryui.com
  5320. *
  5321. * Copyright jQuery Foundation and other contributors
  5322. * Released under the MIT license.
  5323. * http://jquery.org/license
  5324. *
  5325. * http://api.jqueryui.com/menu/
  5326. */
  5327. var menu = $.widget( "ui.menu", {
  5328. version: "1.11.3",
  5329. defaultElement: "<ul>",
  5330. delay: 300,
  5331. options: {
  5332. icons: {
  5333. submenu: "ui-icon-carat-1-e"
  5334. },
  5335. items: "> *",
  5336. menus: "ul",
  5337. position: {
  5338. my: "left-1 top",
  5339. at: "right top"
  5340. },
  5341. role: "menu",
  5342. // callbacks
  5343. blur: null,
  5344. focus: null,
  5345. select: null
  5346. },
  5347. _create: function() {
  5348. this.activeMenu = this.element;
  5349. // Flag used to prevent firing of the click handler
  5350. // as the event bubbles up through nested menus
  5351. this.mouseHandled = false;
  5352. this.element
  5353. .uniqueId()
  5354. .addClass( "ui-menu ui-widget ui-widget-content" )
  5355. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  5356. .attr({
  5357. role: this.options.role,
  5358. tabIndex: 0
  5359. });
  5360. if ( this.options.disabled ) {
  5361. this.element
  5362. .addClass( "ui-state-disabled" )
  5363. .attr( "aria-disabled", "true" );
  5364. }
  5365. this._on({
  5366. // Prevent focus from sticking to links inside menu after clicking
  5367. // them (focus should always stay on UL during navigation).
  5368. "mousedown .ui-menu-item": function( event ) {
  5369. event.preventDefault();
  5370. },
  5371. "click .ui-menu-item": function( event ) {
  5372. var target = $( event.target );
  5373. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  5374. this.select( event );
  5375. // Only set the mouseHandled flag if the event will bubble, see #9469.
  5376. if ( !event.isPropagationStopped() ) {
  5377. this.mouseHandled = true;
  5378. }
  5379. // Open submenu on click
  5380. if ( target.has( ".ui-menu" ).length ) {
  5381. this.expand( event );
  5382. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  5383. // Redirect focus to the menu
  5384. this.element.trigger( "focus", [ true ] );
  5385. // If the active item is on the top level, let it stay active.
  5386. // Otherwise, blur the active item since it is no longer visible.
  5387. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  5388. clearTimeout( this.timer );
  5389. }
  5390. }
  5391. }
  5392. },
  5393. "mouseenter .ui-menu-item": function( event ) {
  5394. // Ignore mouse events while typeahead is active, see #10458.
  5395. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  5396. // is over an item in the menu
  5397. if ( this.previousFilter ) {
  5398. return;
  5399. }
  5400. var target = $( event.currentTarget );
  5401. // Remove ui-state-active class from siblings of the newly focused menu item
  5402. // to avoid a jump caused by adjacent elements both having a class with a border
  5403. target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
  5404. this.focus( event, target );
  5405. },
  5406. mouseleave: "collapseAll",
  5407. "mouseleave .ui-menu": "collapseAll",
  5408. focus: function( event, keepActiveItem ) {
  5409. // If there's already an active item, keep it active
  5410. // If not, activate the first item
  5411. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  5412. if ( !keepActiveItem ) {
  5413. this.focus( event, item );
  5414. }
  5415. },
  5416. blur: function( event ) {
  5417. this._delay(function() {
  5418. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  5419. this.collapseAll( event );
  5420. }
  5421. });
  5422. },
  5423. keydown: "_keydown"
  5424. });
  5425. this.refresh();
  5426. // Clicks outside of a menu collapse any open menus
  5427. this._on( this.document, {
  5428. click: function( event ) {
  5429. if ( this._closeOnDocumentClick( event ) ) {
  5430. this.collapseAll( event );
  5431. }
  5432. // Reset the mouseHandled flag
  5433. this.mouseHandled = false;
  5434. }
  5435. });
  5436. },
  5437. _destroy: function() {
  5438. // Destroy (sub)menus
  5439. this.element
  5440. .removeAttr( "aria-activedescendant" )
  5441. .find( ".ui-menu" ).addBack()
  5442. .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
  5443. .removeAttr( "role" )
  5444. .removeAttr( "tabIndex" )
  5445. .removeAttr( "aria-labelledby" )
  5446. .removeAttr( "aria-expanded" )
  5447. .removeAttr( "aria-hidden" )
  5448. .removeAttr( "aria-disabled" )
  5449. .removeUniqueId()
  5450. .show();
  5451. // Destroy menu items
  5452. this.element.find( ".ui-menu-item" )
  5453. .removeClass( "ui-menu-item" )
  5454. .removeAttr( "role" )
  5455. .removeAttr( "aria-disabled" )
  5456. .removeUniqueId()
  5457. .removeClass( "ui-state-hover" )
  5458. .removeAttr( "tabIndex" )
  5459. .removeAttr( "role" )
  5460. .removeAttr( "aria-haspopup" )
  5461. .children().each( function() {
  5462. var elem = $( this );
  5463. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  5464. elem.remove();
  5465. }
  5466. });
  5467. // Destroy menu dividers
  5468. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  5469. },
  5470. _keydown: function( event ) {
  5471. var match, prev, character, skip,
  5472. preventDefault = true;
  5473. switch ( event.keyCode ) {
  5474. case $.ui.keyCode.PAGE_UP:
  5475. this.previousPage( event );
  5476. break;
  5477. case $.ui.keyCode.PAGE_DOWN:
  5478. this.nextPage( event );
  5479. break;
  5480. case $.ui.keyCode.HOME:
  5481. this._move( "first", "first", event );
  5482. break;
  5483. case $.ui.keyCode.END:
  5484. this._move( "last", "last", event );
  5485. break;
  5486. case $.ui.keyCode.UP:
  5487. this.previous( event );
  5488. break;
  5489. case $.ui.keyCode.DOWN:
  5490. this.next( event );
  5491. break;
  5492. case $.ui.keyCode.LEFT:
  5493. this.collapse( event );
  5494. break;
  5495. case $.ui.keyCode.RIGHT:
  5496. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  5497. this.expand( event );
  5498. }
  5499. break;
  5500. case $.ui.keyCode.ENTER:
  5501. case $.ui.keyCode.SPACE:
  5502. this._activate( event );
  5503. break;
  5504. case $.ui.keyCode.ESCAPE:
  5505. this.collapse( event );
  5506. break;
  5507. default:
  5508. preventDefault = false;
  5509. prev = this.previousFilter || "";
  5510. character = String.fromCharCode( event.keyCode );
  5511. skip = false;
  5512. clearTimeout( this.filterTimer );
  5513. if ( character === prev ) {
  5514. skip = true;
  5515. } else {
  5516. character = prev + character;
  5517. }
  5518. match = this._filterMenuItems( character );
  5519. match = skip && match.index( this.active.next() ) !== -1 ?
  5520. this.active.nextAll( ".ui-menu-item" ) :
  5521. match;
  5522. // If no matches on the current filter, reset to the last character pressed
  5523. // to move down the menu to the first item that starts with that character
  5524. if ( !match.length ) {
  5525. character = String.fromCharCode( event.keyCode );
  5526. match = this._filterMenuItems( character );
  5527. }
  5528. if ( match.length ) {
  5529. this.focus( event, match );
  5530. this.previousFilter = character;
  5531. this.filterTimer = this._delay(function() {
  5532. delete this.previousFilter;
  5533. }, 1000 );
  5534. } else {
  5535. delete this.previousFilter;
  5536. }
  5537. }
  5538. if ( preventDefault ) {
  5539. event.preventDefault();
  5540. }
  5541. },
  5542. _activate: function( event ) {
  5543. if ( !this.active.is( ".ui-state-disabled" ) ) {
  5544. if ( this.active.is( "[aria-haspopup='true']" ) ) {
  5545. this.expand( event );
  5546. } else {
  5547. this.select( event );
  5548. }
  5549. }
  5550. },
  5551. refresh: function() {
  5552. var menus, items,
  5553. that = this,
  5554. icon = this.options.icons.submenu,
  5555. submenus = this.element.find( this.options.menus );
  5556. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  5557. // Initialize nested menus
  5558. submenus.filter( ":not(.ui-menu)" )
  5559. .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
  5560. .hide()
  5561. .attr({
  5562. role: this.options.role,
  5563. "aria-hidden": "true",
  5564. "aria-expanded": "false"
  5565. })
  5566. .each(function() {
  5567. var menu = $( this ),
  5568. item = menu.parent(),
  5569. submenuCarat = $( "<span>" )
  5570. .addClass( "ui-menu-icon ui-icon " + icon )
  5571. .data( "ui-menu-submenu-carat", true );
  5572. item
  5573. .attr( "aria-haspopup", "true" )
  5574. .prepend( submenuCarat );
  5575. menu.attr( "aria-labelledby", item.attr( "id" ) );
  5576. });
  5577. menus = submenus.add( this.element );
  5578. items = menus.find( this.options.items );
  5579. // Initialize menu-items containing spaces and/or dashes only as dividers
  5580. items.not( ".ui-menu-item" ).each(function() {
  5581. var item = $( this );
  5582. if ( that._isDivider( item ) ) {
  5583. item.addClass( "ui-widget-content ui-menu-divider" );
  5584. }
  5585. });
  5586. // Don't refresh list items that are already adapted
  5587. items.not( ".ui-menu-item, .ui-menu-divider" )
  5588. .addClass( "ui-menu-item" )
  5589. .uniqueId()
  5590. .attr({
  5591. tabIndex: -1,
  5592. role: this._itemRole()
  5593. });
  5594. // Add aria-disabled attribute to any disabled menu item
  5595. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  5596. // If the active item has been removed, blur the menu
  5597. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5598. this.blur();
  5599. }
  5600. },
  5601. _itemRole: function() {
  5602. return {
  5603. menu: "menuitem",
  5604. listbox: "option"
  5605. }[ this.options.role ];
  5606. },
  5607. _setOption: function( key, value ) {
  5608. if ( key === "icons" ) {
  5609. this.element.find( ".ui-menu-icon" )
  5610. .removeClass( this.options.icons.submenu )
  5611. .addClass( value.submenu );
  5612. }
  5613. if ( key === "disabled" ) {
  5614. this.element
  5615. .toggleClass( "ui-state-disabled", !!value )
  5616. .attr( "aria-disabled", value );
  5617. }
  5618. this._super( key, value );
  5619. },
  5620. focus: function( event, item ) {
  5621. var nested, focused;
  5622. this.blur( event, event && event.type === "focus" );
  5623. this._scrollIntoView( item );
  5624. this.active = item.first();
  5625. focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
  5626. // Only update aria-activedescendant if there's a role
  5627. // otherwise we assume focus is managed elsewhere
  5628. if ( this.options.role ) {
  5629. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  5630. }
  5631. // Highlight active parent menu item, if any
  5632. this.active
  5633. .parent()
  5634. .closest( ".ui-menu-item" )
  5635. .addClass( "ui-state-active" );
  5636. if ( event && event.type === "keydown" ) {
  5637. this._close();
  5638. } else {
  5639. this.timer = this._delay(function() {
  5640. this._close();
  5641. }, this.delay );
  5642. }
  5643. nested = item.children( ".ui-menu" );
  5644. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  5645. this._startOpening(nested);
  5646. }
  5647. this.activeMenu = item.parent();
  5648. this._trigger( "focus", event, { item: item } );
  5649. },
  5650. _scrollIntoView: function( item ) {
  5651. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  5652. if ( this._hasScroll() ) {
  5653. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  5654. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  5655. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  5656. scroll = this.activeMenu.scrollTop();
  5657. elementHeight = this.activeMenu.height();
  5658. itemHeight = item.outerHeight();
  5659. if ( offset < 0 ) {
  5660. this.activeMenu.scrollTop( scroll + offset );
  5661. } else if ( offset + itemHeight > elementHeight ) {
  5662. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  5663. }
  5664. }
  5665. },
  5666. blur: function( event, fromFocus ) {
  5667. if ( !fromFocus ) {
  5668. clearTimeout( this.timer );
  5669. }
  5670. if ( !this.active ) {
  5671. return;
  5672. }
  5673. this.active.removeClass( "ui-state-focus" );
  5674. this.active = null;
  5675. this._trigger( "blur", event, { item: this.active } );
  5676. },
  5677. _startOpening: function( submenu ) {
  5678. clearTimeout( this.timer );
  5679. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  5680. // shift in the submenu position when mousing over the carat icon
  5681. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  5682. return;
  5683. }
  5684. this.timer = this._delay(function() {
  5685. this._close();
  5686. this._open( submenu );
  5687. }, this.delay );
  5688. },
  5689. _open: function( submenu ) {
  5690. var position = $.extend({
  5691. of: this.active
  5692. }, this.options.position );
  5693. clearTimeout( this.timer );
  5694. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  5695. .hide()
  5696. .attr( "aria-hidden", "true" );
  5697. submenu
  5698. .show()
  5699. .removeAttr( "aria-hidden" )
  5700. .attr( "aria-expanded", "true" )
  5701. .position( position );
  5702. },
  5703. collapseAll: function( event, all ) {
  5704. clearTimeout( this.timer );
  5705. this.timer = this._delay(function() {
  5706. // If we were passed an event, look for the submenu that contains the event
  5707. var currentMenu = all ? this.element :
  5708. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  5709. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  5710. if ( !currentMenu.length ) {
  5711. currentMenu = this.element;
  5712. }
  5713. this._close( currentMenu );
  5714. this.blur( event );
  5715. this.activeMenu = currentMenu;
  5716. }, this.delay );
  5717. },
  5718. // With no arguments, closes the currently active menu - if nothing is active
  5719. // it closes all menus. If passed an argument, it will search for menus BELOW
  5720. _close: function( startMenu ) {
  5721. if ( !startMenu ) {
  5722. startMenu = this.active ? this.active.parent() : this.element;
  5723. }
  5724. startMenu
  5725. .find( ".ui-menu" )
  5726. .hide()
  5727. .attr( "aria-hidden", "true" )
  5728. .attr( "aria-expanded", "false" )
  5729. .end()
  5730. .find( ".ui-state-active" ).not( ".ui-state-focus" )
  5731. .removeClass( "ui-state-active" );
  5732. },
  5733. _closeOnDocumentClick: function( event ) {
  5734. return !$( event.target ).closest( ".ui-menu" ).length;
  5735. },
  5736. _isDivider: function( item ) {
  5737. // Match hyphen, em dash, en dash
  5738. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  5739. },
  5740. collapse: function( event ) {
  5741. var newItem = this.active &&
  5742. this.active.parent().closest( ".ui-menu-item", this.element );
  5743. if ( newItem && newItem.length ) {
  5744. this._close();
  5745. this.focus( event, newItem );
  5746. }
  5747. },
  5748. expand: function( event ) {
  5749. var newItem = this.active &&
  5750. this.active
  5751. .children( ".ui-menu " )
  5752. .find( this.options.items )
  5753. .first();
  5754. if ( newItem && newItem.length ) {
  5755. this._open( newItem.parent() );
  5756. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  5757. this._delay(function() {
  5758. this.focus( event, newItem );
  5759. });
  5760. }
  5761. },
  5762. next: function( event ) {
  5763. this._move( "next", "first", event );
  5764. },
  5765. previous: function( event ) {
  5766. this._move( "prev", "last", event );
  5767. },
  5768. isFirstItem: function() {
  5769. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  5770. },
  5771. isLastItem: function() {
  5772. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  5773. },
  5774. _move: function( direction, filter, event ) {
  5775. var next;
  5776. if ( this.active ) {
  5777. if ( direction === "first" || direction === "last" ) {
  5778. next = this.active
  5779. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  5780. .eq( -1 );
  5781. } else {
  5782. next = this.active
  5783. [ direction + "All" ]( ".ui-menu-item" )
  5784. .eq( 0 );
  5785. }
  5786. }
  5787. if ( !next || !next.length || !this.active ) {
  5788. next = this.activeMenu.find( this.options.items )[ filter ]();
  5789. }
  5790. this.focus( event, next );
  5791. },
  5792. nextPage: function( event ) {
  5793. var item, base, height;
  5794. if ( !this.active ) {
  5795. this.next( event );
  5796. return;
  5797. }
  5798. if ( this.isLastItem() ) {
  5799. return;
  5800. }
  5801. if ( this._hasScroll() ) {
  5802. base = this.active.offset().top;
  5803. height = this.element.height();
  5804. this.active.nextAll( ".ui-menu-item" ).each(function() {
  5805. item = $( this );
  5806. return item.offset().top - base - height < 0;
  5807. });
  5808. this.focus( event, item );
  5809. } else {
  5810. this.focus( event, this.activeMenu.find( this.options.items )
  5811. [ !this.active ? "first" : "last" ]() );
  5812. }
  5813. },
  5814. previousPage: function( event ) {
  5815. var item, base, height;
  5816. if ( !this.active ) {
  5817. this.next( event );
  5818. return;
  5819. }
  5820. if ( this.isFirstItem() ) {
  5821. return;
  5822. }
  5823. if ( this._hasScroll() ) {
  5824. base = this.active.offset().top;
  5825. height = this.element.height();
  5826. this.active.prevAll( ".ui-menu-item" ).each(function() {
  5827. item = $( this );
  5828. return item.offset().top - base + height > 0;
  5829. });
  5830. this.focus( event, item );
  5831. } else {
  5832. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  5833. }
  5834. },
  5835. _hasScroll: function() {
  5836. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  5837. },
  5838. select: function( event ) {
  5839. // TODO: It should never be possible to not have an active item at this
  5840. // point, but the tests don't trigger mouseenter before click.
  5841. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  5842. var ui = { item: this.active };
  5843. if ( !this.active.has( ".ui-menu" ).length ) {
  5844. this.collapseAll( event, true );
  5845. }
  5846. this._trigger( "select", event, ui );
  5847. },
  5848. _filterMenuItems: function(character) {
  5849. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  5850. regex = new RegExp( "^" + escapedCharacter, "i" );
  5851. return this.activeMenu
  5852. .find( this.options.items )
  5853. // Only match on items, not dividers or other content (#10571)
  5854. .filter( ".ui-menu-item" )
  5855. .filter(function() {
  5856. return regex.test( $.trim( $( this ).text() ) );
  5857. });
  5858. }
  5859. });
  5860. /*!
  5861. * jQuery UI Autocomplete 1.11.3
  5862. * http://jqueryui.com
  5863. *
  5864. * Copyright jQuery Foundation and other contributors
  5865. * Released under the MIT license.
  5866. * http://jquery.org/license
  5867. *
  5868. * http://api.jqueryui.com/autocomplete/
  5869. */
  5870. $.widget( "ui.autocomplete", {
  5871. version: "1.11.3",
  5872. defaultElement: "<input>",
  5873. options: {
  5874. appendTo: null,
  5875. autoFocus: false,
  5876. delay: 300,
  5877. minLength: 1,
  5878. position: {
  5879. my: "left top",
  5880. at: "left bottom",
  5881. collision: "none"
  5882. },
  5883. source: null,
  5884. // callbacks
  5885. change: null,
  5886. close: null,
  5887. focus: null,
  5888. open: null,
  5889. response: null,
  5890. search: null,
  5891. select: null
  5892. },
  5893. requestIndex: 0,
  5894. pending: 0,
  5895. _create: function() {
  5896. // Some browsers only repeat keydown events, not keypress events,
  5897. // so we use the suppressKeyPress flag to determine if we've already
  5898. // handled the keydown event. #7269
  5899. // Unfortunately the code for & in keypress is the same as the up arrow,
  5900. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  5901. // events when we know the keydown event was used to modify the
  5902. // search term. #7799
  5903. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  5904. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  5905. isTextarea = nodeName === "textarea",
  5906. isInput = nodeName === "input";
  5907. this.isMultiLine =
  5908. // Textareas are always multi-line
  5909. isTextarea ? true :
  5910. // Inputs are always single-line, even if inside a contentEditable element
  5911. // IE also treats inputs as contentEditable
  5912. isInput ? false :
  5913. // All other element types are determined by whether or not they're contentEditable
  5914. this.element.prop( "isContentEditable" );
  5915. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  5916. this.isNewMenu = true;
  5917. this.element
  5918. .addClass( "ui-autocomplete-input" )
  5919. .attr( "autocomplete", "off" );
  5920. this._on( this.element, {
  5921. keydown: function( event ) {
  5922. if ( this.element.prop( "readOnly" ) ) {
  5923. suppressKeyPress = true;
  5924. suppressInput = true;
  5925. suppressKeyPressRepeat = true;
  5926. return;
  5927. }
  5928. suppressKeyPress = false;
  5929. suppressInput = false;
  5930. suppressKeyPressRepeat = false;
  5931. var keyCode = $.ui.keyCode;
  5932. switch ( event.keyCode ) {
  5933. case keyCode.PAGE_UP:
  5934. suppressKeyPress = true;
  5935. this._move( "previousPage", event );
  5936. break;
  5937. case keyCode.PAGE_DOWN:
  5938. suppressKeyPress = true;
  5939. this._move( "nextPage", event );
  5940. break;
  5941. case keyCode.UP:
  5942. suppressKeyPress = true;
  5943. this._keyEvent( "previous", event );
  5944. break;
  5945. case keyCode.DOWN:
  5946. suppressKeyPress = true;
  5947. this._keyEvent( "next", event );
  5948. break;
  5949. case keyCode.ENTER:
  5950. // when menu is open and has focus
  5951. if ( this.menu.active ) {
  5952. // #6055 - Opera still allows the keypress to occur
  5953. // which causes forms to submit
  5954. suppressKeyPress = true;
  5955. event.preventDefault();
  5956. this.menu.select( event );
  5957. }
  5958. break;
  5959. case keyCode.TAB:
  5960. if ( this.menu.active ) {
  5961. this.menu.select( event );
  5962. }
  5963. break;
  5964. case keyCode.ESCAPE:
  5965. if ( this.menu.element.is( ":visible" ) ) {
  5966. if ( !this.isMultiLine ) {
  5967. this._value( this.term );
  5968. }
  5969. this.close( event );
  5970. // Different browsers have different default behavior for escape
  5971. // Single press can mean undo or clear
  5972. // Double press in IE means clear the whole form
  5973. event.preventDefault();
  5974. }
  5975. break;
  5976. default:
  5977. suppressKeyPressRepeat = true;
  5978. // search timeout should be triggered before the input value is changed
  5979. this._searchTimeout( event );
  5980. break;
  5981. }
  5982. },
  5983. keypress: function( event ) {
  5984. if ( suppressKeyPress ) {
  5985. suppressKeyPress = false;
  5986. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5987. event.preventDefault();
  5988. }
  5989. return;
  5990. }
  5991. if ( suppressKeyPressRepeat ) {
  5992. return;
  5993. }
  5994. // replicate some key handlers to allow them to repeat in Firefox and Opera
  5995. var keyCode = $.ui.keyCode;
  5996. switch ( event.keyCode ) {
  5997. case keyCode.PAGE_UP:
  5998. this._move( "previousPage", event );
  5999. break;
  6000. case keyCode.PAGE_DOWN:
  6001. this._move( "nextPage", event );
  6002. break;
  6003. case keyCode.UP:
  6004. this._keyEvent( "previous", event );
  6005. break;
  6006. case keyCode.DOWN:
  6007. this._keyEvent( "next", event );
  6008. break;
  6009. }
  6010. },
  6011. input: function( event ) {
  6012. if ( suppressInput ) {
  6013. suppressInput = false;
  6014. event.preventDefault();
  6015. return;
  6016. }
  6017. this._searchTimeout( event );
  6018. },
  6019. focus: function() {
  6020. this.selectedItem = null;
  6021. this.previous = this._value();
  6022. },
  6023. blur: function( event ) {
  6024. if ( this.cancelBlur ) {
  6025. delete this.cancelBlur;
  6026. return;
  6027. }
  6028. clearTimeout( this.searching );
  6029. this.close( event );
  6030. this._change( event );
  6031. }
  6032. });
  6033. this._initSource();
  6034. this.menu = $( "<ul>" )
  6035. .addClass( "ui-autocomplete ui-front" )
  6036. .appendTo( this._appendTo() )
  6037. .menu({
  6038. // disable ARIA support, the live region takes care of that
  6039. role: null
  6040. })
  6041. .hide()
  6042. .menu( "instance" );
  6043. this._on( this.menu.element, {
  6044. mousedown: function( event ) {
  6045. // prevent moving focus out of the text field
  6046. event.preventDefault();
  6047. // IE doesn't prevent moving focus even with event.preventDefault()
  6048. // so we set a flag to know when we should ignore the blur event
  6049. this.cancelBlur = true;
  6050. this._delay(function() {
  6051. delete this.cancelBlur;
  6052. });
  6053. // clicking on the scrollbar causes focus to shift to the body
  6054. // but we can't detect a mouseup or a click immediately afterward
  6055. // so we have to track the next mousedown and close the menu if
  6056. // the user clicks somewhere outside of the autocomplete
  6057. var menuElement = this.menu.element[ 0 ];
  6058. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  6059. this._delay(function() {
  6060. var that = this;
  6061. this.document.one( "mousedown", function( event ) {
  6062. if ( event.target !== that.element[ 0 ] &&
  6063. event.target !== menuElement &&
  6064. !$.contains( menuElement, event.target ) ) {
  6065. that.close();
  6066. }
  6067. });
  6068. });
  6069. }
  6070. },
  6071. menufocus: function( event, ui ) {
  6072. var label, item;
  6073. // support: Firefox
  6074. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  6075. if ( this.isNewMenu ) {
  6076. this.isNewMenu = false;
  6077. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  6078. this.menu.blur();
  6079. this.document.one( "mousemove", function() {
  6080. $( event.target ).trigger( event.originalEvent );
  6081. });
  6082. return;
  6083. }
  6084. }
  6085. item = ui.item.data( "ui-autocomplete-item" );
  6086. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  6087. // use value to match what will end up in the input, if it was a key event
  6088. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  6089. this._value( item.value );
  6090. }
  6091. }
  6092. // Announce the value in the liveRegion
  6093. label = ui.item.attr( "aria-label" ) || item.value;
  6094. if ( label && $.trim( label ).length ) {
  6095. this.liveRegion.children().hide();
  6096. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  6097. }
  6098. },
  6099. menuselect: function( event, ui ) {
  6100. var item = ui.item.data( "ui-autocomplete-item" ),
  6101. previous = this.previous;
  6102. // only trigger when focus was lost (click on menu)
  6103. if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
  6104. this.element.focus();
  6105. this.previous = previous;
  6106. // #6109 - IE triggers two focus events and the second
  6107. // is asynchronous, so we need to reset the previous
  6108. // term synchronously and asynchronously :-(
  6109. this._delay(function() {
  6110. this.previous = previous;
  6111. this.selectedItem = item;
  6112. });
  6113. }
  6114. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  6115. this._value( item.value );
  6116. }
  6117. // reset the term after the select event
  6118. // this allows custom select handling to work properly
  6119. this.term = this._value();
  6120. this.close( event );
  6121. this.selectedItem = item;
  6122. }
  6123. });
  6124. this.liveRegion = $( "<span>", {
  6125. role: "status",
  6126. "aria-live": "assertive",
  6127. "aria-relevant": "additions"
  6128. })
  6129. .addClass( "ui-helper-hidden-accessible" )
  6130. .appendTo( this.document[ 0 ].body );
  6131. // turning off autocomplete prevents the browser from remembering the
  6132. // value when navigating through history, so we re-enable autocomplete
  6133. // if the page is unloaded before the widget is destroyed. #7790
  6134. this._on( this.window, {
  6135. beforeunload: function() {
  6136. this.element.removeAttr( "autocomplete" );
  6137. }
  6138. });
  6139. },
  6140. _destroy: function() {
  6141. clearTimeout( this.searching );
  6142. this.element
  6143. .removeClass( "ui-autocomplete-input" )
  6144. .removeAttr( "autocomplete" );
  6145. this.menu.element.remove();
  6146. this.liveRegion.remove();
  6147. },
  6148. _setOption: function( key, value ) {
  6149. this._super( key, value );
  6150. if ( key === "source" ) {
  6151. this._initSource();
  6152. }
  6153. if ( key === "appendTo" ) {
  6154. this.menu.element.appendTo( this._appendTo() );
  6155. }
  6156. if ( key === "disabled" && value && this.xhr ) {
  6157. this.xhr.abort();
  6158. }
  6159. },
  6160. _appendTo: function() {
  6161. var element = this.options.appendTo;
  6162. if ( element ) {
  6163. element = element.jquery || element.nodeType ?
  6164. $( element ) :
  6165. this.document.find( element ).eq( 0 );
  6166. }
  6167. if ( !element || !element[ 0 ] ) {
  6168. element = this.element.closest( ".ui-front" );
  6169. }
  6170. if ( !element.length ) {
  6171. element = this.document[ 0 ].body;
  6172. }
  6173. return element;
  6174. },
  6175. _initSource: function() {
  6176. var array, url,
  6177. that = this;
  6178. if ( $.isArray( this.options.source ) ) {
  6179. array = this.options.source;
  6180. this.source = function( request, response ) {
  6181. response( $.ui.autocomplete.filter( array, request.term ) );
  6182. };
  6183. } else if ( typeof this.options.source === "string" ) {
  6184. url = this.options.source;
  6185. this.source = function( request, response ) {
  6186. if ( that.xhr ) {
  6187. that.xhr.abort();
  6188. }
  6189. that.xhr = $.ajax({
  6190. url: url,
  6191. data: request,
  6192. dataType: "json",
  6193. success: function( data ) {
  6194. response( data );
  6195. },
  6196. error: function() {
  6197. response([]);
  6198. }
  6199. });
  6200. };
  6201. } else {
  6202. this.source = this.options.source;
  6203. }
  6204. },
  6205. _searchTimeout: function( event ) {
  6206. clearTimeout( this.searching );
  6207. this.searching = this._delay(function() {
  6208. // Search if the value has changed, or if the user retypes the same value (see #7434)
  6209. var equalValues = this.term === this._value(),
  6210. menuVisible = this.menu.element.is( ":visible" ),
  6211. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  6212. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  6213. this.selectedItem = null;
  6214. this.search( null, event );
  6215. }
  6216. }, this.options.delay );
  6217. },
  6218. search: function( value, event ) {
  6219. value = value != null ? value : this._value();
  6220. // always save the actual value, not the one passed as an argument
  6221. this.term = this._value();
  6222. if ( value.length < this.options.minLength ) {
  6223. return this.close( event );
  6224. }
  6225. if ( this._trigger( "search", event ) === false ) {
  6226. return;
  6227. }
  6228. return this._search( value );
  6229. },
  6230. _search: function( value ) {
  6231. this.pending++;
  6232. this.element.addClass( "ui-autocomplete-loading" );
  6233. this.cancelSearch = false;
  6234. this.source( { term: value }, this._response() );
  6235. },
  6236. _response: function() {
  6237. var index = ++this.requestIndex;
  6238. return $.proxy(function( content ) {
  6239. if ( index === this.requestIndex ) {
  6240. this.__response( content );
  6241. }
  6242. this.pending--;
  6243. if ( !this.pending ) {
  6244. this.element.removeClass( "ui-autocomplete-loading" );
  6245. }
  6246. }, this );
  6247. },
  6248. __response: function( content ) {
  6249. if ( content ) {
  6250. content = this._normalize( content );
  6251. }
  6252. this._trigger( "response", null, { content: content } );
  6253. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  6254. this._suggest( content );
  6255. this._trigger( "open" );
  6256. } else {
  6257. // use ._close() instead of .close() so we don't cancel future searches
  6258. this._close();
  6259. }
  6260. },
  6261. close: function( event ) {
  6262. this.cancelSearch = true;
  6263. this._close( event );
  6264. },
  6265. _close: function( event ) {
  6266. if ( this.menu.element.is( ":visible" ) ) {
  6267. this.menu.element.hide();
  6268. this.menu.blur();
  6269. this.isNewMenu = true;
  6270. this._trigger( "close", event );
  6271. }
  6272. },
  6273. _change: function( event ) {
  6274. if ( this.previous !== this._value() ) {
  6275. this._trigger( "change", event, { item: this.selectedItem } );
  6276. }
  6277. },
  6278. _normalize: function( items ) {
  6279. // assume all items have the right format when the first item is complete
  6280. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  6281. return items;
  6282. }
  6283. return $.map( items, function( item ) {
  6284. if ( typeof item === "string" ) {
  6285. return {
  6286. label: item,
  6287. value: item
  6288. };
  6289. }
  6290. return $.extend( {}, item, {
  6291. label: item.label || item.value,
  6292. value: item.value || item.label
  6293. });
  6294. });
  6295. },
  6296. _suggest: function( items ) {
  6297. var ul = this.menu.element.empty();
  6298. this._renderMenu( ul, items );
  6299. this.isNewMenu = true;
  6300. this.menu.refresh();
  6301. // size and position menu
  6302. ul.show();
  6303. this._resizeMenu();
  6304. ul.position( $.extend({
  6305. of: this.element
  6306. }, this.options.position ) );
  6307. if ( this.options.autoFocus ) {
  6308. this.menu.next();
  6309. }
  6310. },
  6311. _resizeMenu: function() {
  6312. var ul = this.menu.element;
  6313. ul.outerWidth( Math.max(
  6314. // Firefox wraps long text (possibly a rounding bug)
  6315. // so we add 1px to avoid the wrapping (#7513)
  6316. ul.width( "" ).outerWidth() + 1,
  6317. this.element.outerWidth()
  6318. ) );
  6319. },
  6320. _renderMenu: function( ul, items ) {
  6321. var that = this;
  6322. $.each( items, function( index, item ) {
  6323. that._renderItemData( ul, item );
  6324. });
  6325. },
  6326. _renderItemData: function( ul, item ) {
  6327. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  6328. },
  6329. _renderItem: function( ul, item ) {
  6330. return $( "<li>" ).text( item.label ).appendTo( ul );
  6331. },
  6332. _move: function( direction, event ) {
  6333. if ( !this.menu.element.is( ":visible" ) ) {
  6334. this.search( null, event );
  6335. return;
  6336. }
  6337. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  6338. this.menu.isLastItem() && /^next/.test( direction ) ) {
  6339. if ( !this.isMultiLine ) {
  6340. this._value( this.term );
  6341. }
  6342. this.menu.blur();
  6343. return;
  6344. }
  6345. this.menu[ direction ]( event );
  6346. },
  6347. widget: function() {
  6348. return this.menu.element;
  6349. },
  6350. _value: function() {
  6351. return this.valueMethod.apply( this.element, arguments );
  6352. },
  6353. _keyEvent: function( keyEvent, event ) {
  6354. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  6355. this._move( keyEvent, event );
  6356. // prevents moving cursor to beginning/end of the text field in some browsers
  6357. event.preventDefault();
  6358. }
  6359. }
  6360. });
  6361. $.extend( $.ui.autocomplete, {
  6362. escapeRegex: function( value ) {
  6363. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  6364. },
  6365. filter: function( array, term ) {
  6366. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  6367. return $.grep( array, function( value ) {
  6368. return matcher.test( value.label || value.value || value );
  6369. });
  6370. }
  6371. });
  6372. // live region extension, adding a `messages` option
  6373. // NOTE: This is an experimental API. We are still investigating
  6374. // a full solution for string manipulation and internationalization.
  6375. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  6376. options: {
  6377. messages: {
  6378. noResults: "No search results.",
  6379. results: function( amount ) {
  6380. return amount + ( amount > 1 ? " results are" : " result is" ) +
  6381. " available, use up and down arrow keys to navigate.";
  6382. }
  6383. }
  6384. },
  6385. __response: function( content ) {
  6386. var message;
  6387. this._superApply( arguments );
  6388. if ( this.options.disabled || this.cancelSearch ) {
  6389. return;
  6390. }
  6391. if ( content && content.length ) {
  6392. message = this.options.messages.results( content.length );
  6393. } else {
  6394. message = this.options.messages.noResults;
  6395. }
  6396. this.liveRegion.children().hide();
  6397. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  6398. }
  6399. });
  6400. var autocomplete = $.ui.autocomplete;
  6401. /*!
  6402. * jQuery UI Button 1.11.3
  6403. * http://jqueryui.com
  6404. *
  6405. * Copyright jQuery Foundation and other contributors
  6406. * Released under the MIT license.
  6407. * http://jquery.org/license
  6408. *
  6409. * http://api.jqueryui.com/button/
  6410. */
  6411. var lastActive,
  6412. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  6413. 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",
  6414. formResetHandler = function() {
  6415. var form = $( this );
  6416. setTimeout(function() {
  6417. form.find( ":ui-button" ).button( "refresh" );
  6418. }, 1 );
  6419. },
  6420. radioGroup = function( radio ) {
  6421. var name = radio.name,
  6422. form = radio.form,
  6423. radios = $( [] );
  6424. if ( name ) {
  6425. name = name.replace( /'/g, "\\'" );
  6426. if ( form ) {
  6427. radios = $( form ).find( "[name='" + name + "'][type=radio]" );
  6428. } else {
  6429. radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
  6430. .filter(function() {
  6431. return !this.form;
  6432. });
  6433. }
  6434. }
  6435. return radios;
  6436. };
  6437. $.widget( "ui.button", {
  6438. version: "1.11.3",
  6439. defaultElement: "<button>",
  6440. options: {
  6441. disabled: null,
  6442. text: true,
  6443. label: null,
  6444. icons: {
  6445. primary: null,
  6446. secondary: null
  6447. }
  6448. },
  6449. _create: function() {
  6450. this.element.closest( "form" )
  6451. .unbind( "reset" + this.eventNamespace )
  6452. .bind( "reset" + this.eventNamespace, formResetHandler );
  6453. if ( typeof this.options.disabled !== "boolean" ) {
  6454. this.options.disabled = !!this.element.prop( "disabled" );
  6455. } else {
  6456. this.element.prop( "disabled", this.options.disabled );
  6457. }
  6458. this._determineButtonType();
  6459. this.hasTitle = !!this.buttonElement.attr( "title" );
  6460. var that = this,
  6461. options = this.options,
  6462. toggleButton = this.type === "checkbox" || this.type === "radio",
  6463. activeClass = !toggleButton ? "ui-state-active" : "";
  6464. if ( options.label === null ) {
  6465. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  6466. }
  6467. this._hoverable( this.buttonElement );
  6468. this.buttonElement
  6469. .addClass( baseClasses )
  6470. .attr( "role", "button" )
  6471. .bind( "mouseenter" + this.eventNamespace, function() {
  6472. if ( options.disabled ) {
  6473. return;
  6474. }
  6475. if ( this === lastActive ) {
  6476. $( this ).addClass( "ui-state-active" );
  6477. }
  6478. })
  6479. .bind( "mouseleave" + this.eventNamespace, function() {
  6480. if ( options.disabled ) {
  6481. return;
  6482. }
  6483. $( this ).removeClass( activeClass );
  6484. })
  6485. .bind( "click" + this.eventNamespace, function( event ) {
  6486. if ( options.disabled ) {
  6487. event.preventDefault();
  6488. event.stopImmediatePropagation();
  6489. }
  6490. });
  6491. // Can't use _focusable() because the element that receives focus
  6492. // and the element that gets the ui-state-focus class are different
  6493. this._on({
  6494. focus: function() {
  6495. this.buttonElement.addClass( "ui-state-focus" );
  6496. },
  6497. blur: function() {
  6498. this.buttonElement.removeClass( "ui-state-focus" );
  6499. }
  6500. });
  6501. if ( toggleButton ) {
  6502. this.element.bind( "change" + this.eventNamespace, function() {
  6503. that.refresh();
  6504. });
  6505. }
  6506. if ( this.type === "checkbox" ) {
  6507. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6508. if ( options.disabled ) {
  6509. return false;
  6510. }
  6511. });
  6512. } else if ( this.type === "radio" ) {
  6513. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6514. if ( options.disabled ) {
  6515. return false;
  6516. }
  6517. $( this ).addClass( "ui-state-active" );
  6518. that.buttonElement.attr( "aria-pressed", "true" );
  6519. var radio = that.element[ 0 ];
  6520. radioGroup( radio )
  6521. .not( radio )
  6522. .map(function() {
  6523. return $( this ).button( "widget" )[ 0 ];
  6524. })
  6525. .removeClass( "ui-state-active" )
  6526. .attr( "aria-pressed", "false" );
  6527. });
  6528. } else {
  6529. this.buttonElement
  6530. .bind( "mousedown" + this.eventNamespace, function() {
  6531. if ( options.disabled ) {
  6532. return false;
  6533. }
  6534. $( this ).addClass( "ui-state-active" );
  6535. lastActive = this;
  6536. that.document.one( "mouseup", function() {
  6537. lastActive = null;
  6538. });
  6539. })
  6540. .bind( "mouseup" + this.eventNamespace, function() {
  6541. if ( options.disabled ) {
  6542. return false;
  6543. }
  6544. $( this ).removeClass( "ui-state-active" );
  6545. })
  6546. .bind( "keydown" + this.eventNamespace, function(event) {
  6547. if ( options.disabled ) {
  6548. return false;
  6549. }
  6550. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  6551. $( this ).addClass( "ui-state-active" );
  6552. }
  6553. })
  6554. // see #8559, we bind to blur here in case the button element loses
  6555. // focus between keydown and keyup, it would be left in an "active" state
  6556. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  6557. $( this ).removeClass( "ui-state-active" );
  6558. });
  6559. if ( this.buttonElement.is("a") ) {
  6560. this.buttonElement.keyup(function(event) {
  6561. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  6562. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  6563. $( this ).click();
  6564. }
  6565. });
  6566. }
  6567. }
  6568. this._setOption( "disabled", options.disabled );
  6569. this._resetButton();
  6570. },
  6571. _determineButtonType: function() {
  6572. var ancestor, labelSelector, checked;
  6573. if ( this.element.is("[type=checkbox]") ) {
  6574. this.type = "checkbox";
  6575. } else if ( this.element.is("[type=radio]") ) {
  6576. this.type = "radio";
  6577. } else if ( this.element.is("input") ) {
  6578. this.type = "input";
  6579. } else {
  6580. this.type = "button";
  6581. }
  6582. if ( this.type === "checkbox" || this.type === "radio" ) {
  6583. // we don't search against the document in case the element
  6584. // is disconnected from the DOM
  6585. ancestor = this.element.parents().last();
  6586. labelSelector = "label[for='" + this.element.attr("id") + "']";
  6587. this.buttonElement = ancestor.find( labelSelector );
  6588. if ( !this.buttonElement.length ) {
  6589. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  6590. this.buttonElement = ancestor.filter( labelSelector );
  6591. if ( !this.buttonElement.length ) {
  6592. this.buttonElement = ancestor.find( labelSelector );
  6593. }
  6594. }
  6595. this.element.addClass( "ui-helper-hidden-accessible" );
  6596. checked = this.element.is( ":checked" );
  6597. if ( checked ) {
  6598. this.buttonElement.addClass( "ui-state-active" );
  6599. }
  6600. this.buttonElement.prop( "aria-pressed", checked );
  6601. } else {
  6602. this.buttonElement = this.element;
  6603. }
  6604. },
  6605. widget: function() {
  6606. return this.buttonElement;
  6607. },
  6608. _destroy: function() {
  6609. this.element
  6610. .removeClass( "ui-helper-hidden-accessible" );
  6611. this.buttonElement
  6612. .removeClass( baseClasses + " ui-state-active " + typeClasses )
  6613. .removeAttr( "role" )
  6614. .removeAttr( "aria-pressed" )
  6615. .html( this.buttonElement.find(".ui-button-text").html() );
  6616. if ( !this.hasTitle ) {
  6617. this.buttonElement.removeAttr( "title" );
  6618. }
  6619. },
  6620. _setOption: function( key, value ) {
  6621. this._super( key, value );
  6622. if ( key === "disabled" ) {
  6623. this.widget().toggleClass( "ui-state-disabled", !!value );
  6624. this.element.prop( "disabled", !!value );
  6625. if ( value ) {
  6626. if ( this.type === "checkbox" || this.type === "radio" ) {
  6627. this.buttonElement.removeClass( "ui-state-focus" );
  6628. } else {
  6629. this.buttonElement.removeClass( "ui-state-focus ui-state-active" );
  6630. }
  6631. }
  6632. return;
  6633. }
  6634. this._resetButton();
  6635. },
  6636. refresh: function() {
  6637. //See #8237 & #8828
  6638. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  6639. if ( isDisabled !== this.options.disabled ) {
  6640. this._setOption( "disabled", isDisabled );
  6641. }
  6642. if ( this.type === "radio" ) {
  6643. radioGroup( this.element[0] ).each(function() {
  6644. if ( $( this ).is( ":checked" ) ) {
  6645. $( this ).button( "widget" )
  6646. .addClass( "ui-state-active" )
  6647. .attr( "aria-pressed", "true" );
  6648. } else {
  6649. $( this ).button( "widget" )
  6650. .removeClass( "ui-state-active" )
  6651. .attr( "aria-pressed", "false" );
  6652. }
  6653. });
  6654. } else if ( this.type === "checkbox" ) {
  6655. if ( this.element.is( ":checked" ) ) {
  6656. this.buttonElement
  6657. .addClass( "ui-state-active" )
  6658. .attr( "aria-pressed", "true" );
  6659. } else {
  6660. this.buttonElement
  6661. .removeClass( "ui-state-active" )
  6662. .attr( "aria-pressed", "false" );
  6663. }
  6664. }
  6665. },
  6666. _resetButton: function() {
  6667. if ( this.type === "input" ) {
  6668. if ( this.options.label ) {
  6669. this.element.val( this.options.label );
  6670. }
  6671. return;
  6672. }
  6673. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  6674. buttonText = $( "<span></span>", this.document[0] )
  6675. .addClass( "ui-button-text" )
  6676. .html( this.options.label )
  6677. .appendTo( buttonElement.empty() )
  6678. .text(),
  6679. icons = this.options.icons,
  6680. multipleIcons = icons.primary && icons.secondary,
  6681. buttonClasses = [];
  6682. if ( icons.primary || icons.secondary ) {
  6683. if ( this.options.text ) {
  6684. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  6685. }
  6686. if ( icons.primary ) {
  6687. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  6688. }
  6689. if ( icons.secondary ) {
  6690. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  6691. }
  6692. if ( !this.options.text ) {
  6693. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  6694. if ( !this.hasTitle ) {
  6695. buttonElement.attr( "title", $.trim( buttonText ) );
  6696. }
  6697. }
  6698. } else {
  6699. buttonClasses.push( "ui-button-text-only" );
  6700. }
  6701. buttonElement.addClass( buttonClasses.join( " " ) );
  6702. }
  6703. });
  6704. $.widget( "ui.buttonset", {
  6705. version: "1.11.3",
  6706. options: {
  6707. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  6708. },
  6709. _create: function() {
  6710. this.element.addClass( "ui-buttonset" );
  6711. },
  6712. _init: function() {
  6713. this.refresh();
  6714. },
  6715. _setOption: function( key, value ) {
  6716. if ( key === "disabled" ) {
  6717. this.buttons.button( "option", key, value );
  6718. }
  6719. this._super( key, value );
  6720. },
  6721. refresh: function() {
  6722. var rtl = this.element.css( "direction" ) === "rtl",
  6723. allButtons = this.element.find( this.options.items ),
  6724. existingButtons = allButtons.filter( ":ui-button" );
  6725. // Initialize new buttons
  6726. allButtons.not( ":ui-button" ).button();
  6727. // Refresh existing buttons
  6728. existingButtons.button( "refresh" );
  6729. this.buttons = allButtons
  6730. .map(function() {
  6731. return $( this ).button( "widget" )[ 0 ];
  6732. })
  6733. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  6734. .filter( ":first" )
  6735. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  6736. .end()
  6737. .filter( ":last" )
  6738. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  6739. .end()
  6740. .end();
  6741. },
  6742. _destroy: function() {
  6743. this.element.removeClass( "ui-buttonset" );
  6744. this.buttons
  6745. .map(function() {
  6746. return $( this ).button( "widget" )[ 0 ];
  6747. })
  6748. .removeClass( "ui-corner-left ui-corner-right" )
  6749. .end()
  6750. .button( "destroy" );
  6751. }
  6752. });
  6753. var button = $.ui.button;
  6754. /*!
  6755. * jQuery UI Datepicker 1.11.3
  6756. * http://jqueryui.com
  6757. *
  6758. * Copyright jQuery Foundation and other contributors
  6759. * Released under the MIT license.
  6760. * http://jquery.org/license
  6761. *
  6762. * http://api.jqueryui.com/datepicker/
  6763. */
  6764. $.extend($.ui, { datepicker: { version: "1.11.3" } });
  6765. var datepicker_instActive;
  6766. function datepicker_getZindex( elem ) {
  6767. var position, value;
  6768. while ( elem.length && elem[ 0 ] !== document ) {
  6769. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  6770. // This makes behavior of this function consistent across browsers
  6771. // WebKit always returns auto if the element is positioned
  6772. position = elem.css( "position" );
  6773. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  6774. // IE returns 0 when zIndex is not specified
  6775. // other browsers return a string
  6776. // we ignore the case of nested elements with an explicit value of 0
  6777. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  6778. value = parseInt( elem.css( "zIndex" ), 10 );
  6779. if ( !isNaN( value ) && value !== 0 ) {
  6780. return value;
  6781. }
  6782. }
  6783. elem = elem.parent();
  6784. }
  6785. return 0;
  6786. }
  6787. /* Date picker manager.
  6788. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6789. Settings for (groups of) date pickers are maintained in an instance object,
  6790. allowing multiple different settings on the same page. */
  6791. function Datepicker() {
  6792. this._curInst = null; // The current instance in use
  6793. this._keyEvent = false; // If the last event was a key event
  6794. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6795. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6796. this._inDialog = false; // True if showing within a "dialog", false if not
  6797. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  6798. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  6799. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  6800. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  6801. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  6802. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  6803. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  6804. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  6805. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  6806. this.regional = []; // Available regional settings, indexed by language code
  6807. this.regional[""] = { // Default regional settings
  6808. closeText: "Done", // Display text for close link
  6809. prevText: "Prev", // Display text for previous month link
  6810. nextText: "Next", // Display text for next month link
  6811. currentText: "Today", // Display text for current month link
  6812. monthNames: ["January","February","March","April","May","June",
  6813. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  6814. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  6815. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  6816. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  6817. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  6818. weekHeader: "Wk", // Column header for week of the year
  6819. dateFormat: "mm/dd/yy", // See format options on parseDate
  6820. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6821. isRTL: false, // True if right-to-left language, false if left-to-right
  6822. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6823. yearSuffix: "" // Additional text to append to the year in the month headers
  6824. };
  6825. this._defaults = { // Global defaults for all the date picker instances
  6826. showOn: "focus", // "focus" for popup on focus,
  6827. // "button" for trigger button, or "both" for either
  6828. showAnim: "fadeIn", // Name of jQuery animation for popup
  6829. showOptions: {}, // Options for enhanced animations
  6830. defaultDate: null, // Used when field is blank: actual date,
  6831. // +/-number for offset from today, null for today
  6832. appendText: "", // Display text following the input box, e.g. showing the format
  6833. buttonText: "...", // Text for trigger button
  6834. buttonImage: "", // URL for trigger button image
  6835. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6836. hideIfNoPrevNext: false, // True to hide next/previous month links
  6837. // if not applicable, false to just disable them
  6838. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6839. gotoCurrent: false, // True if today link goes back to current selection instead
  6840. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6841. changeYear: false, // True if year can be selected directly, false if only prev/next
  6842. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  6843. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6844. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6845. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6846. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6847. showWeek: false, // True to show week of the year, false to not show it
  6848. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6849. // takes a Date and returns the number of the week for it
  6850. shortYearCutoff: "+10", // Short year values < this are in the current century,
  6851. // > this are in the previous century,
  6852. // string value starting with "+" for current year + value
  6853. minDate: null, // The earliest selectable date, or null for no limit
  6854. maxDate: null, // The latest selectable date, or null for no limit
  6855. duration: "fast", // Duration of display/closure
  6856. beforeShowDay: null, // Function that takes a date and returns an array with
  6857. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  6858. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6859. beforeShow: null, // Function that takes an input field and
  6860. // returns a set of custom settings for the date picker
  6861. onSelect: null, // Define a callback function when a date is selected
  6862. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6863. onClose: null, // Define a callback function when the datepicker is closed
  6864. numberOfMonths: 1, // Number of months to show at a time
  6865. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6866. stepMonths: 1, // Number of months to step back/forward
  6867. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6868. altField: "", // Selector for an alternate field to store selected dates into
  6869. altFormat: "", // The date format to use for the alternate field
  6870. constrainInput: true, // The input is constrained by the current date format
  6871. showButtonPanel: false, // True to show button panel, false to not show it
  6872. autoSize: false, // True to size the input for the date format, false to leave as is
  6873. disabled: false // The initial disabled state
  6874. };
  6875. $.extend(this._defaults, this.regional[""]);
  6876. this.regional.en = $.extend( true, {}, this.regional[ "" ]);
  6877. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  6878. this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  6879. }
  6880. $.extend(Datepicker.prototype, {
  6881. /* Class name added to elements to indicate already configured with a date picker. */
  6882. markerClassName: "hasDatepicker",
  6883. //Keep track of the maximum number of rows displayed (see #7043)
  6884. maxRows: 4,
  6885. // TODO rename to "widget" when switching to widget factory
  6886. _widgetDatepicker: function() {
  6887. return this.dpDiv;
  6888. },
  6889. /* Override the default settings for all instances of the date picker.
  6890. * @param settings object - the new settings to use as defaults (anonymous object)
  6891. * @return the manager object
  6892. */
  6893. setDefaults: function(settings) {
  6894. datepicker_extendRemove(this._defaults, settings || {});
  6895. return this;
  6896. },
  6897. /* Attach the date picker to a jQuery selection.
  6898. * @param target element - the target input field or division or span
  6899. * @param settings object - the new settings to use for this date picker instance (anonymous)
  6900. */
  6901. _attachDatepicker: function(target, settings) {
  6902. var nodeName, inline, inst;
  6903. nodeName = target.nodeName.toLowerCase();
  6904. inline = (nodeName === "div" || nodeName === "span");
  6905. if (!target.id) {
  6906. this.uuid += 1;
  6907. target.id = "dp" + this.uuid;
  6908. }
  6909. inst = this._newInst($(target), inline);
  6910. inst.settings = $.extend({}, settings || {});
  6911. if (nodeName === "input") {
  6912. this._connectDatepicker(target, inst);
  6913. } else if (inline) {
  6914. this._inlineDatepicker(target, inst);
  6915. }
  6916. },
  6917. /* Create a new instance object. */
  6918. _newInst: function(target, inline) {
  6919. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  6920. return {id: id, input: target, // associated target
  6921. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6922. drawMonth: 0, drawYear: 0, // month being drawn
  6923. inline: inline, // is datepicker inline or not
  6924. dpDiv: (!inline ? this.dpDiv : // presentation div
  6925. datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  6926. },
  6927. /* Attach the date picker to an input field. */
  6928. _connectDatepicker: function(target, inst) {
  6929. var input = $(target);
  6930. inst.append = $([]);
  6931. inst.trigger = $([]);
  6932. if (input.hasClass(this.markerClassName)) {
  6933. return;
  6934. }
  6935. this._attachments(input, inst);
  6936. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  6937. keypress(this._doKeyPress).keyup(this._doKeyUp);
  6938. this._autoSize(inst);
  6939. $.data(target, "datepicker", inst);
  6940. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  6941. if( inst.settings.disabled ) {
  6942. this._disableDatepicker( target );
  6943. }
  6944. },
  6945. /* Make attachments based on settings. */
  6946. _attachments: function(input, inst) {
  6947. var showOn, buttonText, buttonImage,
  6948. appendText = this._get(inst, "appendText"),
  6949. isRTL = this._get(inst, "isRTL");
  6950. if (inst.append) {
  6951. inst.append.remove();
  6952. }
  6953. if (appendText) {
  6954. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  6955. input[isRTL ? "before" : "after"](inst.append);
  6956. }
  6957. input.unbind("focus", this._showDatepicker);
  6958. if (inst.trigger) {
  6959. inst.trigger.remove();
  6960. }
  6961. showOn = this._get(inst, "showOn");
  6962. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  6963. input.focus(this._showDatepicker);
  6964. }
  6965. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  6966. buttonText = this._get(inst, "buttonText");
  6967. buttonImage = this._get(inst, "buttonImage");
  6968. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  6969. $("<img/>").addClass(this._triggerClass).
  6970. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  6971. $("<button type='button'></button>").addClass(this._triggerClass).
  6972. html(!buttonImage ? buttonText : $("<img/>").attr(
  6973. { src:buttonImage, alt:buttonText, title:buttonText })));
  6974. input[isRTL ? "before" : "after"](inst.trigger);
  6975. inst.trigger.click(function() {
  6976. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  6977. $.datepicker._hideDatepicker();
  6978. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  6979. $.datepicker._hideDatepicker();
  6980. $.datepicker._showDatepicker(input[0]);
  6981. } else {
  6982. $.datepicker._showDatepicker(input[0]);
  6983. }
  6984. return false;
  6985. });
  6986. }
  6987. },
  6988. /* Apply the maximum length for the date format. */
  6989. _autoSize: function(inst) {
  6990. if (this._get(inst, "autoSize") && !inst.inline) {
  6991. var findMax, max, maxI, i,
  6992. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  6993. dateFormat = this._get(inst, "dateFormat");
  6994. if (dateFormat.match(/[DM]/)) {
  6995. findMax = function(names) {
  6996. max = 0;
  6997. maxI = 0;
  6998. for (i = 0; i < names.length; i++) {
  6999. if (names[i].length > max) {
  7000. max = names[i].length;
  7001. maxI = i;
  7002. }
  7003. }
  7004. return maxI;
  7005. };
  7006. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  7007. "monthNames" : "monthNamesShort"))));
  7008. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  7009. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  7010. }
  7011. inst.input.attr("size", this._formatDate(inst, date).length);
  7012. }
  7013. },
  7014. /* Attach an inline date picker to a div. */
  7015. _inlineDatepicker: function(target, inst) {
  7016. var divSpan = $(target);
  7017. if (divSpan.hasClass(this.markerClassName)) {
  7018. return;
  7019. }
  7020. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  7021. $.data(target, "datepicker", inst);
  7022. this._setDate(inst, this._getDefaultDate(inst), true);
  7023. this._updateDatepicker(inst);
  7024. this._updateAlternate(inst);
  7025. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  7026. if( inst.settings.disabled ) {
  7027. this._disableDatepicker( target );
  7028. }
  7029. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  7030. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  7031. inst.dpDiv.css( "display", "block" );
  7032. },
  7033. /* Pop-up the date picker in a "dialog" box.
  7034. * @param input element - ignored
  7035. * @param date string or Date - the initial date to display
  7036. * @param onSelect function - the function to call when a date is selected
  7037. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  7038. * @param pos int[2] - coordinates for the dialog's position within the screen or
  7039. * event - with x/y coordinates or
  7040. * leave empty for default (screen centre)
  7041. * @return the manager object
  7042. */
  7043. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  7044. var id, browserWidth, browserHeight, scrollX, scrollY,
  7045. inst = this._dialogInst; // internal instance
  7046. if (!inst) {
  7047. this.uuid += 1;
  7048. id = "dp" + this.uuid;
  7049. this._dialogInput = $("<input type='text' id='" + id +
  7050. "' style='position: absolute; top: -100px; width: 0px;'/>");
  7051. this._dialogInput.keydown(this._doKeyDown);
  7052. $("body").append(this._dialogInput);
  7053. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  7054. inst.settings = {};
  7055. $.data(this._dialogInput[0], "datepicker", inst);
  7056. }
  7057. datepicker_extendRemove(inst.settings, settings || {});
  7058. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  7059. this._dialogInput.val(date);
  7060. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  7061. if (!this._pos) {
  7062. browserWidth = document.documentElement.clientWidth;
  7063. browserHeight = document.documentElement.clientHeight;
  7064. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  7065. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  7066. this._pos = // should use actual width/height below
  7067. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  7068. }
  7069. // move input on screen for focus, but hidden behind dialog
  7070. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  7071. inst.settings.onSelect = onSelect;
  7072. this._inDialog = true;
  7073. this.dpDiv.addClass(this._dialogClass);
  7074. this._showDatepicker(this._dialogInput[0]);
  7075. if ($.blockUI) {
  7076. $.blockUI(this.dpDiv);
  7077. }
  7078. $.data(this._dialogInput[0], "datepicker", inst);
  7079. return this;
  7080. },
  7081. /* Detach a datepicker from its control.
  7082. * @param target element - the target input field or division or span
  7083. */
  7084. _destroyDatepicker: function(target) {
  7085. var nodeName,
  7086. $target = $(target),
  7087. inst = $.data(target, "datepicker");
  7088. if (!$target.hasClass(this.markerClassName)) {
  7089. return;
  7090. }
  7091. nodeName = target.nodeName.toLowerCase();
  7092. $.removeData(target, "datepicker");
  7093. if (nodeName === "input") {
  7094. inst.append.remove();
  7095. inst.trigger.remove();
  7096. $target.removeClass(this.markerClassName).
  7097. unbind("focus", this._showDatepicker).
  7098. unbind("keydown", this._doKeyDown).
  7099. unbind("keypress", this._doKeyPress).
  7100. unbind("keyup", this._doKeyUp);
  7101. } else if (nodeName === "div" || nodeName === "span") {
  7102. $target.removeClass(this.markerClassName).empty();
  7103. }
  7104. if ( datepicker_instActive === inst ) {
  7105. datepicker_instActive = null;
  7106. }
  7107. },
  7108. /* Enable the date picker to a jQuery selection.
  7109. * @param target element - the target input field or division or span
  7110. */
  7111. _enableDatepicker: function(target) {
  7112. var nodeName, inline,
  7113. $target = $(target),
  7114. inst = $.data(target, "datepicker");
  7115. if (!$target.hasClass(this.markerClassName)) {
  7116. return;
  7117. }
  7118. nodeName = target.nodeName.toLowerCase();
  7119. if (nodeName === "input") {
  7120. target.disabled = false;
  7121. inst.trigger.filter("button").
  7122. each(function() { this.disabled = false; }).end().
  7123. filter("img").css({opacity: "1.0", cursor: ""});
  7124. } else if (nodeName === "div" || nodeName === "span") {
  7125. inline = $target.children("." + this._inlineClass);
  7126. inline.children().removeClass("ui-state-disabled");
  7127. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  7128. prop("disabled", false);
  7129. }
  7130. this._disabledInputs = $.map(this._disabledInputs,
  7131. function(value) { return (value === target ? null : value); }); // delete entry
  7132. },
  7133. /* Disable the date picker to a jQuery selection.
  7134. * @param target element - the target input field or division or span
  7135. */
  7136. _disableDatepicker: function(target) {
  7137. var nodeName, inline,
  7138. $target = $(target),
  7139. inst = $.data(target, "datepicker");
  7140. if (!$target.hasClass(this.markerClassName)) {
  7141. return;
  7142. }
  7143. nodeName = target.nodeName.toLowerCase();
  7144. if (nodeName === "input") {
  7145. target.disabled = true;
  7146. inst.trigger.filter("button").
  7147. each(function() { this.disabled = true; }).end().
  7148. filter("img").css({opacity: "0.5", cursor: "default"});
  7149. } else if (nodeName === "div" || nodeName === "span") {
  7150. inline = $target.children("." + this._inlineClass);
  7151. inline.children().addClass("ui-state-disabled");
  7152. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  7153. prop("disabled", true);
  7154. }
  7155. this._disabledInputs = $.map(this._disabledInputs,
  7156. function(value) { return (value === target ? null : value); }); // delete entry
  7157. this._disabledInputs[this._disabledInputs.length] = target;
  7158. },
  7159. /* Is the first field in a jQuery collection disabled as a datepicker?
  7160. * @param target element - the target input field or division or span
  7161. * @return boolean - true if disabled, false if enabled
  7162. */
  7163. _isDisabledDatepicker: function(target) {
  7164. if (!target) {
  7165. return false;
  7166. }
  7167. for (var i = 0; i < this._disabledInputs.length; i++) {
  7168. if (this._disabledInputs[i] === target) {
  7169. return true;
  7170. }
  7171. }
  7172. return false;
  7173. },
  7174. /* Retrieve the instance data for the target control.
  7175. * @param target element - the target input field or division or span
  7176. * @return object - the associated instance data
  7177. * @throws error if a jQuery problem getting data
  7178. */
  7179. _getInst: function(target) {
  7180. try {
  7181. return $.data(target, "datepicker");
  7182. }
  7183. catch (err) {
  7184. throw "Missing instance data for this datepicker";
  7185. }
  7186. },
  7187. /* Update or retrieve the settings for a date picker attached to an input field or division.
  7188. * @param target element - the target input field or division or span
  7189. * @param name object - the new settings to update or
  7190. * string - the name of the setting to change or retrieve,
  7191. * when retrieving also "all" for all instance settings or
  7192. * "defaults" for all global defaults
  7193. * @param value any - the new value for the setting
  7194. * (omit if above is an object or to retrieve a value)
  7195. */
  7196. _optionDatepicker: function(target, name, value) {
  7197. var settings, date, minDate, maxDate,
  7198. inst = this._getInst(target);
  7199. if (arguments.length === 2 && typeof name === "string") {
  7200. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  7201. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  7202. this._get(inst, name)) : null));
  7203. }
  7204. settings = name || {};
  7205. if (typeof name === "string") {
  7206. settings = {};
  7207. settings[name] = value;
  7208. }
  7209. if (inst) {
  7210. if (this._curInst === inst) {
  7211. this._hideDatepicker();
  7212. }
  7213. date = this._getDateDatepicker(target, true);
  7214. minDate = this._getMinMaxDate(inst, "min");
  7215. maxDate = this._getMinMaxDate(inst, "max");
  7216. datepicker_extendRemove(inst.settings, settings);
  7217. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  7218. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  7219. inst.settings.minDate = this._formatDate(inst, minDate);
  7220. }
  7221. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  7222. inst.settings.maxDate = this._formatDate(inst, maxDate);
  7223. }
  7224. if ( "disabled" in settings ) {
  7225. if ( settings.disabled ) {
  7226. this._disableDatepicker(target);
  7227. } else {
  7228. this._enableDatepicker(target);
  7229. }
  7230. }
  7231. this._attachments($(target), inst);
  7232. this._autoSize(inst);
  7233. this._setDate(inst, date);
  7234. this._updateAlternate(inst);
  7235. this._updateDatepicker(inst);
  7236. }
  7237. },
  7238. // change method deprecated
  7239. _changeDatepicker: function(target, name, value) {
  7240. this._optionDatepicker(target, name, value);
  7241. },
  7242. /* Redraw the date picker attached to an input field or division.
  7243. * @param target element - the target input field or division or span
  7244. */
  7245. _refreshDatepicker: function(target) {
  7246. var inst = this._getInst(target);
  7247. if (inst) {
  7248. this._updateDatepicker(inst);
  7249. }
  7250. },
  7251. /* Set the dates for a jQuery selection.
  7252. * @param target element - the target input field or division or span
  7253. * @param date Date - the new date
  7254. */
  7255. _setDateDatepicker: function(target, date) {
  7256. var inst = this._getInst(target);
  7257. if (inst) {
  7258. this._setDate(inst, date);
  7259. this._updateDatepicker(inst);
  7260. this._updateAlternate(inst);
  7261. }
  7262. },
  7263. /* Get the date(s) for the first entry in a jQuery selection.
  7264. * @param target element - the target input field or division or span
  7265. * @param noDefault boolean - true if no default date is to be used
  7266. * @return Date - the current date
  7267. */
  7268. _getDateDatepicker: function(target, noDefault) {
  7269. var inst = this._getInst(target);
  7270. if (inst && !inst.inline) {
  7271. this._setDateFromField(inst, noDefault);
  7272. }
  7273. return (inst ? this._getDate(inst) : null);
  7274. },
  7275. /* Handle keystrokes. */
  7276. _doKeyDown: function(event) {
  7277. var onSelect, dateStr, sel,
  7278. inst = $.datepicker._getInst(event.target),
  7279. handled = true,
  7280. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  7281. inst._keyEvent = true;
  7282. if ($.datepicker._datepickerShowing) {
  7283. switch (event.keyCode) {
  7284. case 9: $.datepicker._hideDatepicker();
  7285. handled = false;
  7286. break; // hide on tab out
  7287. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  7288. $.datepicker._currentClass + ")", inst.dpDiv);
  7289. if (sel[0]) {
  7290. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  7291. }
  7292. onSelect = $.datepicker._get(inst, "onSelect");
  7293. if (onSelect) {
  7294. dateStr = $.datepicker._formatDate(inst);
  7295. // trigger custom callback
  7296. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  7297. } else {
  7298. $.datepicker._hideDatepicker();
  7299. }
  7300. return false; // don't submit the form
  7301. case 27: $.datepicker._hideDatepicker();
  7302. break; // hide on escape
  7303. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7304. -$.datepicker._get(inst, "stepBigMonths") :
  7305. -$.datepicker._get(inst, "stepMonths")), "M");
  7306. break; // previous month/year on page up/+ ctrl
  7307. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7308. +$.datepicker._get(inst, "stepBigMonths") :
  7309. +$.datepicker._get(inst, "stepMonths")), "M");
  7310. break; // next month/year on page down/+ ctrl
  7311. case 35: if (event.ctrlKey || event.metaKey) {
  7312. $.datepicker._clearDate(event.target);
  7313. }
  7314. handled = event.ctrlKey || event.metaKey;
  7315. break; // clear on ctrl or command +end
  7316. case 36: if (event.ctrlKey || event.metaKey) {
  7317. $.datepicker._gotoToday(event.target);
  7318. }
  7319. handled = event.ctrlKey || event.metaKey;
  7320. break; // current on ctrl or command +home
  7321. case 37: if (event.ctrlKey || event.metaKey) {
  7322. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  7323. }
  7324. handled = event.ctrlKey || event.metaKey;
  7325. // -1 day on ctrl or command +left
  7326. if (event.originalEvent.altKey) {
  7327. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7328. -$.datepicker._get(inst, "stepBigMonths") :
  7329. -$.datepicker._get(inst, "stepMonths")), "M");
  7330. }
  7331. // next month/year on alt +left on Mac
  7332. break;
  7333. case 38: if (event.ctrlKey || event.metaKey) {
  7334. $.datepicker._adjustDate(event.target, -7, "D");
  7335. }
  7336. handled = event.ctrlKey || event.metaKey;
  7337. break; // -1 week on ctrl or command +up
  7338. case 39: if (event.ctrlKey || event.metaKey) {
  7339. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  7340. }
  7341. handled = event.ctrlKey || event.metaKey;
  7342. // +1 day on ctrl or command +right
  7343. if (event.originalEvent.altKey) {
  7344. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7345. +$.datepicker._get(inst, "stepBigMonths") :
  7346. +$.datepicker._get(inst, "stepMonths")), "M");
  7347. }
  7348. // next month/year on alt +right
  7349. break;
  7350. case 40: if (event.ctrlKey || event.metaKey) {
  7351. $.datepicker._adjustDate(event.target, +7, "D");
  7352. }
  7353. handled = event.ctrlKey || event.metaKey;
  7354. break; // +1 week on ctrl or command +down
  7355. default: handled = false;
  7356. }
  7357. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  7358. $.datepicker._showDatepicker(this);
  7359. } else {
  7360. handled = false;
  7361. }
  7362. if (handled) {
  7363. event.preventDefault();
  7364. event.stopPropagation();
  7365. }
  7366. },
  7367. /* Filter entered characters - based on date format. */
  7368. _doKeyPress: function(event) {
  7369. var chars, chr,
  7370. inst = $.datepicker._getInst(event.target);
  7371. if ($.datepicker._get(inst, "constrainInput")) {
  7372. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  7373. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  7374. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  7375. }
  7376. },
  7377. /* Synchronise manual entry and field/alternate field. */
  7378. _doKeyUp: function(event) {
  7379. var date,
  7380. inst = $.datepicker._getInst(event.target);
  7381. if (inst.input.val() !== inst.lastVal) {
  7382. try {
  7383. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7384. (inst.input ? inst.input.val() : null),
  7385. $.datepicker._getFormatConfig(inst));
  7386. if (date) { // only if valid
  7387. $.datepicker._setDateFromField(inst);
  7388. $.datepicker._updateAlternate(inst);
  7389. $.datepicker._updateDatepicker(inst);
  7390. }
  7391. }
  7392. catch (err) {
  7393. }
  7394. }
  7395. return true;
  7396. },
  7397. /* Pop-up the date picker for a given input field.
  7398. * If false returned from beforeShow event handler do not show.
  7399. * @param input element - the input field attached to the date picker or
  7400. * event - if triggered by focus
  7401. */
  7402. _showDatepicker: function(input) {
  7403. input = input.target || input;
  7404. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  7405. input = $("input", input.parentNode)[0];
  7406. }
  7407. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  7408. return;
  7409. }
  7410. var inst, beforeShow, beforeShowSettings, isFixed,
  7411. offset, showAnim, duration;
  7412. inst = $.datepicker._getInst(input);
  7413. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  7414. $.datepicker._curInst.dpDiv.stop(true, true);
  7415. if ( inst && $.datepicker._datepickerShowing ) {
  7416. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  7417. }
  7418. }
  7419. beforeShow = $.datepicker._get(inst, "beforeShow");
  7420. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  7421. if(beforeShowSettings === false){
  7422. return;
  7423. }
  7424. datepicker_extendRemove(inst.settings, beforeShowSettings);
  7425. inst.lastVal = null;
  7426. $.datepicker._lastInput = input;
  7427. $.datepicker._setDateFromField(inst);
  7428. if ($.datepicker._inDialog) { // hide cursor
  7429. input.value = "";
  7430. }
  7431. if (!$.datepicker._pos) { // position below input
  7432. $.datepicker._pos = $.datepicker._findPos(input);
  7433. $.datepicker._pos[1] += input.offsetHeight; // add the height
  7434. }
  7435. isFixed = false;
  7436. $(input).parents().each(function() {
  7437. isFixed |= $(this).css("position") === "fixed";
  7438. return !isFixed;
  7439. });
  7440. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  7441. $.datepicker._pos = null;
  7442. //to avoid flashes on Firefox
  7443. inst.dpDiv.empty();
  7444. // determine sizing offscreen
  7445. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  7446. $.datepicker._updateDatepicker(inst);
  7447. // fix width for dynamic number of date pickers
  7448. // and adjust position before showing
  7449. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  7450. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  7451. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  7452. left: offset.left + "px", top: offset.top + "px"});
  7453. if (!inst.inline) {
  7454. showAnim = $.datepicker._get(inst, "showAnim");
  7455. duration = $.datepicker._get(inst, "duration");
  7456. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  7457. $.datepicker._datepickerShowing = true;
  7458. if ( $.effects && $.effects.effect[ showAnim ] ) {
  7459. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  7460. } else {
  7461. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  7462. }
  7463. if ( $.datepicker._shouldFocusInput( inst ) ) {
  7464. inst.input.focus();
  7465. }
  7466. $.datepicker._curInst = inst;
  7467. }
  7468. },
  7469. /* Generate the date picker content. */
  7470. _updateDatepicker: function(inst) {
  7471. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  7472. datepicker_instActive = inst; // for delegate hover events
  7473. inst.dpDiv.empty().append(this._generateHTML(inst));
  7474. this._attachHandlers(inst);
  7475. var origyearshtml,
  7476. numMonths = this._getNumberOfMonths(inst),
  7477. cols = numMonths[1],
  7478. width = 17,
  7479. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
  7480. if ( activeCell.length > 0 ) {
  7481. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  7482. }
  7483. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  7484. if (cols > 1) {
  7485. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  7486. }
  7487. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  7488. "Class"]("ui-datepicker-multi");
  7489. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  7490. "Class"]("ui-datepicker-rtl");
  7491. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  7492. inst.input.focus();
  7493. }
  7494. // deffered render of the years select (to avoid flashes on Firefox)
  7495. if( inst.yearshtml ){
  7496. origyearshtml = inst.yearshtml;
  7497. setTimeout(function(){
  7498. //assure that inst.yearshtml didn't change.
  7499. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  7500. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  7501. }
  7502. origyearshtml = inst.yearshtml = null;
  7503. }, 0);
  7504. }
  7505. },
  7506. // #6694 - don't focus the input if it's already focused
  7507. // this breaks the change event in IE
  7508. // Support: IE and jQuery <1.9
  7509. _shouldFocusInput: function( inst ) {
  7510. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  7511. },
  7512. /* Check positioning to remain on screen. */
  7513. _checkOffset: function(inst, offset, isFixed) {
  7514. var dpWidth = inst.dpDiv.outerWidth(),
  7515. dpHeight = inst.dpDiv.outerHeight(),
  7516. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  7517. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  7518. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  7519. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  7520. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  7521. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  7522. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  7523. // now check if datepicker is showing outside window viewport - move to a better place if so.
  7524. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  7525. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  7526. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  7527. Math.abs(dpHeight + inputHeight) : 0);
  7528. return offset;
  7529. },
  7530. /* Find an object's position on the screen. */
  7531. _findPos: function(obj) {
  7532. var position,
  7533. inst = this._getInst(obj),
  7534. isRTL = this._get(inst, "isRTL");
  7535. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  7536. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  7537. }
  7538. position = $(obj).offset();
  7539. return [position.left, position.top];
  7540. },
  7541. /* Hide the date picker from view.
  7542. * @param input element - the input field attached to the date picker
  7543. */
  7544. _hideDatepicker: function(input) {
  7545. var showAnim, duration, postProcess, onClose,
  7546. inst = this._curInst;
  7547. if (!inst || (input && inst !== $.data(input, "datepicker"))) {
  7548. return;
  7549. }
  7550. if (this._datepickerShowing) {
  7551. showAnim = this._get(inst, "showAnim");
  7552. duration = this._get(inst, "duration");
  7553. postProcess = function() {
  7554. $.datepicker._tidyDialog(inst);
  7555. };
  7556. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  7557. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  7558. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  7559. } else {
  7560. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  7561. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  7562. }
  7563. if (!showAnim) {
  7564. postProcess();
  7565. }
  7566. this._datepickerShowing = false;
  7567. onClose = this._get(inst, "onClose");
  7568. if (onClose) {
  7569. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  7570. }
  7571. this._lastInput = null;
  7572. if (this._inDialog) {
  7573. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  7574. if ($.blockUI) {
  7575. $.unblockUI();
  7576. $("body").append(this.dpDiv);
  7577. }
  7578. }
  7579. this._inDialog = false;
  7580. }
  7581. },
  7582. /* Tidy up after a dialog display. */
  7583. _tidyDialog: function(inst) {
  7584. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  7585. },
  7586. /* Close date picker if clicked elsewhere. */
  7587. _checkExternalClick: function(event) {
  7588. if (!$.datepicker._curInst) {
  7589. return;
  7590. }
  7591. var $target = $(event.target),
  7592. inst = $.datepicker._getInst($target[0]);
  7593. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  7594. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  7595. !$target.hasClass($.datepicker.markerClassName) &&
  7596. !$target.closest("." + $.datepicker._triggerClass).length &&
  7597. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  7598. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  7599. $.datepicker._hideDatepicker();
  7600. }
  7601. },
  7602. /* Adjust one of the date sub-fields. */
  7603. _adjustDate: function(id, offset, period) {
  7604. var target = $(id),
  7605. inst = this._getInst(target[0]);
  7606. if (this._isDisabledDatepicker(target[0])) {
  7607. return;
  7608. }
  7609. this._adjustInstDate(inst, offset +
  7610. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  7611. period);
  7612. this._updateDatepicker(inst);
  7613. },
  7614. /* Action for current link. */
  7615. _gotoToday: function(id) {
  7616. var date,
  7617. target = $(id),
  7618. inst = this._getInst(target[0]);
  7619. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  7620. inst.selectedDay = inst.currentDay;
  7621. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  7622. inst.drawYear = inst.selectedYear = inst.currentYear;
  7623. } else {
  7624. date = new Date();
  7625. inst.selectedDay = date.getDate();
  7626. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7627. inst.drawYear = inst.selectedYear = date.getFullYear();
  7628. }
  7629. this._notifyChange(inst);
  7630. this._adjustDate(target);
  7631. },
  7632. /* Action for selecting a new month/year. */
  7633. _selectMonthYear: function(id, select, period) {
  7634. var target = $(id),
  7635. inst = this._getInst(target[0]);
  7636. inst["selected" + (period === "M" ? "Month" : "Year")] =
  7637. inst["draw" + (period === "M" ? "Month" : "Year")] =
  7638. parseInt(select.options[select.selectedIndex].value,10);
  7639. this._notifyChange(inst);
  7640. this._adjustDate(target);
  7641. },
  7642. /* Action for selecting a day. */
  7643. _selectDay: function(id, month, year, td) {
  7644. var inst,
  7645. target = $(id);
  7646. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  7647. return;
  7648. }
  7649. inst = this._getInst(target[0]);
  7650. inst.selectedDay = inst.currentDay = $("a", td).html();
  7651. inst.selectedMonth = inst.currentMonth = month;
  7652. inst.selectedYear = inst.currentYear = year;
  7653. this._selectDate(id, this._formatDate(inst,
  7654. inst.currentDay, inst.currentMonth, inst.currentYear));
  7655. },
  7656. /* Erase the input field and hide the date picker. */
  7657. _clearDate: function(id) {
  7658. var target = $(id);
  7659. this._selectDate(target, "");
  7660. },
  7661. /* Update the input field with the selected date. */
  7662. _selectDate: function(id, dateStr) {
  7663. var onSelect,
  7664. target = $(id),
  7665. inst = this._getInst(target[0]);
  7666. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  7667. if (inst.input) {
  7668. inst.input.val(dateStr);
  7669. }
  7670. this._updateAlternate(inst);
  7671. onSelect = this._get(inst, "onSelect");
  7672. if (onSelect) {
  7673. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  7674. } else if (inst.input) {
  7675. inst.input.trigger("change"); // fire the change event
  7676. }
  7677. if (inst.inline){
  7678. this._updateDatepicker(inst);
  7679. } else {
  7680. this._hideDatepicker();
  7681. this._lastInput = inst.input[0];
  7682. if (typeof(inst.input[0]) !== "object") {
  7683. inst.input.focus(); // restore focus
  7684. }
  7685. this._lastInput = null;
  7686. }
  7687. },
  7688. /* Update any alternate field to synchronise with the main field. */
  7689. _updateAlternate: function(inst) {
  7690. var altFormat, date, dateStr,
  7691. altField = this._get(inst, "altField");
  7692. if (altField) { // update alternate field too
  7693. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  7694. date = this._getDate(inst);
  7695. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  7696. $(altField).each(function() { $(this).val(dateStr); });
  7697. }
  7698. },
  7699. /* Set as beforeShowDay function to prevent selection of weekends.
  7700. * @param date Date - the date to customise
  7701. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  7702. */
  7703. noWeekends: function(date) {
  7704. var day = date.getDay();
  7705. return [(day > 0 && day < 6), ""];
  7706. },
  7707. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  7708. * @param date Date - the date to get the week for
  7709. * @return number - the number of the week within the year that contains this date
  7710. */
  7711. iso8601Week: function(date) {
  7712. var time,
  7713. checkDate = new Date(date.getTime());
  7714. // Find Thursday of this week starting on Monday
  7715. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  7716. time = checkDate.getTime();
  7717. checkDate.setMonth(0); // Compare with Jan 1
  7718. checkDate.setDate(1);
  7719. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  7720. },
  7721. /* Parse a string value into a date object.
  7722. * See formatDate below for the possible formats.
  7723. *
  7724. * @param format string - the expected format of the date
  7725. * @param value string - the date in the above format
  7726. * @param settings Object - attributes include:
  7727. * shortYearCutoff number - the cutoff year for determining the century (optional)
  7728. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7729. * dayNames string[7] - names of the days from Sunday (optional)
  7730. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7731. * monthNames string[12] - names of the months (optional)
  7732. * @return Date - the extracted date value or null if value is blank
  7733. */
  7734. parseDate: function (format, value, settings) {
  7735. if (format == null || value == null) {
  7736. throw "Invalid arguments";
  7737. }
  7738. value = (typeof value === "object" ? value.toString() : value + "");
  7739. if (value === "") {
  7740. return null;
  7741. }
  7742. var iFormat, dim, extra,
  7743. iValue = 0,
  7744. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  7745. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  7746. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  7747. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7748. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7749. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7750. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7751. year = -1,
  7752. month = -1,
  7753. day = -1,
  7754. doy = -1,
  7755. literal = false,
  7756. date,
  7757. // Check whether a format character is doubled
  7758. lookAhead = function(match) {
  7759. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7760. if (matches) {
  7761. iFormat++;
  7762. }
  7763. return matches;
  7764. },
  7765. // Extract a number from the string value
  7766. getNumber = function(match) {
  7767. var isDoubled = lookAhead(match),
  7768. size = (match === "@" ? 14 : (match === "!" ? 20 :
  7769. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  7770. minSize = (match === "y" ? size : 1),
  7771. digits = new RegExp("^\\d{" + minSize + "," + size + "}"),
  7772. num = value.substring(iValue).match(digits);
  7773. if (!num) {
  7774. throw "Missing number at position " + iValue;
  7775. }
  7776. iValue += num[0].length;
  7777. return parseInt(num[0], 10);
  7778. },
  7779. // Extract a name from the string value and convert to an index
  7780. getName = function(match, shortNames, longNames) {
  7781. var index = -1,
  7782. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  7783. return [ [k, v] ];
  7784. }).sort(function (a, b) {
  7785. return -(a[1].length - b[1].length);
  7786. });
  7787. $.each(names, function (i, pair) {
  7788. var name = pair[1];
  7789. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  7790. index = pair[0];
  7791. iValue += name.length;
  7792. return false;
  7793. }
  7794. });
  7795. if (index !== -1) {
  7796. return index + 1;
  7797. } else {
  7798. throw "Unknown name at position " + iValue;
  7799. }
  7800. },
  7801. // Confirm that a literal character matches the string value
  7802. checkLiteral = function() {
  7803. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  7804. throw "Unexpected literal at position " + iValue;
  7805. }
  7806. iValue++;
  7807. };
  7808. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7809. if (literal) {
  7810. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7811. literal = false;
  7812. } else {
  7813. checkLiteral();
  7814. }
  7815. } else {
  7816. switch (format.charAt(iFormat)) {
  7817. case "d":
  7818. day = getNumber("d");
  7819. break;
  7820. case "D":
  7821. getName("D", dayNamesShort, dayNames);
  7822. break;
  7823. case "o":
  7824. doy = getNumber("o");
  7825. break;
  7826. case "m":
  7827. month = getNumber("m");
  7828. break;
  7829. case "M":
  7830. month = getName("M", monthNamesShort, monthNames);
  7831. break;
  7832. case "y":
  7833. year = getNumber("y");
  7834. break;
  7835. case "@":
  7836. date = new Date(getNumber("@"));
  7837. year = date.getFullYear();
  7838. month = date.getMonth() + 1;
  7839. day = date.getDate();
  7840. break;
  7841. case "!":
  7842. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  7843. year = date.getFullYear();
  7844. month = date.getMonth() + 1;
  7845. day = date.getDate();
  7846. break;
  7847. case "'":
  7848. if (lookAhead("'")){
  7849. checkLiteral();
  7850. } else {
  7851. literal = true;
  7852. }
  7853. break;
  7854. default:
  7855. checkLiteral();
  7856. }
  7857. }
  7858. }
  7859. if (iValue < value.length){
  7860. extra = value.substr(iValue);
  7861. if (!/^\s+/.test(extra)) {
  7862. throw "Extra/unparsed characters found in date: " + extra;
  7863. }
  7864. }
  7865. if (year === -1) {
  7866. year = new Date().getFullYear();
  7867. } else if (year < 100) {
  7868. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7869. (year <= shortYearCutoff ? 0 : -100);
  7870. }
  7871. if (doy > -1) {
  7872. month = 1;
  7873. day = doy;
  7874. do {
  7875. dim = this._getDaysInMonth(year, month - 1);
  7876. if (day <= dim) {
  7877. break;
  7878. }
  7879. month++;
  7880. day -= dim;
  7881. } while (true);
  7882. }
  7883. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  7884. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  7885. throw "Invalid date"; // E.g. 31/02/00
  7886. }
  7887. return date;
  7888. },
  7889. /* Standard date formats. */
  7890. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  7891. COOKIE: "D, dd M yy",
  7892. ISO_8601: "yy-mm-dd",
  7893. RFC_822: "D, d M y",
  7894. RFC_850: "DD, dd-M-y",
  7895. RFC_1036: "D, d M y",
  7896. RFC_1123: "D, d M yy",
  7897. RFC_2822: "D, d M yy",
  7898. RSS: "D, d M y", // RFC 822
  7899. TICKS: "!",
  7900. TIMESTAMP: "@",
  7901. W3C: "yy-mm-dd", // ISO 8601
  7902. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  7903. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  7904. /* Format a date object into a string value.
  7905. * The format can be combinations of the following:
  7906. * d - day of month (no leading zero)
  7907. * dd - day of month (two digit)
  7908. * o - day of year (no leading zeros)
  7909. * oo - day of year (three digit)
  7910. * D - day name short
  7911. * DD - day name long
  7912. * m - month of year (no leading zero)
  7913. * mm - month of year (two digit)
  7914. * M - month name short
  7915. * MM - month name long
  7916. * y - year (two digit)
  7917. * yy - year (four digit)
  7918. * @ - Unix timestamp (ms since 01/01/1970)
  7919. * ! - Windows ticks (100ns since 01/01/0001)
  7920. * "..." - literal text
  7921. * '' - single quote
  7922. *
  7923. * @param format string - the desired format of the date
  7924. * @param date Date - the date value to format
  7925. * @param settings Object - attributes include:
  7926. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7927. * dayNames string[7] - names of the days from Sunday (optional)
  7928. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7929. * monthNames string[12] - names of the months (optional)
  7930. * @return string - the date in the above format
  7931. */
  7932. formatDate: function (format, date, settings) {
  7933. if (!date) {
  7934. return "";
  7935. }
  7936. var iFormat,
  7937. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7938. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7939. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7940. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7941. // Check whether a format character is doubled
  7942. lookAhead = function(match) {
  7943. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7944. if (matches) {
  7945. iFormat++;
  7946. }
  7947. return matches;
  7948. },
  7949. // Format a number, with leading zero if necessary
  7950. formatNumber = function(match, value, len) {
  7951. var num = "" + value;
  7952. if (lookAhead(match)) {
  7953. while (num.length < len) {
  7954. num = "0" + num;
  7955. }
  7956. }
  7957. return num;
  7958. },
  7959. // Format a name, short or long as requested
  7960. formatName = function(match, value, shortNames, longNames) {
  7961. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  7962. },
  7963. output = "",
  7964. literal = false;
  7965. if (date) {
  7966. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7967. if (literal) {
  7968. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7969. literal = false;
  7970. } else {
  7971. output += format.charAt(iFormat);
  7972. }
  7973. } else {
  7974. switch (format.charAt(iFormat)) {
  7975. case "d":
  7976. output += formatNumber("d", date.getDate(), 2);
  7977. break;
  7978. case "D":
  7979. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  7980. break;
  7981. case "o":
  7982. output += formatNumber("o",
  7983. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  7984. break;
  7985. case "m":
  7986. output += formatNumber("m", date.getMonth() + 1, 2);
  7987. break;
  7988. case "M":
  7989. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  7990. break;
  7991. case "y":
  7992. output += (lookAhead("y") ? date.getFullYear() :
  7993. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  7994. break;
  7995. case "@":
  7996. output += date.getTime();
  7997. break;
  7998. case "!":
  7999. output += date.getTime() * 10000 + this._ticksTo1970;
  8000. break;
  8001. case "'":
  8002. if (lookAhead("'")) {
  8003. output += "'";
  8004. } else {
  8005. literal = true;
  8006. }
  8007. break;
  8008. default:
  8009. output += format.charAt(iFormat);
  8010. }
  8011. }
  8012. }
  8013. }
  8014. return output;
  8015. },
  8016. /* Extract all possible characters from the date format. */
  8017. _possibleChars: function (format) {
  8018. var iFormat,
  8019. chars = "",
  8020. literal = false,
  8021. // Check whether a format character is doubled
  8022. lookAhead = function(match) {
  8023. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  8024. if (matches) {
  8025. iFormat++;
  8026. }
  8027. return matches;
  8028. };
  8029. for (iFormat = 0; iFormat < format.length; iFormat++) {
  8030. if (literal) {
  8031. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  8032. literal = false;
  8033. } else {
  8034. chars += format.charAt(iFormat);
  8035. }
  8036. } else {
  8037. switch (format.charAt(iFormat)) {
  8038. case "d": case "m": case "y": case "@":
  8039. chars += "0123456789";
  8040. break;
  8041. case "D": case "M":
  8042. return null; // Accept anything
  8043. case "'":
  8044. if (lookAhead("'")) {
  8045. chars += "'";
  8046. } else {
  8047. literal = true;
  8048. }
  8049. break;
  8050. default:
  8051. chars += format.charAt(iFormat);
  8052. }
  8053. }
  8054. }
  8055. return chars;
  8056. },
  8057. /* Get a setting value, defaulting if necessary. */
  8058. _get: function(inst, name) {
  8059. return inst.settings[name] !== undefined ?
  8060. inst.settings[name] : this._defaults[name];
  8061. },
  8062. /* Parse existing date and initialise date picker. */
  8063. _setDateFromField: function(inst, noDefault) {
  8064. if (inst.input.val() === inst.lastVal) {
  8065. return;
  8066. }
  8067. var dateFormat = this._get(inst, "dateFormat"),
  8068. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  8069. defaultDate = this._getDefaultDate(inst),
  8070. date = defaultDate,
  8071. settings = this._getFormatConfig(inst);
  8072. try {
  8073. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  8074. } catch (event) {
  8075. dates = (noDefault ? "" : dates);
  8076. }
  8077. inst.selectedDay = date.getDate();
  8078. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8079. inst.drawYear = inst.selectedYear = date.getFullYear();
  8080. inst.currentDay = (dates ? date.getDate() : 0);
  8081. inst.currentMonth = (dates ? date.getMonth() : 0);
  8082. inst.currentYear = (dates ? date.getFullYear() : 0);
  8083. this._adjustInstDate(inst);
  8084. },
  8085. /* Retrieve the default date shown on opening. */
  8086. _getDefaultDate: function(inst) {
  8087. return this._restrictMinMax(inst,
  8088. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  8089. },
  8090. /* A date may be specified as an exact value or a relative one. */
  8091. _determineDate: function(inst, date, defaultDate) {
  8092. var offsetNumeric = function(offset) {
  8093. var date = new Date();
  8094. date.setDate(date.getDate() + offset);
  8095. return date;
  8096. },
  8097. offsetString = function(offset) {
  8098. try {
  8099. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  8100. offset, $.datepicker._getFormatConfig(inst));
  8101. }
  8102. catch (e) {
  8103. // Ignore
  8104. }
  8105. var date = (offset.toLowerCase().match(/^c/) ?
  8106. $.datepicker._getDate(inst) : null) || new Date(),
  8107. year = date.getFullYear(),
  8108. month = date.getMonth(),
  8109. day = date.getDate(),
  8110. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  8111. matches = pattern.exec(offset);
  8112. while (matches) {
  8113. switch (matches[2] || "d") {
  8114. case "d" : case "D" :
  8115. day += parseInt(matches[1],10); break;
  8116. case "w" : case "W" :
  8117. day += parseInt(matches[1],10) * 7; break;
  8118. case "m" : case "M" :
  8119. month += parseInt(matches[1],10);
  8120. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  8121. break;
  8122. case "y": case "Y" :
  8123. year += parseInt(matches[1],10);
  8124. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  8125. break;
  8126. }
  8127. matches = pattern.exec(offset);
  8128. }
  8129. return new Date(year, month, day);
  8130. },
  8131. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  8132. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  8133. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  8134. if (newDate) {
  8135. newDate.setHours(0);
  8136. newDate.setMinutes(0);
  8137. newDate.setSeconds(0);
  8138. newDate.setMilliseconds(0);
  8139. }
  8140. return this._daylightSavingAdjust(newDate);
  8141. },
  8142. /* Handle switch to/from daylight saving.
  8143. * Hours may be non-zero on daylight saving cut-over:
  8144. * > 12 when midnight changeover, but then cannot generate
  8145. * midnight datetime, so jump to 1AM, otherwise reset.
  8146. * @param date (Date) the date to check
  8147. * @return (Date) the corrected date
  8148. */
  8149. _daylightSavingAdjust: function(date) {
  8150. if (!date) {
  8151. return null;
  8152. }
  8153. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  8154. return date;
  8155. },
  8156. /* Set the date(s) directly. */
  8157. _setDate: function(inst, date, noChange) {
  8158. var clear = !date,
  8159. origMonth = inst.selectedMonth,
  8160. origYear = inst.selectedYear,
  8161. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  8162. inst.selectedDay = inst.currentDay = newDate.getDate();
  8163. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  8164. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  8165. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  8166. this._notifyChange(inst);
  8167. }
  8168. this._adjustInstDate(inst);
  8169. if (inst.input) {
  8170. inst.input.val(clear ? "" : this._formatDate(inst));
  8171. }
  8172. },
  8173. /* Retrieve the date(s) directly. */
  8174. _getDate: function(inst) {
  8175. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  8176. this._daylightSavingAdjust(new Date(
  8177. inst.currentYear, inst.currentMonth, inst.currentDay)));
  8178. return startDate;
  8179. },
  8180. /* Attach the onxxx handlers. These are declared statically so
  8181. * they work with static code transformers like Caja.
  8182. */
  8183. _attachHandlers: function(inst) {
  8184. var stepMonths = this._get(inst, "stepMonths"),
  8185. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  8186. inst.dpDiv.find("[data-handler]").map(function () {
  8187. var handler = {
  8188. prev: function () {
  8189. $.datepicker._adjustDate(id, -stepMonths, "M");
  8190. },
  8191. next: function () {
  8192. $.datepicker._adjustDate(id, +stepMonths, "M");
  8193. },
  8194. hide: function () {
  8195. $.datepicker._hideDatepicker();
  8196. },
  8197. today: function () {
  8198. $.datepicker._gotoToday(id);
  8199. },
  8200. selectDay: function () {
  8201. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  8202. return false;
  8203. },
  8204. selectMonth: function () {
  8205. $.datepicker._selectMonthYear(id, this, "M");
  8206. return false;
  8207. },
  8208. selectYear: function () {
  8209. $.datepicker._selectMonthYear(id, this, "Y");
  8210. return false;
  8211. }
  8212. };
  8213. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  8214. });
  8215. },
  8216. /* Generate the HTML for the current state of the date picker. */
  8217. _generateHTML: function(inst) {
  8218. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  8219. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  8220. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  8221. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  8222. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  8223. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  8224. tempDate = new Date(),
  8225. today = this._daylightSavingAdjust(
  8226. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  8227. isRTL = this._get(inst, "isRTL"),
  8228. showButtonPanel = this._get(inst, "showButtonPanel"),
  8229. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  8230. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  8231. numMonths = this._getNumberOfMonths(inst),
  8232. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  8233. stepMonths = this._get(inst, "stepMonths"),
  8234. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  8235. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  8236. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  8237. minDate = this._getMinMaxDate(inst, "min"),
  8238. maxDate = this._getMinMaxDate(inst, "max"),
  8239. drawMonth = inst.drawMonth - showCurrentAtPos,
  8240. drawYear = inst.drawYear;
  8241. if (drawMonth < 0) {
  8242. drawMonth += 12;
  8243. drawYear--;
  8244. }
  8245. if (maxDate) {
  8246. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  8247. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  8248. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  8249. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  8250. drawMonth--;
  8251. if (drawMonth < 0) {
  8252. drawMonth = 11;
  8253. drawYear--;
  8254. }
  8255. }
  8256. }
  8257. inst.drawMonth = drawMonth;
  8258. inst.drawYear = drawYear;
  8259. prevText = this._get(inst, "prevText");
  8260. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  8261. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  8262. this._getFormatConfig(inst)));
  8263. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  8264. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  8265. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  8266. (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>"));
  8267. nextText = this._get(inst, "nextText");
  8268. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  8269. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  8270. this._getFormatConfig(inst)));
  8271. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  8272. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  8273. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  8274. (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>"));
  8275. currentText = this._get(inst, "currentText");
  8276. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  8277. currentText = (!navigationAsDateFormat ? currentText :
  8278. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  8279. 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'>" +
  8280. this._get(inst, "closeText") + "</button>" : "");
  8281. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  8282. (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'" +
  8283. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  8284. firstDay = parseInt(this._get(inst, "firstDay"),10);
  8285. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  8286. showWeek = this._get(inst, "showWeek");
  8287. dayNames = this._get(inst, "dayNames");
  8288. dayNamesMin = this._get(inst, "dayNamesMin");
  8289. monthNames = this._get(inst, "monthNames");
  8290. monthNamesShort = this._get(inst, "monthNamesShort");
  8291. beforeShowDay = this._get(inst, "beforeShowDay");
  8292. showOtherMonths = this._get(inst, "showOtherMonths");
  8293. selectOtherMonths = this._get(inst, "selectOtherMonths");
  8294. defaultDate = this._getDefaultDate(inst);
  8295. html = "";
  8296. dow;
  8297. for (row = 0; row < numMonths[0]; row++) {
  8298. group = "";
  8299. this.maxRows = 4;
  8300. for (col = 0; col < numMonths[1]; col++) {
  8301. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  8302. cornerClass = " ui-corner-all";
  8303. calender = "";
  8304. if (isMultiMonth) {
  8305. calender += "<div class='ui-datepicker-group";
  8306. if (numMonths[1] > 1) {
  8307. switch (col) {
  8308. case 0: calender += " ui-datepicker-group-first";
  8309. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  8310. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  8311. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  8312. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  8313. }
  8314. }
  8315. calender += "'>";
  8316. }
  8317. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  8318. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  8319. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  8320. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  8321. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  8322. "</div><table class='ui-datepicker-calendar'><thead>" +
  8323. "<tr>";
  8324. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  8325. for (dow = 0; dow < 7; dow++) { // days of the week
  8326. day = (dow + firstDay) % 7;
  8327. thead += "<th scope='col'" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  8328. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  8329. }
  8330. calender += thead + "</tr></thead><tbody>";
  8331. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  8332. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  8333. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  8334. }
  8335. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  8336. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  8337. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  8338. this.maxRows = numRows;
  8339. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  8340. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  8341. calender += "<tr>";
  8342. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  8343. this._get(inst, "calculateWeek")(printDate) + "</td>");
  8344. for (dow = 0; dow < 7; dow++) { // create date picker days
  8345. daySettings = (beforeShowDay ?
  8346. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  8347. otherMonth = (printDate.getMonth() !== drawMonth);
  8348. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  8349. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  8350. tbody += "<td class='" +
  8351. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  8352. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  8353. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  8354. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  8355. // or defaultDate is current printedDate and defaultDate is selectedDate
  8356. " " + this._dayOverClass : "") + // highlight selected day
  8357. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  8358. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  8359. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  8360. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  8361. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  8362. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  8363. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  8364. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  8365. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  8366. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  8367. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  8368. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  8369. printDate.setDate(printDate.getDate() + 1);
  8370. printDate = this._daylightSavingAdjust(printDate);
  8371. }
  8372. calender += tbody + "</tr>";
  8373. }
  8374. drawMonth++;
  8375. if (drawMonth > 11) {
  8376. drawMonth = 0;
  8377. drawYear++;
  8378. }
  8379. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  8380. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  8381. group += calender;
  8382. }
  8383. html += group;
  8384. }
  8385. html += buttonPanel;
  8386. inst._keyEvent = false;
  8387. return html;
  8388. },
  8389. /* Generate the month and year header. */
  8390. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  8391. secondary, monthNames, monthNamesShort) {
  8392. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  8393. changeMonth = this._get(inst, "changeMonth"),
  8394. changeYear = this._get(inst, "changeYear"),
  8395. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  8396. html = "<div class='ui-datepicker-title'>",
  8397. monthHtml = "";
  8398. // month selection
  8399. if (secondary || !changeMonth) {
  8400. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  8401. } else {
  8402. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  8403. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  8404. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  8405. for ( month = 0; month < 12; month++) {
  8406. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  8407. monthHtml += "<option value='" + month + "'" +
  8408. (month === drawMonth ? " selected='selected'" : "") +
  8409. ">" + monthNamesShort[month] + "</option>";
  8410. }
  8411. }
  8412. monthHtml += "</select>";
  8413. }
  8414. if (!showMonthAfterYear) {
  8415. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  8416. }
  8417. // year selection
  8418. if ( !inst.yearshtml ) {
  8419. inst.yearshtml = "";
  8420. if (secondary || !changeYear) {
  8421. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  8422. } else {
  8423. // determine range of years to display
  8424. years = this._get(inst, "yearRange").split(":");
  8425. thisYear = new Date().getFullYear();
  8426. determineYear = function(value) {
  8427. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  8428. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  8429. parseInt(value, 10)));
  8430. return (isNaN(year) ? thisYear : year);
  8431. };
  8432. year = determineYear(years[0]);
  8433. endYear = Math.max(year, determineYear(years[1] || ""));
  8434. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  8435. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  8436. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  8437. for (; year <= endYear; year++) {
  8438. inst.yearshtml += "<option value='" + year + "'" +
  8439. (year === drawYear ? " selected='selected'" : "") +
  8440. ">" + year + "</option>";
  8441. }
  8442. inst.yearshtml += "</select>";
  8443. html += inst.yearshtml;
  8444. inst.yearshtml = null;
  8445. }
  8446. }
  8447. html += this._get(inst, "yearSuffix");
  8448. if (showMonthAfterYear) {
  8449. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  8450. }
  8451. html += "</div>"; // Close datepicker_header
  8452. return html;
  8453. },
  8454. /* Adjust one of the date sub-fields. */
  8455. _adjustInstDate: function(inst, offset, period) {
  8456. var year = inst.drawYear + (period === "Y" ? offset : 0),
  8457. month = inst.drawMonth + (period === "M" ? offset : 0),
  8458. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  8459. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  8460. inst.selectedDay = date.getDate();
  8461. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8462. inst.drawYear = inst.selectedYear = date.getFullYear();
  8463. if (period === "M" || period === "Y") {
  8464. this._notifyChange(inst);
  8465. }
  8466. },
  8467. /* Ensure a date is within any min/max bounds. */
  8468. _restrictMinMax: function(inst, date) {
  8469. var minDate = this._getMinMaxDate(inst, "min"),
  8470. maxDate = this._getMinMaxDate(inst, "max"),
  8471. newDate = (minDate && date < minDate ? minDate : date);
  8472. return (maxDate && newDate > maxDate ? maxDate : newDate);
  8473. },
  8474. /* Notify change of month/year. */
  8475. _notifyChange: function(inst) {
  8476. var onChange = this._get(inst, "onChangeMonthYear");
  8477. if (onChange) {
  8478. onChange.apply((inst.input ? inst.input[0] : null),
  8479. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  8480. }
  8481. },
  8482. /* Determine the number of months to show. */
  8483. _getNumberOfMonths: function(inst) {
  8484. var numMonths = this._get(inst, "numberOfMonths");
  8485. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  8486. },
  8487. /* Determine the current maximum date - ensure no time components are set. */
  8488. _getMinMaxDate: function(inst, minMax) {
  8489. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  8490. },
  8491. /* Find the number of days in a given month. */
  8492. _getDaysInMonth: function(year, month) {
  8493. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  8494. },
  8495. /* Find the day of the week of the first of a month. */
  8496. _getFirstDayOfMonth: function(year, month) {
  8497. return new Date(year, month, 1).getDay();
  8498. },
  8499. /* Determines if we should allow a "next/prev" month display change. */
  8500. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  8501. var numMonths = this._getNumberOfMonths(inst),
  8502. date = this._daylightSavingAdjust(new Date(curYear,
  8503. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  8504. if (offset < 0) {
  8505. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  8506. }
  8507. return this._isInRange(inst, date);
  8508. },
  8509. /* Is the given date in the accepted range? */
  8510. _isInRange: function(inst, date) {
  8511. var yearSplit, currentYear,
  8512. minDate = this._getMinMaxDate(inst, "min"),
  8513. maxDate = this._getMinMaxDate(inst, "max"),
  8514. minYear = null,
  8515. maxYear = null,
  8516. years = this._get(inst, "yearRange");
  8517. if (years){
  8518. yearSplit = years.split(":");
  8519. currentYear = new Date().getFullYear();
  8520. minYear = parseInt(yearSplit[0], 10);
  8521. maxYear = parseInt(yearSplit[1], 10);
  8522. if ( yearSplit[0].match(/[+\-].*/) ) {
  8523. minYear += currentYear;
  8524. }
  8525. if ( yearSplit[1].match(/[+\-].*/) ) {
  8526. maxYear += currentYear;
  8527. }
  8528. }
  8529. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  8530. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  8531. (!minYear || date.getFullYear() >= minYear) &&
  8532. (!maxYear || date.getFullYear() <= maxYear));
  8533. },
  8534. /* Provide the configuration settings for formatting/parsing. */
  8535. _getFormatConfig: function(inst) {
  8536. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  8537. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  8538. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  8539. return {shortYearCutoff: shortYearCutoff,
  8540. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  8541. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  8542. },
  8543. /* Format the given date for display. */
  8544. _formatDate: function(inst, day, month, year) {
  8545. if (!day) {
  8546. inst.currentDay = inst.selectedDay;
  8547. inst.currentMonth = inst.selectedMonth;
  8548. inst.currentYear = inst.selectedYear;
  8549. }
  8550. var date = (day ? (typeof day === "object" ? day :
  8551. this._daylightSavingAdjust(new Date(year, month, day))) :
  8552. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  8553. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  8554. }
  8555. });
  8556. /*
  8557. * Bind hover events for datepicker elements.
  8558. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  8559. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  8560. */
  8561. function datepicker_bindHover(dpDiv) {
  8562. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  8563. return dpDiv.delegate(selector, "mouseout", function() {
  8564. $(this).removeClass("ui-state-hover");
  8565. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8566. $(this).removeClass("ui-datepicker-prev-hover");
  8567. }
  8568. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8569. $(this).removeClass("ui-datepicker-next-hover");
  8570. }
  8571. })
  8572. .delegate( selector, "mouseover", datepicker_handleMouseover );
  8573. }
  8574. function datepicker_handleMouseover() {
  8575. if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) {
  8576. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  8577. $(this).addClass("ui-state-hover");
  8578. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8579. $(this).addClass("ui-datepicker-prev-hover");
  8580. }
  8581. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8582. $(this).addClass("ui-datepicker-next-hover");
  8583. }
  8584. }
  8585. }
  8586. /* jQuery extend now ignores nulls! */
  8587. function datepicker_extendRemove(target, props) {
  8588. $.extend(target, props);
  8589. for (var name in props) {
  8590. if (props[name] == null) {
  8591. target[name] = props[name];
  8592. }
  8593. }
  8594. return target;
  8595. }
  8596. /* Invoke the datepicker functionality.
  8597. @param options string - a command, optionally followed by additional parameters or
  8598. Object - settings for attaching new datepicker functionality
  8599. @return jQuery object */
  8600. $.fn.datepicker = function(options){
  8601. /* Verify an empty collection wasn't passed - Fixes #6976 */
  8602. if ( !this.length ) {
  8603. return this;
  8604. }
  8605. /* Initialise the date picker. */
  8606. if (!$.datepicker.initialized) {
  8607. $(document).mousedown($.datepicker._checkExternalClick);
  8608. $.datepicker.initialized = true;
  8609. }
  8610. /* Append datepicker main container to body if not exist. */
  8611. if ($("#"+$.datepicker._mainDivId).length === 0) {
  8612. $("body").append($.datepicker.dpDiv);
  8613. }
  8614. var otherArgs = Array.prototype.slice.call(arguments, 1);
  8615. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  8616. return $.datepicker["_" + options + "Datepicker"].
  8617. apply($.datepicker, [this[0]].concat(otherArgs));
  8618. }
  8619. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  8620. return $.datepicker["_" + options + "Datepicker"].
  8621. apply($.datepicker, [this[0]].concat(otherArgs));
  8622. }
  8623. return this.each(function() {
  8624. typeof options === "string" ?
  8625. $.datepicker["_" + options + "Datepicker"].
  8626. apply($.datepicker, [this].concat(otherArgs)) :
  8627. $.datepicker._attachDatepicker(this, options);
  8628. });
  8629. };
  8630. $.datepicker = new Datepicker(); // singleton instance
  8631. $.datepicker.initialized = false;
  8632. $.datepicker.uuid = new Date().getTime();
  8633. $.datepicker.version = "1.11.3";
  8634. var datepicker = $.datepicker;
  8635. /*!
  8636. * jQuery UI Dialog 1.11.3
  8637. * http://jqueryui.com
  8638. *
  8639. * Copyright jQuery Foundation and other contributors
  8640. * Released under the MIT license.
  8641. * http://jquery.org/license
  8642. *
  8643. * http://api.jqueryui.com/dialog/
  8644. */
  8645. var dialog = $.widget( "ui.dialog", {
  8646. version: "1.11.3",
  8647. options: {
  8648. appendTo: "body",
  8649. autoOpen: true,
  8650. buttons: [],
  8651. closeOnEscape: true,
  8652. closeText: "Close",
  8653. dialogClass: "",
  8654. draggable: true,
  8655. hide: null,
  8656. height: "auto",
  8657. maxHeight: null,
  8658. maxWidth: null,
  8659. minHeight: 150,
  8660. minWidth: 150,
  8661. modal: false,
  8662. position: {
  8663. my: "center",
  8664. at: "center",
  8665. of: window,
  8666. collision: "fit",
  8667. // Ensure the titlebar is always visible
  8668. using: function( pos ) {
  8669. var topOffset = $( this ).css( pos ).offset().top;
  8670. if ( topOffset < 0 ) {
  8671. $( this ).css( "top", pos.top - topOffset );
  8672. }
  8673. }
  8674. },
  8675. resizable: true,
  8676. show: null,
  8677. title: null,
  8678. width: 300,
  8679. // callbacks
  8680. beforeClose: null,
  8681. close: null,
  8682. drag: null,
  8683. dragStart: null,
  8684. dragStop: null,
  8685. focus: null,
  8686. open: null,
  8687. resize: null,
  8688. resizeStart: null,
  8689. resizeStop: null
  8690. },
  8691. sizeRelatedOptions: {
  8692. buttons: true,
  8693. height: true,
  8694. maxHeight: true,
  8695. maxWidth: true,
  8696. minHeight: true,
  8697. minWidth: true,
  8698. width: true
  8699. },
  8700. resizableRelatedOptions: {
  8701. maxHeight: true,
  8702. maxWidth: true,
  8703. minHeight: true,
  8704. minWidth: true
  8705. },
  8706. _create: function() {
  8707. this.originalCss = {
  8708. display: this.element[ 0 ].style.display,
  8709. width: this.element[ 0 ].style.width,
  8710. minHeight: this.element[ 0 ].style.minHeight,
  8711. maxHeight: this.element[ 0 ].style.maxHeight,
  8712. height: this.element[ 0 ].style.height
  8713. };
  8714. this.originalPosition = {
  8715. parent: this.element.parent(),
  8716. index: this.element.parent().children().index( this.element )
  8717. };
  8718. this.originalTitle = this.element.attr( "title" );
  8719. this.options.title = this.options.title || this.originalTitle;
  8720. this._createWrapper();
  8721. this.element
  8722. .show()
  8723. .removeAttr( "title" )
  8724. .addClass( "ui-dialog-content ui-widget-content" )
  8725. .appendTo( this.uiDialog );
  8726. this._createTitlebar();
  8727. this._createButtonPane();
  8728. if ( this.options.draggable && $.fn.draggable ) {
  8729. this._makeDraggable();
  8730. }
  8731. if ( this.options.resizable && $.fn.resizable ) {
  8732. this._makeResizable();
  8733. }
  8734. this._isOpen = false;
  8735. this._trackFocus();
  8736. },
  8737. _init: function() {
  8738. if ( this.options.autoOpen ) {
  8739. this.open();
  8740. }
  8741. },
  8742. _appendTo: function() {
  8743. var element = this.options.appendTo;
  8744. if ( element && (element.jquery || element.nodeType) ) {
  8745. return $( element );
  8746. }
  8747. return this.document.find( element || "body" ).eq( 0 );
  8748. },
  8749. _destroy: function() {
  8750. var next,
  8751. originalPosition = this.originalPosition;
  8752. this._destroyOverlay();
  8753. this.element
  8754. .removeUniqueId()
  8755. .removeClass( "ui-dialog-content ui-widget-content" )
  8756. .css( this.originalCss )
  8757. // Without detaching first, the following becomes really slow
  8758. .detach();
  8759. this.uiDialog.stop( true, true ).remove();
  8760. if ( this.originalTitle ) {
  8761. this.element.attr( "title", this.originalTitle );
  8762. }
  8763. next = originalPosition.parent.children().eq( originalPosition.index );
  8764. // Don't try to place the dialog next to itself (#8613)
  8765. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  8766. next.before( this.element );
  8767. } else {
  8768. originalPosition.parent.append( this.element );
  8769. }
  8770. },
  8771. widget: function() {
  8772. return this.uiDialog;
  8773. },
  8774. disable: $.noop,
  8775. enable: $.noop,
  8776. close: function( event ) {
  8777. var activeElement,
  8778. that = this;
  8779. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  8780. return;
  8781. }
  8782. this._isOpen = false;
  8783. this._focusedElement = null;
  8784. this._destroyOverlay();
  8785. this._untrackInstance();
  8786. if ( !this.opener.filter( ":focusable" ).focus().length ) {
  8787. // support: IE9
  8788. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  8789. try {
  8790. activeElement = this.document[ 0 ].activeElement;
  8791. // Support: IE9, IE10
  8792. // If the <body> is blurred, IE will switch windows, see #4520
  8793. if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {
  8794. // Hiding a focused element doesn't trigger blur in WebKit
  8795. // so in case we have nothing to focus on, explicitly blur the active element
  8796. // https://bugs.webkit.org/show_bug.cgi?id=47182
  8797. $( activeElement ).blur();
  8798. }
  8799. } catch ( error ) {}
  8800. }
  8801. this._hide( this.uiDialog, this.options.hide, function() {
  8802. that._trigger( "close", event );
  8803. });
  8804. },
  8805. isOpen: function() {
  8806. return this._isOpen;
  8807. },
  8808. moveToTop: function() {
  8809. this._moveToTop();
  8810. },
  8811. _moveToTop: function( event, silent ) {
  8812. var moved = false,
  8813. zIndicies = this.uiDialog.siblings( ".ui-front:visible" ).map(function() {
  8814. return +$( this ).css( "z-index" );
  8815. }).get(),
  8816. zIndexMax = Math.max.apply( null, zIndicies );
  8817. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  8818. this.uiDialog.css( "z-index", zIndexMax + 1 );
  8819. moved = true;
  8820. }
  8821. if ( moved && !silent ) {
  8822. this._trigger( "focus", event );
  8823. }
  8824. return moved;
  8825. },
  8826. open: function() {
  8827. var that = this;
  8828. if ( this._isOpen ) {
  8829. if ( this._moveToTop() ) {
  8830. this._focusTabbable();
  8831. }
  8832. return;
  8833. }
  8834. this._isOpen = true;
  8835. this.opener = $( this.document[ 0 ].activeElement );
  8836. this._size();
  8837. this._position();
  8838. this._createOverlay();
  8839. this._moveToTop( null, true );
  8840. // Ensure the overlay is moved to the top with the dialog, but only when
  8841. // opening. The overlay shouldn't move after the dialog is open so that
  8842. // modeless dialogs opened after the modal dialog stack properly.
  8843. if ( this.overlay ) {
  8844. this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
  8845. }
  8846. this._show( this.uiDialog, this.options.show, function() {
  8847. that._focusTabbable();
  8848. that._trigger( "focus" );
  8849. });
  8850. // Track the dialog immediately upon openening in case a focus event
  8851. // somehow occurs outside of the dialog before an element inside the
  8852. // dialog is focused (#10152)
  8853. this._makeFocusTarget();
  8854. this._trigger( "open" );
  8855. },
  8856. _focusTabbable: function() {
  8857. // Set focus to the first match:
  8858. // 1. An element that was focused previously
  8859. // 2. First element inside the dialog matching [autofocus]
  8860. // 3. Tabbable element inside the content element
  8861. // 4. Tabbable element inside the buttonpane
  8862. // 5. The close button
  8863. // 6. The dialog itself
  8864. var hasFocus = this._focusedElement;
  8865. if ( !hasFocus ) {
  8866. hasFocus = this.element.find( "[autofocus]" );
  8867. }
  8868. if ( !hasFocus.length ) {
  8869. hasFocus = this.element.find( ":tabbable" );
  8870. }
  8871. if ( !hasFocus.length ) {
  8872. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  8873. }
  8874. if ( !hasFocus.length ) {
  8875. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  8876. }
  8877. if ( !hasFocus.length ) {
  8878. hasFocus = this.uiDialog;
  8879. }
  8880. hasFocus.eq( 0 ).focus();
  8881. },
  8882. _keepFocus: function( event ) {
  8883. function checkFocus() {
  8884. var activeElement = this.document[0].activeElement,
  8885. isActive = this.uiDialog[0] === activeElement ||
  8886. $.contains( this.uiDialog[0], activeElement );
  8887. if ( !isActive ) {
  8888. this._focusTabbable();
  8889. }
  8890. }
  8891. event.preventDefault();
  8892. checkFocus.call( this );
  8893. // support: IE
  8894. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  8895. // so we check again later
  8896. this._delay( checkFocus );
  8897. },
  8898. _createWrapper: function() {
  8899. this.uiDialog = $("<div>")
  8900. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  8901. this.options.dialogClass )
  8902. .hide()
  8903. .attr({
  8904. // Setting tabIndex makes the div focusable
  8905. tabIndex: -1,
  8906. role: "dialog"
  8907. })
  8908. .appendTo( this._appendTo() );
  8909. this._on( this.uiDialog, {
  8910. keydown: function( event ) {
  8911. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  8912. event.keyCode === $.ui.keyCode.ESCAPE ) {
  8913. event.preventDefault();
  8914. this.close( event );
  8915. return;
  8916. }
  8917. // prevent tabbing out of dialogs
  8918. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  8919. return;
  8920. }
  8921. var tabbables = this.uiDialog.find( ":tabbable" ),
  8922. first = tabbables.filter( ":first" ),
  8923. last = tabbables.filter( ":last" );
  8924. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  8925. this._delay(function() {
  8926. first.focus();
  8927. });
  8928. event.preventDefault();
  8929. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  8930. this._delay(function() {
  8931. last.focus();
  8932. });
  8933. event.preventDefault();
  8934. }
  8935. },
  8936. mousedown: function( event ) {
  8937. if ( this._moveToTop( event ) ) {
  8938. this._focusTabbable();
  8939. }
  8940. }
  8941. });
  8942. // We assume that any existing aria-describedby attribute means
  8943. // that the dialog content is marked up properly
  8944. // otherwise we brute force the content as the description
  8945. if ( !this.element.find( "[aria-describedby]" ).length ) {
  8946. this.uiDialog.attr({
  8947. "aria-describedby": this.element.uniqueId().attr( "id" )
  8948. });
  8949. }
  8950. },
  8951. _createTitlebar: function() {
  8952. var uiDialogTitle;
  8953. this.uiDialogTitlebar = $( "<div>" )
  8954. .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" )
  8955. .prependTo( this.uiDialog );
  8956. this._on( this.uiDialogTitlebar, {
  8957. mousedown: function( event ) {
  8958. // Don't prevent click on close button (#8838)
  8959. // Focusing a dialog that is partially scrolled out of view
  8960. // causes the browser to scroll it into view, preventing the click event
  8961. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  8962. // Dialog isn't getting focus when dragging (#8063)
  8963. this.uiDialog.focus();
  8964. }
  8965. }
  8966. });
  8967. // support: IE
  8968. // Use type="button" to prevent enter keypresses in textboxes from closing the
  8969. // dialog in IE (#9312)
  8970. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  8971. .button({
  8972. label: this.options.closeText,
  8973. icons: {
  8974. primary: "ui-icon-closethick"
  8975. },
  8976. text: false
  8977. })
  8978. .addClass( "ui-dialog-titlebar-close" )
  8979. .appendTo( this.uiDialogTitlebar );
  8980. this._on( this.uiDialogTitlebarClose, {
  8981. click: function( event ) {
  8982. event.preventDefault();
  8983. this.close( event );
  8984. }
  8985. });
  8986. uiDialogTitle = $( "<span>" )
  8987. .uniqueId()
  8988. .addClass( "ui-dialog-title" )
  8989. .prependTo( this.uiDialogTitlebar );
  8990. this._title( uiDialogTitle );
  8991. this.uiDialog.attr({
  8992. "aria-labelledby": uiDialogTitle.attr( "id" )
  8993. });
  8994. },
  8995. _title: function( title ) {
  8996. if ( !this.options.title ) {
  8997. title.html( "&#160;" );
  8998. }
  8999. title.text( this.options.title );
  9000. },
  9001. _createButtonPane: function() {
  9002. this.uiDialogButtonPane = $( "<div>" )
  9003. .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
  9004. this.uiButtonSet = $( "<div>" )
  9005. .addClass( "ui-dialog-buttonset" )
  9006. .appendTo( this.uiDialogButtonPane );
  9007. this._createButtons();
  9008. },
  9009. _createButtons: function() {
  9010. var that = this,
  9011. buttons = this.options.buttons;
  9012. // if we already have a button pane, remove it
  9013. this.uiDialogButtonPane.remove();
  9014. this.uiButtonSet.empty();
  9015. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  9016. this.uiDialog.removeClass( "ui-dialog-buttons" );
  9017. return;
  9018. }
  9019. $.each( buttons, function( name, props ) {
  9020. var click, buttonOptions;
  9021. props = $.isFunction( props ) ?
  9022. { click: props, text: name } :
  9023. props;
  9024. // Default to a non-submitting button
  9025. props = $.extend( { type: "button" }, props );
  9026. // Change the context for the click callback to be the main element
  9027. click = props.click;
  9028. props.click = function() {
  9029. click.apply( that.element[ 0 ], arguments );
  9030. };
  9031. buttonOptions = {
  9032. icons: props.icons,
  9033. text: props.showText
  9034. };
  9035. delete props.icons;
  9036. delete props.showText;
  9037. $( "<button></button>", props )
  9038. .button( buttonOptions )
  9039. .appendTo( that.uiButtonSet );
  9040. });
  9041. this.uiDialog.addClass( "ui-dialog-buttons" );
  9042. this.uiDialogButtonPane.appendTo( this.uiDialog );
  9043. },
  9044. _makeDraggable: function() {
  9045. var that = this,
  9046. options = this.options;
  9047. function filteredUi( ui ) {
  9048. return {
  9049. position: ui.position,
  9050. offset: ui.offset
  9051. };
  9052. }
  9053. this.uiDialog.draggable({
  9054. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  9055. handle: ".ui-dialog-titlebar",
  9056. containment: "document",
  9057. start: function( event, ui ) {
  9058. $( this ).addClass( "ui-dialog-dragging" );
  9059. that._blockFrames();
  9060. that._trigger( "dragStart", event, filteredUi( ui ) );
  9061. },
  9062. drag: function( event, ui ) {
  9063. that._trigger( "drag", event, filteredUi( ui ) );
  9064. },
  9065. stop: function( event, ui ) {
  9066. var left = ui.offset.left - that.document.scrollLeft(),
  9067. top = ui.offset.top - that.document.scrollTop();
  9068. options.position = {
  9069. my: "left top",
  9070. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  9071. "top" + (top >= 0 ? "+" : "") + top,
  9072. of: that.window
  9073. };
  9074. $( this ).removeClass( "ui-dialog-dragging" );
  9075. that._unblockFrames();
  9076. that._trigger( "dragStop", event, filteredUi( ui ) );
  9077. }
  9078. });
  9079. },
  9080. _makeResizable: function() {
  9081. var that = this,
  9082. options = this.options,
  9083. handles = options.resizable,
  9084. // .ui-resizable has position: relative defined in the stylesheet
  9085. // but dialogs have to use absolute or fixed positioning
  9086. position = this.uiDialog.css("position"),
  9087. resizeHandles = typeof handles === "string" ?
  9088. handles :
  9089. "n,e,s,w,se,sw,ne,nw";
  9090. function filteredUi( ui ) {
  9091. return {
  9092. originalPosition: ui.originalPosition,
  9093. originalSize: ui.originalSize,
  9094. position: ui.position,
  9095. size: ui.size
  9096. };
  9097. }
  9098. this.uiDialog.resizable({
  9099. cancel: ".ui-dialog-content",
  9100. containment: "document",
  9101. alsoResize: this.element,
  9102. maxWidth: options.maxWidth,
  9103. maxHeight: options.maxHeight,
  9104. minWidth: options.minWidth,
  9105. minHeight: this._minHeight(),
  9106. handles: resizeHandles,
  9107. start: function( event, ui ) {
  9108. $( this ).addClass( "ui-dialog-resizing" );
  9109. that._blockFrames();
  9110. that._trigger( "resizeStart", event, filteredUi( ui ) );
  9111. },
  9112. resize: function( event, ui ) {
  9113. that._trigger( "resize", event, filteredUi( ui ) );
  9114. },
  9115. stop: function( event, ui ) {
  9116. var offset = that.uiDialog.offset(),
  9117. left = offset.left - that.document.scrollLeft(),
  9118. top = offset.top - that.document.scrollTop();
  9119. options.height = that.uiDialog.height();
  9120. options.width = that.uiDialog.width();
  9121. options.position = {
  9122. my: "left top",
  9123. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  9124. "top" + (top >= 0 ? "+" : "") + top,
  9125. of: that.window
  9126. };
  9127. $( this ).removeClass( "ui-dialog-resizing" );
  9128. that._unblockFrames();
  9129. that._trigger( "resizeStop", event, filteredUi( ui ) );
  9130. }
  9131. })
  9132. .css( "position", position );
  9133. },
  9134. _trackFocus: function() {
  9135. this._on( this.widget(), {
  9136. focusin: function( event ) {
  9137. this._makeFocusTarget();
  9138. this._focusedElement = $( event.target );
  9139. }
  9140. });
  9141. },
  9142. _makeFocusTarget: function() {
  9143. this._untrackInstance();
  9144. this._trackingInstances().unshift( this );
  9145. },
  9146. _untrackInstance: function() {
  9147. var instances = this._trackingInstances(),
  9148. exists = $.inArray( this, instances );
  9149. if ( exists !== -1 ) {
  9150. instances.splice( exists, 1 );
  9151. }
  9152. },
  9153. _trackingInstances: function() {
  9154. var instances = this.document.data( "ui-dialog-instances" );
  9155. if ( !instances ) {
  9156. instances = [];
  9157. this.document.data( "ui-dialog-instances", instances );
  9158. }
  9159. return instances;
  9160. },
  9161. _minHeight: function() {
  9162. var options = this.options;
  9163. return options.height === "auto" ?
  9164. options.minHeight :
  9165. Math.min( options.minHeight, options.height );
  9166. },
  9167. _position: function() {
  9168. // Need to show the dialog to get the actual offset in the position plugin
  9169. var isVisible = this.uiDialog.is( ":visible" );
  9170. if ( !isVisible ) {
  9171. this.uiDialog.show();
  9172. }
  9173. this.uiDialog.position( this.options.position );
  9174. if ( !isVisible ) {
  9175. this.uiDialog.hide();
  9176. }
  9177. },
  9178. _setOptions: function( options ) {
  9179. var that = this,
  9180. resize = false,
  9181. resizableOptions = {};
  9182. $.each( options, function( key, value ) {
  9183. that._setOption( key, value );
  9184. if ( key in that.sizeRelatedOptions ) {
  9185. resize = true;
  9186. }
  9187. if ( key in that.resizableRelatedOptions ) {
  9188. resizableOptions[ key ] = value;
  9189. }
  9190. });
  9191. if ( resize ) {
  9192. this._size();
  9193. this._position();
  9194. }
  9195. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  9196. this.uiDialog.resizable( "option", resizableOptions );
  9197. }
  9198. },
  9199. _setOption: function( key, value ) {
  9200. var isDraggable, isResizable,
  9201. uiDialog = this.uiDialog;
  9202. if ( key === "dialogClass" ) {
  9203. uiDialog
  9204. .removeClass( this.options.dialogClass )
  9205. .addClass( value );
  9206. }
  9207. if ( key === "disabled" ) {
  9208. return;
  9209. }
  9210. this._super( key, value );
  9211. if ( key === "appendTo" ) {
  9212. this.uiDialog.appendTo( this._appendTo() );
  9213. }
  9214. if ( key === "buttons" ) {
  9215. this._createButtons();
  9216. }
  9217. if ( key === "closeText" ) {
  9218. this.uiDialogTitlebarClose.button({
  9219. // Ensure that we always pass a string
  9220. label: "" + value
  9221. });
  9222. }
  9223. if ( key === "draggable" ) {
  9224. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  9225. if ( isDraggable && !value ) {
  9226. uiDialog.draggable( "destroy" );
  9227. }
  9228. if ( !isDraggable && value ) {
  9229. this._makeDraggable();
  9230. }
  9231. }
  9232. if ( key === "position" ) {
  9233. this._position();
  9234. }
  9235. if ( key === "resizable" ) {
  9236. // currently resizable, becoming non-resizable
  9237. isResizable = uiDialog.is( ":data(ui-resizable)" );
  9238. if ( isResizable && !value ) {
  9239. uiDialog.resizable( "destroy" );
  9240. }
  9241. // currently resizable, changing handles
  9242. if ( isResizable && typeof value === "string" ) {
  9243. uiDialog.resizable( "option", "handles", value );
  9244. }
  9245. // currently non-resizable, becoming resizable
  9246. if ( !isResizable && value !== false ) {
  9247. this._makeResizable();
  9248. }
  9249. }
  9250. if ( key === "title" ) {
  9251. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  9252. }
  9253. },
  9254. _size: function() {
  9255. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  9256. // divs will both have width and height set, so we need to reset them
  9257. var nonContentHeight, minContentHeight, maxContentHeight,
  9258. options = this.options;
  9259. // Reset content sizing
  9260. this.element.show().css({
  9261. width: "auto",
  9262. minHeight: 0,
  9263. maxHeight: "none",
  9264. height: 0
  9265. });
  9266. if ( options.minWidth > options.width ) {
  9267. options.width = options.minWidth;
  9268. }
  9269. // reset wrapper sizing
  9270. // determine the height of all the non-content elements
  9271. nonContentHeight = this.uiDialog.css({
  9272. height: "auto",
  9273. width: options.width
  9274. })
  9275. .outerHeight();
  9276. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  9277. maxContentHeight = typeof options.maxHeight === "number" ?
  9278. Math.max( 0, options.maxHeight - nonContentHeight ) :
  9279. "none";
  9280. if ( options.height === "auto" ) {
  9281. this.element.css({
  9282. minHeight: minContentHeight,
  9283. maxHeight: maxContentHeight,
  9284. height: "auto"
  9285. });
  9286. } else {
  9287. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  9288. }
  9289. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  9290. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  9291. }
  9292. },
  9293. _blockFrames: function() {
  9294. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  9295. var iframe = $( this );
  9296. return $( "<div>" )
  9297. .css({
  9298. position: "absolute",
  9299. width: iframe.outerWidth(),
  9300. height: iframe.outerHeight()
  9301. })
  9302. .appendTo( iframe.parent() )
  9303. .offset( iframe.offset() )[0];
  9304. });
  9305. },
  9306. _unblockFrames: function() {
  9307. if ( this.iframeBlocks ) {
  9308. this.iframeBlocks.remove();
  9309. delete this.iframeBlocks;
  9310. }
  9311. },
  9312. _allowInteraction: function( event ) {
  9313. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  9314. return true;
  9315. }
  9316. // TODO: Remove hack when datepicker implements
  9317. // the .ui-front logic (#8989)
  9318. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  9319. },
  9320. _createOverlay: function() {
  9321. if ( !this.options.modal ) {
  9322. return;
  9323. }
  9324. // We use a delay in case the overlay is created from an
  9325. // event that we're going to be cancelling (#2804)
  9326. var isOpening = true;
  9327. this._delay(function() {
  9328. isOpening = false;
  9329. });
  9330. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  9331. // Prevent use of anchors and inputs
  9332. // Using _on() for an event handler shared across many instances is
  9333. // safe because the dialogs stack and must be closed in reverse order
  9334. this._on( this.document, {
  9335. focusin: function( event ) {
  9336. if ( isOpening ) {
  9337. return;
  9338. }
  9339. if ( !this._allowInteraction( event ) ) {
  9340. event.preventDefault();
  9341. this._trackingInstances()[ 0 ]._focusTabbable();
  9342. }
  9343. }
  9344. });
  9345. }
  9346. this.overlay = $( "<div>" )
  9347. .addClass( "ui-widget-overlay ui-front" )
  9348. .appendTo( this._appendTo() );
  9349. this._on( this.overlay, {
  9350. mousedown: "_keepFocus"
  9351. });
  9352. this.document.data( "ui-dialog-overlays",
  9353. (this.document.data( "ui-dialog-overlays" ) || 0) + 1 );
  9354. },
  9355. _destroyOverlay: function() {
  9356. if ( !this.options.modal ) {
  9357. return;
  9358. }
  9359. if ( this.overlay ) {
  9360. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  9361. if ( !overlays ) {
  9362. this.document
  9363. .unbind( "focusin" )
  9364. .removeData( "ui-dialog-overlays" );
  9365. } else {
  9366. this.document.data( "ui-dialog-overlays", overlays );
  9367. }
  9368. this.overlay.remove();
  9369. this.overlay = null;
  9370. }
  9371. }
  9372. });
  9373. /*!
  9374. * jQuery UI Progressbar 1.11.3
  9375. * http://jqueryui.com
  9376. *
  9377. * Copyright jQuery Foundation and other contributors
  9378. * Released under the MIT license.
  9379. * http://jquery.org/license
  9380. *
  9381. * http://api.jqueryui.com/progressbar/
  9382. */
  9383. var progressbar = $.widget( "ui.progressbar", {
  9384. version: "1.11.3",
  9385. options: {
  9386. max: 100,
  9387. value: 0,
  9388. change: null,
  9389. complete: null
  9390. },
  9391. min: 0,
  9392. _create: function() {
  9393. // Constrain initial value
  9394. this.oldValue = this.options.value = this._constrainedValue();
  9395. this.element
  9396. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  9397. .attr({
  9398. // Only set static values, aria-valuenow and aria-valuemax are
  9399. // set inside _refreshValue()
  9400. role: "progressbar",
  9401. "aria-valuemin": this.min
  9402. });
  9403. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  9404. .appendTo( this.element );
  9405. this._refreshValue();
  9406. },
  9407. _destroy: function() {
  9408. this.element
  9409. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  9410. .removeAttr( "role" )
  9411. .removeAttr( "aria-valuemin" )
  9412. .removeAttr( "aria-valuemax" )
  9413. .removeAttr( "aria-valuenow" );
  9414. this.valueDiv.remove();
  9415. },
  9416. value: function( newValue ) {
  9417. if ( newValue === undefined ) {
  9418. return this.options.value;
  9419. }
  9420. this.options.value = this._constrainedValue( newValue );
  9421. this._refreshValue();
  9422. },
  9423. _constrainedValue: function( newValue ) {
  9424. if ( newValue === undefined ) {
  9425. newValue = this.options.value;
  9426. }
  9427. this.indeterminate = newValue === false;
  9428. // sanitize value
  9429. if ( typeof newValue !== "number" ) {
  9430. newValue = 0;
  9431. }
  9432. return this.indeterminate ? false :
  9433. Math.min( this.options.max, Math.max( this.min, newValue ) );
  9434. },
  9435. _setOptions: function( options ) {
  9436. // Ensure "value" option is set after other values (like max)
  9437. var value = options.value;
  9438. delete options.value;
  9439. this._super( options );
  9440. this.options.value = this._constrainedValue( value );
  9441. this._refreshValue();
  9442. },
  9443. _setOption: function( key, value ) {
  9444. if ( key === "max" ) {
  9445. // Don't allow a max less than min
  9446. value = Math.max( this.min, value );
  9447. }
  9448. if ( key === "disabled" ) {
  9449. this.element
  9450. .toggleClass( "ui-state-disabled", !!value )
  9451. .attr( "aria-disabled", value );
  9452. }
  9453. this._super( key, value );
  9454. },
  9455. _percentage: function() {
  9456. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  9457. },
  9458. _refreshValue: function() {
  9459. var value = this.options.value,
  9460. percentage = this._percentage();
  9461. this.valueDiv
  9462. .toggle( this.indeterminate || value > this.min )
  9463. .toggleClass( "ui-corner-right", value === this.options.max )
  9464. .width( percentage.toFixed(0) + "%" );
  9465. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  9466. if ( this.indeterminate ) {
  9467. this.element.removeAttr( "aria-valuenow" );
  9468. if ( !this.overlayDiv ) {
  9469. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  9470. }
  9471. } else {
  9472. this.element.attr({
  9473. "aria-valuemax": this.options.max,
  9474. "aria-valuenow": value
  9475. });
  9476. if ( this.overlayDiv ) {
  9477. this.overlayDiv.remove();
  9478. this.overlayDiv = null;
  9479. }
  9480. }
  9481. if ( this.oldValue !== value ) {
  9482. this.oldValue = value;
  9483. this._trigger( "change" );
  9484. }
  9485. if ( value === this.options.max ) {
  9486. this._trigger( "complete" );
  9487. }
  9488. }
  9489. });
  9490. /*!
  9491. * jQuery UI Selectmenu 1.11.3
  9492. * http://jqueryui.com
  9493. *
  9494. * Copyright jQuery Foundation and other contributors
  9495. * Released under the MIT license.
  9496. * http://jquery.org/license
  9497. *
  9498. * http://api.jqueryui.com/selectmenu
  9499. */
  9500. var selectmenu = $.widget( "ui.selectmenu", {
  9501. version: "1.11.3",
  9502. defaultElement: "<select>",
  9503. options: {
  9504. appendTo: null,
  9505. disabled: null,
  9506. icons: {
  9507. button: "ui-icon-triangle-1-s"
  9508. },
  9509. position: {
  9510. my: "left top",
  9511. at: "left bottom",
  9512. collision: "none"
  9513. },
  9514. width: null,
  9515. // callbacks
  9516. change: null,
  9517. close: null,
  9518. focus: null,
  9519. open: null,
  9520. select: null
  9521. },
  9522. _create: function() {
  9523. var selectmenuId = this.element.uniqueId().attr( "id" );
  9524. this.ids = {
  9525. element: selectmenuId,
  9526. button: selectmenuId + "-button",
  9527. menu: selectmenuId + "-menu"
  9528. };
  9529. this._drawButton();
  9530. this._drawMenu();
  9531. if ( this.options.disabled ) {
  9532. this.disable();
  9533. }
  9534. },
  9535. _drawButton: function() {
  9536. var that = this;
  9537. // Associate existing label with the new button
  9538. this.label = $( "label[for='" + this.ids.element + "']" ).attr( "for", this.ids.button );
  9539. this._on( this.label, {
  9540. click: function( event ) {
  9541. this.button.focus();
  9542. event.preventDefault();
  9543. }
  9544. });
  9545. // Hide original select element
  9546. this.element.hide();
  9547. // Create button
  9548. this.button = $( "<span>", {
  9549. "class": "ui-selectmenu-button ui-widget ui-state-default ui-corner-all",
  9550. tabindex: this.options.disabled ? -1 : 0,
  9551. id: this.ids.button,
  9552. role: "combobox",
  9553. "aria-expanded": "false",
  9554. "aria-autocomplete": "list",
  9555. "aria-owns": this.ids.menu,
  9556. "aria-haspopup": "true"
  9557. })
  9558. .insertAfter( this.element );
  9559. $( "<span>", {
  9560. "class": "ui-icon " + this.options.icons.button
  9561. })
  9562. .prependTo( this.button );
  9563. this.buttonText = $( "<span>", {
  9564. "class": "ui-selectmenu-text"
  9565. })
  9566. .appendTo( this.button );
  9567. this._setText( this.buttonText, this.element.find( "option:selected" ).text() );
  9568. this._resizeButton();
  9569. this._on( this.button, this._buttonEvents );
  9570. this.button.one( "focusin", function() {
  9571. // Delay rendering the menu items until the button receives focus.
  9572. // The menu may have already been rendered via a programmatic open.
  9573. if ( !that.menuItems ) {
  9574. that._refreshMenu();
  9575. }
  9576. });
  9577. this._hoverable( this.button );
  9578. this._focusable( this.button );
  9579. },
  9580. _drawMenu: function() {
  9581. var that = this;
  9582. // Create menu
  9583. this.menu = $( "<ul>", {
  9584. "aria-hidden": "true",
  9585. "aria-labelledby": this.ids.button,
  9586. id: this.ids.menu
  9587. });
  9588. // Wrap menu
  9589. this.menuWrap = $( "<div>", {
  9590. "class": "ui-selectmenu-menu ui-front"
  9591. })
  9592. .append( this.menu )
  9593. .appendTo( this._appendTo() );
  9594. // Initialize menu widget
  9595. this.menuInstance = this.menu
  9596. .menu({
  9597. role: "listbox",
  9598. select: function( event, ui ) {
  9599. event.preventDefault();
  9600. // support: IE8
  9601. // If the item was selected via a click, the text selection
  9602. // will be destroyed in IE
  9603. that._setSelection();
  9604. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  9605. },
  9606. focus: function( event, ui ) {
  9607. var item = ui.item.data( "ui-selectmenu-item" );
  9608. // Prevent inital focus from firing and check if its a newly focused item
  9609. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  9610. that._trigger( "focus", event, { item: item } );
  9611. if ( !that.isOpen ) {
  9612. that._select( item, event );
  9613. }
  9614. }
  9615. that.focusIndex = item.index;
  9616. that.button.attr( "aria-activedescendant",
  9617. that.menuItems.eq( item.index ).attr( "id" ) );
  9618. }
  9619. })
  9620. .menu( "instance" );
  9621. // Adjust menu styles to dropdown
  9622. this.menu
  9623. .addClass( "ui-corner-bottom" )
  9624. .removeClass( "ui-corner-all" );
  9625. // Don't close the menu on mouseleave
  9626. this.menuInstance._off( this.menu, "mouseleave" );
  9627. // Cancel the menu's collapseAll on document click
  9628. this.menuInstance._closeOnDocumentClick = function() {
  9629. return false;
  9630. };
  9631. // Selects often contain empty items, but never contain dividers
  9632. this.menuInstance._isDivider = function() {
  9633. return false;
  9634. };
  9635. },
  9636. refresh: function() {
  9637. this._refreshMenu();
  9638. this._setText( this.buttonText, this._getSelectedItem().text() );
  9639. if ( !this.options.width ) {
  9640. this._resizeButton();
  9641. }
  9642. },
  9643. _refreshMenu: function() {
  9644. this.menu.empty();
  9645. var item,
  9646. options = this.element.find( "option" );
  9647. if ( !options.length ) {
  9648. return;
  9649. }
  9650. this._parseOptions( options );
  9651. this._renderMenu( this.menu, this.items );
  9652. this.menuInstance.refresh();
  9653. this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" );
  9654. item = this._getSelectedItem();
  9655. // Update the menu to have the correct item focused
  9656. this.menuInstance.focus( null, item );
  9657. this._setAria( item.data( "ui-selectmenu-item" ) );
  9658. // Set disabled state
  9659. this._setOption( "disabled", this.element.prop( "disabled" ) );
  9660. },
  9661. open: function( event ) {
  9662. if ( this.options.disabled ) {
  9663. return;
  9664. }
  9665. // If this is the first time the menu is being opened, render the items
  9666. if ( !this.menuItems ) {
  9667. this._refreshMenu();
  9668. } else {
  9669. // Menu clears focus on close, reset focus to selected item
  9670. this.menu.find( ".ui-state-focus" ).removeClass( "ui-state-focus" );
  9671. this.menuInstance.focus( null, this._getSelectedItem() );
  9672. }
  9673. this.isOpen = true;
  9674. this._toggleAttr();
  9675. this._resizeMenu();
  9676. this._position();
  9677. this._on( this.document, this._documentClick );
  9678. this._trigger( "open", event );
  9679. },
  9680. _position: function() {
  9681. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  9682. },
  9683. close: function( event ) {
  9684. if ( !this.isOpen ) {
  9685. return;
  9686. }
  9687. this.isOpen = false;
  9688. this._toggleAttr();
  9689. this.range = null;
  9690. this._off( this.document );
  9691. this._trigger( "close", event );
  9692. },
  9693. widget: function() {
  9694. return this.button;
  9695. },
  9696. menuWidget: function() {
  9697. return this.menu;
  9698. },
  9699. _renderMenu: function( ul, items ) {
  9700. var that = this,
  9701. currentOptgroup = "";
  9702. $.each( items, function( index, item ) {
  9703. if ( item.optgroup !== currentOptgroup ) {
  9704. $( "<li>", {
  9705. "class": "ui-selectmenu-optgroup ui-menu-divider" +
  9706. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  9707. " ui-state-disabled" :
  9708. "" ),
  9709. text: item.optgroup
  9710. })
  9711. .appendTo( ul );
  9712. currentOptgroup = item.optgroup;
  9713. }
  9714. that._renderItemData( ul, item );
  9715. });
  9716. },
  9717. _renderItemData: function( ul, item ) {
  9718. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  9719. },
  9720. _renderItem: function( ul, item ) {
  9721. var li = $( "<li>" );
  9722. if ( item.disabled ) {
  9723. li.addClass( "ui-state-disabled" );
  9724. }
  9725. this._setText( li, item.label );
  9726. return li.appendTo( ul );
  9727. },
  9728. _setText: function( element, value ) {
  9729. if ( value ) {
  9730. element.text( value );
  9731. } else {
  9732. element.html( "&#160;" );
  9733. }
  9734. },
  9735. _move: function( direction, event ) {
  9736. var item, next,
  9737. filter = ".ui-menu-item";
  9738. if ( this.isOpen ) {
  9739. item = this.menuItems.eq( this.focusIndex );
  9740. } else {
  9741. item = this.menuItems.eq( this.element[ 0 ].selectedIndex );
  9742. filter += ":not(.ui-state-disabled)";
  9743. }
  9744. if ( direction === "first" || direction === "last" ) {
  9745. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  9746. } else {
  9747. next = item[ direction + "All" ]( filter ).eq( 0 );
  9748. }
  9749. if ( next.length ) {
  9750. this.menuInstance.focus( event, next );
  9751. }
  9752. },
  9753. _getSelectedItem: function() {
  9754. return this.menuItems.eq( this.element[ 0 ].selectedIndex );
  9755. },
  9756. _toggle: function( event ) {
  9757. this[ this.isOpen ? "close" : "open" ]( event );
  9758. },
  9759. _setSelection: function() {
  9760. var selection;
  9761. if ( !this.range ) {
  9762. return;
  9763. }
  9764. if ( window.getSelection ) {
  9765. selection = window.getSelection();
  9766. selection.removeAllRanges();
  9767. selection.addRange( this.range );
  9768. // support: IE8
  9769. } else {
  9770. this.range.select();
  9771. }
  9772. // support: IE
  9773. // Setting the text selection kills the button focus in IE, but
  9774. // restoring the focus doesn't kill the selection.
  9775. this.button.focus();
  9776. },
  9777. _documentClick: {
  9778. mousedown: function( event ) {
  9779. if ( !this.isOpen ) {
  9780. return;
  9781. }
  9782. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + this.ids.button ).length ) {
  9783. this.close( event );
  9784. }
  9785. }
  9786. },
  9787. _buttonEvents: {
  9788. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  9789. mousedown: function() {
  9790. var selection;
  9791. if ( window.getSelection ) {
  9792. selection = window.getSelection();
  9793. if ( selection.rangeCount ) {
  9794. this.range = selection.getRangeAt( 0 );
  9795. }
  9796. // support: IE8
  9797. } else {
  9798. this.range = document.selection.createRange();
  9799. }
  9800. },
  9801. click: function( event ) {
  9802. this._setSelection();
  9803. this._toggle( event );
  9804. },
  9805. keydown: function( event ) {
  9806. var preventDefault = true;
  9807. switch ( event.keyCode ) {
  9808. case $.ui.keyCode.TAB:
  9809. case $.ui.keyCode.ESCAPE:
  9810. this.close( event );
  9811. preventDefault = false;
  9812. break;
  9813. case $.ui.keyCode.ENTER:
  9814. if ( this.isOpen ) {
  9815. this._selectFocusedItem( event );
  9816. }
  9817. break;
  9818. case $.ui.keyCode.UP:
  9819. if ( event.altKey ) {
  9820. this._toggle( event );
  9821. } else {
  9822. this._move( "prev", event );
  9823. }
  9824. break;
  9825. case $.ui.keyCode.DOWN:
  9826. if ( event.altKey ) {
  9827. this._toggle( event );
  9828. } else {
  9829. this._move( "next", event );
  9830. }
  9831. break;
  9832. case $.ui.keyCode.SPACE:
  9833. if ( this.isOpen ) {
  9834. this._selectFocusedItem( event );
  9835. } else {
  9836. this._toggle( event );
  9837. }
  9838. break;
  9839. case $.ui.keyCode.LEFT:
  9840. this._move( "prev", event );
  9841. break;
  9842. case $.ui.keyCode.RIGHT:
  9843. this._move( "next", event );
  9844. break;
  9845. case $.ui.keyCode.HOME:
  9846. case $.ui.keyCode.PAGE_UP:
  9847. this._move( "first", event );
  9848. break;
  9849. case $.ui.keyCode.END:
  9850. case $.ui.keyCode.PAGE_DOWN:
  9851. this._move( "last", event );
  9852. break;
  9853. default:
  9854. this.menu.trigger( event );
  9855. preventDefault = false;
  9856. }
  9857. if ( preventDefault ) {
  9858. event.preventDefault();
  9859. }
  9860. }
  9861. },
  9862. _selectFocusedItem: function( event ) {
  9863. var item = this.menuItems.eq( this.focusIndex );
  9864. if ( !item.hasClass( "ui-state-disabled" ) ) {
  9865. this._select( item.data( "ui-selectmenu-item" ), event );
  9866. }
  9867. },
  9868. _select: function( item, event ) {
  9869. var oldIndex = this.element[ 0 ].selectedIndex;
  9870. // Change native select element
  9871. this.element[ 0 ].selectedIndex = item.index;
  9872. this._setText( this.buttonText, item.label );
  9873. this._setAria( item );
  9874. this._trigger( "select", event, { item: item } );
  9875. if ( item.index !== oldIndex ) {
  9876. this._trigger( "change", event, { item: item } );
  9877. }
  9878. this.close( event );
  9879. },
  9880. _setAria: function( item ) {
  9881. var id = this.menuItems.eq( item.index ).attr( "id" );
  9882. this.button.attr({
  9883. "aria-labelledby": id,
  9884. "aria-activedescendant": id
  9885. });
  9886. this.menu.attr( "aria-activedescendant", id );
  9887. },
  9888. _setOption: function( key, value ) {
  9889. if ( key === "icons" ) {
  9890. this.button.find( "span.ui-icon" )
  9891. .removeClass( this.options.icons.button )
  9892. .addClass( value.button );
  9893. }
  9894. this._super( key, value );
  9895. if ( key === "appendTo" ) {
  9896. this.menuWrap.appendTo( this._appendTo() );
  9897. }
  9898. if ( key === "disabled" ) {
  9899. this.menuInstance.option( "disabled", value );
  9900. this.button
  9901. .toggleClass( "ui-state-disabled", value )
  9902. .attr( "aria-disabled", value );
  9903. this.element.prop( "disabled", value );
  9904. if ( value ) {
  9905. this.button.attr( "tabindex", -1 );
  9906. this.close();
  9907. } else {
  9908. this.button.attr( "tabindex", 0 );
  9909. }
  9910. }
  9911. if ( key === "width" ) {
  9912. this._resizeButton();
  9913. }
  9914. },
  9915. _appendTo: function() {
  9916. var element = this.options.appendTo;
  9917. if ( element ) {
  9918. element = element.jquery || element.nodeType ?
  9919. $( element ) :
  9920. this.document.find( element ).eq( 0 );
  9921. }
  9922. if ( !element || !element[ 0 ] ) {
  9923. element = this.element.closest( ".ui-front" );
  9924. }
  9925. if ( !element.length ) {
  9926. element = this.document[ 0 ].body;
  9927. }
  9928. return element;
  9929. },
  9930. _toggleAttr: function() {
  9931. this.button
  9932. .toggleClass( "ui-corner-top", this.isOpen )
  9933. .toggleClass( "ui-corner-all", !this.isOpen )
  9934. .attr( "aria-expanded", this.isOpen );
  9935. this.menuWrap.toggleClass( "ui-selectmenu-open", this.isOpen );
  9936. this.menu.attr( "aria-hidden", !this.isOpen );
  9937. },
  9938. _resizeButton: function() {
  9939. var width = this.options.width;
  9940. if ( !width ) {
  9941. width = this.element.show().outerWidth();
  9942. this.element.hide();
  9943. }
  9944. this.button.outerWidth( width );
  9945. },
  9946. _resizeMenu: function() {
  9947. this.menu.outerWidth( Math.max(
  9948. this.button.outerWidth(),
  9949. // support: IE10
  9950. // IE10 wraps long text (possibly a rounding bug)
  9951. // so we add 1px to avoid the wrapping
  9952. this.menu.width( "" ).outerWidth() + 1
  9953. ) );
  9954. },
  9955. _getCreateOptions: function() {
  9956. return { disabled: this.element.prop( "disabled" ) };
  9957. },
  9958. _parseOptions: function( options ) {
  9959. var data = [];
  9960. options.each(function( index, item ) {
  9961. var option = $( item ),
  9962. optgroup = option.parent( "optgroup" );
  9963. data.push({
  9964. element: option,
  9965. index: index,
  9966. value: option.val(),
  9967. label: option.text(),
  9968. optgroup: optgroup.attr( "label" ) || "",
  9969. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  9970. });
  9971. });
  9972. this.items = data;
  9973. },
  9974. _destroy: function() {
  9975. this.menuWrap.remove();
  9976. this.button.remove();
  9977. this.element.show();
  9978. this.element.removeUniqueId();
  9979. this.label.attr( "for", this.ids.element );
  9980. }
  9981. });
  9982. /*!
  9983. * jQuery UI Slider 1.11.3
  9984. * http://jqueryui.com
  9985. *
  9986. * Copyright jQuery Foundation and other contributors
  9987. * Released under the MIT license.
  9988. * http://jquery.org/license
  9989. *
  9990. * http://api.jqueryui.com/slider/
  9991. */
  9992. var slider = $.widget( "ui.slider", $.ui.mouse, {
  9993. version: "1.11.3",
  9994. widgetEventPrefix: "slide",
  9995. options: {
  9996. animate: false,
  9997. distance: 0,
  9998. max: 100,
  9999. min: 0,
  10000. orientation: "horizontal",
  10001. range: false,
  10002. step: 1,
  10003. value: 0,
  10004. values: null,
  10005. // callbacks
  10006. change: null,
  10007. slide: null,
  10008. start: null,
  10009. stop: null
  10010. },
  10011. // number of pages in a slider
  10012. // (how many times can you page up/down to go through the whole range)
  10013. numPages: 5,
  10014. _create: function() {
  10015. this._keySliding = false;
  10016. this._mouseSliding = false;
  10017. this._animateOff = true;
  10018. this._handleIndex = null;
  10019. this._detectOrientation();
  10020. this._mouseInit();
  10021. this._calculateNewMax();
  10022. this.element
  10023. .addClass( "ui-slider" +
  10024. " ui-slider-" + this.orientation +
  10025. " ui-widget" +
  10026. " ui-widget-content" +
  10027. " ui-corner-all");
  10028. this._refresh();
  10029. this._setOption( "disabled", this.options.disabled );
  10030. this._animateOff = false;
  10031. },
  10032. _refresh: function() {
  10033. this._createRange();
  10034. this._createHandles();
  10035. this._setupEvents();
  10036. this._refreshValue();
  10037. },
  10038. _createHandles: function() {
  10039. var i, handleCount,
  10040. options = this.options,
  10041. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  10042. handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",
  10043. handles = [];
  10044. handleCount = ( options.values && options.values.length ) || 1;
  10045. if ( existingHandles.length > handleCount ) {
  10046. existingHandles.slice( handleCount ).remove();
  10047. existingHandles = existingHandles.slice( 0, handleCount );
  10048. }
  10049. for ( i = existingHandles.length; i < handleCount; i++ ) {
  10050. handles.push( handle );
  10051. }
  10052. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  10053. this.handle = this.handles.eq( 0 );
  10054. this.handles.each(function( i ) {
  10055. $( this ).data( "ui-slider-handle-index", i );
  10056. });
  10057. },
  10058. _createRange: function() {
  10059. var options = this.options,
  10060. classes = "";
  10061. if ( options.range ) {
  10062. if ( options.range === true ) {
  10063. if ( !options.values ) {
  10064. options.values = [ this._valueMin(), this._valueMin() ];
  10065. } else if ( options.values.length && options.values.length !== 2 ) {
  10066. options.values = [ options.values[0], options.values[0] ];
  10067. } else if ( $.isArray( options.values ) ) {
  10068. options.values = options.values.slice(0);
  10069. }
  10070. }
  10071. if ( !this.range || !this.range.length ) {
  10072. this.range = $( "<div></div>" )
  10073. .appendTo( this.element );
  10074. classes = "ui-slider-range" +
  10075. // note: this isn't the most fittingly semantic framework class for this element,
  10076. // but worked best visually with a variety of themes
  10077. " ui-widget-header ui-corner-all";
  10078. } else {
  10079. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  10080. // Handle range switching from true to min/max
  10081. .css({
  10082. "left": "",
  10083. "bottom": ""
  10084. });
  10085. }
  10086. this.range.addClass( classes +
  10087. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  10088. } else {
  10089. if ( this.range ) {
  10090. this.range.remove();
  10091. }
  10092. this.range = null;
  10093. }
  10094. },
  10095. _setupEvents: function() {
  10096. this._off( this.handles );
  10097. this._on( this.handles, this._handleEvents );
  10098. this._hoverable( this.handles );
  10099. this._focusable( this.handles );
  10100. },
  10101. _destroy: function() {
  10102. this.handles.remove();
  10103. if ( this.range ) {
  10104. this.range.remove();
  10105. }
  10106. this.element
  10107. .removeClass( "ui-slider" +
  10108. " ui-slider-horizontal" +
  10109. " ui-slider-vertical" +
  10110. " ui-widget" +
  10111. " ui-widget-content" +
  10112. " ui-corner-all" );
  10113. this._mouseDestroy();
  10114. },
  10115. _mouseCapture: function( event ) {
  10116. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  10117. that = this,
  10118. o = this.options;
  10119. if ( o.disabled ) {
  10120. return false;
  10121. }
  10122. this.elementSize = {
  10123. width: this.element.outerWidth(),
  10124. height: this.element.outerHeight()
  10125. };
  10126. this.elementOffset = this.element.offset();
  10127. position = { x: event.pageX, y: event.pageY };
  10128. normValue = this._normValueFromMouse( position );
  10129. distance = this._valueMax() - this._valueMin() + 1;
  10130. this.handles.each(function( i ) {
  10131. var thisDistance = Math.abs( normValue - that.values(i) );
  10132. if (( distance > thisDistance ) ||
  10133. ( distance === thisDistance &&
  10134. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  10135. distance = thisDistance;
  10136. closestHandle = $( this );
  10137. index = i;
  10138. }
  10139. });
  10140. allowed = this._start( event, index );
  10141. if ( allowed === false ) {
  10142. return false;
  10143. }
  10144. this._mouseSliding = true;
  10145. this._handleIndex = index;
  10146. closestHandle
  10147. .addClass( "ui-state-active" )
  10148. .focus();
  10149. offset = closestHandle.offset();
  10150. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  10151. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  10152. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  10153. top: event.pageY - offset.top -
  10154. ( closestHandle.height() / 2 ) -
  10155. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  10156. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  10157. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  10158. };
  10159. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  10160. this._slide( event, index, normValue );
  10161. }
  10162. this._animateOff = true;
  10163. return true;
  10164. },
  10165. _mouseStart: function() {
  10166. return true;
  10167. },
  10168. _mouseDrag: function( event ) {
  10169. var position = { x: event.pageX, y: event.pageY },
  10170. normValue = this._normValueFromMouse( position );
  10171. this._slide( event, this._handleIndex, normValue );
  10172. return false;
  10173. },
  10174. _mouseStop: function( event ) {
  10175. this.handles.removeClass( "ui-state-active" );
  10176. this._mouseSliding = false;
  10177. this._stop( event, this._handleIndex );
  10178. this._change( event, this._handleIndex );
  10179. this._handleIndex = null;
  10180. this._clickOffset = null;
  10181. this._animateOff = false;
  10182. return false;
  10183. },
  10184. _detectOrientation: function() {
  10185. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  10186. },
  10187. _normValueFromMouse: function( position ) {
  10188. var pixelTotal,
  10189. pixelMouse,
  10190. percentMouse,
  10191. valueTotal,
  10192. valueMouse;
  10193. if ( this.orientation === "horizontal" ) {
  10194. pixelTotal = this.elementSize.width;
  10195. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  10196. } else {
  10197. pixelTotal = this.elementSize.height;
  10198. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  10199. }
  10200. percentMouse = ( pixelMouse / pixelTotal );
  10201. if ( percentMouse > 1 ) {
  10202. percentMouse = 1;
  10203. }
  10204. if ( percentMouse < 0 ) {
  10205. percentMouse = 0;
  10206. }
  10207. if ( this.orientation === "vertical" ) {
  10208. percentMouse = 1 - percentMouse;
  10209. }
  10210. valueTotal = this._valueMax() - this._valueMin();
  10211. valueMouse = this._valueMin() + percentMouse * valueTotal;
  10212. return this._trimAlignValue( valueMouse );
  10213. },
  10214. _start: function( event, index ) {
  10215. var uiHash = {
  10216. handle: this.handles[ index ],
  10217. value: this.value()
  10218. };
  10219. if ( this.options.values && this.options.values.length ) {
  10220. uiHash.value = this.values( index );
  10221. uiHash.values = this.values();
  10222. }
  10223. return this._trigger( "start", event, uiHash );
  10224. },
  10225. _slide: function( event, index, newVal ) {
  10226. var otherVal,
  10227. newValues,
  10228. allowed;
  10229. if ( this.options.values && this.options.values.length ) {
  10230. otherVal = this.values( index ? 0 : 1 );
  10231. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  10232. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  10233. ) {
  10234. newVal = otherVal;
  10235. }
  10236. if ( newVal !== this.values( index ) ) {
  10237. newValues = this.values();
  10238. newValues[ index ] = newVal;
  10239. // A slide can be canceled by returning false from the slide callback
  10240. allowed = this._trigger( "slide", event, {
  10241. handle: this.handles[ index ],
  10242. value: newVal,
  10243. values: newValues
  10244. } );
  10245. otherVal = this.values( index ? 0 : 1 );
  10246. if ( allowed !== false ) {
  10247. this.values( index, newVal );
  10248. }
  10249. }
  10250. } else {
  10251. if ( newVal !== this.value() ) {
  10252. // A slide can be canceled by returning false from the slide callback
  10253. allowed = this._trigger( "slide", event, {
  10254. handle: this.handles[ index ],
  10255. value: newVal
  10256. } );
  10257. if ( allowed !== false ) {
  10258. this.value( newVal );
  10259. }
  10260. }
  10261. }
  10262. },
  10263. _stop: function( event, index ) {
  10264. var uiHash = {
  10265. handle: this.handles[ index ],
  10266. value: this.value()
  10267. };
  10268. if ( this.options.values && this.options.values.length ) {
  10269. uiHash.value = this.values( index );
  10270. uiHash.values = this.values();
  10271. }
  10272. this._trigger( "stop", event, uiHash );
  10273. },
  10274. _change: function( event, index ) {
  10275. if ( !this._keySliding && !this._mouseSliding ) {
  10276. var uiHash = {
  10277. handle: this.handles[ index ],
  10278. value: this.value()
  10279. };
  10280. if ( this.options.values && this.options.values.length ) {
  10281. uiHash.value = this.values( index );
  10282. uiHash.values = this.values();
  10283. }
  10284. //store the last changed value index for reference when handles overlap
  10285. this._lastChangedValue = index;
  10286. this._trigger( "change", event, uiHash );
  10287. }
  10288. },
  10289. value: function( newValue ) {
  10290. if ( arguments.length ) {
  10291. this.options.value = this._trimAlignValue( newValue );
  10292. this._refreshValue();
  10293. this._change( null, 0 );
  10294. return;
  10295. }
  10296. return this._value();
  10297. },
  10298. values: function( index, newValue ) {
  10299. var vals,
  10300. newValues,
  10301. i;
  10302. if ( arguments.length > 1 ) {
  10303. this.options.values[ index ] = this._trimAlignValue( newValue );
  10304. this._refreshValue();
  10305. this._change( null, index );
  10306. return;
  10307. }
  10308. if ( arguments.length ) {
  10309. if ( $.isArray( arguments[ 0 ] ) ) {
  10310. vals = this.options.values;
  10311. newValues = arguments[ 0 ];
  10312. for ( i = 0; i < vals.length; i += 1 ) {
  10313. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  10314. this._change( null, i );
  10315. }
  10316. this._refreshValue();
  10317. } else {
  10318. if ( this.options.values && this.options.values.length ) {
  10319. return this._values( index );
  10320. } else {
  10321. return this.value();
  10322. }
  10323. }
  10324. } else {
  10325. return this._values();
  10326. }
  10327. },
  10328. _setOption: function( key, value ) {
  10329. var i,
  10330. valsLength = 0;
  10331. if ( key === "range" && this.options.range === true ) {
  10332. if ( value === "min" ) {
  10333. this.options.value = this._values( 0 );
  10334. this.options.values = null;
  10335. } else if ( value === "max" ) {
  10336. this.options.value = this._values( this.options.values.length - 1 );
  10337. this.options.values = null;
  10338. }
  10339. }
  10340. if ( $.isArray( this.options.values ) ) {
  10341. valsLength = this.options.values.length;
  10342. }
  10343. if ( key === "disabled" ) {
  10344. this.element.toggleClass( "ui-state-disabled", !!value );
  10345. }
  10346. this._super( key, value );
  10347. switch ( key ) {
  10348. case "orientation":
  10349. this._detectOrientation();
  10350. this.element
  10351. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  10352. .addClass( "ui-slider-" + this.orientation );
  10353. this._refreshValue();
  10354. // Reset positioning from previous orientation
  10355. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  10356. break;
  10357. case "value":
  10358. this._animateOff = true;
  10359. this._refreshValue();
  10360. this._change( null, 0 );
  10361. this._animateOff = false;
  10362. break;
  10363. case "values":
  10364. this._animateOff = true;
  10365. this._refreshValue();
  10366. for ( i = 0; i < valsLength; i += 1 ) {
  10367. this._change( null, i );
  10368. }
  10369. this._animateOff = false;
  10370. break;
  10371. case "step":
  10372. case "min":
  10373. case "max":
  10374. this._animateOff = true;
  10375. this._calculateNewMax();
  10376. this._refreshValue();
  10377. this._animateOff = false;
  10378. break;
  10379. case "range":
  10380. this._animateOff = true;
  10381. this._refresh();
  10382. this._animateOff = false;
  10383. break;
  10384. }
  10385. },
  10386. //internal value getter
  10387. // _value() returns value trimmed by min and max, aligned by step
  10388. _value: function() {
  10389. var val = this.options.value;
  10390. val = this._trimAlignValue( val );
  10391. return val;
  10392. },
  10393. //internal values getter
  10394. // _values() returns array of values trimmed by min and max, aligned by step
  10395. // _values( index ) returns single value trimmed by min and max, aligned by step
  10396. _values: function( index ) {
  10397. var val,
  10398. vals,
  10399. i;
  10400. if ( arguments.length ) {
  10401. val = this.options.values[ index ];
  10402. val = this._trimAlignValue( val );
  10403. return val;
  10404. } else if ( this.options.values && this.options.values.length ) {
  10405. // .slice() creates a copy of the array
  10406. // this copy gets trimmed by min and max and then returned
  10407. vals = this.options.values.slice();
  10408. for ( i = 0; i < vals.length; i += 1) {
  10409. vals[ i ] = this._trimAlignValue( vals[ i ] );
  10410. }
  10411. return vals;
  10412. } else {
  10413. return [];
  10414. }
  10415. },
  10416. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  10417. _trimAlignValue: function( val ) {
  10418. if ( val <= this._valueMin() ) {
  10419. return this._valueMin();
  10420. }
  10421. if ( val >= this._valueMax() ) {
  10422. return this._valueMax();
  10423. }
  10424. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  10425. valModStep = (val - this._valueMin()) % step,
  10426. alignValue = val - valModStep;
  10427. if ( Math.abs(valModStep) * 2 >= step ) {
  10428. alignValue += ( valModStep > 0 ) ? step : ( -step );
  10429. }
  10430. // Since JavaScript has problems with large floats, round
  10431. // the final value to 5 digits after the decimal point (see #4124)
  10432. return parseFloat( alignValue.toFixed(5) );
  10433. },
  10434. _calculateNewMax: function() {
  10435. var max = this.options.max,
  10436. min = this._valueMin(),
  10437. step = this.options.step,
  10438. aboveMin = Math.floor( ( max - min ) / step ) * step;
  10439. max = aboveMin + min;
  10440. this.max = parseFloat( max.toFixed( this._precision() ) );
  10441. },
  10442. _precision: function() {
  10443. var precision = this._precisionOf( this.options.step );
  10444. if ( this.options.min !== null ) {
  10445. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  10446. }
  10447. return precision;
  10448. },
  10449. _precisionOf: function( num ) {
  10450. var str = num.toString(),
  10451. decimal = str.indexOf( "." );
  10452. return decimal === -1 ? 0 : str.length - decimal - 1;
  10453. },
  10454. _valueMin: function() {
  10455. return this.options.min;
  10456. },
  10457. _valueMax: function() {
  10458. return this.max;
  10459. },
  10460. _refreshValue: function() {
  10461. var lastValPercent, valPercent, value, valueMin, valueMax,
  10462. oRange = this.options.range,
  10463. o = this.options,
  10464. that = this,
  10465. animate = ( !this._animateOff ) ? o.animate : false,
  10466. _set = {};
  10467. if ( this.options.values && this.options.values.length ) {
  10468. this.handles.each(function( i ) {
  10469. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  10470. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  10471. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  10472. if ( that.options.range === true ) {
  10473. if ( that.orientation === "horizontal" ) {
  10474. if ( i === 0 ) {
  10475. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  10476. }
  10477. if ( i === 1 ) {
  10478. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  10479. }
  10480. } else {
  10481. if ( i === 0 ) {
  10482. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  10483. }
  10484. if ( i === 1 ) {
  10485. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  10486. }
  10487. }
  10488. }
  10489. lastValPercent = valPercent;
  10490. });
  10491. } else {
  10492. value = this.value();
  10493. valueMin = this._valueMin();
  10494. valueMax = this._valueMax();
  10495. valPercent = ( valueMax !== valueMin ) ?
  10496. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  10497. 0;
  10498. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  10499. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  10500. if ( oRange === "min" && this.orientation === "horizontal" ) {
  10501. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  10502. }
  10503. if ( oRange === "max" && this.orientation === "horizontal" ) {
  10504. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  10505. }
  10506. if ( oRange === "min" && this.orientation === "vertical" ) {
  10507. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  10508. }
  10509. if ( oRange === "max" && this.orientation === "vertical" ) {
  10510. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  10511. }
  10512. }
  10513. },
  10514. _handleEvents: {
  10515. keydown: function( event ) {
  10516. var allowed, curVal, newVal, step,
  10517. index = $( event.target ).data( "ui-slider-handle-index" );
  10518. switch ( event.keyCode ) {
  10519. case $.ui.keyCode.HOME:
  10520. case $.ui.keyCode.END:
  10521. case $.ui.keyCode.PAGE_UP:
  10522. case $.ui.keyCode.PAGE_DOWN:
  10523. case $.ui.keyCode.UP:
  10524. case $.ui.keyCode.RIGHT:
  10525. case $.ui.keyCode.DOWN:
  10526. case $.ui.keyCode.LEFT:
  10527. event.preventDefault();
  10528. if ( !this._keySliding ) {
  10529. this._keySliding = true;
  10530. $( event.target ).addClass( "ui-state-active" );
  10531. allowed = this._start( event, index );
  10532. if ( allowed === false ) {
  10533. return;
  10534. }
  10535. }
  10536. break;
  10537. }
  10538. step = this.options.step;
  10539. if ( this.options.values && this.options.values.length ) {
  10540. curVal = newVal = this.values( index );
  10541. } else {
  10542. curVal = newVal = this.value();
  10543. }
  10544. switch ( event.keyCode ) {
  10545. case $.ui.keyCode.HOME:
  10546. newVal = this._valueMin();
  10547. break;
  10548. case $.ui.keyCode.END:
  10549. newVal = this._valueMax();
  10550. break;
  10551. case $.ui.keyCode.PAGE_UP:
  10552. newVal = this._trimAlignValue(
  10553. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  10554. );
  10555. break;
  10556. case $.ui.keyCode.PAGE_DOWN:
  10557. newVal = this._trimAlignValue(
  10558. curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
  10559. break;
  10560. case $.ui.keyCode.UP:
  10561. case $.ui.keyCode.RIGHT:
  10562. if ( curVal === this._valueMax() ) {
  10563. return;
  10564. }
  10565. newVal = this._trimAlignValue( curVal + step );
  10566. break;
  10567. case $.ui.keyCode.DOWN:
  10568. case $.ui.keyCode.LEFT:
  10569. if ( curVal === this._valueMin() ) {
  10570. return;
  10571. }
  10572. newVal = this._trimAlignValue( curVal - step );
  10573. break;
  10574. }
  10575. this._slide( event, index, newVal );
  10576. },
  10577. keyup: function( event ) {
  10578. var index = $( event.target ).data( "ui-slider-handle-index" );
  10579. if ( this._keySliding ) {
  10580. this._keySliding = false;
  10581. this._stop( event, index );
  10582. this._change( event, index );
  10583. $( event.target ).removeClass( "ui-state-active" );
  10584. }
  10585. }
  10586. }
  10587. });
  10588. /*!
  10589. * jQuery UI Spinner 1.11.3
  10590. * http://jqueryui.com
  10591. *
  10592. * Copyright jQuery Foundation and other contributors
  10593. * Released under the MIT license.
  10594. * http://jquery.org/license
  10595. *
  10596. * http://api.jqueryui.com/spinner/
  10597. */
  10598. function spinner_modifier( fn ) {
  10599. return function() {
  10600. var previous = this.element.val();
  10601. fn.apply( this, arguments );
  10602. this._refresh();
  10603. if ( previous !== this.element.val() ) {
  10604. this._trigger( "change" );
  10605. }
  10606. };
  10607. }
  10608. var spinner = $.widget( "ui.spinner", {
  10609. version: "1.11.3",
  10610. defaultElement: "<input>",
  10611. widgetEventPrefix: "spin",
  10612. options: {
  10613. culture: null,
  10614. icons: {
  10615. down: "ui-icon-triangle-1-s",
  10616. up: "ui-icon-triangle-1-n"
  10617. },
  10618. incremental: true,
  10619. max: null,
  10620. min: null,
  10621. numberFormat: null,
  10622. page: 10,
  10623. step: 1,
  10624. change: null,
  10625. spin: null,
  10626. start: null,
  10627. stop: null
  10628. },
  10629. _create: function() {
  10630. // handle string values that need to be parsed
  10631. this._setOption( "max", this.options.max );
  10632. this._setOption( "min", this.options.min );
  10633. this._setOption( "step", this.options.step );
  10634. // Only format if there is a value, prevents the field from being marked
  10635. // as invalid in Firefox, see #9573.
  10636. if ( this.value() !== "" ) {
  10637. // Format the value, but don't constrain.
  10638. this._value( this.element.val(), true );
  10639. }
  10640. this._draw();
  10641. this._on( this._events );
  10642. this._refresh();
  10643. // turning off autocomplete prevents the browser from remembering the
  10644. // value when navigating through history, so we re-enable autocomplete
  10645. // if the page is unloaded before the widget is destroyed. #7790
  10646. this._on( this.window, {
  10647. beforeunload: function() {
  10648. this.element.removeAttr( "autocomplete" );
  10649. }
  10650. });
  10651. },
  10652. _getCreateOptions: function() {
  10653. var options = {},
  10654. element = this.element;
  10655. $.each( [ "min", "max", "step" ], function( i, option ) {
  10656. var value = element.attr( option );
  10657. if ( value !== undefined && value.length ) {
  10658. options[ option ] = value;
  10659. }
  10660. });
  10661. return options;
  10662. },
  10663. _events: {
  10664. keydown: function( event ) {
  10665. if ( this._start( event ) && this._keydown( event ) ) {
  10666. event.preventDefault();
  10667. }
  10668. },
  10669. keyup: "_stop",
  10670. focus: function() {
  10671. this.previous = this.element.val();
  10672. },
  10673. blur: function( event ) {
  10674. if ( this.cancelBlur ) {
  10675. delete this.cancelBlur;
  10676. return;
  10677. }
  10678. this._stop();
  10679. this._refresh();
  10680. if ( this.previous !== this.element.val() ) {
  10681. this._trigger( "change", event );
  10682. }
  10683. },
  10684. mousewheel: function( event, delta ) {
  10685. if ( !delta ) {
  10686. return;
  10687. }
  10688. if ( !this.spinning && !this._start( event ) ) {
  10689. return false;
  10690. }
  10691. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  10692. clearTimeout( this.mousewheelTimer );
  10693. this.mousewheelTimer = this._delay(function() {
  10694. if ( this.spinning ) {
  10695. this._stop( event );
  10696. }
  10697. }, 100 );
  10698. event.preventDefault();
  10699. },
  10700. "mousedown .ui-spinner-button": function( event ) {
  10701. var previous;
  10702. // We never want the buttons to have focus; whenever the user is
  10703. // interacting with the spinner, the focus should be on the input.
  10704. // If the input is focused then this.previous is properly set from
  10705. // when the input first received focus. If the input is not focused
  10706. // then we need to set this.previous based on the value before spinning.
  10707. previous = this.element[0] === this.document[0].activeElement ?
  10708. this.previous : this.element.val();
  10709. function checkFocus() {
  10710. var isActive = this.element[0] === this.document[0].activeElement;
  10711. if ( !isActive ) {
  10712. this.element.focus();
  10713. this.previous = previous;
  10714. // support: IE
  10715. // IE sets focus asynchronously, so we need to check if focus
  10716. // moved off of the input because the user clicked on the button.
  10717. this._delay(function() {
  10718. this.previous = previous;
  10719. });
  10720. }
  10721. }
  10722. // ensure focus is on (or stays on) the text field
  10723. event.preventDefault();
  10724. checkFocus.call( this );
  10725. // support: IE
  10726. // IE doesn't prevent moving focus even with event.preventDefault()
  10727. // so we set a flag to know when we should ignore the blur event
  10728. // and check (again) if focus moved off of the input.
  10729. this.cancelBlur = true;
  10730. this._delay(function() {
  10731. delete this.cancelBlur;
  10732. checkFocus.call( this );
  10733. });
  10734. if ( this._start( event ) === false ) {
  10735. return;
  10736. }
  10737. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  10738. },
  10739. "mouseup .ui-spinner-button": "_stop",
  10740. "mouseenter .ui-spinner-button": function( event ) {
  10741. // button will add ui-state-active if mouse was down while mouseleave and kept down
  10742. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  10743. return;
  10744. }
  10745. if ( this._start( event ) === false ) {
  10746. return false;
  10747. }
  10748. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  10749. },
  10750. // TODO: do we really want to consider this a stop?
  10751. // shouldn't we just stop the repeater and wait until mouseup before
  10752. // we trigger the stop event?
  10753. "mouseleave .ui-spinner-button": "_stop"
  10754. },
  10755. _draw: function() {
  10756. var uiSpinner = this.uiSpinner = this.element
  10757. .addClass( "ui-spinner-input" )
  10758. .attr( "autocomplete", "off" )
  10759. .wrap( this._uiSpinnerHtml() )
  10760. .parent()
  10761. // add buttons
  10762. .append( this._buttonHtml() );
  10763. this.element.attr( "role", "spinbutton" );
  10764. // button bindings
  10765. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  10766. .attr( "tabIndex", -1 )
  10767. .button()
  10768. .removeClass( "ui-corner-all" );
  10769. // IE 6 doesn't understand height: 50% for the buttons
  10770. // unless the wrapper has an explicit height
  10771. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  10772. uiSpinner.height() > 0 ) {
  10773. uiSpinner.height( uiSpinner.height() );
  10774. }
  10775. // disable spinner if element was already disabled
  10776. if ( this.options.disabled ) {
  10777. this.disable();
  10778. }
  10779. },
  10780. _keydown: function( event ) {
  10781. var options = this.options,
  10782. keyCode = $.ui.keyCode;
  10783. switch ( event.keyCode ) {
  10784. case keyCode.UP:
  10785. this._repeat( null, 1, event );
  10786. return true;
  10787. case keyCode.DOWN:
  10788. this._repeat( null, -1, event );
  10789. return true;
  10790. case keyCode.PAGE_UP:
  10791. this._repeat( null, options.page, event );
  10792. return true;
  10793. case keyCode.PAGE_DOWN:
  10794. this._repeat( null, -options.page, event );
  10795. return true;
  10796. }
  10797. return false;
  10798. },
  10799. _uiSpinnerHtml: function() {
  10800. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  10801. },
  10802. _buttonHtml: function() {
  10803. return "" +
  10804. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  10805. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  10806. "</a>" +
  10807. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  10808. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  10809. "</a>";
  10810. },
  10811. _start: function( event ) {
  10812. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  10813. return false;
  10814. }
  10815. if ( !this.counter ) {
  10816. this.counter = 1;
  10817. }
  10818. this.spinning = true;
  10819. return true;
  10820. },
  10821. _repeat: function( i, steps, event ) {
  10822. i = i || 500;
  10823. clearTimeout( this.timer );
  10824. this.timer = this._delay(function() {
  10825. this._repeat( 40, steps, event );
  10826. }, i );
  10827. this._spin( steps * this.options.step, event );
  10828. },
  10829. _spin: function( step, event ) {
  10830. var value = this.value() || 0;
  10831. if ( !this.counter ) {
  10832. this.counter = 1;
  10833. }
  10834. value = this._adjustValue( value + step * this._increment( this.counter ) );
  10835. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  10836. this._value( value );
  10837. this.counter++;
  10838. }
  10839. },
  10840. _increment: function( i ) {
  10841. var incremental = this.options.incremental;
  10842. if ( incremental ) {
  10843. return $.isFunction( incremental ) ?
  10844. incremental( i ) :
  10845. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  10846. }
  10847. return 1;
  10848. },
  10849. _precision: function() {
  10850. var precision = this._precisionOf( this.options.step );
  10851. if ( this.options.min !== null ) {
  10852. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  10853. }
  10854. return precision;
  10855. },
  10856. _precisionOf: function( num ) {
  10857. var str = num.toString(),
  10858. decimal = str.indexOf( "." );
  10859. return decimal === -1 ? 0 : str.length - decimal - 1;
  10860. },
  10861. _adjustValue: function( value ) {
  10862. var base, aboveMin,
  10863. options = this.options;
  10864. // make sure we're at a valid step
  10865. // - find out where we are relative to the base (min or 0)
  10866. base = options.min !== null ? options.min : 0;
  10867. aboveMin = value - base;
  10868. // - round to the nearest step
  10869. aboveMin = Math.round(aboveMin / options.step) * options.step;
  10870. // - rounding is based on 0, so adjust back to our base
  10871. value = base + aboveMin;
  10872. // fix precision from bad JS floating point math
  10873. value = parseFloat( value.toFixed( this._precision() ) );
  10874. // clamp the value
  10875. if ( options.max !== null && value > options.max) {
  10876. return options.max;
  10877. }
  10878. if ( options.min !== null && value < options.min ) {
  10879. return options.min;
  10880. }
  10881. return value;
  10882. },
  10883. _stop: function( event ) {
  10884. if ( !this.spinning ) {
  10885. return;
  10886. }
  10887. clearTimeout( this.timer );
  10888. clearTimeout( this.mousewheelTimer );
  10889. this.counter = 0;
  10890. this.spinning = false;
  10891. this._trigger( "stop", event );
  10892. },
  10893. _setOption: function( key, value ) {
  10894. if ( key === "culture" || key === "numberFormat" ) {
  10895. var prevValue = this._parse( this.element.val() );
  10896. this.options[ key ] = value;
  10897. this.element.val( this._format( prevValue ) );
  10898. return;
  10899. }
  10900. if ( key === "max" || key === "min" || key === "step" ) {
  10901. if ( typeof value === "string" ) {
  10902. value = this._parse( value );
  10903. }
  10904. }
  10905. if ( key === "icons" ) {
  10906. this.buttons.first().find( ".ui-icon" )
  10907. .removeClass( this.options.icons.up )
  10908. .addClass( value.up );
  10909. this.buttons.last().find( ".ui-icon" )
  10910. .removeClass( this.options.icons.down )
  10911. .addClass( value.down );
  10912. }
  10913. this._super( key, value );
  10914. if ( key === "disabled" ) {
  10915. this.widget().toggleClass( "ui-state-disabled", !!value );
  10916. this.element.prop( "disabled", !!value );
  10917. this.buttons.button( value ? "disable" : "enable" );
  10918. }
  10919. },
  10920. _setOptions: spinner_modifier(function( options ) {
  10921. this._super( options );
  10922. }),
  10923. _parse: function( val ) {
  10924. if ( typeof val === "string" && val !== "" ) {
  10925. val = window.Globalize && this.options.numberFormat ?
  10926. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  10927. }
  10928. return val === "" || isNaN( val ) ? null : val;
  10929. },
  10930. _format: function( value ) {
  10931. if ( value === "" ) {
  10932. return "";
  10933. }
  10934. return window.Globalize && this.options.numberFormat ?
  10935. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  10936. value;
  10937. },
  10938. _refresh: function() {
  10939. this.element.attr({
  10940. "aria-valuemin": this.options.min,
  10941. "aria-valuemax": this.options.max,
  10942. // TODO: what should we do with values that can't be parsed?
  10943. "aria-valuenow": this._parse( this.element.val() )
  10944. });
  10945. },
  10946. isValid: function() {
  10947. var value = this.value();
  10948. // null is invalid
  10949. if ( value === null ) {
  10950. return false;
  10951. }
  10952. // if value gets adjusted, it's invalid
  10953. return value === this._adjustValue( value );
  10954. },
  10955. // update the value without triggering change
  10956. _value: function( value, allowAny ) {
  10957. var parsed;
  10958. if ( value !== "" ) {
  10959. parsed = this._parse( value );
  10960. if ( parsed !== null ) {
  10961. if ( !allowAny ) {
  10962. parsed = this._adjustValue( parsed );
  10963. }
  10964. value = this._format( parsed );
  10965. }
  10966. }
  10967. this.element.val( value );
  10968. this._refresh();
  10969. },
  10970. _destroy: function() {
  10971. this.element
  10972. .removeClass( "ui-spinner-input" )
  10973. .prop( "disabled", false )
  10974. .removeAttr( "autocomplete" )
  10975. .removeAttr( "role" )
  10976. .removeAttr( "aria-valuemin" )
  10977. .removeAttr( "aria-valuemax" )
  10978. .removeAttr( "aria-valuenow" );
  10979. this.uiSpinner.replaceWith( this.element );
  10980. },
  10981. stepUp: spinner_modifier(function( steps ) {
  10982. this._stepUp( steps );
  10983. }),
  10984. _stepUp: function( steps ) {
  10985. if ( this._start() ) {
  10986. this._spin( (steps || 1) * this.options.step );
  10987. this._stop();
  10988. }
  10989. },
  10990. stepDown: spinner_modifier(function( steps ) {
  10991. this._stepDown( steps );
  10992. }),
  10993. _stepDown: function( steps ) {
  10994. if ( this._start() ) {
  10995. this._spin( (steps || 1) * -this.options.step );
  10996. this._stop();
  10997. }
  10998. },
  10999. pageUp: spinner_modifier(function( pages ) {
  11000. this._stepUp( (pages || 1) * this.options.page );
  11001. }),
  11002. pageDown: spinner_modifier(function( pages ) {
  11003. this._stepDown( (pages || 1) * this.options.page );
  11004. }),
  11005. value: function( newVal ) {
  11006. if ( !arguments.length ) {
  11007. return this._parse( this.element.val() );
  11008. }
  11009. spinner_modifier( this._value ).call( this, newVal );
  11010. },
  11011. widget: function() {
  11012. return this.uiSpinner;
  11013. }
  11014. });
  11015. /*!
  11016. * jQuery UI Tabs 1.11.3
  11017. * http://jqueryui.com
  11018. *
  11019. * Copyright jQuery Foundation and other contributors
  11020. * Released under the MIT license.
  11021. * http://jquery.org/license
  11022. *
  11023. * http://api.jqueryui.com/tabs/
  11024. */
  11025. var tabs = $.widget( "ui.tabs", {
  11026. version: "1.11.3",
  11027. delay: 300,
  11028. options: {
  11029. active: null,
  11030. collapsible: false,
  11031. event: "click",
  11032. heightStyle: "content",
  11033. hide: null,
  11034. show: null,
  11035. // callbacks
  11036. activate: null,
  11037. beforeActivate: null,
  11038. beforeLoad: null,
  11039. load: null
  11040. },
  11041. _isLocal: (function() {
  11042. var rhash = /#.*$/;
  11043. return function( anchor ) {
  11044. var anchorUrl, locationUrl;
  11045. // support: IE7
  11046. // IE7 doesn't normalize the href property when set via script (#9317)
  11047. anchor = anchor.cloneNode( false );
  11048. anchorUrl = anchor.href.replace( rhash, "" );
  11049. locationUrl = location.href.replace( rhash, "" );
  11050. // decoding may throw an error if the URL isn't UTF-8 (#9518)
  11051. try {
  11052. anchorUrl = decodeURIComponent( anchorUrl );
  11053. } catch ( error ) {}
  11054. try {
  11055. locationUrl = decodeURIComponent( locationUrl );
  11056. } catch ( error ) {}
  11057. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  11058. };
  11059. })(),
  11060. _create: function() {
  11061. var that = this,
  11062. options = this.options;
  11063. this.running = false;
  11064. this.element
  11065. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  11066. .toggleClass( "ui-tabs-collapsible", options.collapsible );
  11067. this._processTabs();
  11068. options.active = this._initialActive();
  11069. // Take disabling tabs via class attribute from HTML
  11070. // into account and update option properly.
  11071. if ( $.isArray( options.disabled ) ) {
  11072. options.disabled = $.unique( options.disabled.concat(
  11073. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  11074. return that.tabs.index( li );
  11075. })
  11076. ) ).sort();
  11077. }
  11078. // check for length avoids error when initializing empty list
  11079. if ( this.options.active !== false && this.anchors.length ) {
  11080. this.active = this._findActive( options.active );
  11081. } else {
  11082. this.active = $();
  11083. }
  11084. this._refresh();
  11085. if ( this.active.length ) {
  11086. this.load( options.active );
  11087. }
  11088. },
  11089. _initialActive: function() {
  11090. var active = this.options.active,
  11091. collapsible = this.options.collapsible,
  11092. locationHash = location.hash.substring( 1 );
  11093. if ( active === null ) {
  11094. // check the fragment identifier in the URL
  11095. if ( locationHash ) {
  11096. this.tabs.each(function( i, tab ) {
  11097. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  11098. active = i;
  11099. return false;
  11100. }
  11101. });
  11102. }
  11103. // check for a tab marked active via a class
  11104. if ( active === null ) {
  11105. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  11106. }
  11107. // no active tab, set to false
  11108. if ( active === null || active === -1 ) {
  11109. active = this.tabs.length ? 0 : false;
  11110. }
  11111. }
  11112. // handle numbers: negative, out of range
  11113. if ( active !== false ) {
  11114. active = this.tabs.index( this.tabs.eq( active ) );
  11115. if ( active === -1 ) {
  11116. active = collapsible ? false : 0;
  11117. }
  11118. }
  11119. // don't allow collapsible: false and active: false
  11120. if ( !collapsible && active === false && this.anchors.length ) {
  11121. active = 0;
  11122. }
  11123. return active;
  11124. },
  11125. _getCreateEventData: function() {
  11126. return {
  11127. tab: this.active,
  11128. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  11129. };
  11130. },
  11131. _tabKeydown: function( event ) {
  11132. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  11133. selectedIndex = this.tabs.index( focusedTab ),
  11134. goingForward = true;
  11135. if ( this._handlePageNav( event ) ) {
  11136. return;
  11137. }
  11138. switch ( event.keyCode ) {
  11139. case $.ui.keyCode.RIGHT:
  11140. case $.ui.keyCode.DOWN:
  11141. selectedIndex++;
  11142. break;
  11143. case $.ui.keyCode.UP:
  11144. case $.ui.keyCode.LEFT:
  11145. goingForward = false;
  11146. selectedIndex--;
  11147. break;
  11148. case $.ui.keyCode.END:
  11149. selectedIndex = this.anchors.length - 1;
  11150. break;
  11151. case $.ui.keyCode.HOME:
  11152. selectedIndex = 0;
  11153. break;
  11154. case $.ui.keyCode.SPACE:
  11155. // Activate only, no collapsing
  11156. event.preventDefault();
  11157. clearTimeout( this.activating );
  11158. this._activate( selectedIndex );
  11159. return;
  11160. case $.ui.keyCode.ENTER:
  11161. // Toggle (cancel delayed activation, allow collapsing)
  11162. event.preventDefault();
  11163. clearTimeout( this.activating );
  11164. // Determine if we should collapse or activate
  11165. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  11166. return;
  11167. default:
  11168. return;
  11169. }
  11170. // Focus the appropriate tab, based on which key was pressed
  11171. event.preventDefault();
  11172. clearTimeout( this.activating );
  11173. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  11174. // Navigating with control/command key will prevent automatic activation
  11175. if ( !event.ctrlKey && !event.metaKey ) {
  11176. // Update aria-selected immediately so that AT think the tab is already selected.
  11177. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  11178. // but the tab will already be activated by the time the announcement finishes.
  11179. focusedTab.attr( "aria-selected", "false" );
  11180. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  11181. this.activating = this._delay(function() {
  11182. this.option( "active", selectedIndex );
  11183. }, this.delay );
  11184. }
  11185. },
  11186. _panelKeydown: function( event ) {
  11187. if ( this._handlePageNav( event ) ) {
  11188. return;
  11189. }
  11190. // Ctrl+up moves focus to the current tab
  11191. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  11192. event.preventDefault();
  11193. this.active.focus();
  11194. }
  11195. },
  11196. // Alt+page up/down moves focus to the previous/next tab (and activates)
  11197. _handlePageNav: function( event ) {
  11198. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  11199. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  11200. return true;
  11201. }
  11202. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  11203. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  11204. return true;
  11205. }
  11206. },
  11207. _findNextTab: function( index, goingForward ) {
  11208. var lastTabIndex = this.tabs.length - 1;
  11209. function constrain() {
  11210. if ( index > lastTabIndex ) {
  11211. index = 0;
  11212. }
  11213. if ( index < 0 ) {
  11214. index = lastTabIndex;
  11215. }
  11216. return index;
  11217. }
  11218. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  11219. index = goingForward ? index + 1 : index - 1;
  11220. }
  11221. return index;
  11222. },
  11223. _focusNextTab: function( index, goingForward ) {
  11224. index = this._findNextTab( index, goingForward );
  11225. this.tabs.eq( index ).focus();
  11226. return index;
  11227. },
  11228. _setOption: function( key, value ) {
  11229. if ( key === "active" ) {
  11230. // _activate() will handle invalid values and update this.options
  11231. this._activate( value );
  11232. return;
  11233. }
  11234. if ( key === "disabled" ) {
  11235. // don't use the widget factory's disabled handling
  11236. this._setupDisabled( value );
  11237. return;
  11238. }
  11239. this._super( key, value);
  11240. if ( key === "collapsible" ) {
  11241. this.element.toggleClass( "ui-tabs-collapsible", value );
  11242. // Setting collapsible: false while collapsed; open first panel
  11243. if ( !value && this.options.active === false ) {
  11244. this._activate( 0 );
  11245. }
  11246. }
  11247. if ( key === "event" ) {
  11248. this._setupEvents( value );
  11249. }
  11250. if ( key === "heightStyle" ) {
  11251. this._setupHeightStyle( value );
  11252. }
  11253. },
  11254. _sanitizeSelector: function( hash ) {
  11255. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  11256. },
  11257. refresh: function() {
  11258. var options = this.options,
  11259. lis = this.tablist.children( ":has(a[href])" );
  11260. // get disabled tabs from class attribute from HTML
  11261. // this will get converted to a boolean if needed in _refresh()
  11262. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  11263. return lis.index( tab );
  11264. });
  11265. this._processTabs();
  11266. // was collapsed or no tabs
  11267. if ( options.active === false || !this.anchors.length ) {
  11268. options.active = false;
  11269. this.active = $();
  11270. // was active, but active tab is gone
  11271. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  11272. // all remaining tabs are disabled
  11273. if ( this.tabs.length === options.disabled.length ) {
  11274. options.active = false;
  11275. this.active = $();
  11276. // activate previous tab
  11277. } else {
  11278. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  11279. }
  11280. // was active, active tab still exists
  11281. } else {
  11282. // make sure active index is correct
  11283. options.active = this.tabs.index( this.active );
  11284. }
  11285. this._refresh();
  11286. },
  11287. _refresh: function() {
  11288. this._setupDisabled( this.options.disabled );
  11289. this._setupEvents( this.options.event );
  11290. this._setupHeightStyle( this.options.heightStyle );
  11291. this.tabs.not( this.active ).attr({
  11292. "aria-selected": "false",
  11293. "aria-expanded": "false",
  11294. tabIndex: -1
  11295. });
  11296. this.panels.not( this._getPanelForTab( this.active ) )
  11297. .hide()
  11298. .attr({
  11299. "aria-hidden": "true"
  11300. });
  11301. // Make sure one tab is in the tab order
  11302. if ( !this.active.length ) {
  11303. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  11304. } else {
  11305. this.active
  11306. .addClass( "ui-tabs-active ui-state-active" )
  11307. .attr({
  11308. "aria-selected": "true",
  11309. "aria-expanded": "true",
  11310. tabIndex: 0
  11311. });
  11312. this._getPanelForTab( this.active )
  11313. .show()
  11314. .attr({
  11315. "aria-hidden": "false"
  11316. });
  11317. }
  11318. },
  11319. _processTabs: function() {
  11320. var that = this,
  11321. prevTabs = this.tabs,
  11322. prevAnchors = this.anchors,
  11323. prevPanels = this.panels;
  11324. this.tablist = this._getList()
  11325. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  11326. .attr( "role", "tablist" )
  11327. // Prevent users from focusing disabled tabs via click
  11328. .delegate( "> li", "mousedown" + this.eventNamespace, function( event ) {
  11329. if ( $( this ).is( ".ui-state-disabled" ) ) {
  11330. event.preventDefault();
  11331. }
  11332. })
  11333. // support: IE <9
  11334. // Preventing the default action in mousedown doesn't prevent IE
  11335. // from focusing the element, so if the anchor gets focused, blur.
  11336. // We don't have to worry about focusing the previously focused
  11337. // element since clicking on a non-focusable element should focus
  11338. // the body anyway.
  11339. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  11340. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  11341. this.blur();
  11342. }
  11343. });
  11344. this.tabs = this.tablist.find( "> li:has(a[href])" )
  11345. .addClass( "ui-state-default ui-corner-top" )
  11346. .attr({
  11347. role: "tab",
  11348. tabIndex: -1
  11349. });
  11350. this.anchors = this.tabs.map(function() {
  11351. return $( "a", this )[ 0 ];
  11352. })
  11353. .addClass( "ui-tabs-anchor" )
  11354. .attr({
  11355. role: "presentation",
  11356. tabIndex: -1
  11357. });
  11358. this.panels = $();
  11359. this.anchors.each(function( i, anchor ) {
  11360. var selector, panel, panelId,
  11361. anchorId = $( anchor ).uniqueId().attr( "id" ),
  11362. tab = $( anchor ).closest( "li" ),
  11363. originalAriaControls = tab.attr( "aria-controls" );
  11364. // inline tab
  11365. if ( that._isLocal( anchor ) ) {
  11366. selector = anchor.hash;
  11367. panelId = selector.substring( 1 );
  11368. panel = that.element.find( that._sanitizeSelector( selector ) );
  11369. // remote tab
  11370. } else {
  11371. // If the tab doesn't already have aria-controls,
  11372. // generate an id by using a throw-away element
  11373. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  11374. selector = "#" + panelId;
  11375. panel = that.element.find( selector );
  11376. if ( !panel.length ) {
  11377. panel = that._createPanel( panelId );
  11378. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  11379. }
  11380. panel.attr( "aria-live", "polite" );
  11381. }
  11382. if ( panel.length) {
  11383. that.panels = that.panels.add( panel );
  11384. }
  11385. if ( originalAriaControls ) {
  11386. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  11387. }
  11388. tab.attr({
  11389. "aria-controls": panelId,
  11390. "aria-labelledby": anchorId
  11391. });
  11392. panel.attr( "aria-labelledby", anchorId );
  11393. });
  11394. this.panels
  11395. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  11396. .attr( "role", "tabpanel" );
  11397. // Avoid memory leaks (#10056)
  11398. if ( prevTabs ) {
  11399. this._off( prevTabs.not( this.tabs ) );
  11400. this._off( prevAnchors.not( this.anchors ) );
  11401. this._off( prevPanels.not( this.panels ) );
  11402. }
  11403. },
  11404. // allow overriding how to find the list for rare usage scenarios (#7715)
  11405. _getList: function() {
  11406. return this.tablist || this.element.find( "ol,ul" ).eq( 0 );
  11407. },
  11408. _createPanel: function( id ) {
  11409. return $( "<div>" )
  11410. .attr( "id", id )
  11411. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  11412. .data( "ui-tabs-destroy", true );
  11413. },
  11414. _setupDisabled: function( disabled ) {
  11415. if ( $.isArray( disabled ) ) {
  11416. if ( !disabled.length ) {
  11417. disabled = false;
  11418. } else if ( disabled.length === this.anchors.length ) {
  11419. disabled = true;
  11420. }
  11421. }
  11422. // disable tabs
  11423. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  11424. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  11425. $( li )
  11426. .addClass( "ui-state-disabled" )
  11427. .attr( "aria-disabled", "true" );
  11428. } else {
  11429. $( li )
  11430. .removeClass( "ui-state-disabled" )
  11431. .removeAttr( "aria-disabled" );
  11432. }
  11433. }
  11434. this.options.disabled = disabled;
  11435. },
  11436. _setupEvents: function( event ) {
  11437. var events = {};
  11438. if ( event ) {
  11439. $.each( event.split(" "), function( index, eventName ) {
  11440. events[ eventName ] = "_eventHandler";
  11441. });
  11442. }
  11443. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  11444. // Always prevent the default action, even when disabled
  11445. this._on( true, this.anchors, {
  11446. click: function( event ) {
  11447. event.preventDefault();
  11448. }
  11449. });
  11450. this._on( this.anchors, events );
  11451. this._on( this.tabs, { keydown: "_tabKeydown" } );
  11452. this._on( this.panels, { keydown: "_panelKeydown" } );
  11453. this._focusable( this.tabs );
  11454. this._hoverable( this.tabs );
  11455. },
  11456. _setupHeightStyle: function( heightStyle ) {
  11457. var maxHeight,
  11458. parent = this.element.parent();
  11459. if ( heightStyle === "fill" ) {
  11460. maxHeight = parent.height();
  11461. maxHeight -= this.element.outerHeight() - this.element.height();
  11462. this.element.siblings( ":visible" ).each(function() {
  11463. var elem = $( this ),
  11464. position = elem.css( "position" );
  11465. if ( position === "absolute" || position === "fixed" ) {
  11466. return;
  11467. }
  11468. maxHeight -= elem.outerHeight( true );
  11469. });
  11470. this.element.children().not( this.panels ).each(function() {
  11471. maxHeight -= $( this ).outerHeight( true );
  11472. });
  11473. this.panels.each(function() {
  11474. $( this ).height( Math.max( 0, maxHeight -
  11475. $( this ).innerHeight() + $( this ).height() ) );
  11476. })
  11477. .css( "overflow", "auto" );
  11478. } else if ( heightStyle === "auto" ) {
  11479. maxHeight = 0;
  11480. this.panels.each(function() {
  11481. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  11482. }).height( maxHeight );
  11483. }
  11484. },
  11485. _eventHandler: function( event ) {
  11486. var options = this.options,
  11487. active = this.active,
  11488. anchor = $( event.currentTarget ),
  11489. tab = anchor.closest( "li" ),
  11490. clickedIsActive = tab[ 0 ] === active[ 0 ],
  11491. collapsing = clickedIsActive && options.collapsible,
  11492. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  11493. toHide = !active.length ? $() : this._getPanelForTab( active ),
  11494. eventData = {
  11495. oldTab: active,
  11496. oldPanel: toHide,
  11497. newTab: collapsing ? $() : tab,
  11498. newPanel: toShow
  11499. };
  11500. event.preventDefault();
  11501. if ( tab.hasClass( "ui-state-disabled" ) ||
  11502. // tab is already loading
  11503. tab.hasClass( "ui-tabs-loading" ) ||
  11504. // can't switch durning an animation
  11505. this.running ||
  11506. // click on active header, but not collapsible
  11507. ( clickedIsActive && !options.collapsible ) ||
  11508. // allow canceling activation
  11509. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  11510. return;
  11511. }
  11512. options.active = collapsing ? false : this.tabs.index( tab );
  11513. this.active = clickedIsActive ? $() : tab;
  11514. if ( this.xhr ) {
  11515. this.xhr.abort();
  11516. }
  11517. if ( !toHide.length && !toShow.length ) {
  11518. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  11519. }
  11520. if ( toShow.length ) {
  11521. this.load( this.tabs.index( tab ), event );
  11522. }
  11523. this._toggle( event, eventData );
  11524. },
  11525. // handles show/hide for selecting tabs
  11526. _toggle: function( event, eventData ) {
  11527. var that = this,
  11528. toShow = eventData.newPanel,
  11529. toHide = eventData.oldPanel;
  11530. this.running = true;
  11531. function complete() {
  11532. that.running = false;
  11533. that._trigger( "activate", event, eventData );
  11534. }
  11535. function show() {
  11536. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  11537. if ( toShow.length && that.options.show ) {
  11538. that._show( toShow, that.options.show, complete );
  11539. } else {
  11540. toShow.show();
  11541. complete();
  11542. }
  11543. }
  11544. // start out by hiding, then showing, then completing
  11545. if ( toHide.length && this.options.hide ) {
  11546. this._hide( toHide, this.options.hide, function() {
  11547. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  11548. show();
  11549. });
  11550. } else {
  11551. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  11552. toHide.hide();
  11553. show();
  11554. }
  11555. toHide.attr( "aria-hidden", "true" );
  11556. eventData.oldTab.attr({
  11557. "aria-selected": "false",
  11558. "aria-expanded": "false"
  11559. });
  11560. // If we're switching tabs, remove the old tab from the tab order.
  11561. // If we're opening from collapsed state, remove the previous tab from the tab order.
  11562. // If we're collapsing, then keep the collapsing tab in the tab order.
  11563. if ( toShow.length && toHide.length ) {
  11564. eventData.oldTab.attr( "tabIndex", -1 );
  11565. } else if ( toShow.length ) {
  11566. this.tabs.filter(function() {
  11567. return $( this ).attr( "tabIndex" ) === 0;
  11568. })
  11569. .attr( "tabIndex", -1 );
  11570. }
  11571. toShow.attr( "aria-hidden", "false" );
  11572. eventData.newTab.attr({
  11573. "aria-selected": "true",
  11574. "aria-expanded": "true",
  11575. tabIndex: 0
  11576. });
  11577. },
  11578. _activate: function( index ) {
  11579. var anchor,
  11580. active = this._findActive( index );
  11581. // trying to activate the already active panel
  11582. if ( active[ 0 ] === this.active[ 0 ] ) {
  11583. return;
  11584. }
  11585. // trying to collapse, simulate a click on the current active header
  11586. if ( !active.length ) {
  11587. active = this.active;
  11588. }
  11589. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  11590. this._eventHandler({
  11591. target: anchor,
  11592. currentTarget: anchor,
  11593. preventDefault: $.noop
  11594. });
  11595. },
  11596. _findActive: function( index ) {
  11597. return index === false ? $() : this.tabs.eq( index );
  11598. },
  11599. _getIndex: function( index ) {
  11600. // meta-function to give users option to provide a href string instead of a numerical index.
  11601. if ( typeof index === "string" ) {
  11602. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  11603. }
  11604. return index;
  11605. },
  11606. _destroy: function() {
  11607. if ( this.xhr ) {
  11608. this.xhr.abort();
  11609. }
  11610. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  11611. this.tablist
  11612. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  11613. .removeAttr( "role" );
  11614. this.anchors
  11615. .removeClass( "ui-tabs-anchor" )
  11616. .removeAttr( "role" )
  11617. .removeAttr( "tabIndex" )
  11618. .removeUniqueId();
  11619. this.tablist.unbind( this.eventNamespace );
  11620. this.tabs.add( this.panels ).each(function() {
  11621. if ( $.data( this, "ui-tabs-destroy" ) ) {
  11622. $( this ).remove();
  11623. } else {
  11624. $( this )
  11625. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  11626. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  11627. .removeAttr( "tabIndex" )
  11628. .removeAttr( "aria-live" )
  11629. .removeAttr( "aria-busy" )
  11630. .removeAttr( "aria-selected" )
  11631. .removeAttr( "aria-labelledby" )
  11632. .removeAttr( "aria-hidden" )
  11633. .removeAttr( "aria-expanded" )
  11634. .removeAttr( "role" );
  11635. }
  11636. });
  11637. this.tabs.each(function() {
  11638. var li = $( this ),
  11639. prev = li.data( "ui-tabs-aria-controls" );
  11640. if ( prev ) {
  11641. li
  11642. .attr( "aria-controls", prev )
  11643. .removeData( "ui-tabs-aria-controls" );
  11644. } else {
  11645. li.removeAttr( "aria-controls" );
  11646. }
  11647. });
  11648. this.panels.show();
  11649. if ( this.options.heightStyle !== "content" ) {
  11650. this.panels.css( "height", "" );
  11651. }
  11652. },
  11653. enable: function( index ) {
  11654. var disabled = this.options.disabled;
  11655. if ( disabled === false ) {
  11656. return;
  11657. }
  11658. if ( index === undefined ) {
  11659. disabled = false;
  11660. } else {
  11661. index = this._getIndex( index );
  11662. if ( $.isArray( disabled ) ) {
  11663. disabled = $.map( disabled, function( num ) {
  11664. return num !== index ? num : null;
  11665. });
  11666. } else {
  11667. disabled = $.map( this.tabs, function( li, num ) {
  11668. return num !== index ? num : null;
  11669. });
  11670. }
  11671. }
  11672. this._setupDisabled( disabled );
  11673. },
  11674. disable: function( index ) {
  11675. var disabled = this.options.disabled;
  11676. if ( disabled === true ) {
  11677. return;
  11678. }
  11679. if ( index === undefined ) {
  11680. disabled = true;
  11681. } else {
  11682. index = this._getIndex( index );
  11683. if ( $.inArray( index, disabled ) !== -1 ) {
  11684. return;
  11685. }
  11686. if ( $.isArray( disabled ) ) {
  11687. disabled = $.merge( [ index ], disabled ).sort();
  11688. } else {
  11689. disabled = [ index ];
  11690. }
  11691. }
  11692. this._setupDisabled( disabled );
  11693. },
  11694. load: function( index, event ) {
  11695. index = this._getIndex( index );
  11696. var that = this,
  11697. tab = this.tabs.eq( index ),
  11698. anchor = tab.find( ".ui-tabs-anchor" ),
  11699. panel = this._getPanelForTab( tab ),
  11700. eventData = {
  11701. tab: tab,
  11702. panel: panel
  11703. };
  11704. // not remote
  11705. if ( this._isLocal( anchor[ 0 ] ) ) {
  11706. return;
  11707. }
  11708. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  11709. // support: jQuery <1.8
  11710. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  11711. // but as of 1.8, $.ajax() always returns a jqXHR object.
  11712. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  11713. tab.addClass( "ui-tabs-loading" );
  11714. panel.attr( "aria-busy", "true" );
  11715. this.xhr
  11716. .success(function( response ) {
  11717. // support: jQuery <1.8
  11718. // http://bugs.jquery.com/ticket/11778
  11719. setTimeout(function() {
  11720. panel.html( response );
  11721. that._trigger( "load", event, eventData );
  11722. }, 1 );
  11723. })
  11724. .complete(function( jqXHR, status ) {
  11725. // support: jQuery <1.8
  11726. // http://bugs.jquery.com/ticket/11778
  11727. setTimeout(function() {
  11728. if ( status === "abort" ) {
  11729. that.panels.stop( false, true );
  11730. }
  11731. tab.removeClass( "ui-tabs-loading" );
  11732. panel.removeAttr( "aria-busy" );
  11733. if ( jqXHR === that.xhr ) {
  11734. delete that.xhr;
  11735. }
  11736. }, 1 );
  11737. });
  11738. }
  11739. },
  11740. _ajaxSettings: function( anchor, event, eventData ) {
  11741. var that = this;
  11742. return {
  11743. url: anchor.attr( "href" ),
  11744. beforeSend: function( jqXHR, settings ) {
  11745. return that._trigger( "beforeLoad", event,
  11746. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  11747. }
  11748. };
  11749. },
  11750. _getPanelForTab: function( tab ) {
  11751. var id = $( tab ).attr( "aria-controls" );
  11752. return this.element.find( this._sanitizeSelector( "#" + id ) );
  11753. }
  11754. });
  11755. /*!
  11756. * jQuery UI Tooltip 1.11.3
  11757. * http://jqueryui.com
  11758. *
  11759. * Copyright jQuery Foundation and other contributors
  11760. * Released under the MIT license.
  11761. * http://jquery.org/license
  11762. *
  11763. * http://api.jqueryui.com/tooltip/
  11764. */
  11765. var tooltip = $.widget( "ui.tooltip", {
  11766. version: "1.11.3",
  11767. options: {
  11768. content: function() {
  11769. // support: IE<9, Opera in jQuery <1.7
  11770. // .text() can't accept undefined, so coerce to a string
  11771. var title = $( this ).attr( "title" ) || "";
  11772. // Escape title, since we're going from an attribute to raw HTML
  11773. return $( "<a>" ).text( title ).html();
  11774. },
  11775. hide: true,
  11776. // Disabled elements have inconsistent behavior across browsers (#8661)
  11777. items: "[title]:not([disabled])",
  11778. position: {
  11779. my: "left top+15",
  11780. at: "left bottom",
  11781. collision: "flipfit flip"
  11782. },
  11783. show: true,
  11784. tooltipClass: null,
  11785. track: false,
  11786. // callbacks
  11787. close: null,
  11788. open: null
  11789. },
  11790. _addDescribedBy: function( elem, id ) {
  11791. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  11792. describedby.push( id );
  11793. elem
  11794. .data( "ui-tooltip-id", id )
  11795. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  11796. },
  11797. _removeDescribedBy: function( elem ) {
  11798. var id = elem.data( "ui-tooltip-id" ),
  11799. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  11800. index = $.inArray( id, describedby );
  11801. if ( index !== -1 ) {
  11802. describedby.splice( index, 1 );
  11803. }
  11804. elem.removeData( "ui-tooltip-id" );
  11805. describedby = $.trim( describedby.join( " " ) );
  11806. if ( describedby ) {
  11807. elem.attr( "aria-describedby", describedby );
  11808. } else {
  11809. elem.removeAttr( "aria-describedby" );
  11810. }
  11811. },
  11812. _create: function() {
  11813. this._on({
  11814. mouseover: "open",
  11815. focusin: "open"
  11816. });
  11817. // IDs of generated tooltips, needed for destroy
  11818. this.tooltips = {};
  11819. // IDs of parent tooltips where we removed the title attribute
  11820. this.parents = {};
  11821. if ( this.options.disabled ) {
  11822. this._disable();
  11823. }
  11824. // Append the aria-live region so tooltips announce correctly
  11825. this.liveRegion = $( "<div>" )
  11826. .attr({
  11827. role: "log",
  11828. "aria-live": "assertive",
  11829. "aria-relevant": "additions"
  11830. })
  11831. .addClass( "ui-helper-hidden-accessible" )
  11832. .appendTo( this.document[ 0 ].body );
  11833. },
  11834. _setOption: function( key, value ) {
  11835. var that = this;
  11836. if ( key === "disabled" ) {
  11837. this[ value ? "_disable" : "_enable" ]();
  11838. this.options[ key ] = value;
  11839. // disable element style changes
  11840. return;
  11841. }
  11842. this._super( key, value );
  11843. if ( key === "content" ) {
  11844. $.each( this.tooltips, function( id, tooltipData ) {
  11845. that._updateContent( tooltipData.element );
  11846. });
  11847. }
  11848. },
  11849. _disable: function() {
  11850. var that = this;
  11851. // close open tooltips
  11852. $.each( this.tooltips, function( id, tooltipData ) {
  11853. var event = $.Event( "blur" );
  11854. event.target = event.currentTarget = tooltipData.element[ 0 ];
  11855. that.close( event, true );
  11856. });
  11857. // remove title attributes to prevent native tooltips
  11858. this.element.find( this.options.items ).addBack().each(function() {
  11859. var element = $( this );
  11860. if ( element.is( "[title]" ) ) {
  11861. element
  11862. .data( "ui-tooltip-title", element.attr( "title" ) )
  11863. .removeAttr( "title" );
  11864. }
  11865. });
  11866. },
  11867. _enable: function() {
  11868. // restore title attributes
  11869. this.element.find( this.options.items ).addBack().each(function() {
  11870. var element = $( this );
  11871. if ( element.data( "ui-tooltip-title" ) ) {
  11872. element.attr( "title", element.data( "ui-tooltip-title" ) );
  11873. }
  11874. });
  11875. },
  11876. open: function( event ) {
  11877. var that = this,
  11878. target = $( event ? event.target : this.element )
  11879. // we need closest here due to mouseover bubbling,
  11880. // but always pointing at the same event target
  11881. .closest( this.options.items );
  11882. // No element to show a tooltip for or the tooltip is already open
  11883. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  11884. return;
  11885. }
  11886. if ( target.attr( "title" ) ) {
  11887. target.data( "ui-tooltip-title", target.attr( "title" ) );
  11888. }
  11889. target.data( "ui-tooltip-open", true );
  11890. // kill parent tooltips, custom or native, for hover
  11891. if ( event && event.type === "mouseover" ) {
  11892. target.parents().each(function() {
  11893. var parent = $( this ),
  11894. blurEvent;
  11895. if ( parent.data( "ui-tooltip-open" ) ) {
  11896. blurEvent = $.Event( "blur" );
  11897. blurEvent.target = blurEvent.currentTarget = this;
  11898. that.close( blurEvent, true );
  11899. }
  11900. if ( parent.attr( "title" ) ) {
  11901. parent.uniqueId();
  11902. that.parents[ this.id ] = {
  11903. element: this,
  11904. title: parent.attr( "title" )
  11905. };
  11906. parent.attr( "title", "" );
  11907. }
  11908. });
  11909. }
  11910. this._updateContent( target, event );
  11911. },
  11912. _updateContent: function( target, event ) {
  11913. var content,
  11914. contentOption = this.options.content,
  11915. that = this,
  11916. eventType = event ? event.type : null;
  11917. if ( typeof contentOption === "string" ) {
  11918. return this._open( event, target, contentOption );
  11919. }
  11920. content = contentOption.call( target[0], function( response ) {
  11921. // ignore async response if tooltip was closed already
  11922. if ( !target.data( "ui-tooltip-open" ) ) {
  11923. return;
  11924. }
  11925. // IE may instantly serve a cached response for ajax requests
  11926. // delay this call to _open so the other call to _open runs first
  11927. that._delay(function() {
  11928. // jQuery creates a special event for focusin when it doesn't
  11929. // exist natively. To improve performance, the native event
  11930. // object is reused and the type is changed. Therefore, we can't
  11931. // rely on the type being correct after the event finished
  11932. // bubbling, so we set it back to the previous value. (#8740)
  11933. if ( event ) {
  11934. event.type = eventType;
  11935. }
  11936. this._open( event, target, response );
  11937. });
  11938. });
  11939. if ( content ) {
  11940. this._open( event, target, content );
  11941. }
  11942. },
  11943. _open: function( event, target, content ) {
  11944. var tooltipData, tooltip, events, delayedShow, a11yContent,
  11945. positionOption = $.extend( {}, this.options.position );
  11946. if ( !content ) {
  11947. return;
  11948. }
  11949. // Content can be updated multiple times. If the tooltip already
  11950. // exists, then just update the content and bail.
  11951. tooltipData = this._find( target );
  11952. if ( tooltipData ) {
  11953. tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
  11954. return;
  11955. }
  11956. // if we have a title, clear it to prevent the native tooltip
  11957. // we have to check first to avoid defining a title if none exists
  11958. // (we don't want to cause an element to start matching [title])
  11959. //
  11960. // We use removeAttr only for key events, to allow IE to export the correct
  11961. // accessible attributes. For mouse events, set to empty string to avoid
  11962. // native tooltip showing up (happens only when removing inside mouseover).
  11963. if ( target.is( "[title]" ) ) {
  11964. if ( event && event.type === "mouseover" ) {
  11965. target.attr( "title", "" );
  11966. } else {
  11967. target.removeAttr( "title" );
  11968. }
  11969. }
  11970. tooltipData = this._tooltip( target );
  11971. tooltip = tooltipData.tooltip;
  11972. this._addDescribedBy( target, tooltip.attr( "id" ) );
  11973. tooltip.find( ".ui-tooltip-content" ).html( content );
  11974. // Support: Voiceover on OS X, JAWS on IE <= 9
  11975. // JAWS announces deletions even when aria-relevant="additions"
  11976. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  11977. this.liveRegion.children().hide();
  11978. if ( content.clone ) {
  11979. a11yContent = content.clone();
  11980. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  11981. } else {
  11982. a11yContent = content;
  11983. }
  11984. $( "<div>" ).html( a11yContent ).appendTo( this.liveRegion );
  11985. function position( event ) {
  11986. positionOption.of = event;
  11987. if ( tooltip.is( ":hidden" ) ) {
  11988. return;
  11989. }
  11990. tooltip.position( positionOption );
  11991. }
  11992. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  11993. this._on( this.document, {
  11994. mousemove: position
  11995. });
  11996. // trigger once to override element-relative positioning
  11997. position( event );
  11998. } else {
  11999. tooltip.position( $.extend({
  12000. of: target
  12001. }, this.options.position ) );
  12002. }
  12003. tooltip.hide();
  12004. this._show( tooltip, this.options.show );
  12005. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  12006. // as the tooltip is visible, position the tooltip using the most recent
  12007. // event.
  12008. if ( this.options.show && this.options.show.delay ) {
  12009. delayedShow = this.delayedShow = setInterval(function() {
  12010. if ( tooltip.is( ":visible" ) ) {
  12011. position( positionOption.of );
  12012. clearInterval( delayedShow );
  12013. }
  12014. }, $.fx.interval );
  12015. }
  12016. this._trigger( "open", event, { tooltip: tooltip } );
  12017. events = {
  12018. keyup: function( event ) {
  12019. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  12020. var fakeEvent = $.Event(event);
  12021. fakeEvent.currentTarget = target[0];
  12022. this.close( fakeEvent, true );
  12023. }
  12024. }
  12025. };
  12026. // Only bind remove handler for delegated targets. Non-delegated
  12027. // tooltips will handle this in destroy.
  12028. if ( target[ 0 ] !== this.element[ 0 ] ) {
  12029. events.remove = function() {
  12030. this._removeTooltip( tooltip );
  12031. };
  12032. }
  12033. if ( !event || event.type === "mouseover" ) {
  12034. events.mouseleave = "close";
  12035. }
  12036. if ( !event || event.type === "focusin" ) {
  12037. events.focusout = "close";
  12038. }
  12039. this._on( true, target, events );
  12040. },
  12041. close: function( event ) {
  12042. var tooltip,
  12043. that = this,
  12044. target = $( event ? event.currentTarget : this.element ),
  12045. tooltipData = this._find( target );
  12046. // The tooltip may already be closed
  12047. if ( !tooltipData ) {
  12048. return;
  12049. }
  12050. tooltip = tooltipData.tooltip;
  12051. // disabling closes the tooltip, so we need to track when we're closing
  12052. // to avoid an infinite loop in case the tooltip becomes disabled on close
  12053. if ( tooltipData.closing ) {
  12054. return;
  12055. }
  12056. // Clear the interval for delayed tracking tooltips
  12057. clearInterval( this.delayedShow );
  12058. // only set title if we had one before (see comment in _open())
  12059. // If the title attribute has changed since open(), don't restore
  12060. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  12061. target.attr( "title", target.data( "ui-tooltip-title" ) );
  12062. }
  12063. this._removeDescribedBy( target );
  12064. tooltipData.hiding = true;
  12065. tooltip.stop( true );
  12066. this._hide( tooltip, this.options.hide, function() {
  12067. that._removeTooltip( $( this ) );
  12068. });
  12069. target.removeData( "ui-tooltip-open" );
  12070. this._off( target, "mouseleave focusout keyup" );
  12071. // Remove 'remove' binding only on delegated targets
  12072. if ( target[ 0 ] !== this.element[ 0 ] ) {
  12073. this._off( target, "remove" );
  12074. }
  12075. this._off( this.document, "mousemove" );
  12076. if ( event && event.type === "mouseleave" ) {
  12077. $.each( this.parents, function( id, parent ) {
  12078. $( parent.element ).attr( "title", parent.title );
  12079. delete that.parents[ id ];
  12080. });
  12081. }
  12082. tooltipData.closing = true;
  12083. this._trigger( "close", event, { tooltip: tooltip } );
  12084. if ( !tooltipData.hiding ) {
  12085. tooltipData.closing = false;
  12086. }
  12087. },
  12088. _tooltip: function( element ) {
  12089. var tooltip = $( "<div>" )
  12090. .attr( "role", "tooltip" )
  12091. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  12092. ( this.options.tooltipClass || "" ) ),
  12093. id = tooltip.uniqueId().attr( "id" );
  12094. $( "<div>" )
  12095. .addClass( "ui-tooltip-content" )
  12096. .appendTo( tooltip );
  12097. tooltip.appendTo( this.document[0].body );
  12098. return this.tooltips[ id ] = {
  12099. element: element,
  12100. tooltip: tooltip
  12101. };
  12102. },
  12103. _find: function( target ) {
  12104. var id = target.data( "ui-tooltip-id" );
  12105. return id ? this.tooltips[ id ] : null;
  12106. },
  12107. _removeTooltip: function( tooltip ) {
  12108. tooltip.remove();
  12109. delete this.tooltips[ tooltip.attr( "id" ) ];
  12110. },
  12111. _destroy: function() {
  12112. var that = this;
  12113. // close open tooltips
  12114. $.each( this.tooltips, function( id, tooltipData ) {
  12115. // Delegate to close method to handle common cleanup
  12116. var event = $.Event( "blur" ),
  12117. element = tooltipData.element;
  12118. event.target = event.currentTarget = element[ 0 ];
  12119. that.close( event, true );
  12120. // Remove immediately; destroying an open tooltip doesn't use the
  12121. // hide animation
  12122. $( "#" + id ).remove();
  12123. // Restore the title
  12124. if ( element.data( "ui-tooltip-title" ) ) {
  12125. // If the title attribute has changed since open(), don't restore
  12126. if ( !element.attr( "title" ) ) {
  12127. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12128. }
  12129. element.removeData( "ui-tooltip-title" );
  12130. }
  12131. });
  12132. this.liveRegion.remove();
  12133. }
  12134. });
  12135. /*!
  12136. * jQuery UI Effects 1.11.3
  12137. * http://jqueryui.com
  12138. *
  12139. * Copyright jQuery Foundation and other contributors
  12140. * Released under the MIT license.
  12141. * http://jquery.org/license
  12142. *
  12143. * http://api.jqueryui.com/category/effects-core/
  12144. */
  12145. var dataSpace = "ui-effects-",
  12146. // Create a local jQuery because jQuery Color relies on it and the
  12147. // global may not exist with AMD and a custom build (#10199)
  12148. jQuery = $;
  12149. $.effects = {
  12150. effect: {}
  12151. };
  12152. /*!
  12153. * jQuery Color Animations v2.1.2
  12154. * https://github.com/jquery/jquery-color
  12155. *
  12156. * Copyright 2014 jQuery Foundation and other contributors
  12157. * Released under the MIT license.
  12158. * http://jquery.org/license
  12159. *
  12160. * Date: Wed Jan 16 08:47:09 2013 -0600
  12161. */
  12162. (function( jQuery, undefined ) {
  12163. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  12164. // plusequals test for += 100 -= 100
  12165. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  12166. // a set of RE's that can match strings and generate color tuples.
  12167. stringParsers = [ {
  12168. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  12169. parse: function( execResult ) {
  12170. return [
  12171. execResult[ 1 ],
  12172. execResult[ 2 ],
  12173. execResult[ 3 ],
  12174. execResult[ 4 ]
  12175. ];
  12176. }
  12177. }, {
  12178. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  12179. parse: function( execResult ) {
  12180. return [
  12181. execResult[ 1 ] * 2.55,
  12182. execResult[ 2 ] * 2.55,
  12183. execResult[ 3 ] * 2.55,
  12184. execResult[ 4 ]
  12185. ];
  12186. }
  12187. }, {
  12188. // this regex ignores A-F because it's compared against an already lowercased string
  12189. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  12190. parse: function( execResult ) {
  12191. return [
  12192. parseInt( execResult[ 1 ], 16 ),
  12193. parseInt( execResult[ 2 ], 16 ),
  12194. parseInt( execResult[ 3 ], 16 )
  12195. ];
  12196. }
  12197. }, {
  12198. // this regex ignores A-F because it's compared against an already lowercased string
  12199. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  12200. parse: function( execResult ) {
  12201. return [
  12202. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  12203. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  12204. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  12205. ];
  12206. }
  12207. }, {
  12208. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  12209. space: "hsla",
  12210. parse: function( execResult ) {
  12211. return [
  12212. execResult[ 1 ],
  12213. execResult[ 2 ] / 100,
  12214. execResult[ 3 ] / 100,
  12215. execResult[ 4 ]
  12216. ];
  12217. }
  12218. } ],
  12219. // jQuery.Color( )
  12220. color = jQuery.Color = function( color, green, blue, alpha ) {
  12221. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  12222. },
  12223. spaces = {
  12224. rgba: {
  12225. props: {
  12226. red: {
  12227. idx: 0,
  12228. type: "byte"
  12229. },
  12230. green: {
  12231. idx: 1,
  12232. type: "byte"
  12233. },
  12234. blue: {
  12235. idx: 2,
  12236. type: "byte"
  12237. }
  12238. }
  12239. },
  12240. hsla: {
  12241. props: {
  12242. hue: {
  12243. idx: 0,
  12244. type: "degrees"
  12245. },
  12246. saturation: {
  12247. idx: 1,
  12248. type: "percent"
  12249. },
  12250. lightness: {
  12251. idx: 2,
  12252. type: "percent"
  12253. }
  12254. }
  12255. }
  12256. },
  12257. propTypes = {
  12258. "byte": {
  12259. floor: true,
  12260. max: 255
  12261. },
  12262. "percent": {
  12263. max: 1
  12264. },
  12265. "degrees": {
  12266. mod: 360,
  12267. floor: true
  12268. }
  12269. },
  12270. support = color.support = {},
  12271. // element for support tests
  12272. supportElem = jQuery( "<p>" )[ 0 ],
  12273. // colors = jQuery.Color.names
  12274. colors,
  12275. // local aliases of functions called often
  12276. each = jQuery.each;
  12277. // determine rgba support immediately
  12278. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  12279. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  12280. // define cache name and alpha properties
  12281. // for rgba and hsla spaces
  12282. each( spaces, function( spaceName, space ) {
  12283. space.cache = "_" + spaceName;
  12284. space.props.alpha = {
  12285. idx: 3,
  12286. type: "percent",
  12287. def: 1
  12288. };
  12289. });
  12290. function clamp( value, prop, allowEmpty ) {
  12291. var type = propTypes[ prop.type ] || {};
  12292. if ( value == null ) {
  12293. return (allowEmpty || !prop.def) ? null : prop.def;
  12294. }
  12295. // ~~ is an short way of doing floor for positive numbers
  12296. value = type.floor ? ~~value : parseFloat( value );
  12297. // IE will pass in empty strings as value for alpha,
  12298. // which will hit this case
  12299. if ( isNaN( value ) ) {
  12300. return prop.def;
  12301. }
  12302. if ( type.mod ) {
  12303. // we add mod before modding to make sure that negatives values
  12304. // get converted properly: -10 -> 350
  12305. return (value + type.mod) % type.mod;
  12306. }
  12307. // for now all property types without mod have min and max
  12308. return 0 > value ? 0 : type.max < value ? type.max : value;
  12309. }
  12310. function stringParse( string ) {
  12311. var inst = color(),
  12312. rgba = inst._rgba = [];
  12313. string = string.toLowerCase();
  12314. each( stringParsers, function( i, parser ) {
  12315. var parsed,
  12316. match = parser.re.exec( string ),
  12317. values = match && parser.parse( match ),
  12318. spaceName = parser.space || "rgba";
  12319. if ( values ) {
  12320. parsed = inst[ spaceName ]( values );
  12321. // if this was an rgba parse the assignment might happen twice
  12322. // oh well....
  12323. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  12324. rgba = inst._rgba = parsed._rgba;
  12325. // exit each( stringParsers ) here because we matched
  12326. return false;
  12327. }
  12328. });
  12329. // Found a stringParser that handled it
  12330. if ( rgba.length ) {
  12331. // if this came from a parsed string, force "transparent" when alpha is 0
  12332. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  12333. if ( rgba.join() === "0,0,0,0" ) {
  12334. jQuery.extend( rgba, colors.transparent );
  12335. }
  12336. return inst;
  12337. }
  12338. // named colors
  12339. return colors[ string ];
  12340. }
  12341. color.fn = jQuery.extend( color.prototype, {
  12342. parse: function( red, green, blue, alpha ) {
  12343. if ( red === undefined ) {
  12344. this._rgba = [ null, null, null, null ];
  12345. return this;
  12346. }
  12347. if ( red.jquery || red.nodeType ) {
  12348. red = jQuery( red ).css( green );
  12349. green = undefined;
  12350. }
  12351. var inst = this,
  12352. type = jQuery.type( red ),
  12353. rgba = this._rgba = [];
  12354. // more than 1 argument specified - assume ( red, green, blue, alpha )
  12355. if ( green !== undefined ) {
  12356. red = [ red, green, blue, alpha ];
  12357. type = "array";
  12358. }
  12359. if ( type === "string" ) {
  12360. return this.parse( stringParse( red ) || colors._default );
  12361. }
  12362. if ( type === "array" ) {
  12363. each( spaces.rgba.props, function( key, prop ) {
  12364. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  12365. });
  12366. return this;
  12367. }
  12368. if ( type === "object" ) {
  12369. if ( red instanceof color ) {
  12370. each( spaces, function( spaceName, space ) {
  12371. if ( red[ space.cache ] ) {
  12372. inst[ space.cache ] = red[ space.cache ].slice();
  12373. }
  12374. });
  12375. } else {
  12376. each( spaces, function( spaceName, space ) {
  12377. var cache = space.cache;
  12378. each( space.props, function( key, prop ) {
  12379. // if the cache doesn't exist, and we know how to convert
  12380. if ( !inst[ cache ] && space.to ) {
  12381. // if the value was null, we don't need to copy it
  12382. // if the key was alpha, we don't need to copy it either
  12383. if ( key === "alpha" || red[ key ] == null ) {
  12384. return;
  12385. }
  12386. inst[ cache ] = space.to( inst._rgba );
  12387. }
  12388. // this is the only case where we allow nulls for ALL properties.
  12389. // call clamp with alwaysAllowEmpty
  12390. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  12391. });
  12392. // everything defined but alpha?
  12393. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  12394. // use the default of 1
  12395. inst[ cache ][ 3 ] = 1;
  12396. if ( space.from ) {
  12397. inst._rgba = space.from( inst[ cache ] );
  12398. }
  12399. }
  12400. });
  12401. }
  12402. return this;
  12403. }
  12404. },
  12405. is: function( compare ) {
  12406. var is = color( compare ),
  12407. same = true,
  12408. inst = this;
  12409. each( spaces, function( _, space ) {
  12410. var localCache,
  12411. isCache = is[ space.cache ];
  12412. if (isCache) {
  12413. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  12414. each( space.props, function( _, prop ) {
  12415. if ( isCache[ prop.idx ] != null ) {
  12416. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  12417. return same;
  12418. }
  12419. });
  12420. }
  12421. return same;
  12422. });
  12423. return same;
  12424. },
  12425. _space: function() {
  12426. var used = [],
  12427. inst = this;
  12428. each( spaces, function( spaceName, space ) {
  12429. if ( inst[ space.cache ] ) {
  12430. used.push( spaceName );
  12431. }
  12432. });
  12433. return used.pop();
  12434. },
  12435. transition: function( other, distance ) {
  12436. var end = color( other ),
  12437. spaceName = end._space(),
  12438. space = spaces[ spaceName ],
  12439. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  12440. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  12441. result = start.slice();
  12442. end = end[ space.cache ];
  12443. each( space.props, function( key, prop ) {
  12444. var index = prop.idx,
  12445. startValue = start[ index ],
  12446. endValue = end[ index ],
  12447. type = propTypes[ prop.type ] || {};
  12448. // if null, don't override start value
  12449. if ( endValue === null ) {
  12450. return;
  12451. }
  12452. // if null - use end
  12453. if ( startValue === null ) {
  12454. result[ index ] = endValue;
  12455. } else {
  12456. if ( type.mod ) {
  12457. if ( endValue - startValue > type.mod / 2 ) {
  12458. startValue += type.mod;
  12459. } else if ( startValue - endValue > type.mod / 2 ) {
  12460. startValue -= type.mod;
  12461. }
  12462. }
  12463. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  12464. }
  12465. });
  12466. return this[ spaceName ]( result );
  12467. },
  12468. blend: function( opaque ) {
  12469. // if we are already opaque - return ourself
  12470. if ( this._rgba[ 3 ] === 1 ) {
  12471. return this;
  12472. }
  12473. var rgb = this._rgba.slice(),
  12474. a = rgb.pop(),
  12475. blend = color( opaque )._rgba;
  12476. return color( jQuery.map( rgb, function( v, i ) {
  12477. return ( 1 - a ) * blend[ i ] + a * v;
  12478. }));
  12479. },
  12480. toRgbaString: function() {
  12481. var prefix = "rgba(",
  12482. rgba = jQuery.map( this._rgba, function( v, i ) {
  12483. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  12484. });
  12485. if ( rgba[ 3 ] === 1 ) {
  12486. rgba.pop();
  12487. prefix = "rgb(";
  12488. }
  12489. return prefix + rgba.join() + ")";
  12490. },
  12491. toHslaString: function() {
  12492. var prefix = "hsla(",
  12493. hsla = jQuery.map( this.hsla(), function( v, i ) {
  12494. if ( v == null ) {
  12495. v = i > 2 ? 1 : 0;
  12496. }
  12497. // catch 1 and 2
  12498. if ( i && i < 3 ) {
  12499. v = Math.round( v * 100 ) + "%";
  12500. }
  12501. return v;
  12502. });
  12503. if ( hsla[ 3 ] === 1 ) {
  12504. hsla.pop();
  12505. prefix = "hsl(";
  12506. }
  12507. return prefix + hsla.join() + ")";
  12508. },
  12509. toHexString: function( includeAlpha ) {
  12510. var rgba = this._rgba.slice(),
  12511. alpha = rgba.pop();
  12512. if ( includeAlpha ) {
  12513. rgba.push( ~~( alpha * 255 ) );
  12514. }
  12515. return "#" + jQuery.map( rgba, function( v ) {
  12516. // default to 0 when nulls exist
  12517. v = ( v || 0 ).toString( 16 );
  12518. return v.length === 1 ? "0" + v : v;
  12519. }).join("");
  12520. },
  12521. toString: function() {
  12522. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  12523. }
  12524. });
  12525. color.fn.parse.prototype = color.fn;
  12526. // hsla conversions adapted from:
  12527. function hue2rgb( p, q, h ) {
  12528. h = ( h + 1 ) % 1;
  12529. if ( h * 6 < 1 ) {
  12530. return p + ( q - p ) * h * 6;
  12531. }
  12532. if ( h * 2 < 1) {
  12533. return q;
  12534. }
  12535. if ( h * 3 < 2 ) {
  12536. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  12537. }
  12538. return p;
  12539. }
  12540. spaces.hsla.to = function( rgba ) {
  12541. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  12542. return [ null, null, null, rgba[ 3 ] ];
  12543. }
  12544. var r = rgba[ 0 ] / 255,
  12545. g = rgba[ 1 ] / 255,
  12546. b = rgba[ 2 ] / 255,
  12547. a = rgba[ 3 ],
  12548. max = Math.max( r, g, b ),
  12549. min = Math.min( r, g, b ),
  12550. diff = max - min,
  12551. add = max + min,
  12552. l = add * 0.5,
  12553. h, s;
  12554. if ( min === max ) {
  12555. h = 0;
  12556. } else if ( r === max ) {
  12557. h = ( 60 * ( g - b ) / diff ) + 360;
  12558. } else if ( g === max ) {
  12559. h = ( 60 * ( b - r ) / diff ) + 120;
  12560. } else {
  12561. h = ( 60 * ( r - g ) / diff ) + 240;
  12562. }
  12563. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  12564. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  12565. if ( diff === 0 ) {
  12566. s = 0;
  12567. } else if ( l <= 0.5 ) {
  12568. s = diff / add;
  12569. } else {
  12570. s = diff / ( 2 - add );
  12571. }
  12572. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  12573. };
  12574. spaces.hsla.from = function( hsla ) {
  12575. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  12576. return [ null, null, null, hsla[ 3 ] ];
  12577. }
  12578. var h = hsla[ 0 ] / 360,
  12579. s = hsla[ 1 ],
  12580. l = hsla[ 2 ],
  12581. a = hsla[ 3 ],
  12582. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  12583. p = 2 * l - q;
  12584. return [
  12585. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  12586. Math.round( hue2rgb( p, q, h ) * 255 ),
  12587. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  12588. a
  12589. ];
  12590. };
  12591. each( spaces, function( spaceName, space ) {
  12592. var props = space.props,
  12593. cache = space.cache,
  12594. to = space.to,
  12595. from = space.from;
  12596. // makes rgba() and hsla()
  12597. color.fn[ spaceName ] = function( value ) {
  12598. // generate a cache for this space if it doesn't exist
  12599. if ( to && !this[ cache ] ) {
  12600. this[ cache ] = to( this._rgba );
  12601. }
  12602. if ( value === undefined ) {
  12603. return this[ cache ].slice();
  12604. }
  12605. var ret,
  12606. type = jQuery.type( value ),
  12607. arr = ( type === "array" || type === "object" ) ? value : arguments,
  12608. local = this[ cache ].slice();
  12609. each( props, function( key, prop ) {
  12610. var val = arr[ type === "object" ? key : prop.idx ];
  12611. if ( val == null ) {
  12612. val = local[ prop.idx ];
  12613. }
  12614. local[ prop.idx ] = clamp( val, prop );
  12615. });
  12616. if ( from ) {
  12617. ret = color( from( local ) );
  12618. ret[ cache ] = local;
  12619. return ret;
  12620. } else {
  12621. return color( local );
  12622. }
  12623. };
  12624. // makes red() green() blue() alpha() hue() saturation() lightness()
  12625. each( props, function( key, prop ) {
  12626. // alpha is included in more than one space
  12627. if ( color.fn[ key ] ) {
  12628. return;
  12629. }
  12630. color.fn[ key ] = function( value ) {
  12631. var vtype = jQuery.type( value ),
  12632. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  12633. local = this[ fn ](),
  12634. cur = local[ prop.idx ],
  12635. match;
  12636. if ( vtype === "undefined" ) {
  12637. return cur;
  12638. }
  12639. if ( vtype === "function" ) {
  12640. value = value.call( this, cur );
  12641. vtype = jQuery.type( value );
  12642. }
  12643. if ( value == null && prop.empty ) {
  12644. return this;
  12645. }
  12646. if ( vtype === "string" ) {
  12647. match = rplusequals.exec( value );
  12648. if ( match ) {
  12649. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  12650. }
  12651. }
  12652. local[ prop.idx ] = value;
  12653. return this[ fn ]( local );
  12654. };
  12655. });
  12656. });
  12657. // add cssHook and .fx.step function for each named hook.
  12658. // accept a space separated string of properties
  12659. color.hook = function( hook ) {
  12660. var hooks = hook.split( " " );
  12661. each( hooks, function( i, hook ) {
  12662. jQuery.cssHooks[ hook ] = {
  12663. set: function( elem, value ) {
  12664. var parsed, curElem,
  12665. backgroundColor = "";
  12666. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  12667. value = color( parsed || value );
  12668. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  12669. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  12670. while (
  12671. (backgroundColor === "" || backgroundColor === "transparent") &&
  12672. curElem && curElem.style
  12673. ) {
  12674. try {
  12675. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  12676. curElem = curElem.parentNode;
  12677. } catch ( e ) {
  12678. }
  12679. }
  12680. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  12681. backgroundColor :
  12682. "_default" );
  12683. }
  12684. value = value.toRgbaString();
  12685. }
  12686. try {
  12687. elem.style[ hook ] = value;
  12688. } catch ( e ) {
  12689. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  12690. }
  12691. }
  12692. };
  12693. jQuery.fx.step[ hook ] = function( fx ) {
  12694. if ( !fx.colorInit ) {
  12695. fx.start = color( fx.elem, hook );
  12696. fx.end = color( fx.end );
  12697. fx.colorInit = true;
  12698. }
  12699. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  12700. };
  12701. });
  12702. };
  12703. color.hook( stepHooks );
  12704. jQuery.cssHooks.borderColor = {
  12705. expand: function( value ) {
  12706. var expanded = {};
  12707. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  12708. expanded[ "border" + part + "Color" ] = value;
  12709. });
  12710. return expanded;
  12711. }
  12712. };
  12713. // Basic color names only.
  12714. // Usage of any of the other color names requires adding yourself or including
  12715. // jquery.color.svg-names.js.
  12716. colors = jQuery.Color.names = {
  12717. // 4.1. Basic color keywords
  12718. aqua: "#00ffff",
  12719. black: "#000000",
  12720. blue: "#0000ff",
  12721. fuchsia: "#ff00ff",
  12722. gray: "#808080",
  12723. green: "#008000",
  12724. lime: "#00ff00",
  12725. maroon: "#800000",
  12726. navy: "#000080",
  12727. olive: "#808000",
  12728. purple: "#800080",
  12729. red: "#ff0000",
  12730. silver: "#c0c0c0",
  12731. teal: "#008080",
  12732. white: "#ffffff",
  12733. yellow: "#ffff00",
  12734. // 4.2.3. "transparent" color keyword
  12735. transparent: [ null, null, null, 0 ],
  12736. _default: "#ffffff"
  12737. };
  12738. })( jQuery );
  12739. /******************************************************************************/
  12740. /****************************** CLASS ANIMATIONS ******************************/
  12741. /******************************************************************************/
  12742. (function() {
  12743. var classAnimationActions = [ "add", "remove", "toggle" ],
  12744. shorthandStyles = {
  12745. border: 1,
  12746. borderBottom: 1,
  12747. borderColor: 1,
  12748. borderLeft: 1,
  12749. borderRight: 1,
  12750. borderTop: 1,
  12751. borderWidth: 1,
  12752. margin: 1,
  12753. padding: 1
  12754. };
  12755. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  12756. $.fx.step[ prop ] = function( fx ) {
  12757. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  12758. jQuery.style( fx.elem, prop, fx.end );
  12759. fx.setAttr = true;
  12760. }
  12761. };
  12762. });
  12763. function getElementStyles( elem ) {
  12764. var key, len,
  12765. style = elem.ownerDocument.defaultView ?
  12766. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  12767. elem.currentStyle,
  12768. styles = {};
  12769. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  12770. len = style.length;
  12771. while ( len-- ) {
  12772. key = style[ len ];
  12773. if ( typeof style[ key ] === "string" ) {
  12774. styles[ $.camelCase( key ) ] = style[ key ];
  12775. }
  12776. }
  12777. // support: Opera, IE <9
  12778. } else {
  12779. for ( key in style ) {
  12780. if ( typeof style[ key ] === "string" ) {
  12781. styles[ key ] = style[ key ];
  12782. }
  12783. }
  12784. }
  12785. return styles;
  12786. }
  12787. function styleDifference( oldStyle, newStyle ) {
  12788. var diff = {},
  12789. name, value;
  12790. for ( name in newStyle ) {
  12791. value = newStyle[ name ];
  12792. if ( oldStyle[ name ] !== value ) {
  12793. if ( !shorthandStyles[ name ] ) {
  12794. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  12795. diff[ name ] = value;
  12796. }
  12797. }
  12798. }
  12799. }
  12800. return diff;
  12801. }
  12802. // support: jQuery <1.8
  12803. if ( !$.fn.addBack ) {
  12804. $.fn.addBack = function( selector ) {
  12805. return this.add( selector == null ?
  12806. this.prevObject : this.prevObject.filter( selector )
  12807. );
  12808. };
  12809. }
  12810. $.effects.animateClass = function( value, duration, easing, callback ) {
  12811. var o = $.speed( duration, easing, callback );
  12812. return this.queue( function() {
  12813. var animated = $( this ),
  12814. baseClass = animated.attr( "class" ) || "",
  12815. applyClassChange,
  12816. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  12817. // map the animated objects to store the original styles.
  12818. allAnimations = allAnimations.map(function() {
  12819. var el = $( this );
  12820. return {
  12821. el: el,
  12822. start: getElementStyles( this )
  12823. };
  12824. });
  12825. // apply class change
  12826. applyClassChange = function() {
  12827. $.each( classAnimationActions, function(i, action) {
  12828. if ( value[ action ] ) {
  12829. animated[ action + "Class" ]( value[ action ] );
  12830. }
  12831. });
  12832. };
  12833. applyClassChange();
  12834. // map all animated objects again - calculate new styles and diff
  12835. allAnimations = allAnimations.map(function() {
  12836. this.end = getElementStyles( this.el[ 0 ] );
  12837. this.diff = styleDifference( this.start, this.end );
  12838. return this;
  12839. });
  12840. // apply original class
  12841. animated.attr( "class", baseClass );
  12842. // map all animated objects again - this time collecting a promise
  12843. allAnimations = allAnimations.map(function() {
  12844. var styleInfo = this,
  12845. dfd = $.Deferred(),
  12846. opts = $.extend({}, o, {
  12847. queue: false,
  12848. complete: function() {
  12849. dfd.resolve( styleInfo );
  12850. }
  12851. });
  12852. this.el.animate( this.diff, opts );
  12853. return dfd.promise();
  12854. });
  12855. // once all animations have completed:
  12856. $.when.apply( $, allAnimations.get() ).done(function() {
  12857. // set the final class
  12858. applyClassChange();
  12859. // for each animated element,
  12860. // clear all css properties that were animated
  12861. $.each( arguments, function() {
  12862. var el = this.el;
  12863. $.each( this.diff, function(key) {
  12864. el.css( key, "" );
  12865. });
  12866. });
  12867. // this is guarnteed to be there if you use jQuery.speed()
  12868. // it also handles dequeuing the next anim...
  12869. o.complete.call( animated[ 0 ] );
  12870. });
  12871. });
  12872. };
  12873. $.fn.extend({
  12874. addClass: (function( orig ) {
  12875. return function( classNames, speed, easing, callback ) {
  12876. return speed ?
  12877. $.effects.animateClass.call( this,
  12878. { add: classNames }, speed, easing, callback ) :
  12879. orig.apply( this, arguments );
  12880. };
  12881. })( $.fn.addClass ),
  12882. removeClass: (function( orig ) {
  12883. return function( classNames, speed, easing, callback ) {
  12884. return arguments.length > 1 ?
  12885. $.effects.animateClass.call( this,
  12886. { remove: classNames }, speed, easing, callback ) :
  12887. orig.apply( this, arguments );
  12888. };
  12889. })( $.fn.removeClass ),
  12890. toggleClass: (function( orig ) {
  12891. return function( classNames, force, speed, easing, callback ) {
  12892. if ( typeof force === "boolean" || force === undefined ) {
  12893. if ( !speed ) {
  12894. // without speed parameter
  12895. return orig.apply( this, arguments );
  12896. } else {
  12897. return $.effects.animateClass.call( this,
  12898. (force ? { add: classNames } : { remove: classNames }),
  12899. speed, easing, callback );
  12900. }
  12901. } else {
  12902. // without force parameter
  12903. return $.effects.animateClass.call( this,
  12904. { toggle: classNames }, force, speed, easing );
  12905. }
  12906. };
  12907. })( $.fn.toggleClass ),
  12908. switchClass: function( remove, add, speed, easing, callback) {
  12909. return $.effects.animateClass.call( this, {
  12910. add: add,
  12911. remove: remove
  12912. }, speed, easing, callback );
  12913. }
  12914. });
  12915. })();
  12916. /******************************************************************************/
  12917. /*********************************** EFFECTS **********************************/
  12918. /******************************************************************************/
  12919. (function() {
  12920. $.extend( $.effects, {
  12921. version: "1.11.3",
  12922. // Saves a set of properties in a data storage
  12923. save: function( element, set ) {
  12924. for ( var i = 0; i < set.length; i++ ) {
  12925. if ( set[ i ] !== null ) {
  12926. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  12927. }
  12928. }
  12929. },
  12930. // Restores a set of previously saved properties from a data storage
  12931. restore: function( element, set ) {
  12932. var val, i;
  12933. for ( i = 0; i < set.length; i++ ) {
  12934. if ( set[ i ] !== null ) {
  12935. val = element.data( dataSpace + set[ i ] );
  12936. // support: jQuery 1.6.2
  12937. // http://bugs.jquery.com/ticket/9917
  12938. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  12939. // We can't differentiate between "" and 0 here, so we just assume
  12940. // empty string since it's likely to be a more common value...
  12941. if ( val === undefined ) {
  12942. val = "";
  12943. }
  12944. element.css( set[ i ], val );
  12945. }
  12946. }
  12947. },
  12948. setMode: function( el, mode ) {
  12949. if (mode === "toggle") {
  12950. mode = el.is( ":hidden" ) ? "show" : "hide";
  12951. }
  12952. return mode;
  12953. },
  12954. // Translates a [top,left] array into a baseline value
  12955. // this should be a little more flexible in the future to handle a string & hash
  12956. getBaseline: function( origin, original ) {
  12957. var y, x;
  12958. switch ( origin[ 0 ] ) {
  12959. case "top": y = 0; break;
  12960. case "middle": y = 0.5; break;
  12961. case "bottom": y = 1; break;
  12962. default: y = origin[ 0 ] / original.height;
  12963. }
  12964. switch ( origin[ 1 ] ) {
  12965. case "left": x = 0; break;
  12966. case "center": x = 0.5; break;
  12967. case "right": x = 1; break;
  12968. default: x = origin[ 1 ] / original.width;
  12969. }
  12970. return {
  12971. x: x,
  12972. y: y
  12973. };
  12974. },
  12975. // Wraps the element around a wrapper that copies position properties
  12976. createWrapper: function( element ) {
  12977. // if the element is already wrapped, return it
  12978. if ( element.parent().is( ".ui-effects-wrapper" )) {
  12979. return element.parent();
  12980. }
  12981. // wrap the element
  12982. var props = {
  12983. width: element.outerWidth(true),
  12984. height: element.outerHeight(true),
  12985. "float": element.css( "float" )
  12986. },
  12987. wrapper = $( "<div></div>" )
  12988. .addClass( "ui-effects-wrapper" )
  12989. .css({
  12990. fontSize: "100%",
  12991. background: "transparent",
  12992. border: "none",
  12993. margin: 0,
  12994. padding: 0
  12995. }),
  12996. // Store the size in case width/height are defined in % - Fixes #5245
  12997. size = {
  12998. width: element.width(),
  12999. height: element.height()
  13000. },
  13001. active = document.activeElement;
  13002. // support: Firefox
  13003. // Firefox incorrectly exposes anonymous content
  13004. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  13005. try {
  13006. active.id;
  13007. } catch ( e ) {
  13008. active = document.body;
  13009. }
  13010. element.wrap( wrapper );
  13011. // Fixes #7595 - Elements lose focus when wrapped.
  13012. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  13013. $( active ).focus();
  13014. }
  13015. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  13016. // transfer positioning properties to the wrapper
  13017. if ( element.css( "position" ) === "static" ) {
  13018. wrapper.css({ position: "relative" });
  13019. element.css({ position: "relative" });
  13020. } else {
  13021. $.extend( props, {
  13022. position: element.css( "position" ),
  13023. zIndex: element.css( "z-index" )
  13024. });
  13025. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  13026. props[ pos ] = element.css( pos );
  13027. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  13028. props[ pos ] = "auto";
  13029. }
  13030. });
  13031. element.css({
  13032. position: "relative",
  13033. top: 0,
  13034. left: 0,
  13035. right: "auto",
  13036. bottom: "auto"
  13037. });
  13038. }
  13039. element.css(size);
  13040. return wrapper.css( props ).show();
  13041. },
  13042. removeWrapper: function( element ) {
  13043. var active = document.activeElement;
  13044. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  13045. element.parent().replaceWith( element );
  13046. // Fixes #7595 - Elements lose focus when wrapped.
  13047. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  13048. $( active ).focus();
  13049. }
  13050. }
  13051. return element;
  13052. },
  13053. setTransition: function( element, list, factor, value ) {
  13054. value = value || {};
  13055. $.each( list, function( i, x ) {
  13056. var unit = element.cssUnit( x );
  13057. if ( unit[ 0 ] > 0 ) {
  13058. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  13059. }
  13060. });
  13061. return value;
  13062. }
  13063. });
  13064. // return an effect options object for the given parameters:
  13065. function _normalizeArguments( effect, options, speed, callback ) {
  13066. // allow passing all options as the first parameter
  13067. if ( $.isPlainObject( effect ) ) {
  13068. options = effect;
  13069. effect = effect.effect;
  13070. }
  13071. // convert to an object
  13072. effect = { effect: effect };
  13073. // catch (effect, null, ...)
  13074. if ( options == null ) {
  13075. options = {};
  13076. }
  13077. // catch (effect, callback)
  13078. if ( $.isFunction( options ) ) {
  13079. callback = options;
  13080. speed = null;
  13081. options = {};
  13082. }
  13083. // catch (effect, speed, ?)
  13084. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  13085. callback = speed;
  13086. speed = options;
  13087. options = {};
  13088. }
  13089. // catch (effect, options, callback)
  13090. if ( $.isFunction( speed ) ) {
  13091. callback = speed;
  13092. speed = null;
  13093. }
  13094. // add options to effect
  13095. if ( options ) {
  13096. $.extend( effect, options );
  13097. }
  13098. speed = speed || options.duration;
  13099. effect.duration = $.fx.off ? 0 :
  13100. typeof speed === "number" ? speed :
  13101. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  13102. $.fx.speeds._default;
  13103. effect.complete = callback || options.complete;
  13104. return effect;
  13105. }
  13106. function standardAnimationOption( option ) {
  13107. // Valid standard speeds (nothing, number, named speed)
  13108. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  13109. return true;
  13110. }
  13111. // Invalid strings - treat as "normal" speed
  13112. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  13113. return true;
  13114. }
  13115. // Complete callback
  13116. if ( $.isFunction( option ) ) {
  13117. return true;
  13118. }
  13119. // Options hash (but not naming an effect)
  13120. if ( typeof option === "object" && !option.effect ) {
  13121. return true;
  13122. }
  13123. // Didn't match any standard API
  13124. return false;
  13125. }
  13126. $.fn.extend({
  13127. effect: function( /* effect, options, speed, callback */ ) {
  13128. var args = _normalizeArguments.apply( this, arguments ),
  13129. mode = args.mode,
  13130. queue = args.queue,
  13131. effectMethod = $.effects.effect[ args.effect ];
  13132. if ( $.fx.off || !effectMethod ) {
  13133. // delegate to the original method (e.g., .show()) if possible
  13134. if ( mode ) {
  13135. return this[ mode ]( args.duration, args.complete );
  13136. } else {
  13137. return this.each( function() {
  13138. if ( args.complete ) {
  13139. args.complete.call( this );
  13140. }
  13141. });
  13142. }
  13143. }
  13144. function run( next ) {
  13145. var elem = $( this ),
  13146. complete = args.complete,
  13147. mode = args.mode;
  13148. function done() {
  13149. if ( $.isFunction( complete ) ) {
  13150. complete.call( elem[0] );
  13151. }
  13152. if ( $.isFunction( next ) ) {
  13153. next();
  13154. }
  13155. }
  13156. // If the element already has the correct final state, delegate to
  13157. // the core methods so the internal tracking of "olddisplay" works.
  13158. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  13159. elem[ mode ]();
  13160. done();
  13161. } else {
  13162. effectMethod.call( elem[0], args, done );
  13163. }
  13164. }
  13165. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  13166. },
  13167. show: (function( orig ) {
  13168. return function( option ) {
  13169. if ( standardAnimationOption( option ) ) {
  13170. return orig.apply( this, arguments );
  13171. } else {
  13172. var args = _normalizeArguments.apply( this, arguments );
  13173. args.mode = "show";
  13174. return this.effect.call( this, args );
  13175. }
  13176. };
  13177. })( $.fn.show ),
  13178. hide: (function( orig ) {
  13179. return function( option ) {
  13180. if ( standardAnimationOption( option ) ) {
  13181. return orig.apply( this, arguments );
  13182. } else {
  13183. var args = _normalizeArguments.apply( this, arguments );
  13184. args.mode = "hide";
  13185. return this.effect.call( this, args );
  13186. }
  13187. };
  13188. })( $.fn.hide ),
  13189. toggle: (function( orig ) {
  13190. return function( option ) {
  13191. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  13192. return orig.apply( this, arguments );
  13193. } else {
  13194. var args = _normalizeArguments.apply( this, arguments );
  13195. args.mode = "toggle";
  13196. return this.effect.call( this, args );
  13197. }
  13198. };
  13199. })( $.fn.toggle ),
  13200. // helper functions
  13201. cssUnit: function(key) {
  13202. var style = this.css( key ),
  13203. val = [];
  13204. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  13205. if ( style.indexOf( unit ) > 0 ) {
  13206. val = [ parseFloat( style ), unit ];
  13207. }
  13208. });
  13209. return val;
  13210. }
  13211. });
  13212. })();
  13213. /******************************************************************************/
  13214. /*********************************** EASING ***********************************/
  13215. /******************************************************************************/
  13216. (function() {
  13217. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  13218. var baseEasings = {};
  13219. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  13220. baseEasings[ name ] = function( p ) {
  13221. return Math.pow( p, i + 2 );
  13222. };
  13223. });
  13224. $.extend( baseEasings, {
  13225. Sine: function( p ) {
  13226. return 1 - Math.cos( p * Math.PI / 2 );
  13227. },
  13228. Circ: function( p ) {
  13229. return 1 - Math.sqrt( 1 - p * p );
  13230. },
  13231. Elastic: function( p ) {
  13232. return p === 0 || p === 1 ? p :
  13233. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  13234. },
  13235. Back: function( p ) {
  13236. return p * p * ( 3 * p - 2 );
  13237. },
  13238. Bounce: function( p ) {
  13239. var pow2,
  13240. bounce = 4;
  13241. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  13242. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  13243. }
  13244. });
  13245. $.each( baseEasings, function( name, easeIn ) {
  13246. $.easing[ "easeIn" + name ] = easeIn;
  13247. $.easing[ "easeOut" + name ] = function( p ) {
  13248. return 1 - easeIn( 1 - p );
  13249. };
  13250. $.easing[ "easeInOut" + name ] = function( p ) {
  13251. return p < 0.5 ?
  13252. easeIn( p * 2 ) / 2 :
  13253. 1 - easeIn( p * -2 + 2 ) / 2;
  13254. };
  13255. });
  13256. })();
  13257. var effect = $.effects;
  13258. /*!
  13259. * jQuery UI Effects Blind 1.11.3
  13260. * http://jqueryui.com
  13261. *
  13262. * Copyright jQuery Foundation and other contributors
  13263. * Released under the MIT license.
  13264. * http://jquery.org/license
  13265. *
  13266. * http://api.jqueryui.com/blind-effect/
  13267. */
  13268. var effectBlind = $.effects.effect.blind = function( o, done ) {
  13269. // Create element
  13270. var el = $( this ),
  13271. rvertical = /up|down|vertical/,
  13272. rpositivemotion = /up|left|vertical|horizontal/,
  13273. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13274. mode = $.effects.setMode( el, o.mode || "hide" ),
  13275. direction = o.direction || "up",
  13276. vertical = rvertical.test( direction ),
  13277. ref = vertical ? "height" : "width",
  13278. ref2 = vertical ? "top" : "left",
  13279. motion = rpositivemotion.test( direction ),
  13280. animation = {},
  13281. show = mode === "show",
  13282. wrapper, distance, margin;
  13283. // if already wrapped, the wrapper's properties are my property. #6245
  13284. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  13285. $.effects.save( el.parent(), props );
  13286. } else {
  13287. $.effects.save( el, props );
  13288. }
  13289. el.show();
  13290. wrapper = $.effects.createWrapper( el ).css({
  13291. overflow: "hidden"
  13292. });
  13293. distance = wrapper[ ref ]();
  13294. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  13295. animation[ ref ] = show ? distance : 0;
  13296. if ( !motion ) {
  13297. el
  13298. .css( vertical ? "bottom" : "right", 0 )
  13299. .css( vertical ? "top" : "left", "auto" )
  13300. .css({ position: "absolute" });
  13301. animation[ ref2 ] = show ? margin : distance + margin;
  13302. }
  13303. // start at 0 if we are showing
  13304. if ( show ) {
  13305. wrapper.css( ref, 0 );
  13306. if ( !motion ) {
  13307. wrapper.css( ref2, margin + distance );
  13308. }
  13309. }
  13310. // Animate
  13311. wrapper.animate( animation, {
  13312. duration: o.duration,
  13313. easing: o.easing,
  13314. queue: false,
  13315. complete: function() {
  13316. if ( mode === "hide" ) {
  13317. el.hide();
  13318. }
  13319. $.effects.restore( el, props );
  13320. $.effects.removeWrapper( el );
  13321. done();
  13322. }
  13323. });
  13324. };
  13325. /*!
  13326. * jQuery UI Effects Bounce 1.11.3
  13327. * http://jqueryui.com
  13328. *
  13329. * Copyright jQuery Foundation and other contributors
  13330. * Released under the MIT license.
  13331. * http://jquery.org/license
  13332. *
  13333. * http://api.jqueryui.com/bounce-effect/
  13334. */
  13335. var effectBounce = $.effects.effect.bounce = function( o, done ) {
  13336. var el = $( this ),
  13337. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13338. // defaults:
  13339. mode = $.effects.setMode( el, o.mode || "effect" ),
  13340. hide = mode === "hide",
  13341. show = mode === "show",
  13342. direction = o.direction || "up",
  13343. distance = o.distance,
  13344. times = o.times || 5,
  13345. // number of internal animations
  13346. anims = times * 2 + ( show || hide ? 1 : 0 ),
  13347. speed = o.duration / anims,
  13348. easing = o.easing,
  13349. // utility:
  13350. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  13351. motion = ( direction === "up" || direction === "left" ),
  13352. i,
  13353. upAnim,
  13354. downAnim,
  13355. // we will need to re-assemble the queue to stack our animations in place
  13356. queue = el.queue(),
  13357. queuelen = queue.length;
  13358. // Avoid touching opacity to prevent clearType and PNG issues in IE
  13359. if ( show || hide ) {
  13360. props.push( "opacity" );
  13361. }
  13362. $.effects.save( el, props );
  13363. el.show();
  13364. $.effects.createWrapper( el ); // Create Wrapper
  13365. // default distance for the BIGGEST bounce is the outer Distance / 3
  13366. if ( !distance ) {
  13367. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  13368. }
  13369. if ( show ) {
  13370. downAnim = { opacity: 1 };
  13371. downAnim[ ref ] = 0;
  13372. // if we are showing, force opacity 0 and set the initial position
  13373. // then do the "first" animation
  13374. el.css( "opacity", 0 )
  13375. .css( ref, motion ? -distance * 2 : distance * 2 )
  13376. .animate( downAnim, speed, easing );
  13377. }
  13378. // start at the smallest distance if we are hiding
  13379. if ( hide ) {
  13380. distance = distance / Math.pow( 2, times - 1 );
  13381. }
  13382. downAnim = {};
  13383. downAnim[ ref ] = 0;
  13384. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  13385. for ( i = 0; i < times; i++ ) {
  13386. upAnim = {};
  13387. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  13388. el.animate( upAnim, speed, easing )
  13389. .animate( downAnim, speed, easing );
  13390. distance = hide ? distance * 2 : distance / 2;
  13391. }
  13392. // Last Bounce when Hiding
  13393. if ( hide ) {
  13394. upAnim = { opacity: 0 };
  13395. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  13396. el.animate( upAnim, speed, easing );
  13397. }
  13398. el.queue(function() {
  13399. if ( hide ) {
  13400. el.hide();
  13401. }
  13402. $.effects.restore( el, props );
  13403. $.effects.removeWrapper( el );
  13404. done();
  13405. });
  13406. // inject all the animations we just queued to be first in line (after "inprogress")
  13407. if ( queuelen > 1) {
  13408. queue.splice.apply( queue,
  13409. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  13410. }
  13411. el.dequeue();
  13412. };
  13413. /*!
  13414. * jQuery UI Effects Clip 1.11.3
  13415. * http://jqueryui.com
  13416. *
  13417. * Copyright jQuery Foundation and other contributors
  13418. * Released under the MIT license.
  13419. * http://jquery.org/license
  13420. *
  13421. * http://api.jqueryui.com/clip-effect/
  13422. */
  13423. var effectClip = $.effects.effect.clip = function( o, done ) {
  13424. // Create element
  13425. var el = $( this ),
  13426. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13427. mode = $.effects.setMode( el, o.mode || "hide" ),
  13428. show = mode === "show",
  13429. direction = o.direction || "vertical",
  13430. vert = direction === "vertical",
  13431. size = vert ? "height" : "width",
  13432. position = vert ? "top" : "left",
  13433. animation = {},
  13434. wrapper, animate, distance;
  13435. // Save & Show
  13436. $.effects.save( el, props );
  13437. el.show();
  13438. // Create Wrapper
  13439. wrapper = $.effects.createWrapper( el ).css({
  13440. overflow: "hidden"
  13441. });
  13442. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  13443. distance = animate[ size ]();
  13444. // Shift
  13445. if ( show ) {
  13446. animate.css( size, 0 );
  13447. animate.css( position, distance / 2 );
  13448. }
  13449. // Create Animation Object:
  13450. animation[ size ] = show ? distance : 0;
  13451. animation[ position ] = show ? 0 : distance / 2;
  13452. // Animate
  13453. animate.animate( animation, {
  13454. queue: false,
  13455. duration: o.duration,
  13456. easing: o.easing,
  13457. complete: function() {
  13458. if ( !show ) {
  13459. el.hide();
  13460. }
  13461. $.effects.restore( el, props );
  13462. $.effects.removeWrapper( el );
  13463. done();
  13464. }
  13465. });
  13466. };
  13467. /*!
  13468. * jQuery UI Effects Drop 1.11.3
  13469. * http://jqueryui.com
  13470. *
  13471. * Copyright jQuery Foundation and other contributors
  13472. * Released under the MIT license.
  13473. * http://jquery.org/license
  13474. *
  13475. * http://api.jqueryui.com/drop-effect/
  13476. */
  13477. var effectDrop = $.effects.effect.drop = function( o, done ) {
  13478. var el = $( this ),
  13479. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  13480. mode = $.effects.setMode( el, o.mode || "hide" ),
  13481. show = mode === "show",
  13482. direction = o.direction || "left",
  13483. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  13484. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  13485. animation = {
  13486. opacity: show ? 1 : 0
  13487. },
  13488. distance;
  13489. // Adjust
  13490. $.effects.save( el, props );
  13491. el.show();
  13492. $.effects.createWrapper( el );
  13493. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  13494. if ( show ) {
  13495. el
  13496. .css( "opacity", 0 )
  13497. .css( ref, motion === "pos" ? -distance : distance );
  13498. }
  13499. // Animation
  13500. animation[ ref ] = ( show ?
  13501. ( motion === "pos" ? "+=" : "-=" ) :
  13502. ( motion === "pos" ? "-=" : "+=" ) ) +
  13503. distance;
  13504. // Animate
  13505. el.animate( animation, {
  13506. queue: false,
  13507. duration: o.duration,
  13508. easing: o.easing,
  13509. complete: function() {
  13510. if ( mode === "hide" ) {
  13511. el.hide();
  13512. }
  13513. $.effects.restore( el, props );
  13514. $.effects.removeWrapper( el );
  13515. done();
  13516. }
  13517. });
  13518. };
  13519. /*!
  13520. * jQuery UI Effects Explode 1.11.3
  13521. * http://jqueryui.com
  13522. *
  13523. * Copyright jQuery Foundation and other contributors
  13524. * Released under the MIT license.
  13525. * http://jquery.org/license
  13526. *
  13527. * http://api.jqueryui.com/explode-effect/
  13528. */
  13529. var effectExplode = $.effects.effect.explode = function( o, done ) {
  13530. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  13531. cells = rows,
  13532. el = $( this ),
  13533. mode = $.effects.setMode( el, o.mode || "hide" ),
  13534. show = mode === "show",
  13535. // show and then visibility:hidden the element before calculating offset
  13536. offset = el.show().css( "visibility", "hidden" ).offset(),
  13537. // width and height of a piece
  13538. width = Math.ceil( el.outerWidth() / cells ),
  13539. height = Math.ceil( el.outerHeight() / rows ),
  13540. pieces = [],
  13541. // loop
  13542. i, j, left, top, mx, my;
  13543. // children animate complete:
  13544. function childComplete() {
  13545. pieces.push( this );
  13546. if ( pieces.length === rows * cells ) {
  13547. animComplete();
  13548. }
  13549. }
  13550. // clone the element for each row and cell.
  13551. for ( i = 0; i < rows ; i++ ) { // ===>
  13552. top = offset.top + i * height;
  13553. my = i - ( rows - 1 ) / 2 ;
  13554. for ( j = 0; j < cells ; j++ ) { // |||
  13555. left = offset.left + j * width;
  13556. mx = j - ( cells - 1 ) / 2 ;
  13557. // Create a clone of the now hidden main element that will be absolute positioned
  13558. // within a wrapper div off the -left and -top equal to size of our pieces
  13559. el
  13560. .clone()
  13561. .appendTo( "body" )
  13562. .wrap( "<div></div>" )
  13563. .css({
  13564. position: "absolute",
  13565. visibility: "visible",
  13566. left: -j * width,
  13567. top: -i * height
  13568. })
  13569. // select the wrapper - make it overflow: hidden and absolute positioned based on
  13570. // where the original was located +left and +top equal to the size of pieces
  13571. .parent()
  13572. .addClass( "ui-effects-explode" )
  13573. .css({
  13574. position: "absolute",
  13575. overflow: "hidden",
  13576. width: width,
  13577. height: height,
  13578. left: left + ( show ? mx * width : 0 ),
  13579. top: top + ( show ? my * height : 0 ),
  13580. opacity: show ? 0 : 1
  13581. }).animate({
  13582. left: left + ( show ? 0 : mx * width ),
  13583. top: top + ( show ? 0 : my * height ),
  13584. opacity: show ? 1 : 0
  13585. }, o.duration || 500, o.easing, childComplete );
  13586. }
  13587. }
  13588. function animComplete() {
  13589. el.css({
  13590. visibility: "visible"
  13591. });
  13592. $( pieces ).remove();
  13593. if ( !show ) {
  13594. el.hide();
  13595. }
  13596. done();
  13597. }
  13598. };
  13599. /*!
  13600. * jQuery UI Effects Fade 1.11.3
  13601. * http://jqueryui.com
  13602. *
  13603. * Copyright jQuery Foundation and other contributors
  13604. * Released under the MIT license.
  13605. * http://jquery.org/license
  13606. *
  13607. * http://api.jqueryui.com/fade-effect/
  13608. */
  13609. var effectFade = $.effects.effect.fade = function( o, done ) {
  13610. var el = $( this ),
  13611. mode = $.effects.setMode( el, o.mode || "toggle" );
  13612. el.animate({
  13613. opacity: mode
  13614. }, {
  13615. queue: false,
  13616. duration: o.duration,
  13617. easing: o.easing,
  13618. complete: done
  13619. });
  13620. };
  13621. /*!
  13622. * jQuery UI Effects Fold 1.11.3
  13623. * http://jqueryui.com
  13624. *
  13625. * Copyright jQuery Foundation and other contributors
  13626. * Released under the MIT license.
  13627. * http://jquery.org/license
  13628. *
  13629. * http://api.jqueryui.com/fold-effect/
  13630. */
  13631. var effectFold = $.effects.effect.fold = function( o, done ) {
  13632. // Create element
  13633. var el = $( this ),
  13634. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13635. mode = $.effects.setMode( el, o.mode || "hide" ),
  13636. show = mode === "show",
  13637. hide = mode === "hide",
  13638. size = o.size || 15,
  13639. percent = /([0-9]+)%/.exec( size ),
  13640. horizFirst = !!o.horizFirst,
  13641. widthFirst = show !== horizFirst,
  13642. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  13643. duration = o.duration / 2,
  13644. wrapper, distance,
  13645. animation1 = {},
  13646. animation2 = {};
  13647. $.effects.save( el, props );
  13648. el.show();
  13649. // Create Wrapper
  13650. wrapper = $.effects.createWrapper( el ).css({
  13651. overflow: "hidden"
  13652. });
  13653. distance = widthFirst ?
  13654. [ wrapper.width(), wrapper.height() ] :
  13655. [ wrapper.height(), wrapper.width() ];
  13656. if ( percent ) {
  13657. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  13658. }
  13659. if ( show ) {
  13660. wrapper.css( horizFirst ? {
  13661. height: 0,
  13662. width: size
  13663. } : {
  13664. height: size,
  13665. width: 0
  13666. });
  13667. }
  13668. // Animation
  13669. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  13670. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  13671. // Animate
  13672. wrapper
  13673. .animate( animation1, duration, o.easing )
  13674. .animate( animation2, duration, o.easing, function() {
  13675. if ( hide ) {
  13676. el.hide();
  13677. }
  13678. $.effects.restore( el, props );
  13679. $.effects.removeWrapper( el );
  13680. done();
  13681. });
  13682. };
  13683. /*!
  13684. * jQuery UI Effects Highlight 1.11.3
  13685. * http://jqueryui.com
  13686. *
  13687. * Copyright jQuery Foundation and other contributors
  13688. * Released under the MIT license.
  13689. * http://jquery.org/license
  13690. *
  13691. * http://api.jqueryui.com/highlight-effect/
  13692. */
  13693. var effectHighlight = $.effects.effect.highlight = function( o, done ) {
  13694. var elem = $( this ),
  13695. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  13696. mode = $.effects.setMode( elem, o.mode || "show" ),
  13697. animation = {
  13698. backgroundColor: elem.css( "backgroundColor" )
  13699. };
  13700. if (mode === "hide") {
  13701. animation.opacity = 0;
  13702. }
  13703. $.effects.save( elem, props );
  13704. elem
  13705. .show()
  13706. .css({
  13707. backgroundImage: "none",
  13708. backgroundColor: o.color || "#ffff99"
  13709. })
  13710. .animate( animation, {
  13711. queue: false,
  13712. duration: o.duration,
  13713. easing: o.easing,
  13714. complete: function() {
  13715. if ( mode === "hide" ) {
  13716. elem.hide();
  13717. }
  13718. $.effects.restore( elem, props );
  13719. done();
  13720. }
  13721. });
  13722. };
  13723. /*!
  13724. * jQuery UI Effects Size 1.11.3
  13725. * http://jqueryui.com
  13726. *
  13727. * Copyright jQuery Foundation and other contributors
  13728. * Released under the MIT license.
  13729. * http://jquery.org/license
  13730. *
  13731. * http://api.jqueryui.com/size-effect/
  13732. */
  13733. var effectSize = $.effects.effect.size = function( o, done ) {
  13734. // Create element
  13735. var original, baseline, factor,
  13736. el = $( this ),
  13737. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  13738. // Always restore
  13739. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  13740. // Copy for children
  13741. props2 = [ "width", "height", "overflow" ],
  13742. cProps = [ "fontSize" ],
  13743. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  13744. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  13745. // Set options
  13746. mode = $.effects.setMode( el, o.mode || "effect" ),
  13747. restore = o.restore || mode !== "effect",
  13748. scale = o.scale || "both",
  13749. origin = o.origin || [ "middle", "center" ],
  13750. position = el.css( "position" ),
  13751. props = restore ? props0 : props1,
  13752. zero = {
  13753. height: 0,
  13754. width: 0,
  13755. outerHeight: 0,
  13756. outerWidth: 0
  13757. };
  13758. if ( mode === "show" ) {
  13759. el.show();
  13760. }
  13761. original = {
  13762. height: el.height(),
  13763. width: el.width(),
  13764. outerHeight: el.outerHeight(),
  13765. outerWidth: el.outerWidth()
  13766. };
  13767. if ( o.mode === "toggle" && mode === "show" ) {
  13768. el.from = o.to || zero;
  13769. el.to = o.from || original;
  13770. } else {
  13771. el.from = o.from || ( mode === "show" ? zero : original );
  13772. el.to = o.to || ( mode === "hide" ? zero : original );
  13773. }
  13774. // Set scaling factor
  13775. factor = {
  13776. from: {
  13777. y: el.from.height / original.height,
  13778. x: el.from.width / original.width
  13779. },
  13780. to: {
  13781. y: el.to.height / original.height,
  13782. x: el.to.width / original.width
  13783. }
  13784. };
  13785. // Scale the css box
  13786. if ( scale === "box" || scale === "both" ) {
  13787. // Vertical props scaling
  13788. if ( factor.from.y !== factor.to.y ) {
  13789. props = props.concat( vProps );
  13790. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  13791. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  13792. }
  13793. // Horizontal props scaling
  13794. if ( factor.from.x !== factor.to.x ) {
  13795. props = props.concat( hProps );
  13796. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  13797. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  13798. }
  13799. }
  13800. // Scale the content
  13801. if ( scale === "content" || scale === "both" ) {
  13802. // Vertical props scaling
  13803. if ( factor.from.y !== factor.to.y ) {
  13804. props = props.concat( cProps ).concat( props2 );
  13805. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  13806. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  13807. }
  13808. }
  13809. $.effects.save( el, props );
  13810. el.show();
  13811. $.effects.createWrapper( el );
  13812. el.css( "overflow", "hidden" ).css( el.from );
  13813. // Adjust
  13814. if (origin) { // Calculate baseline shifts
  13815. baseline = $.effects.getBaseline( origin, original );
  13816. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  13817. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  13818. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  13819. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  13820. }
  13821. el.css( el.from ); // set top & left
  13822. // Animate
  13823. if ( scale === "content" || scale === "both" ) { // Scale the children
  13824. // Add margins/font-size
  13825. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  13826. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  13827. props2 = props0.concat(vProps).concat(hProps);
  13828. el.find( "*[width]" ).each( function() {
  13829. var child = $( this ),
  13830. c_original = {
  13831. height: child.height(),
  13832. width: child.width(),
  13833. outerHeight: child.outerHeight(),
  13834. outerWidth: child.outerWidth()
  13835. };
  13836. if (restore) {
  13837. $.effects.save(child, props2);
  13838. }
  13839. child.from = {
  13840. height: c_original.height * factor.from.y,
  13841. width: c_original.width * factor.from.x,
  13842. outerHeight: c_original.outerHeight * factor.from.y,
  13843. outerWidth: c_original.outerWidth * factor.from.x
  13844. };
  13845. child.to = {
  13846. height: c_original.height * factor.to.y,
  13847. width: c_original.width * factor.to.x,
  13848. outerHeight: c_original.height * factor.to.y,
  13849. outerWidth: c_original.width * factor.to.x
  13850. };
  13851. // Vertical props scaling
  13852. if ( factor.from.y !== factor.to.y ) {
  13853. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  13854. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  13855. }
  13856. // Horizontal props scaling
  13857. if ( factor.from.x !== factor.to.x ) {
  13858. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  13859. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  13860. }
  13861. // Animate children
  13862. child.css( child.from );
  13863. child.animate( child.to, o.duration, o.easing, function() {
  13864. // Restore children
  13865. if ( restore ) {
  13866. $.effects.restore( child, props2 );
  13867. }
  13868. });
  13869. });
  13870. }
  13871. // Animate
  13872. el.animate( el.to, {
  13873. queue: false,
  13874. duration: o.duration,
  13875. easing: o.easing,
  13876. complete: function() {
  13877. if ( el.to.opacity === 0 ) {
  13878. el.css( "opacity", el.from.opacity );
  13879. }
  13880. if ( mode === "hide" ) {
  13881. el.hide();
  13882. }
  13883. $.effects.restore( el, props );
  13884. if ( !restore ) {
  13885. // we need to calculate our new positioning based on the scaling
  13886. if ( position === "static" ) {
  13887. el.css({
  13888. position: "relative",
  13889. top: el.to.top,
  13890. left: el.to.left
  13891. });
  13892. } else {
  13893. $.each([ "top", "left" ], function( idx, pos ) {
  13894. el.css( pos, function( _, str ) {
  13895. var val = parseInt( str, 10 ),
  13896. toRef = idx ? el.to.left : el.to.top;
  13897. // if original was "auto", recalculate the new value from wrapper
  13898. if ( str === "auto" ) {
  13899. return toRef + "px";
  13900. }
  13901. return val + toRef + "px";
  13902. });
  13903. });
  13904. }
  13905. }
  13906. $.effects.removeWrapper( el );
  13907. done();
  13908. }
  13909. });
  13910. };
  13911. /*!
  13912. * jQuery UI Effects Scale 1.11.3
  13913. * http://jqueryui.com
  13914. *
  13915. * Copyright jQuery Foundation and other contributors
  13916. * Released under the MIT license.
  13917. * http://jquery.org/license
  13918. *
  13919. * http://api.jqueryui.com/scale-effect/
  13920. */
  13921. var effectScale = $.effects.effect.scale = function( o, done ) {
  13922. // Create element
  13923. var el = $( this ),
  13924. options = $.extend( true, {}, o ),
  13925. mode = $.effects.setMode( el, o.mode || "effect" ),
  13926. percent = parseInt( o.percent, 10 ) ||
  13927. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  13928. direction = o.direction || "both",
  13929. origin = o.origin,
  13930. original = {
  13931. height: el.height(),
  13932. width: el.width(),
  13933. outerHeight: el.outerHeight(),
  13934. outerWidth: el.outerWidth()
  13935. },
  13936. factor = {
  13937. y: direction !== "horizontal" ? (percent / 100) : 1,
  13938. x: direction !== "vertical" ? (percent / 100) : 1
  13939. };
  13940. // We are going to pass this effect to the size effect:
  13941. options.effect = "size";
  13942. options.queue = false;
  13943. options.complete = done;
  13944. // Set default origin and restore for show/hide
  13945. if ( mode !== "effect" ) {
  13946. options.origin = origin || [ "middle", "center" ];
  13947. options.restore = true;
  13948. }
  13949. options.from = o.from || ( mode === "show" ? {
  13950. height: 0,
  13951. width: 0,
  13952. outerHeight: 0,
  13953. outerWidth: 0
  13954. } : original );
  13955. options.to = {
  13956. height: original.height * factor.y,
  13957. width: original.width * factor.x,
  13958. outerHeight: original.outerHeight * factor.y,
  13959. outerWidth: original.outerWidth * factor.x
  13960. };
  13961. // Fade option to support puff
  13962. if ( options.fade ) {
  13963. if ( mode === "show" ) {
  13964. options.from.opacity = 0;
  13965. options.to.opacity = 1;
  13966. }
  13967. if ( mode === "hide" ) {
  13968. options.from.opacity = 1;
  13969. options.to.opacity = 0;
  13970. }
  13971. }
  13972. // Animate
  13973. el.effect( options );
  13974. };
  13975. /*!
  13976. * jQuery UI Effects Puff 1.11.3
  13977. * http://jqueryui.com
  13978. *
  13979. * Copyright jQuery Foundation and other contributors
  13980. * Released under the MIT license.
  13981. * http://jquery.org/license
  13982. *
  13983. * http://api.jqueryui.com/puff-effect/
  13984. */
  13985. var effectPuff = $.effects.effect.puff = function( o, done ) {
  13986. var elem = $( this ),
  13987. mode = $.effects.setMode( elem, o.mode || "hide" ),
  13988. hide = mode === "hide",
  13989. percent = parseInt( o.percent, 10 ) || 150,
  13990. factor = percent / 100,
  13991. original = {
  13992. height: elem.height(),
  13993. width: elem.width(),
  13994. outerHeight: elem.outerHeight(),
  13995. outerWidth: elem.outerWidth()
  13996. };
  13997. $.extend( o, {
  13998. effect: "scale",
  13999. queue: false,
  14000. fade: true,
  14001. mode: mode,
  14002. complete: done,
  14003. percent: hide ? percent : 100,
  14004. from: hide ?
  14005. original :
  14006. {
  14007. height: original.height * factor,
  14008. width: original.width * factor,
  14009. outerHeight: original.outerHeight * factor,
  14010. outerWidth: original.outerWidth * factor
  14011. }
  14012. });
  14013. elem.effect( o );
  14014. };
  14015. /*!
  14016. * jQuery UI Effects Pulsate 1.11.3
  14017. * http://jqueryui.com
  14018. *
  14019. * Copyright jQuery Foundation and other contributors
  14020. * Released under the MIT license.
  14021. * http://jquery.org/license
  14022. *
  14023. * http://api.jqueryui.com/pulsate-effect/
  14024. */
  14025. var effectPulsate = $.effects.effect.pulsate = function( o, done ) {
  14026. var elem = $( this ),
  14027. mode = $.effects.setMode( elem, o.mode || "show" ),
  14028. show = mode === "show",
  14029. hide = mode === "hide",
  14030. showhide = ( show || mode === "hide" ),
  14031. // showing or hiding leaves of the "last" animation
  14032. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  14033. duration = o.duration / anims,
  14034. animateTo = 0,
  14035. queue = elem.queue(),
  14036. queuelen = queue.length,
  14037. i;
  14038. if ( show || !elem.is(":visible")) {
  14039. elem.css( "opacity", 0 ).show();
  14040. animateTo = 1;
  14041. }
  14042. // anims - 1 opacity "toggles"
  14043. for ( i = 1; i < anims; i++ ) {
  14044. elem.animate({
  14045. opacity: animateTo
  14046. }, duration, o.easing );
  14047. animateTo = 1 - animateTo;
  14048. }
  14049. elem.animate({
  14050. opacity: animateTo
  14051. }, duration, o.easing);
  14052. elem.queue(function() {
  14053. if ( hide ) {
  14054. elem.hide();
  14055. }
  14056. done();
  14057. });
  14058. // We just queued up "anims" animations, we need to put them next in the queue
  14059. if ( queuelen > 1 ) {
  14060. queue.splice.apply( queue,
  14061. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  14062. }
  14063. elem.dequeue();
  14064. };
  14065. /*!
  14066. * jQuery UI Effects Shake 1.11.3
  14067. * http://jqueryui.com
  14068. *
  14069. * Copyright jQuery Foundation and other contributors
  14070. * Released under the MIT license.
  14071. * http://jquery.org/license
  14072. *
  14073. * http://api.jqueryui.com/shake-effect/
  14074. */
  14075. var effectShake = $.effects.effect.shake = function( o, done ) {
  14076. var el = $( this ),
  14077. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  14078. mode = $.effects.setMode( el, o.mode || "effect" ),
  14079. direction = o.direction || "left",
  14080. distance = o.distance || 20,
  14081. times = o.times || 3,
  14082. anims = times * 2 + 1,
  14083. speed = Math.round( o.duration / anims ),
  14084. ref = (direction === "up" || direction === "down") ? "top" : "left",
  14085. positiveMotion = (direction === "up" || direction === "left"),
  14086. animation = {},
  14087. animation1 = {},
  14088. animation2 = {},
  14089. i,
  14090. // we will need to re-assemble the queue to stack our animations in place
  14091. queue = el.queue(),
  14092. queuelen = queue.length;
  14093. $.effects.save( el, props );
  14094. el.show();
  14095. $.effects.createWrapper( el );
  14096. // Animation
  14097. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  14098. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  14099. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  14100. // Animate
  14101. el.animate( animation, speed, o.easing );
  14102. // Shakes
  14103. for ( i = 1; i < times; i++ ) {
  14104. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  14105. }
  14106. el
  14107. .animate( animation1, speed, o.easing )
  14108. .animate( animation, speed / 2, o.easing )
  14109. .queue(function() {
  14110. if ( mode === "hide" ) {
  14111. el.hide();
  14112. }
  14113. $.effects.restore( el, props );
  14114. $.effects.removeWrapper( el );
  14115. done();
  14116. });
  14117. // inject all the animations we just queued to be first in line (after "inprogress")
  14118. if ( queuelen > 1) {
  14119. queue.splice.apply( queue,
  14120. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  14121. }
  14122. el.dequeue();
  14123. };
  14124. /*!
  14125. * jQuery UI Effects Slide 1.11.3
  14126. * http://jqueryui.com
  14127. *
  14128. * Copyright jQuery Foundation and other contributors
  14129. * Released under the MIT license.
  14130. * http://jquery.org/license
  14131. *
  14132. * http://api.jqueryui.com/slide-effect/
  14133. */
  14134. var effectSlide = $.effects.effect.slide = function( o, done ) {
  14135. // Create element
  14136. var el = $( this ),
  14137. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  14138. mode = $.effects.setMode( el, o.mode || "show" ),
  14139. show = mode === "show",
  14140. direction = o.direction || "left",
  14141. ref = (direction === "up" || direction === "down") ? "top" : "left",
  14142. positiveMotion = (direction === "up" || direction === "left"),
  14143. distance,
  14144. animation = {};
  14145. // Adjust
  14146. $.effects.save( el, props );
  14147. el.show();
  14148. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  14149. $.effects.createWrapper( el ).css({
  14150. overflow: "hidden"
  14151. });
  14152. if ( show ) {
  14153. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  14154. }
  14155. // Animation
  14156. animation[ ref ] = ( show ?
  14157. ( positiveMotion ? "+=" : "-=") :
  14158. ( positiveMotion ? "-=" : "+=")) +
  14159. distance;
  14160. // Animate
  14161. el.animate( animation, {
  14162. queue: false,
  14163. duration: o.duration,
  14164. easing: o.easing,
  14165. complete: function() {
  14166. if ( mode === "hide" ) {
  14167. el.hide();
  14168. }
  14169. $.effects.restore( el, props );
  14170. $.effects.removeWrapper( el );
  14171. done();
  14172. }
  14173. });
  14174. };
  14175. /*!
  14176. * jQuery UI Effects Transfer 1.11.3
  14177. * http://jqueryui.com
  14178. *
  14179. * Copyright jQuery Foundation and other contributors
  14180. * Released under the MIT license.
  14181. * http://jquery.org/license
  14182. *
  14183. * http://api.jqueryui.com/transfer-effect/
  14184. */
  14185. var effectTransfer = $.effects.effect.transfer = function( o, done ) {
  14186. var elem = $( this ),
  14187. target = $( o.to ),
  14188. targetFixed = target.css( "position" ) === "fixed",
  14189. body = $("body"),
  14190. fixTop = targetFixed ? body.scrollTop() : 0,
  14191. fixLeft = targetFixed ? body.scrollLeft() : 0,
  14192. endPosition = target.offset(),
  14193. animation = {
  14194. top: endPosition.top - fixTop,
  14195. left: endPosition.left - fixLeft,
  14196. height: target.innerHeight(),
  14197. width: target.innerWidth()
  14198. },
  14199. startPosition = elem.offset(),
  14200. transfer = $( "<div class='ui-effects-transfer'></div>" )
  14201. .appendTo( document.body )
  14202. .addClass( o.className )
  14203. .css({
  14204. top: startPosition.top - fixTop,
  14205. left: startPosition.left - fixLeft,
  14206. height: elem.innerHeight(),
  14207. width: elem.innerWidth(),
  14208. position: targetFixed ? "fixed" : "absolute"
  14209. })
  14210. .animate( animation, o.duration, o.easing, function() {
  14211. transfer.remove();
  14212. done();
  14213. });
  14214. };
  14215. }));