jquery-ui.js 447 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159
  1. /*! jQuery UI - v1.11.4 - 2016-04-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, 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 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.4
  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.4",
  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.4
  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.4
  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.4",
  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.4
  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.4
  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.4",
  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. // Store draggable's parent in case we need to reappend to it later.
  2010. draggable._parent = ui.helper.parent();
  2011. sortable.currentItem = ui.helper
  2012. .appendTo( sortable.element )
  2013. .data( "ui-sortable-item", true );
  2014. // Store helper option to later restore it
  2015. sortable.options._helper = sortable.options.helper;
  2016. sortable.options.helper = function() {
  2017. return ui.helper[ 0 ];
  2018. };
  2019. // Fire the start events of the sortable with our passed browser event,
  2020. // and our own helper (so it doesn't create a new one)
  2021. event.target = sortable.currentItem[ 0 ];
  2022. sortable._mouseCapture( event, true );
  2023. sortable._mouseStart( event, true, true );
  2024. // Because the browser event is way off the new appended portlet,
  2025. // modify necessary variables to reflect the changes
  2026. sortable.offset.click.top = draggable.offset.click.top;
  2027. sortable.offset.click.left = draggable.offset.click.left;
  2028. sortable.offset.parent.left -= draggable.offset.parent.left -
  2029. sortable.offset.parent.left;
  2030. sortable.offset.parent.top -= draggable.offset.parent.top -
  2031. sortable.offset.parent.top;
  2032. draggable._trigger( "toSortable", event );
  2033. // Inform draggable that the helper is in a valid drop zone,
  2034. // used solely in the revert option to handle "valid/invalid".
  2035. draggable.dropped = sortable.element;
  2036. // Need to refreshPositions of all sortables in the case that
  2037. // adding to one sortable changes the location of the other sortables (#9675)
  2038. $.each( draggable.sortables, function() {
  2039. this.refreshPositions();
  2040. });
  2041. // hack so receive/update callbacks work (mostly)
  2042. draggable.currentItem = draggable.element;
  2043. sortable.fromOutside = draggable;
  2044. }
  2045. if ( sortable.currentItem ) {
  2046. sortable._mouseDrag( event );
  2047. // Copy the sortable's position because the draggable's can potentially reflect
  2048. // a relative position, while sortable is always absolute, which the dragged
  2049. // element has now become. (#8809)
  2050. ui.position = sortable.position;
  2051. }
  2052. } else {
  2053. // If it doesn't intersect with the sortable, and it intersected before,
  2054. // we fake the drag stop of the sortable, but make sure it doesn't remove
  2055. // the helper by using cancelHelperRemoval.
  2056. if ( sortable.isOver ) {
  2057. sortable.isOver = 0;
  2058. sortable.cancelHelperRemoval = true;
  2059. // Calling sortable's mouseStop would trigger a revert,
  2060. // so revert must be temporarily false until after mouseStop is called.
  2061. sortable.options._revert = sortable.options.revert;
  2062. sortable.options.revert = false;
  2063. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  2064. sortable._mouseStop( event, true );
  2065. // restore sortable behaviors that were modfied
  2066. // when the draggable entered the sortable area (#9481)
  2067. sortable.options.revert = sortable.options._revert;
  2068. sortable.options.helper = sortable.options._helper;
  2069. if ( sortable.placeholder ) {
  2070. sortable.placeholder.remove();
  2071. }
  2072. // Restore and recalculate the draggable's offset considering the sortable
  2073. // may have modified them in unexpected ways. (#8809, #10669)
  2074. ui.helper.appendTo( draggable._parent );
  2075. draggable._refreshOffsets( event );
  2076. ui.position = draggable._generatePosition( event, true );
  2077. draggable._trigger( "fromSortable", event );
  2078. // Inform draggable that the helper is no longer in a valid drop zone
  2079. draggable.dropped = false;
  2080. // Need to refreshPositions of all sortables just in case removing
  2081. // from one sortable changes the location of other sortables (#9675)
  2082. $.each( draggable.sortables, function() {
  2083. this.refreshPositions();
  2084. });
  2085. }
  2086. }
  2087. });
  2088. }
  2089. });
  2090. $.ui.plugin.add("draggable", "cursor", {
  2091. start: function( event, ui, instance ) {
  2092. var t = $( "body" ),
  2093. o = instance.options;
  2094. if (t.css("cursor")) {
  2095. o._cursor = t.css("cursor");
  2096. }
  2097. t.css("cursor", o.cursor);
  2098. },
  2099. stop: function( event, ui, instance ) {
  2100. var o = instance.options;
  2101. if (o._cursor) {
  2102. $("body").css("cursor", o._cursor);
  2103. }
  2104. }
  2105. });
  2106. $.ui.plugin.add("draggable", "opacity", {
  2107. start: function( event, ui, instance ) {
  2108. var t = $( ui.helper ),
  2109. o = instance.options;
  2110. if (t.css("opacity")) {
  2111. o._opacity = t.css("opacity");
  2112. }
  2113. t.css("opacity", o.opacity);
  2114. },
  2115. stop: function( event, ui, instance ) {
  2116. var o = instance.options;
  2117. if (o._opacity) {
  2118. $(ui.helper).css("opacity", o._opacity);
  2119. }
  2120. }
  2121. });
  2122. $.ui.plugin.add("draggable", "scroll", {
  2123. start: function( event, ui, i ) {
  2124. if ( !i.scrollParentNotHidden ) {
  2125. i.scrollParentNotHidden = i.helper.scrollParent( false );
  2126. }
  2127. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  2128. i.overflowOffset = i.scrollParentNotHidden.offset();
  2129. }
  2130. },
  2131. drag: function( event, ui, i ) {
  2132. var o = i.options,
  2133. scrolled = false,
  2134. scrollParent = i.scrollParentNotHidden[ 0 ],
  2135. document = i.document[ 0 ];
  2136. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  2137. if ( !o.axis || o.axis !== "x" ) {
  2138. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) {
  2139. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  2140. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  2141. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  2142. }
  2143. }
  2144. if ( !o.axis || o.axis !== "y" ) {
  2145. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) {
  2146. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  2147. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  2148. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  2149. }
  2150. }
  2151. } else {
  2152. if (!o.axis || o.axis !== "x") {
  2153. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  2154. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  2155. } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  2156. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  2157. }
  2158. }
  2159. if (!o.axis || o.axis !== "y") {
  2160. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  2161. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  2162. } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  2163. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  2164. }
  2165. }
  2166. }
  2167. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  2168. $.ui.ddmanager.prepareOffsets(i, event);
  2169. }
  2170. }
  2171. });
  2172. $.ui.plugin.add("draggable", "snap", {
  2173. start: function( event, ui, i ) {
  2174. var o = i.options;
  2175. i.snapElements = [];
  2176. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  2177. var $t = $(this),
  2178. $o = $t.offset();
  2179. if (this !== i.element[0]) {
  2180. i.snapElements.push({
  2181. item: this,
  2182. width: $t.outerWidth(), height: $t.outerHeight(),
  2183. top: $o.top, left: $o.left
  2184. });
  2185. }
  2186. });
  2187. },
  2188. drag: function( event, ui, inst ) {
  2189. var ts, bs, ls, rs, l, r, t, b, i, first,
  2190. o = inst.options,
  2191. d = o.snapTolerance,
  2192. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  2193. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  2194. for (i = inst.snapElements.length - 1; i >= 0; i--){
  2195. l = inst.snapElements[i].left - inst.margins.left;
  2196. r = l + inst.snapElements[i].width;
  2197. t = inst.snapElements[i].top - inst.margins.top;
  2198. b = t + inst.snapElements[i].height;
  2199. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  2200. if (inst.snapElements[i].snapping) {
  2201. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2202. }
  2203. inst.snapElements[i].snapping = false;
  2204. continue;
  2205. }
  2206. if (o.snapMode !== "inner") {
  2207. ts = Math.abs(t - y2) <= d;
  2208. bs = Math.abs(b - y1) <= d;
  2209. ls = Math.abs(l - x2) <= d;
  2210. rs = Math.abs(r - x1) <= d;
  2211. if (ts) {
  2212. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
  2213. }
  2214. if (bs) {
  2215. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
  2216. }
  2217. if (ls) {
  2218. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
  2219. }
  2220. if (rs) {
  2221. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
  2222. }
  2223. }
  2224. first = (ts || bs || ls || rs);
  2225. if (o.snapMode !== "outer") {
  2226. ts = Math.abs(t - y1) <= d;
  2227. bs = Math.abs(b - y2) <= d;
  2228. ls = Math.abs(l - x1) <= d;
  2229. rs = Math.abs(r - x2) <= d;
  2230. if (ts) {
  2231. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
  2232. }
  2233. if (bs) {
  2234. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
  2235. }
  2236. if (ls) {
  2237. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
  2238. }
  2239. if (rs) {
  2240. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
  2241. }
  2242. }
  2243. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  2244. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2245. }
  2246. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  2247. }
  2248. }
  2249. });
  2250. $.ui.plugin.add("draggable", "stack", {
  2251. start: function( event, ui, instance ) {
  2252. var min,
  2253. o = instance.options,
  2254. group = $.makeArray($(o.stack)).sort(function(a, b) {
  2255. return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
  2256. });
  2257. if (!group.length) { return; }
  2258. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  2259. $(group).each(function(i) {
  2260. $(this).css("zIndex", min + i);
  2261. });
  2262. this.css("zIndex", (min + group.length));
  2263. }
  2264. });
  2265. $.ui.plugin.add("draggable", "zIndex", {
  2266. start: function( event, ui, instance ) {
  2267. var t = $( ui.helper ),
  2268. o = instance.options;
  2269. if (t.css("zIndex")) {
  2270. o._zIndex = t.css("zIndex");
  2271. }
  2272. t.css("zIndex", o.zIndex);
  2273. },
  2274. stop: function( event, ui, instance ) {
  2275. var o = instance.options;
  2276. if (o._zIndex) {
  2277. $(ui.helper).css("zIndex", o._zIndex);
  2278. }
  2279. }
  2280. });
  2281. var draggable = $.ui.draggable;
  2282. /*!
  2283. * jQuery UI Droppable 1.11.4
  2284. * http://jqueryui.com
  2285. *
  2286. * Copyright jQuery Foundation and other contributors
  2287. * Released under the MIT license.
  2288. * http://jquery.org/license
  2289. *
  2290. * http://api.jqueryui.com/droppable/
  2291. */
  2292. $.widget( "ui.droppable", {
  2293. version: "1.11.4",
  2294. widgetEventPrefix: "drop",
  2295. options: {
  2296. accept: "*",
  2297. activeClass: false,
  2298. addClasses: true,
  2299. greedy: false,
  2300. hoverClass: false,
  2301. scope: "default",
  2302. tolerance: "intersect",
  2303. // callbacks
  2304. activate: null,
  2305. deactivate: null,
  2306. drop: null,
  2307. out: null,
  2308. over: null
  2309. },
  2310. _create: function() {
  2311. var proportions,
  2312. o = this.options,
  2313. accept = o.accept;
  2314. this.isover = false;
  2315. this.isout = true;
  2316. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  2317. return d.is( accept );
  2318. };
  2319. this.proportions = function( /* valueToWrite */ ) {
  2320. if ( arguments.length ) {
  2321. // Store the droppable's proportions
  2322. proportions = arguments[ 0 ];
  2323. } else {
  2324. // Retrieve or derive the droppable's proportions
  2325. return proportions ?
  2326. proportions :
  2327. proportions = {
  2328. width: this.element[ 0 ].offsetWidth,
  2329. height: this.element[ 0 ].offsetHeight
  2330. };
  2331. }
  2332. };
  2333. this._addToManager( o.scope );
  2334. o.addClasses && this.element.addClass( "ui-droppable" );
  2335. },
  2336. _addToManager: function( scope ) {
  2337. // Add the reference and positions to the manager
  2338. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  2339. $.ui.ddmanager.droppables[ scope ].push( this );
  2340. },
  2341. _splice: function( drop ) {
  2342. var i = 0;
  2343. for ( ; i < drop.length; i++ ) {
  2344. if ( drop[ i ] === this ) {
  2345. drop.splice( i, 1 );
  2346. }
  2347. }
  2348. },
  2349. _destroy: function() {
  2350. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2351. this._splice( drop );
  2352. this.element.removeClass( "ui-droppable ui-droppable-disabled" );
  2353. },
  2354. _setOption: function( key, value ) {
  2355. if ( key === "accept" ) {
  2356. this.accept = $.isFunction( value ) ? value : function( d ) {
  2357. return d.is( value );
  2358. };
  2359. } else if ( key === "scope" ) {
  2360. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2361. this._splice( drop );
  2362. this._addToManager( value );
  2363. }
  2364. this._super( key, value );
  2365. },
  2366. _activate: function( event ) {
  2367. var draggable = $.ui.ddmanager.current;
  2368. if ( this.options.activeClass ) {
  2369. this.element.addClass( this.options.activeClass );
  2370. }
  2371. if ( draggable ){
  2372. this._trigger( "activate", event, this.ui( draggable ) );
  2373. }
  2374. },
  2375. _deactivate: function( event ) {
  2376. var draggable = $.ui.ddmanager.current;
  2377. if ( this.options.activeClass ) {
  2378. this.element.removeClass( this.options.activeClass );
  2379. }
  2380. if ( draggable ){
  2381. this._trigger( "deactivate", event, this.ui( draggable ) );
  2382. }
  2383. },
  2384. _over: function( event ) {
  2385. var draggable = $.ui.ddmanager.current;
  2386. // Bail if draggable and droppable are same element
  2387. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2388. return;
  2389. }
  2390. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2391. if ( this.options.hoverClass ) {
  2392. this.element.addClass( this.options.hoverClass );
  2393. }
  2394. this._trigger( "over", event, this.ui( draggable ) );
  2395. }
  2396. },
  2397. _out: function( event ) {
  2398. var draggable = $.ui.ddmanager.current;
  2399. // Bail if draggable and droppable are same element
  2400. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2401. return;
  2402. }
  2403. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2404. if ( this.options.hoverClass ) {
  2405. this.element.removeClass( this.options.hoverClass );
  2406. }
  2407. this._trigger( "out", event, this.ui( draggable ) );
  2408. }
  2409. },
  2410. _drop: function( event, custom ) {
  2411. var draggable = custom || $.ui.ddmanager.current,
  2412. childrenIntersection = false;
  2413. // Bail if draggable and droppable are same element
  2414. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2415. return false;
  2416. }
  2417. this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
  2418. var inst = $( this ).droppable( "instance" );
  2419. if (
  2420. inst.options.greedy &&
  2421. !inst.options.disabled &&
  2422. inst.options.scope === draggable.options.scope &&
  2423. inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
  2424. $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
  2425. ) { childrenIntersection = true; return false; }
  2426. });
  2427. if ( childrenIntersection ) {
  2428. return false;
  2429. }
  2430. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2431. if ( this.options.activeClass ) {
  2432. this.element.removeClass( this.options.activeClass );
  2433. }
  2434. if ( this.options.hoverClass ) {
  2435. this.element.removeClass( this.options.hoverClass );
  2436. }
  2437. this._trigger( "drop", event, this.ui( draggable ) );
  2438. return this.element;
  2439. }
  2440. return false;
  2441. },
  2442. ui: function( c ) {
  2443. return {
  2444. draggable: ( c.currentItem || c.element ),
  2445. helper: c.helper,
  2446. position: c.position,
  2447. offset: c.positionAbs
  2448. };
  2449. }
  2450. });
  2451. $.ui.intersect = (function() {
  2452. function isOverAxis( x, reference, size ) {
  2453. return ( x >= reference ) && ( x < ( reference + size ) );
  2454. }
  2455. return function( draggable, droppable, toleranceMode, event ) {
  2456. if ( !droppable.offset ) {
  2457. return false;
  2458. }
  2459. var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left,
  2460. y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top,
  2461. x2 = x1 + draggable.helperProportions.width,
  2462. y2 = y1 + draggable.helperProportions.height,
  2463. l = droppable.offset.left,
  2464. t = droppable.offset.top,
  2465. r = l + droppable.proportions().width,
  2466. b = t + droppable.proportions().height;
  2467. switch ( toleranceMode ) {
  2468. case "fit":
  2469. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  2470. case "intersect":
  2471. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  2472. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  2473. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  2474. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  2475. case "pointer":
  2476. return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
  2477. case "touch":
  2478. return (
  2479. ( y1 >= t && y1 <= b ) || // Top edge touching
  2480. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  2481. ( y1 < t && y2 > b ) // Surrounded vertically
  2482. ) && (
  2483. ( x1 >= l && x1 <= r ) || // Left edge touching
  2484. ( x2 >= l && x2 <= r ) || // Right edge touching
  2485. ( x1 < l && x2 > r ) // Surrounded horizontally
  2486. );
  2487. default:
  2488. return false;
  2489. }
  2490. };
  2491. })();
  2492. /*
  2493. This manager tracks offsets of draggables and droppables
  2494. */
  2495. $.ui.ddmanager = {
  2496. current: null,
  2497. droppables: { "default": [] },
  2498. prepareOffsets: function( t, event ) {
  2499. var i, j,
  2500. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  2501. type = event ? event.type : null, // workaround for #2317
  2502. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  2503. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  2504. // No disabled and non-accepted
  2505. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
  2506. continue;
  2507. }
  2508. // Filter out elements in the current dragged item
  2509. for ( j = 0; j < list.length; j++ ) {
  2510. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  2511. m[ i ].proportions().height = 0;
  2512. continue droppablesLoop;
  2513. }
  2514. }
  2515. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  2516. if ( !m[ i ].visible ) {
  2517. continue;
  2518. }
  2519. // Activate the droppable if used directly from draggables
  2520. if ( type === "mousedown" ) {
  2521. m[ i ]._activate.call( m[ i ], event );
  2522. }
  2523. m[ i ].offset = m[ i ].element.offset();
  2524. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  2525. }
  2526. },
  2527. drop: function( draggable, event ) {
  2528. var dropped = false;
  2529. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2530. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  2531. if ( !this.options ) {
  2532. return;
  2533. }
  2534. if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
  2535. dropped = this._drop.call( this, event ) || dropped;
  2536. }
  2537. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2538. this.isout = true;
  2539. this.isover = false;
  2540. this._deactivate.call( this, event );
  2541. }
  2542. });
  2543. return dropped;
  2544. },
  2545. dragStart: function( draggable, event ) {
  2546. // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  2547. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  2548. if ( !draggable.options.refreshPositions ) {
  2549. $.ui.ddmanager.prepareOffsets( draggable, event );
  2550. }
  2551. });
  2552. },
  2553. drag: function( draggable, event ) {
  2554. // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  2555. if ( draggable.options.refreshPositions ) {
  2556. $.ui.ddmanager.prepareOffsets( draggable, event );
  2557. }
  2558. // Run through all droppables and check their positions based on specific tolerance options
  2559. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  2560. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  2561. return;
  2562. }
  2563. var parentInstance, scope, parent,
  2564. intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
  2565. c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
  2566. if ( !c ) {
  2567. return;
  2568. }
  2569. if ( this.options.greedy ) {
  2570. // find droppable parents with same scope
  2571. scope = this.options.scope;
  2572. parent = this.element.parents( ":data(ui-droppable)" ).filter(function() {
  2573. return $( this ).droppable( "instance" ).options.scope === scope;
  2574. });
  2575. if ( parent.length ) {
  2576. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  2577. parentInstance.greedyChild = ( c === "isover" );
  2578. }
  2579. }
  2580. // we just moved into a greedy child
  2581. if ( parentInstance && c === "isover" ) {
  2582. parentInstance.isover = false;
  2583. parentInstance.isout = true;
  2584. parentInstance._out.call( parentInstance, event );
  2585. }
  2586. this[ c ] = true;
  2587. this[c === "isout" ? "isover" : "isout"] = false;
  2588. this[c === "isover" ? "_over" : "_out"].call( this, event );
  2589. // we just moved out of a greedy child
  2590. if ( parentInstance && c === "isout" ) {
  2591. parentInstance.isout = false;
  2592. parentInstance.isover = true;
  2593. parentInstance._over.call( parentInstance, event );
  2594. }
  2595. });
  2596. },
  2597. dragStop: function( draggable, event ) {
  2598. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  2599. // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  2600. if ( !draggable.options.refreshPositions ) {
  2601. $.ui.ddmanager.prepareOffsets( draggable, event );
  2602. }
  2603. }
  2604. };
  2605. var droppable = $.ui.droppable;
  2606. /*!
  2607. * jQuery UI Resizable 1.11.4
  2608. * http://jqueryui.com
  2609. *
  2610. * Copyright jQuery Foundation and other contributors
  2611. * Released under the MIT license.
  2612. * http://jquery.org/license
  2613. *
  2614. * http://api.jqueryui.com/resizable/
  2615. */
  2616. $.widget("ui.resizable", $.ui.mouse, {
  2617. version: "1.11.4",
  2618. widgetEventPrefix: "resize",
  2619. options: {
  2620. alsoResize: false,
  2621. animate: false,
  2622. animateDuration: "slow",
  2623. animateEasing: "swing",
  2624. aspectRatio: false,
  2625. autoHide: false,
  2626. containment: false,
  2627. ghost: false,
  2628. grid: false,
  2629. handles: "e,s,se",
  2630. helper: false,
  2631. maxHeight: null,
  2632. maxWidth: null,
  2633. minHeight: 10,
  2634. minWidth: 10,
  2635. // See #7960
  2636. zIndex: 90,
  2637. // callbacks
  2638. resize: null,
  2639. start: null,
  2640. stop: null
  2641. },
  2642. _num: function( value ) {
  2643. return parseInt( value, 10 ) || 0;
  2644. },
  2645. _isNumber: function( value ) {
  2646. return !isNaN( parseInt( value, 10 ) );
  2647. },
  2648. _hasScroll: function( el, a ) {
  2649. if ( $( el ).css( "overflow" ) === "hidden") {
  2650. return false;
  2651. }
  2652. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  2653. has = false;
  2654. if ( el[ scroll ] > 0 ) {
  2655. return true;
  2656. }
  2657. // TODO: determine which cases actually cause this to happen
  2658. // if the element doesn't have the scroll set, see if it's possible to
  2659. // set the scroll
  2660. el[ scroll ] = 1;
  2661. has = ( el[ scroll ] > 0 );
  2662. el[ scroll ] = 0;
  2663. return has;
  2664. },
  2665. _create: function() {
  2666. var n, i, handle, axis, hname,
  2667. that = this,
  2668. o = this.options;
  2669. this.element.addClass("ui-resizable");
  2670. $.extend(this, {
  2671. _aspectRatio: !!(o.aspectRatio),
  2672. aspectRatio: o.aspectRatio,
  2673. originalElement: this.element,
  2674. _proportionallyResizeElements: [],
  2675. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  2676. });
  2677. // Wrap the element if it cannot hold child nodes
  2678. if (this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)) {
  2679. this.element.wrap(
  2680. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  2681. position: this.element.css("position"),
  2682. width: this.element.outerWidth(),
  2683. height: this.element.outerHeight(),
  2684. top: this.element.css("top"),
  2685. left: this.element.css("left")
  2686. })
  2687. );
  2688. this.element = this.element.parent().data(
  2689. "ui-resizable", this.element.resizable( "instance" )
  2690. );
  2691. this.elementIsWrapper = true;
  2692. this.element.css({
  2693. marginLeft: this.originalElement.css("marginLeft"),
  2694. marginTop: this.originalElement.css("marginTop"),
  2695. marginRight: this.originalElement.css("marginRight"),
  2696. marginBottom: this.originalElement.css("marginBottom")
  2697. });
  2698. this.originalElement.css({
  2699. marginLeft: 0,
  2700. marginTop: 0,
  2701. marginRight: 0,
  2702. marginBottom: 0
  2703. });
  2704. // support: Safari
  2705. // Prevent Safari textarea resize
  2706. this.originalResizeStyle = this.originalElement.css("resize");
  2707. this.originalElement.css("resize", "none");
  2708. this._proportionallyResizeElements.push( this.originalElement.css({
  2709. position: "static",
  2710. zoom: 1,
  2711. display: "block"
  2712. }) );
  2713. // support: IE9
  2714. // avoid IE jump (hard set the margin)
  2715. this.originalElement.css({ margin: this.originalElement.css("margin") });
  2716. this._proportionallyResize();
  2717. }
  2718. this.handles = o.handles ||
  2719. ( !$(".ui-resizable-handle", this.element).length ?
  2720. "e,s,se" : {
  2721. n: ".ui-resizable-n",
  2722. e: ".ui-resizable-e",
  2723. s: ".ui-resizable-s",
  2724. w: ".ui-resizable-w",
  2725. se: ".ui-resizable-se",
  2726. sw: ".ui-resizable-sw",
  2727. ne: ".ui-resizable-ne",
  2728. nw: ".ui-resizable-nw"
  2729. } );
  2730. this._handles = $();
  2731. if ( this.handles.constructor === String ) {
  2732. if ( this.handles === "all") {
  2733. this.handles = "n,e,s,w,se,sw,ne,nw";
  2734. }
  2735. n = this.handles.split(",");
  2736. this.handles = {};
  2737. for (i = 0; i < n.length; i++) {
  2738. handle = $.trim(n[i]);
  2739. hname = "ui-resizable-" + handle;
  2740. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  2741. axis.css({ zIndex: o.zIndex });
  2742. // TODO : What's going on here?
  2743. if ("se" === handle) {
  2744. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  2745. }
  2746. this.handles[handle] = ".ui-resizable-" + handle;
  2747. this.element.append(axis);
  2748. }
  2749. }
  2750. this._renderAxis = function(target) {
  2751. var i, axis, padPos, padWrapper;
  2752. target = target || this.element;
  2753. for (i in this.handles) {
  2754. if (this.handles[i].constructor === String) {
  2755. this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
  2756. } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
  2757. this.handles[ i ] = $( this.handles[ i ] );
  2758. this._on( this.handles[ i ], { "mousedown": that._mouseDown });
  2759. }
  2760. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)) {
  2761. axis = $(this.handles[i], this.element);
  2762. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2763. padPos = [ "padding",
  2764. /ne|nw|n/.test(i) ? "Top" :
  2765. /se|sw|s/.test(i) ? "Bottom" :
  2766. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2767. target.css(padPos, padWrapper);
  2768. this._proportionallyResize();
  2769. }
  2770. this._handles = this._handles.add( this.handles[ i ] );
  2771. }
  2772. };
  2773. // TODO: make renderAxis a prototype function
  2774. this._renderAxis(this.element);
  2775. this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
  2776. this._handles.disableSelection();
  2777. this._handles.mouseover(function() {
  2778. if (!that.resizing) {
  2779. if (this.className) {
  2780. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2781. }
  2782. that.axis = axis && axis[1] ? axis[1] : "se";
  2783. }
  2784. });
  2785. if (o.autoHide) {
  2786. this._handles.hide();
  2787. $(this.element)
  2788. .addClass("ui-resizable-autohide")
  2789. .mouseenter(function() {
  2790. if (o.disabled) {
  2791. return;
  2792. }
  2793. $(this).removeClass("ui-resizable-autohide");
  2794. that._handles.show();
  2795. })
  2796. .mouseleave(function() {
  2797. if (o.disabled) {
  2798. return;
  2799. }
  2800. if (!that.resizing) {
  2801. $(this).addClass("ui-resizable-autohide");
  2802. that._handles.hide();
  2803. }
  2804. });
  2805. }
  2806. this._mouseInit();
  2807. },
  2808. _destroy: function() {
  2809. this._mouseDestroy();
  2810. var wrapper,
  2811. _destroy = function(exp) {
  2812. $(exp)
  2813. .removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2814. .removeData("resizable")
  2815. .removeData("ui-resizable")
  2816. .unbind(".resizable")
  2817. .find(".ui-resizable-handle")
  2818. .remove();
  2819. };
  2820. // TODO: Unwrap at same DOM position
  2821. if (this.elementIsWrapper) {
  2822. _destroy(this.element);
  2823. wrapper = this.element;
  2824. this.originalElement.css({
  2825. position: wrapper.css("position"),
  2826. width: wrapper.outerWidth(),
  2827. height: wrapper.outerHeight(),
  2828. top: wrapper.css("top"),
  2829. left: wrapper.css("left")
  2830. }).insertAfter( wrapper );
  2831. wrapper.remove();
  2832. }
  2833. this.originalElement.css("resize", this.originalResizeStyle);
  2834. _destroy(this.originalElement);
  2835. return this;
  2836. },
  2837. _mouseCapture: function(event) {
  2838. var i, handle,
  2839. capture = false;
  2840. for (i in this.handles) {
  2841. handle = $(this.handles[i])[0];
  2842. if (handle === event.target || $.contains(handle, event.target)) {
  2843. capture = true;
  2844. }
  2845. }
  2846. return !this.options.disabled && capture;
  2847. },
  2848. _mouseStart: function(event) {
  2849. var curleft, curtop, cursor,
  2850. o = this.options,
  2851. el = this.element;
  2852. this.resizing = true;
  2853. this._renderProxy();
  2854. curleft = this._num(this.helper.css("left"));
  2855. curtop = this._num(this.helper.css("top"));
  2856. if (o.containment) {
  2857. curleft += $(o.containment).scrollLeft() || 0;
  2858. curtop += $(o.containment).scrollTop() || 0;
  2859. }
  2860. this.offset = this.helper.offset();
  2861. this.position = { left: curleft, top: curtop };
  2862. this.size = this._helper ? {
  2863. width: this.helper.width(),
  2864. height: this.helper.height()
  2865. } : {
  2866. width: el.width(),
  2867. height: el.height()
  2868. };
  2869. this.originalSize = this._helper ? {
  2870. width: el.outerWidth(),
  2871. height: el.outerHeight()
  2872. } : {
  2873. width: el.width(),
  2874. height: el.height()
  2875. };
  2876. this.sizeDiff = {
  2877. width: el.outerWidth() - el.width(),
  2878. height: el.outerHeight() - el.height()
  2879. };
  2880. this.originalPosition = { left: curleft, top: curtop };
  2881. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2882. this.aspectRatio = (typeof o.aspectRatio === "number") ?
  2883. o.aspectRatio :
  2884. ((this.originalSize.width / this.originalSize.height) || 1);
  2885. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2886. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2887. el.addClass("ui-resizable-resizing");
  2888. this._propagate("start", event);
  2889. return true;
  2890. },
  2891. _mouseDrag: function(event) {
  2892. var data, props,
  2893. smp = this.originalMousePosition,
  2894. a = this.axis,
  2895. dx = (event.pageX - smp.left) || 0,
  2896. dy = (event.pageY - smp.top) || 0,
  2897. trigger = this._change[a];
  2898. this._updatePrevProperties();
  2899. if (!trigger) {
  2900. return false;
  2901. }
  2902. data = trigger.apply(this, [ event, dx, dy ]);
  2903. this._updateVirtualBoundaries(event.shiftKey);
  2904. if (this._aspectRatio || event.shiftKey) {
  2905. data = this._updateRatio(data, event);
  2906. }
  2907. data = this._respectSize(data, event);
  2908. this._updateCache(data);
  2909. this._propagate("resize", event);
  2910. props = this._applyChanges();
  2911. if ( !this._helper && this._proportionallyResizeElements.length ) {
  2912. this._proportionallyResize();
  2913. }
  2914. if ( !$.isEmptyObject( props ) ) {
  2915. this._updatePrevProperties();
  2916. this._trigger( "resize", event, this.ui() );
  2917. this._applyChanges();
  2918. }
  2919. return false;
  2920. },
  2921. _mouseStop: function(event) {
  2922. this.resizing = false;
  2923. var pr, ista, soffseth, soffsetw, s, left, top,
  2924. o = this.options, that = this;
  2925. if (this._helper) {
  2926. pr = this._proportionallyResizeElements;
  2927. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2928. soffseth = ista && this._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height;
  2929. soffsetw = ista ? 0 : that.sizeDiff.width;
  2930. s = {
  2931. width: (that.helper.width() - soffsetw),
  2932. height: (that.helper.height() - soffseth)
  2933. };
  2934. left = (parseInt(that.element.css("left"), 10) +
  2935. (that.position.left - that.originalPosition.left)) || null;
  2936. top = (parseInt(that.element.css("top"), 10) +
  2937. (that.position.top - that.originalPosition.top)) || null;
  2938. if (!o.animate) {
  2939. this.element.css($.extend(s, { top: top, left: left }));
  2940. }
  2941. that.helper.height(that.size.height);
  2942. that.helper.width(that.size.width);
  2943. if (this._helper && !o.animate) {
  2944. this._proportionallyResize();
  2945. }
  2946. }
  2947. $("body").css("cursor", "auto");
  2948. this.element.removeClass("ui-resizable-resizing");
  2949. this._propagate("stop", event);
  2950. if (this._helper) {
  2951. this.helper.remove();
  2952. }
  2953. return false;
  2954. },
  2955. _updatePrevProperties: function() {
  2956. this.prevPosition = {
  2957. top: this.position.top,
  2958. left: this.position.left
  2959. };
  2960. this.prevSize = {
  2961. width: this.size.width,
  2962. height: this.size.height
  2963. };
  2964. },
  2965. _applyChanges: function() {
  2966. var props = {};
  2967. if ( this.position.top !== this.prevPosition.top ) {
  2968. props.top = this.position.top + "px";
  2969. }
  2970. if ( this.position.left !== this.prevPosition.left ) {
  2971. props.left = this.position.left + "px";
  2972. }
  2973. if ( this.size.width !== this.prevSize.width ) {
  2974. props.width = this.size.width + "px";
  2975. }
  2976. if ( this.size.height !== this.prevSize.height ) {
  2977. props.height = this.size.height + "px";
  2978. }
  2979. this.helper.css( props );
  2980. return props;
  2981. },
  2982. _updateVirtualBoundaries: function(forceAspectRatio) {
  2983. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2984. o = this.options;
  2985. b = {
  2986. minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
  2987. maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2988. minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
  2989. maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2990. };
  2991. if (this._aspectRatio || forceAspectRatio) {
  2992. pMinWidth = b.minHeight * this.aspectRatio;
  2993. pMinHeight = b.minWidth / this.aspectRatio;
  2994. pMaxWidth = b.maxHeight * this.aspectRatio;
  2995. pMaxHeight = b.maxWidth / this.aspectRatio;
  2996. if (pMinWidth > b.minWidth) {
  2997. b.minWidth = pMinWidth;
  2998. }
  2999. if (pMinHeight > b.minHeight) {
  3000. b.minHeight = pMinHeight;
  3001. }
  3002. if (pMaxWidth < b.maxWidth) {
  3003. b.maxWidth = pMaxWidth;
  3004. }
  3005. if (pMaxHeight < b.maxHeight) {
  3006. b.maxHeight = pMaxHeight;
  3007. }
  3008. }
  3009. this._vBoundaries = b;
  3010. },
  3011. _updateCache: function(data) {
  3012. this.offset = this.helper.offset();
  3013. if (this._isNumber(data.left)) {
  3014. this.position.left = data.left;
  3015. }
  3016. if (this._isNumber(data.top)) {
  3017. this.position.top = data.top;
  3018. }
  3019. if (this._isNumber(data.height)) {
  3020. this.size.height = data.height;
  3021. }
  3022. if (this._isNumber(data.width)) {
  3023. this.size.width = data.width;
  3024. }
  3025. },
  3026. _updateRatio: function( data ) {
  3027. var cpos = this.position,
  3028. csize = this.size,
  3029. a = this.axis;
  3030. if (this._isNumber(data.height)) {
  3031. data.width = (data.height * this.aspectRatio);
  3032. } else if (this._isNumber(data.width)) {
  3033. data.height = (data.width / this.aspectRatio);
  3034. }
  3035. if (a === "sw") {
  3036. data.left = cpos.left + (csize.width - data.width);
  3037. data.top = null;
  3038. }
  3039. if (a === "nw") {
  3040. data.top = cpos.top + (csize.height - data.height);
  3041. data.left = cpos.left + (csize.width - data.width);
  3042. }
  3043. return data;
  3044. },
  3045. _respectSize: function( data ) {
  3046. var o = this._vBoundaries,
  3047. a = this.axis,
  3048. ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width),
  3049. ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  3050. isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width),
  3051. isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  3052. dw = this.originalPosition.left + this.originalSize.width,
  3053. dh = this.position.top + this.size.height,
  3054. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  3055. if (isminw) {
  3056. data.width = o.minWidth;
  3057. }
  3058. if (isminh) {
  3059. data.height = o.minHeight;
  3060. }
  3061. if (ismaxw) {
  3062. data.width = o.maxWidth;
  3063. }
  3064. if (ismaxh) {
  3065. data.height = o.maxHeight;
  3066. }
  3067. if (isminw && cw) {
  3068. data.left = dw - o.minWidth;
  3069. }
  3070. if (ismaxw && cw) {
  3071. data.left = dw - o.maxWidth;
  3072. }
  3073. if (isminh && ch) {
  3074. data.top = dh - o.minHeight;
  3075. }
  3076. if (ismaxh && ch) {
  3077. data.top = dh - o.maxHeight;
  3078. }
  3079. // Fixing jump error on top/left - bug #2330
  3080. if (!data.width && !data.height && !data.left && data.top) {
  3081. data.top = null;
  3082. } else if (!data.width && !data.height && !data.top && data.left) {
  3083. data.left = null;
  3084. }
  3085. return data;
  3086. },
  3087. _getPaddingPlusBorderDimensions: function( element ) {
  3088. var i = 0,
  3089. widths = [],
  3090. borders = [
  3091. element.css( "borderTopWidth" ),
  3092. element.css( "borderRightWidth" ),
  3093. element.css( "borderBottomWidth" ),
  3094. element.css( "borderLeftWidth" )
  3095. ],
  3096. paddings = [
  3097. element.css( "paddingTop" ),
  3098. element.css( "paddingRight" ),
  3099. element.css( "paddingBottom" ),
  3100. element.css( "paddingLeft" )
  3101. ];
  3102. for ( ; i < 4; i++ ) {
  3103. widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 );
  3104. widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 );
  3105. }
  3106. return {
  3107. height: widths[ 0 ] + widths[ 2 ],
  3108. width: widths[ 1 ] + widths[ 3 ]
  3109. };
  3110. },
  3111. _proportionallyResize: function() {
  3112. if (!this._proportionallyResizeElements.length) {
  3113. return;
  3114. }
  3115. var prel,
  3116. i = 0,
  3117. element = this.helper || this.element;
  3118. for ( ; i < this._proportionallyResizeElements.length; i++) {
  3119. prel = this._proportionallyResizeElements[i];
  3120. // TODO: Seems like a bug to cache this.outerDimensions
  3121. // considering that we are in a loop.
  3122. if (!this.outerDimensions) {
  3123. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  3124. }
  3125. prel.css({
  3126. height: (element.height() - this.outerDimensions.height) || 0,
  3127. width: (element.width() - this.outerDimensions.width) || 0
  3128. });
  3129. }
  3130. },
  3131. _renderProxy: function() {
  3132. var el = this.element, o = this.options;
  3133. this.elementOffset = el.offset();
  3134. if (this._helper) {
  3135. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  3136. this.helper.addClass(this._helper).css({
  3137. width: this.element.outerWidth() - 1,
  3138. height: this.element.outerHeight() - 1,
  3139. position: "absolute",
  3140. left: this.elementOffset.left + "px",
  3141. top: this.elementOffset.top + "px",
  3142. zIndex: ++o.zIndex //TODO: Don't modify option
  3143. });
  3144. this.helper
  3145. .appendTo("body")
  3146. .disableSelection();
  3147. } else {
  3148. this.helper = this.element;
  3149. }
  3150. },
  3151. _change: {
  3152. e: function(event, dx) {
  3153. return { width: this.originalSize.width + dx };
  3154. },
  3155. w: function(event, dx) {
  3156. var cs = this.originalSize, sp = this.originalPosition;
  3157. return { left: sp.left + dx, width: cs.width - dx };
  3158. },
  3159. n: function(event, dx, dy) {
  3160. var cs = this.originalSize, sp = this.originalPosition;
  3161. return { top: sp.top + dy, height: cs.height - dy };
  3162. },
  3163. s: function(event, dx, dy) {
  3164. return { height: this.originalSize.height + dy };
  3165. },
  3166. se: function(event, dx, dy) {
  3167. return $.extend(this._change.s.apply(this, arguments),
  3168. this._change.e.apply(this, [ event, dx, dy ]));
  3169. },
  3170. sw: function(event, dx, dy) {
  3171. return $.extend(this._change.s.apply(this, arguments),
  3172. this._change.w.apply(this, [ event, dx, dy ]));
  3173. },
  3174. ne: function(event, dx, dy) {
  3175. return $.extend(this._change.n.apply(this, arguments),
  3176. this._change.e.apply(this, [ event, dx, dy ]));
  3177. },
  3178. nw: function(event, dx, dy) {
  3179. return $.extend(this._change.n.apply(this, arguments),
  3180. this._change.w.apply(this, [ event, dx, dy ]));
  3181. }
  3182. },
  3183. _propagate: function(n, event) {
  3184. $.ui.plugin.call(this, n, [ event, this.ui() ]);
  3185. (n !== "resize" && this._trigger(n, event, this.ui()));
  3186. },
  3187. plugins: {},
  3188. ui: function() {
  3189. return {
  3190. originalElement: this.originalElement,
  3191. element: this.element,
  3192. helper: this.helper,
  3193. position: this.position,
  3194. size: this.size,
  3195. originalSize: this.originalSize,
  3196. originalPosition: this.originalPosition
  3197. };
  3198. }
  3199. });
  3200. /*
  3201. * Resizable Extensions
  3202. */
  3203. $.ui.plugin.add("resizable", "animate", {
  3204. stop: function( event ) {
  3205. var that = $(this).resizable( "instance" ),
  3206. o = that.options,
  3207. pr = that._proportionallyResizeElements,
  3208. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  3209. soffseth = ista && that._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height,
  3210. soffsetw = ista ? 0 : that.sizeDiff.width,
  3211. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  3212. left = (parseInt(that.element.css("left"), 10) +
  3213. (that.position.left - that.originalPosition.left)) || null,
  3214. top = (parseInt(that.element.css("top"), 10) +
  3215. (that.position.top - that.originalPosition.top)) || null;
  3216. that.element.animate(
  3217. $.extend(style, top && left ? { top: top, left: left } : {}), {
  3218. duration: o.animateDuration,
  3219. easing: o.animateEasing,
  3220. step: function() {
  3221. var data = {
  3222. width: parseInt(that.element.css("width"), 10),
  3223. height: parseInt(that.element.css("height"), 10),
  3224. top: parseInt(that.element.css("top"), 10),
  3225. left: parseInt(that.element.css("left"), 10)
  3226. };
  3227. if (pr && pr.length) {
  3228. $(pr[0]).css({ width: data.width, height: data.height });
  3229. }
  3230. // propagating resize, and updating values for each animation step
  3231. that._updateCache(data);
  3232. that._propagate("resize", event);
  3233. }
  3234. }
  3235. );
  3236. }
  3237. });
  3238. $.ui.plugin.add( "resizable", "containment", {
  3239. start: function() {
  3240. var element, p, co, ch, cw, width, height,
  3241. that = $( this ).resizable( "instance" ),
  3242. o = that.options,
  3243. el = that.element,
  3244. oc = o.containment,
  3245. ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  3246. if ( !ce ) {
  3247. return;
  3248. }
  3249. that.containerElement = $( ce );
  3250. if ( /document/.test( oc ) || oc === document ) {
  3251. that.containerOffset = {
  3252. left: 0,
  3253. top: 0
  3254. };
  3255. that.containerPosition = {
  3256. left: 0,
  3257. top: 0
  3258. };
  3259. that.parentData = {
  3260. element: $( document ),
  3261. left: 0,
  3262. top: 0,
  3263. width: $( document ).width(),
  3264. height: $( document ).height() || document.body.parentNode.scrollHeight
  3265. };
  3266. } else {
  3267. element = $( ce );
  3268. p = [];
  3269. $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {
  3270. p[ i ] = that._num( element.css( "padding" + name ) );
  3271. });
  3272. that.containerOffset = element.offset();
  3273. that.containerPosition = element.position();
  3274. that.containerSize = {
  3275. height: ( element.innerHeight() - p[ 3 ] ),
  3276. width: ( element.innerWidth() - p[ 1 ] )
  3277. };
  3278. co = that.containerOffset;
  3279. ch = that.containerSize.height;
  3280. cw = that.containerSize.width;
  3281. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  3282. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  3283. that.parentData = {
  3284. element: ce,
  3285. left: co.left,
  3286. top: co.top,
  3287. width: width,
  3288. height: height
  3289. };
  3290. }
  3291. },
  3292. resize: function( event ) {
  3293. var woset, hoset, isParent, isOffsetRelative,
  3294. that = $( this ).resizable( "instance" ),
  3295. o = that.options,
  3296. co = that.containerOffset,
  3297. cp = that.position,
  3298. pRatio = that._aspectRatio || event.shiftKey,
  3299. cop = {
  3300. top: 0,
  3301. left: 0
  3302. },
  3303. ce = that.containerElement,
  3304. continueResize = true;
  3305. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  3306. cop = co;
  3307. }
  3308. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  3309. that.size.width = that.size.width +
  3310. ( that._helper ?
  3311. ( that.position.left - co.left ) :
  3312. ( that.position.left - cop.left ) );
  3313. if ( pRatio ) {
  3314. that.size.height = that.size.width / that.aspectRatio;
  3315. continueResize = false;
  3316. }
  3317. that.position.left = o.helper ? co.left : 0;
  3318. }
  3319. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  3320. that.size.height = that.size.height +
  3321. ( that._helper ?
  3322. ( that.position.top - co.top ) :
  3323. that.position.top );
  3324. if ( pRatio ) {
  3325. that.size.width = that.size.height * that.aspectRatio;
  3326. continueResize = false;
  3327. }
  3328. that.position.top = that._helper ? co.top : 0;
  3329. }
  3330. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  3331. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  3332. if ( isParent && isOffsetRelative ) {
  3333. that.offset.left = that.parentData.left + that.position.left;
  3334. that.offset.top = that.parentData.top + that.position.top;
  3335. } else {
  3336. that.offset.left = that.element.offset().left;
  3337. that.offset.top = that.element.offset().top;
  3338. }
  3339. woset = Math.abs( that.sizeDiff.width +
  3340. (that._helper ?
  3341. that.offset.left - cop.left :
  3342. (that.offset.left - co.left)) );
  3343. hoset = Math.abs( that.sizeDiff.height +
  3344. (that._helper ?
  3345. that.offset.top - cop.top :
  3346. (that.offset.top - co.top)) );
  3347. if ( woset + that.size.width >= that.parentData.width ) {
  3348. that.size.width = that.parentData.width - woset;
  3349. if ( pRatio ) {
  3350. that.size.height = that.size.width / that.aspectRatio;
  3351. continueResize = false;
  3352. }
  3353. }
  3354. if ( hoset + that.size.height >= that.parentData.height ) {
  3355. that.size.height = that.parentData.height - hoset;
  3356. if ( pRatio ) {
  3357. that.size.width = that.size.height * that.aspectRatio;
  3358. continueResize = false;
  3359. }
  3360. }
  3361. if ( !continueResize ) {
  3362. that.position.left = that.prevPosition.left;
  3363. that.position.top = that.prevPosition.top;
  3364. that.size.width = that.prevSize.width;
  3365. that.size.height = that.prevSize.height;
  3366. }
  3367. },
  3368. stop: function() {
  3369. var that = $( this ).resizable( "instance" ),
  3370. o = that.options,
  3371. co = that.containerOffset,
  3372. cop = that.containerPosition,
  3373. ce = that.containerElement,
  3374. helper = $( that.helper ),
  3375. ho = helper.offset(),
  3376. w = helper.outerWidth() - that.sizeDiff.width,
  3377. h = helper.outerHeight() - that.sizeDiff.height;
  3378. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  3379. $( this ).css({
  3380. left: ho.left - cop.left - co.left,
  3381. width: w,
  3382. height: h
  3383. });
  3384. }
  3385. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  3386. $( this ).css({
  3387. left: ho.left - cop.left - co.left,
  3388. width: w,
  3389. height: h
  3390. });
  3391. }
  3392. }
  3393. });
  3394. $.ui.plugin.add("resizable", "alsoResize", {
  3395. start: function() {
  3396. var that = $(this).resizable( "instance" ),
  3397. o = that.options;
  3398. $(o.alsoResize).each(function() {
  3399. var el = $(this);
  3400. el.data("ui-resizable-alsoresize", {
  3401. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  3402. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  3403. });
  3404. });
  3405. },
  3406. resize: function(event, ui) {
  3407. var that = $(this).resizable( "instance" ),
  3408. o = that.options,
  3409. os = that.originalSize,
  3410. op = that.originalPosition,
  3411. delta = {
  3412. height: (that.size.height - os.height) || 0,
  3413. width: (that.size.width - os.width) || 0,
  3414. top: (that.position.top - op.top) || 0,
  3415. left: (that.position.left - op.left) || 0
  3416. };
  3417. $(o.alsoResize).each(function() {
  3418. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  3419. css = el.parents(ui.originalElement[0]).length ?
  3420. [ "width", "height" ] :
  3421. [ "width", "height", "top", "left" ];
  3422. $.each(css, function(i, prop) {
  3423. var sum = (start[prop] || 0) + (delta[prop] || 0);
  3424. if (sum && sum >= 0) {
  3425. style[prop] = sum || null;
  3426. }
  3427. });
  3428. el.css(style);
  3429. });
  3430. },
  3431. stop: function() {
  3432. $(this).removeData("resizable-alsoresize");
  3433. }
  3434. });
  3435. $.ui.plugin.add("resizable", "ghost", {
  3436. start: function() {
  3437. var that = $(this).resizable( "instance" ), o = that.options, cs = that.size;
  3438. that.ghost = that.originalElement.clone();
  3439. that.ghost
  3440. .css({
  3441. opacity: 0.25,
  3442. display: "block",
  3443. position: "relative",
  3444. height: cs.height,
  3445. width: cs.width,
  3446. margin: 0,
  3447. left: 0,
  3448. top: 0
  3449. })
  3450. .addClass("ui-resizable-ghost")
  3451. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  3452. that.ghost.appendTo(that.helper);
  3453. },
  3454. resize: function() {
  3455. var that = $(this).resizable( "instance" );
  3456. if (that.ghost) {
  3457. that.ghost.css({
  3458. position: "relative",
  3459. height: that.size.height,
  3460. width: that.size.width
  3461. });
  3462. }
  3463. },
  3464. stop: function() {
  3465. var that = $(this).resizable( "instance" );
  3466. if (that.ghost && that.helper) {
  3467. that.helper.get(0).removeChild(that.ghost.get(0));
  3468. }
  3469. }
  3470. });
  3471. $.ui.plugin.add("resizable", "grid", {
  3472. resize: function() {
  3473. var outerDimensions,
  3474. that = $(this).resizable( "instance" ),
  3475. o = that.options,
  3476. cs = that.size,
  3477. os = that.originalSize,
  3478. op = that.originalPosition,
  3479. a = that.axis,
  3480. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  3481. gridX = (grid[0] || 1),
  3482. gridY = (grid[1] || 1),
  3483. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  3484. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  3485. newWidth = os.width + ox,
  3486. newHeight = os.height + oy,
  3487. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  3488. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  3489. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  3490. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  3491. o.grid = grid;
  3492. if (isMinWidth) {
  3493. newWidth += gridX;
  3494. }
  3495. if (isMinHeight) {
  3496. newHeight += gridY;
  3497. }
  3498. if (isMaxWidth) {
  3499. newWidth -= gridX;
  3500. }
  3501. if (isMaxHeight) {
  3502. newHeight -= gridY;
  3503. }
  3504. if (/^(se|s|e)$/.test(a)) {
  3505. that.size.width = newWidth;
  3506. that.size.height = newHeight;
  3507. } else if (/^(ne)$/.test(a)) {
  3508. that.size.width = newWidth;
  3509. that.size.height = newHeight;
  3510. that.position.top = op.top - oy;
  3511. } else if (/^(sw)$/.test(a)) {
  3512. that.size.width = newWidth;
  3513. that.size.height = newHeight;
  3514. that.position.left = op.left - ox;
  3515. } else {
  3516. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) {
  3517. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  3518. }
  3519. if ( newHeight - gridY > 0 ) {
  3520. that.size.height = newHeight;
  3521. that.position.top = op.top - oy;
  3522. } else {
  3523. newHeight = gridY - outerDimensions.height;
  3524. that.size.height = newHeight;
  3525. that.position.top = op.top + os.height - newHeight;
  3526. }
  3527. if ( newWidth - gridX > 0 ) {
  3528. that.size.width = newWidth;
  3529. that.position.left = op.left - ox;
  3530. } else {
  3531. newWidth = gridX - outerDimensions.width;
  3532. that.size.width = newWidth;
  3533. that.position.left = op.left + os.width - newWidth;
  3534. }
  3535. }
  3536. }
  3537. });
  3538. var resizable = $.ui.resizable;
  3539. /*!
  3540. * jQuery UI Selectable 1.11.4
  3541. * http://jqueryui.com
  3542. *
  3543. * Copyright jQuery Foundation and other contributors
  3544. * Released under the MIT license.
  3545. * http://jquery.org/license
  3546. *
  3547. * http://api.jqueryui.com/selectable/
  3548. */
  3549. var selectable = $.widget("ui.selectable", $.ui.mouse, {
  3550. version: "1.11.4",
  3551. options: {
  3552. appendTo: "body",
  3553. autoRefresh: true,
  3554. distance: 0,
  3555. filter: "*",
  3556. tolerance: "touch",
  3557. // callbacks
  3558. selected: null,
  3559. selecting: null,
  3560. start: null,
  3561. stop: null,
  3562. unselected: null,
  3563. unselecting: null
  3564. },
  3565. _create: function() {
  3566. var selectees,
  3567. that = this;
  3568. this.element.addClass("ui-selectable");
  3569. this.dragged = false;
  3570. // cache selectee children based on filter
  3571. this.refresh = function() {
  3572. selectees = $(that.options.filter, that.element[0]);
  3573. selectees.addClass("ui-selectee");
  3574. selectees.each(function() {
  3575. var $this = $(this),
  3576. pos = $this.offset();
  3577. $.data(this, "selectable-item", {
  3578. element: this,
  3579. $element: $this,
  3580. left: pos.left,
  3581. top: pos.top,
  3582. right: pos.left + $this.outerWidth(),
  3583. bottom: pos.top + $this.outerHeight(),
  3584. startselected: false,
  3585. selected: $this.hasClass("ui-selected"),
  3586. selecting: $this.hasClass("ui-selecting"),
  3587. unselecting: $this.hasClass("ui-unselecting")
  3588. });
  3589. });
  3590. };
  3591. this.refresh();
  3592. this.selectees = selectees.addClass("ui-selectee");
  3593. this._mouseInit();
  3594. this.helper = $("<div class='ui-selectable-helper'></div>");
  3595. },
  3596. _destroy: function() {
  3597. this.selectees
  3598. .removeClass("ui-selectee")
  3599. .removeData("selectable-item");
  3600. this.element
  3601. .removeClass("ui-selectable ui-selectable-disabled");
  3602. this._mouseDestroy();
  3603. },
  3604. _mouseStart: function(event) {
  3605. var that = this,
  3606. options = this.options;
  3607. this.opos = [ event.pageX, event.pageY ];
  3608. if (this.options.disabled) {
  3609. return;
  3610. }
  3611. this.selectees = $(options.filter, this.element[0]);
  3612. this._trigger("start", event);
  3613. $(options.appendTo).append(this.helper);
  3614. // position helper (lasso)
  3615. this.helper.css({
  3616. "left": event.pageX,
  3617. "top": event.pageY,
  3618. "width": 0,
  3619. "height": 0
  3620. });
  3621. if (options.autoRefresh) {
  3622. this.refresh();
  3623. }
  3624. this.selectees.filter(".ui-selected").each(function() {
  3625. var selectee = $.data(this, "selectable-item");
  3626. selectee.startselected = true;
  3627. if (!event.metaKey && !event.ctrlKey) {
  3628. selectee.$element.removeClass("ui-selected");
  3629. selectee.selected = false;
  3630. selectee.$element.addClass("ui-unselecting");
  3631. selectee.unselecting = true;
  3632. // selectable UNSELECTING callback
  3633. that._trigger("unselecting", event, {
  3634. unselecting: selectee.element
  3635. });
  3636. }
  3637. });
  3638. $(event.target).parents().addBack().each(function() {
  3639. var doSelect,
  3640. selectee = $.data(this, "selectable-item");
  3641. if (selectee) {
  3642. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  3643. selectee.$element
  3644. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  3645. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  3646. selectee.unselecting = !doSelect;
  3647. selectee.selecting = doSelect;
  3648. selectee.selected = doSelect;
  3649. // selectable (UN)SELECTING callback
  3650. if (doSelect) {
  3651. that._trigger("selecting", event, {
  3652. selecting: selectee.element
  3653. });
  3654. } else {
  3655. that._trigger("unselecting", event, {
  3656. unselecting: selectee.element
  3657. });
  3658. }
  3659. return false;
  3660. }
  3661. });
  3662. },
  3663. _mouseDrag: function(event) {
  3664. this.dragged = true;
  3665. if (this.options.disabled) {
  3666. return;
  3667. }
  3668. var tmp,
  3669. that = this,
  3670. options = this.options,
  3671. x1 = this.opos[0],
  3672. y1 = this.opos[1],
  3673. x2 = event.pageX,
  3674. y2 = event.pageY;
  3675. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  3676. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  3677. this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });
  3678. this.selectees.each(function() {
  3679. var selectee = $.data(this, "selectable-item"),
  3680. hit = false;
  3681. //prevent helper from being selected if appendTo: selectable
  3682. if (!selectee || selectee.element === that.element[0]) {
  3683. return;
  3684. }
  3685. if (options.tolerance === "touch") {
  3686. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  3687. } else if (options.tolerance === "fit") {
  3688. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  3689. }
  3690. if (hit) {
  3691. // SELECT
  3692. if (selectee.selected) {
  3693. selectee.$element.removeClass("ui-selected");
  3694. selectee.selected = false;
  3695. }
  3696. if (selectee.unselecting) {
  3697. selectee.$element.removeClass("ui-unselecting");
  3698. selectee.unselecting = false;
  3699. }
  3700. if (!selectee.selecting) {
  3701. selectee.$element.addClass("ui-selecting");
  3702. selectee.selecting = true;
  3703. // selectable SELECTING callback
  3704. that._trigger("selecting", event, {
  3705. selecting: selectee.element
  3706. });
  3707. }
  3708. } else {
  3709. // UNSELECT
  3710. if (selectee.selecting) {
  3711. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  3712. selectee.$element.removeClass("ui-selecting");
  3713. selectee.selecting = false;
  3714. selectee.$element.addClass("ui-selected");
  3715. selectee.selected = true;
  3716. } else {
  3717. selectee.$element.removeClass("ui-selecting");
  3718. selectee.selecting = false;
  3719. if (selectee.startselected) {
  3720. selectee.$element.addClass("ui-unselecting");
  3721. selectee.unselecting = true;
  3722. }
  3723. // selectable UNSELECTING callback
  3724. that._trigger("unselecting", event, {
  3725. unselecting: selectee.element
  3726. });
  3727. }
  3728. }
  3729. if (selectee.selected) {
  3730. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  3731. selectee.$element.removeClass("ui-selected");
  3732. selectee.selected = false;
  3733. selectee.$element.addClass("ui-unselecting");
  3734. selectee.unselecting = true;
  3735. // selectable UNSELECTING callback
  3736. that._trigger("unselecting", event, {
  3737. unselecting: selectee.element
  3738. });
  3739. }
  3740. }
  3741. }
  3742. });
  3743. return false;
  3744. },
  3745. _mouseStop: function(event) {
  3746. var that = this;
  3747. this.dragged = false;
  3748. $(".ui-unselecting", this.element[0]).each(function() {
  3749. var selectee = $.data(this, "selectable-item");
  3750. selectee.$element.removeClass("ui-unselecting");
  3751. selectee.unselecting = false;
  3752. selectee.startselected = false;
  3753. that._trigger("unselected", event, {
  3754. unselected: selectee.element
  3755. });
  3756. });
  3757. $(".ui-selecting", this.element[0]).each(function() {
  3758. var selectee = $.data(this, "selectable-item");
  3759. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  3760. selectee.selecting = false;
  3761. selectee.selected = true;
  3762. selectee.startselected = true;
  3763. that._trigger("selected", event, {
  3764. selected: selectee.element
  3765. });
  3766. });
  3767. this._trigger("stop", event);
  3768. this.helper.remove();
  3769. return false;
  3770. }
  3771. });
  3772. /*!
  3773. * jQuery UI Sortable 1.11.4
  3774. * http://jqueryui.com
  3775. *
  3776. * Copyright jQuery Foundation and other contributors
  3777. * Released under the MIT license.
  3778. * http://jquery.org/license
  3779. *
  3780. * http://api.jqueryui.com/sortable/
  3781. */
  3782. var sortable = $.widget("ui.sortable", $.ui.mouse, {
  3783. version: "1.11.4",
  3784. widgetEventPrefix: "sort",
  3785. ready: false,
  3786. options: {
  3787. appendTo: "parent",
  3788. axis: false,
  3789. connectWith: false,
  3790. containment: false,
  3791. cursor: "auto",
  3792. cursorAt: false,
  3793. dropOnEmpty: true,
  3794. forcePlaceholderSize: false,
  3795. forceHelperSize: false,
  3796. grid: false,
  3797. handle: false,
  3798. helper: "original",
  3799. items: "> *",
  3800. opacity: false,
  3801. placeholder: false,
  3802. revert: false,
  3803. scroll: true,
  3804. scrollSensitivity: 20,
  3805. scrollSpeed: 20,
  3806. scope: "default",
  3807. tolerance: "intersect",
  3808. zIndex: 1000,
  3809. // callbacks
  3810. activate: null,
  3811. beforeStop: null,
  3812. change: null,
  3813. deactivate: null,
  3814. out: null,
  3815. over: null,
  3816. receive: null,
  3817. remove: null,
  3818. sort: null,
  3819. start: null,
  3820. stop: null,
  3821. update: null
  3822. },
  3823. _isOverAxis: function( x, reference, size ) {
  3824. return ( x >= reference ) && ( x < ( reference + size ) );
  3825. },
  3826. _isFloating: function( item ) {
  3827. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  3828. },
  3829. _create: function() {
  3830. this.containerCache = {};
  3831. this.element.addClass("ui-sortable");
  3832. //Get the items
  3833. this.refresh();
  3834. //Let's determine the parent's offset
  3835. this.offset = this.element.offset();
  3836. //Initialize mouse events for interaction
  3837. this._mouseInit();
  3838. this._setHandleClassName();
  3839. //We're ready to go
  3840. this.ready = true;
  3841. },
  3842. _setOption: function( key, value ) {
  3843. this._super( key, value );
  3844. if ( key === "handle" ) {
  3845. this._setHandleClassName();
  3846. }
  3847. },
  3848. _setHandleClassName: function() {
  3849. this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" );
  3850. $.each( this.items, function() {
  3851. ( this.instance.options.handle ?
  3852. this.item.find( this.instance.options.handle ) : this.item )
  3853. .addClass( "ui-sortable-handle" );
  3854. });
  3855. },
  3856. _destroy: function() {
  3857. this.element
  3858. .removeClass( "ui-sortable ui-sortable-disabled" )
  3859. .find( ".ui-sortable-handle" )
  3860. .removeClass( "ui-sortable-handle" );
  3861. this._mouseDestroy();
  3862. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  3863. this.items[i].item.removeData(this.widgetName + "-item");
  3864. }
  3865. return this;
  3866. },
  3867. _mouseCapture: function(event, overrideHandle) {
  3868. var currentItem = null,
  3869. validHandle = false,
  3870. that = this;
  3871. if (this.reverting) {
  3872. return false;
  3873. }
  3874. if(this.options.disabled || this.options.type === "static") {
  3875. return false;
  3876. }
  3877. //We have to refresh the items data once first
  3878. this._refreshItems(event);
  3879. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  3880. $(event.target).parents().each(function() {
  3881. if($.data(this, that.widgetName + "-item") === that) {
  3882. currentItem = $(this);
  3883. return false;
  3884. }
  3885. });
  3886. if($.data(event.target, that.widgetName + "-item") === that) {
  3887. currentItem = $(event.target);
  3888. }
  3889. if(!currentItem) {
  3890. return false;
  3891. }
  3892. if(this.options.handle && !overrideHandle) {
  3893. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  3894. if(this === event.target) {
  3895. validHandle = true;
  3896. }
  3897. });
  3898. if(!validHandle) {
  3899. return false;
  3900. }
  3901. }
  3902. this.currentItem = currentItem;
  3903. this._removeCurrentsFromItems();
  3904. return true;
  3905. },
  3906. _mouseStart: function(event, overrideHandle, noActivation) {
  3907. var i, body,
  3908. o = this.options;
  3909. this.currentContainer = this;
  3910. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3911. this.refreshPositions();
  3912. //Create and append the visible helper
  3913. this.helper = this._createHelper(event);
  3914. //Cache the helper size
  3915. this._cacheHelperProportions();
  3916. /*
  3917. * - Position generation -
  3918. * This block generates everything position related - it's the core of draggables.
  3919. */
  3920. //Cache the margins of the original element
  3921. this._cacheMargins();
  3922. //Get the next scrolling parent
  3923. this.scrollParent = this.helper.scrollParent();
  3924. //The element's absolute position on the page minus margins
  3925. this.offset = this.currentItem.offset();
  3926. this.offset = {
  3927. top: this.offset.top - this.margins.top,
  3928. left: this.offset.left - this.margins.left
  3929. };
  3930. $.extend(this.offset, {
  3931. click: { //Where the click happened, relative to the element
  3932. left: event.pageX - this.offset.left,
  3933. top: event.pageY - this.offset.top
  3934. },
  3935. parent: this._getParentOffset(),
  3936. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3937. });
  3938. // Only after we got the offset, we can change the helper's position to absolute
  3939. // TODO: Still need to figure out a way to make relative sorting possible
  3940. this.helper.css("position", "absolute");
  3941. this.cssPosition = this.helper.css("position");
  3942. //Generate the original position
  3943. this.originalPosition = this._generatePosition(event);
  3944. this.originalPageX = event.pageX;
  3945. this.originalPageY = event.pageY;
  3946. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3947. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3948. //Cache the former DOM position
  3949. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3950. //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
  3951. if(this.helper[0] !== this.currentItem[0]) {
  3952. this.currentItem.hide();
  3953. }
  3954. //Create the placeholder
  3955. this._createPlaceholder();
  3956. //Set a containment if given in the options
  3957. if(o.containment) {
  3958. this._setContainment();
  3959. }
  3960. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  3961. body = this.document.find( "body" );
  3962. // support: IE
  3963. this.storedCursor = body.css( "cursor" );
  3964. body.css( "cursor", o.cursor );
  3965. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  3966. }
  3967. if(o.opacity) { // opacity option
  3968. if (this.helper.css("opacity")) {
  3969. this._storedOpacity = this.helper.css("opacity");
  3970. }
  3971. this.helper.css("opacity", o.opacity);
  3972. }
  3973. if(o.zIndex) { // zIndex option
  3974. if (this.helper.css("zIndex")) {
  3975. this._storedZIndex = this.helper.css("zIndex");
  3976. }
  3977. this.helper.css("zIndex", o.zIndex);
  3978. }
  3979. //Prepare scrolling
  3980. if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
  3981. this.overflowOffset = this.scrollParent.offset();
  3982. }
  3983. //Call callbacks
  3984. this._trigger("start", event, this._uiHash());
  3985. //Recache the helper size
  3986. if(!this._preserveHelperProportions) {
  3987. this._cacheHelperProportions();
  3988. }
  3989. //Post "activate" events to possible containers
  3990. if( !noActivation ) {
  3991. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  3992. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  3993. }
  3994. }
  3995. //Prepare possible droppables
  3996. if($.ui.ddmanager) {
  3997. $.ui.ddmanager.current = this;
  3998. }
  3999. if ($.ui.ddmanager && !o.dropBehaviour) {
  4000. $.ui.ddmanager.prepareOffsets(this, event);
  4001. }
  4002. this.dragging = true;
  4003. this.helper.addClass("ui-sortable-helper");
  4004. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  4005. return true;
  4006. },
  4007. _mouseDrag: function(event) {
  4008. var i, item, itemElement, intersection,
  4009. o = this.options,
  4010. scrolled = false;
  4011. //Compute the helpers position
  4012. this.position = this._generatePosition(event);
  4013. this.positionAbs = this._convertPositionTo("absolute");
  4014. if (!this.lastPositionAbs) {
  4015. this.lastPositionAbs = this.positionAbs;
  4016. }
  4017. //Do scrolling
  4018. if(this.options.scroll) {
  4019. if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
  4020. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  4021. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  4022. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  4023. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  4024. }
  4025. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  4026. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  4027. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  4028. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  4029. }
  4030. } else {
  4031. if(event.pageY - this.document.scrollTop() < o.scrollSensitivity) {
  4032. scrolled = this.document.scrollTop(this.document.scrollTop() - o.scrollSpeed);
  4033. } else if(this.window.height() - (event.pageY - this.document.scrollTop()) < o.scrollSensitivity) {
  4034. scrolled = this.document.scrollTop(this.document.scrollTop() + o.scrollSpeed);
  4035. }
  4036. if(event.pageX - this.document.scrollLeft() < o.scrollSensitivity) {
  4037. scrolled = this.document.scrollLeft(this.document.scrollLeft() - o.scrollSpeed);
  4038. } else if(this.window.width() - (event.pageX - this.document.scrollLeft()) < o.scrollSensitivity) {
  4039. scrolled = this.document.scrollLeft(this.document.scrollLeft() + o.scrollSpeed);
  4040. }
  4041. }
  4042. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  4043. $.ui.ddmanager.prepareOffsets(this, event);
  4044. }
  4045. }
  4046. //Regenerate the absolute position used for position checks
  4047. this.positionAbs = this._convertPositionTo("absolute");
  4048. //Set the helper position
  4049. if(!this.options.axis || this.options.axis !== "y") {
  4050. this.helper[0].style.left = this.position.left+"px";
  4051. }
  4052. if(!this.options.axis || this.options.axis !== "x") {
  4053. this.helper[0].style.top = this.position.top+"px";
  4054. }
  4055. //Rearrange
  4056. for (i = this.items.length - 1; i >= 0; i--) {
  4057. //Cache variables and intersection, continue if no intersection
  4058. item = this.items[i];
  4059. itemElement = item.item[0];
  4060. intersection = this._intersectsWithPointer(item);
  4061. if (!intersection) {
  4062. continue;
  4063. }
  4064. // Only put the placeholder inside the current Container, skip all
  4065. // items from other containers. This works because when moving
  4066. // an item from one container to another the
  4067. // currentContainer is switched before the placeholder is moved.
  4068. //
  4069. // Without this, moving items in "sub-sortables" can cause
  4070. // the placeholder to jitter between the outer and inner container.
  4071. if (item.instance !== this.currentContainer) {
  4072. continue;
  4073. }
  4074. // cannot intersect with itself
  4075. // no useless actions that have been done before
  4076. // no action if the item moved is the parent of the item checked
  4077. if (itemElement !== this.currentItem[0] &&
  4078. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  4079. !$.contains(this.placeholder[0], itemElement) &&
  4080. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  4081. ) {
  4082. this.direction = intersection === 1 ? "down" : "up";
  4083. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  4084. this._rearrange(event, item);
  4085. } else {
  4086. break;
  4087. }
  4088. this._trigger("change", event, this._uiHash());
  4089. break;
  4090. }
  4091. }
  4092. //Post events to containers
  4093. this._contactContainers(event);
  4094. //Interconnect with droppables
  4095. if($.ui.ddmanager) {
  4096. $.ui.ddmanager.drag(this, event);
  4097. }
  4098. //Call callbacks
  4099. this._trigger("sort", event, this._uiHash());
  4100. this.lastPositionAbs = this.positionAbs;
  4101. return false;
  4102. },
  4103. _mouseStop: function(event, noPropagation) {
  4104. if(!event) {
  4105. return;
  4106. }
  4107. //If we are using droppables, inform the manager about the drop
  4108. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  4109. $.ui.ddmanager.drop(this, event);
  4110. }
  4111. if(this.options.revert) {
  4112. var that = this,
  4113. cur = this.placeholder.offset(),
  4114. axis = this.options.axis,
  4115. animation = {};
  4116. if ( !axis || axis === "x" ) {
  4117. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollLeft);
  4118. }
  4119. if ( !axis || axis === "y" ) {
  4120. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollTop);
  4121. }
  4122. this.reverting = true;
  4123. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  4124. that._clear(event);
  4125. });
  4126. } else {
  4127. this._clear(event, noPropagation);
  4128. }
  4129. return false;
  4130. },
  4131. cancel: function() {
  4132. if(this.dragging) {
  4133. this._mouseUp({ target: null });
  4134. if(this.options.helper === "original") {
  4135. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  4136. } else {
  4137. this.currentItem.show();
  4138. }
  4139. //Post deactivating events to containers
  4140. for (var i = this.containers.length - 1; i >= 0; i--){
  4141. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  4142. if(this.containers[i].containerCache.over) {
  4143. this.containers[i]._trigger("out", null, this._uiHash(this));
  4144. this.containers[i].containerCache.over = 0;
  4145. }
  4146. }
  4147. }
  4148. if (this.placeholder) {
  4149. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  4150. if(this.placeholder[0].parentNode) {
  4151. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  4152. }
  4153. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  4154. this.helper.remove();
  4155. }
  4156. $.extend(this, {
  4157. helper: null,
  4158. dragging: false,
  4159. reverting: false,
  4160. _noFinalSort: null
  4161. });
  4162. if(this.domPosition.prev) {
  4163. $(this.domPosition.prev).after(this.currentItem);
  4164. } else {
  4165. $(this.domPosition.parent).prepend(this.currentItem);
  4166. }
  4167. }
  4168. return this;
  4169. },
  4170. serialize: function(o) {
  4171. var items = this._getItemsAsjQuery(o && o.connected),
  4172. str = [];
  4173. o = o || {};
  4174. $(items).each(function() {
  4175. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  4176. if (res) {
  4177. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  4178. }
  4179. });
  4180. if(!str.length && o.key) {
  4181. str.push(o.key + "=");
  4182. }
  4183. return str.join("&");
  4184. },
  4185. toArray: function(o) {
  4186. var items = this._getItemsAsjQuery(o && o.connected),
  4187. ret = [];
  4188. o = o || {};
  4189. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  4190. return ret;
  4191. },
  4192. /* Be careful with the following core functions */
  4193. _intersectsWith: function(item) {
  4194. var x1 = this.positionAbs.left,
  4195. x2 = x1 + this.helperProportions.width,
  4196. y1 = this.positionAbs.top,
  4197. y2 = y1 + this.helperProportions.height,
  4198. l = item.left,
  4199. r = l + item.width,
  4200. t = item.top,
  4201. b = t + item.height,
  4202. dyClick = this.offset.click.top,
  4203. dxClick = this.offset.click.left,
  4204. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  4205. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  4206. isOverElement = isOverElementHeight && isOverElementWidth;
  4207. if ( this.options.tolerance === "pointer" ||
  4208. this.options.forcePointerForContainers ||
  4209. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  4210. ) {
  4211. return isOverElement;
  4212. } else {
  4213. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  4214. x2 - (this.helperProportions.width / 2) < r && // Left Half
  4215. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  4216. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  4217. }
  4218. },
  4219. _intersectsWithPointer: function(item) {
  4220. var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  4221. isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  4222. isOverElement = isOverElementHeight && isOverElementWidth,
  4223. verticalDirection = this._getDragVerticalDirection(),
  4224. horizontalDirection = this._getDragHorizontalDirection();
  4225. if (!isOverElement) {
  4226. return false;
  4227. }
  4228. return this.floating ?
  4229. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  4230. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  4231. },
  4232. _intersectsWithSides: function(item) {
  4233. var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  4234. isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  4235. verticalDirection = this._getDragVerticalDirection(),
  4236. horizontalDirection = this._getDragHorizontalDirection();
  4237. if (this.floating && horizontalDirection) {
  4238. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  4239. } else {
  4240. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  4241. }
  4242. },
  4243. _getDragVerticalDirection: function() {
  4244. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  4245. return delta !== 0 && (delta > 0 ? "down" : "up");
  4246. },
  4247. _getDragHorizontalDirection: function() {
  4248. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  4249. return delta !== 0 && (delta > 0 ? "right" : "left");
  4250. },
  4251. refresh: function(event) {
  4252. this._refreshItems(event);
  4253. this._setHandleClassName();
  4254. this.refreshPositions();
  4255. return this;
  4256. },
  4257. _connectWith: function() {
  4258. var options = this.options;
  4259. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  4260. },
  4261. _getItemsAsjQuery: function(connected) {
  4262. var i, j, cur, inst,
  4263. items = [],
  4264. queries = [],
  4265. connectWith = this._connectWith();
  4266. if(connectWith && connected) {
  4267. for (i = connectWith.length - 1; i >= 0; i--){
  4268. cur = $(connectWith[i], this.document[0]);
  4269. for ( j = cur.length - 1; j >= 0; j--){
  4270. inst = $.data(cur[j], this.widgetFullName);
  4271. if(inst && inst !== this && !inst.options.disabled) {
  4272. 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]);
  4273. }
  4274. }
  4275. }
  4276. }
  4277. 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]);
  4278. function addItems() {
  4279. items.push( this );
  4280. }
  4281. for (i = queries.length - 1; i >= 0; i--){
  4282. queries[i][0].each( addItems );
  4283. }
  4284. return $(items);
  4285. },
  4286. _removeCurrentsFromItems: function() {
  4287. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  4288. this.items = $.grep(this.items, function (item) {
  4289. for (var j=0; j < list.length; j++) {
  4290. if(list[j] === item.item[0]) {
  4291. return false;
  4292. }
  4293. }
  4294. return true;
  4295. });
  4296. },
  4297. _refreshItems: function(event) {
  4298. this.items = [];
  4299. this.containers = [this];
  4300. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  4301. items = this.items,
  4302. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  4303. connectWith = this._connectWith();
  4304. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  4305. for (i = connectWith.length - 1; i >= 0; i--){
  4306. cur = $(connectWith[i], this.document[0]);
  4307. for (j = cur.length - 1; j >= 0; j--){
  4308. inst = $.data(cur[j], this.widgetFullName);
  4309. if(inst && inst !== this && !inst.options.disabled) {
  4310. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  4311. this.containers.push(inst);
  4312. }
  4313. }
  4314. }
  4315. }
  4316. for (i = queries.length - 1; i >= 0; i--) {
  4317. targetData = queries[i][1];
  4318. _queries = queries[i][0];
  4319. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  4320. item = $(_queries[j]);
  4321. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  4322. items.push({
  4323. item: item,
  4324. instance: targetData,
  4325. width: 0, height: 0,
  4326. left: 0, top: 0
  4327. });
  4328. }
  4329. }
  4330. },
  4331. refreshPositions: function(fast) {
  4332. // Determine whether items are being displayed horizontally
  4333. this.floating = this.items.length ?
  4334. this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
  4335. false;
  4336. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  4337. if(this.offsetParent && this.helper) {
  4338. this.offset.parent = this._getParentOffset();
  4339. }
  4340. var i, item, t, p;
  4341. for (i = this.items.length - 1; i >= 0; i--){
  4342. item = this.items[i];
  4343. //We ignore calculating positions of all connected containers when we're not over them
  4344. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  4345. continue;
  4346. }
  4347. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  4348. if (!fast) {
  4349. item.width = t.outerWidth();
  4350. item.height = t.outerHeight();
  4351. }
  4352. p = t.offset();
  4353. item.left = p.left;
  4354. item.top = p.top;
  4355. }
  4356. if(this.options.custom && this.options.custom.refreshContainers) {
  4357. this.options.custom.refreshContainers.call(this);
  4358. } else {
  4359. for (i = this.containers.length - 1; i >= 0; i--){
  4360. p = this.containers[i].element.offset();
  4361. this.containers[i].containerCache.left = p.left;
  4362. this.containers[i].containerCache.top = p.top;
  4363. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  4364. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  4365. }
  4366. }
  4367. return this;
  4368. },
  4369. _createPlaceholder: function(that) {
  4370. that = that || this;
  4371. var className,
  4372. o = that.options;
  4373. if(!o.placeholder || o.placeholder.constructor === String) {
  4374. className = o.placeholder;
  4375. o.placeholder = {
  4376. element: function() {
  4377. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  4378. element = $( "<" + nodeName + ">", that.document[0] )
  4379. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  4380. .removeClass("ui-sortable-helper");
  4381. if ( nodeName === "tbody" ) {
  4382. that._createTrPlaceholder(
  4383. that.currentItem.find( "tr" ).eq( 0 ),
  4384. $( "<tr>", that.document[ 0 ] ).appendTo( element )
  4385. );
  4386. } else if ( nodeName === "tr" ) {
  4387. that._createTrPlaceholder( that.currentItem, element );
  4388. } else if ( nodeName === "img" ) {
  4389. element.attr( "src", that.currentItem.attr( "src" ) );
  4390. }
  4391. if ( !className ) {
  4392. element.css( "visibility", "hidden" );
  4393. }
  4394. return element;
  4395. },
  4396. update: function(container, p) {
  4397. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  4398. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  4399. if(className && !o.forcePlaceholderSize) {
  4400. return;
  4401. }
  4402. //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
  4403. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  4404. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  4405. }
  4406. };
  4407. }
  4408. //Create the placeholder
  4409. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  4410. //Append it after the actual current item
  4411. that.currentItem.after(that.placeholder);
  4412. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  4413. o.placeholder.update(that, that.placeholder);
  4414. },
  4415. _createTrPlaceholder: function( sourceTr, targetTr ) {
  4416. var that = this;
  4417. sourceTr.children().each(function() {
  4418. $( "<td>&#160;</td>", that.document[ 0 ] )
  4419. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  4420. .appendTo( targetTr );
  4421. });
  4422. },
  4423. _contactContainers: function(event) {
  4424. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
  4425. innermostContainer = null,
  4426. innermostIndex = null;
  4427. // get innermost container that intersects with item
  4428. for (i = this.containers.length - 1; i >= 0; i--) {
  4429. // never consider a container that's located within the item itself
  4430. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  4431. continue;
  4432. }
  4433. if(this._intersectsWith(this.containers[i].containerCache)) {
  4434. // if we've already found a container and it's more "inner" than this, then continue
  4435. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  4436. continue;
  4437. }
  4438. innermostContainer = this.containers[i];
  4439. innermostIndex = i;
  4440. } else {
  4441. // container doesn't intersect. trigger "out" event if necessary
  4442. if(this.containers[i].containerCache.over) {
  4443. this.containers[i]._trigger("out", event, this._uiHash(this));
  4444. this.containers[i].containerCache.over = 0;
  4445. }
  4446. }
  4447. }
  4448. // if no intersecting containers found, return
  4449. if(!innermostContainer) {
  4450. return;
  4451. }
  4452. // move the item into the container if it's not there already
  4453. if(this.containers.length === 1) {
  4454. if (!this.containers[innermostIndex].containerCache.over) {
  4455. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4456. this.containers[innermostIndex].containerCache.over = 1;
  4457. }
  4458. } else {
  4459. //When entering a new container, we will find the item with the least distance and append our item near it
  4460. dist = 10000;
  4461. itemWithLeastDistance = null;
  4462. floating = innermostContainer.floating || this._isFloating(this.currentItem);
  4463. posProperty = floating ? "left" : "top";
  4464. sizeProperty = floating ? "width" : "height";
  4465. axis = floating ? "clientX" : "clientY";
  4466. for (j = this.items.length - 1; j >= 0; j--) {
  4467. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  4468. continue;
  4469. }
  4470. if(this.items[j].item[0] === this.currentItem[0]) {
  4471. continue;
  4472. }
  4473. cur = this.items[j].item.offset()[posProperty];
  4474. nearBottom = false;
  4475. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  4476. nearBottom = true;
  4477. }
  4478. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  4479. dist = Math.abs( event[ axis ] - cur );
  4480. itemWithLeastDistance = this.items[ j ];
  4481. this.direction = nearBottom ? "up": "down";
  4482. }
  4483. }
  4484. //Check if dropOnEmpty is enabled
  4485. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  4486. return;
  4487. }
  4488. if(this.currentContainer === this.containers[innermostIndex]) {
  4489. if ( !this.currentContainer.containerCache.over ) {
  4490. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  4491. this.currentContainer.containerCache.over = 1;
  4492. }
  4493. return;
  4494. }
  4495. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  4496. this._trigger("change", event, this._uiHash());
  4497. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  4498. this.currentContainer = this.containers[innermostIndex];
  4499. //Update the placeholder
  4500. this.options.placeholder.update(this.currentContainer, this.placeholder);
  4501. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4502. this.containers[innermostIndex].containerCache.over = 1;
  4503. }
  4504. },
  4505. _createHelper: function(event) {
  4506. var o = this.options,
  4507. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  4508. //Add the helper to the DOM if that didn't happen already
  4509. if(!helper.parents("body").length) {
  4510. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  4511. }
  4512. if(helper[0] === this.currentItem[0]) {
  4513. 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") };
  4514. }
  4515. if(!helper[0].style.width || o.forceHelperSize) {
  4516. helper.width(this.currentItem.width());
  4517. }
  4518. if(!helper[0].style.height || o.forceHelperSize) {
  4519. helper.height(this.currentItem.height());
  4520. }
  4521. return helper;
  4522. },
  4523. _adjustOffsetFromHelper: function(obj) {
  4524. if (typeof obj === "string") {
  4525. obj = obj.split(" ");
  4526. }
  4527. if ($.isArray(obj)) {
  4528. obj = {left: +obj[0], top: +obj[1] || 0};
  4529. }
  4530. if ("left" in obj) {
  4531. this.offset.click.left = obj.left + this.margins.left;
  4532. }
  4533. if ("right" in obj) {
  4534. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  4535. }
  4536. if ("top" in obj) {
  4537. this.offset.click.top = obj.top + this.margins.top;
  4538. }
  4539. if ("bottom" in obj) {
  4540. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  4541. }
  4542. },
  4543. _getParentOffset: function() {
  4544. //Get the offsetParent and cache its position
  4545. this.offsetParent = this.helper.offsetParent();
  4546. var po = this.offsetParent.offset();
  4547. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  4548. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  4549. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  4550. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  4551. if(this.cssPosition === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  4552. po.left += this.scrollParent.scrollLeft();
  4553. po.top += this.scrollParent.scrollTop();
  4554. }
  4555. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  4556. // with an ugly IE fix
  4557. if( this.offsetParent[0] === this.document[0].body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  4558. po = { top: 0, left: 0 };
  4559. }
  4560. return {
  4561. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  4562. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  4563. };
  4564. },
  4565. _getRelativeOffset: function() {
  4566. if(this.cssPosition === "relative") {
  4567. var p = this.currentItem.position();
  4568. return {
  4569. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  4570. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  4571. };
  4572. } else {
  4573. return { top: 0, left: 0 };
  4574. }
  4575. },
  4576. _cacheMargins: function() {
  4577. this.margins = {
  4578. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  4579. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  4580. };
  4581. },
  4582. _cacheHelperProportions: function() {
  4583. this.helperProportions = {
  4584. width: this.helper.outerWidth(),
  4585. height: this.helper.outerHeight()
  4586. };
  4587. },
  4588. _setContainment: function() {
  4589. var ce, co, over,
  4590. o = this.options;
  4591. if(o.containment === "parent") {
  4592. o.containment = this.helper[0].parentNode;
  4593. }
  4594. if(o.containment === "document" || o.containment === "window") {
  4595. this.containment = [
  4596. 0 - this.offset.relative.left - this.offset.parent.left,
  4597. 0 - this.offset.relative.top - this.offset.parent.top,
  4598. o.containment === "document" ? this.document.width() : this.window.width() - this.helperProportions.width - this.margins.left,
  4599. (o.containment === "document" ? this.document.width() : this.window.height() || this.document[0].body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  4600. ];
  4601. }
  4602. if(!(/^(document|window|parent)$/).test(o.containment)) {
  4603. ce = $(o.containment)[0];
  4604. co = $(o.containment).offset();
  4605. over = ($(ce).css("overflow") !== "hidden");
  4606. this.containment = [
  4607. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  4608. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  4609. 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,
  4610. 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
  4611. ];
  4612. }
  4613. },
  4614. _convertPositionTo: function(d, pos) {
  4615. if(!pos) {
  4616. pos = this.position;
  4617. }
  4618. var mod = d === "absolute" ? 1 : -1,
  4619. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  4620. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  4621. return {
  4622. top: (
  4623. pos.top + // The absolute mouse position
  4624. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4625. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  4626. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  4627. ),
  4628. left: (
  4629. pos.left + // The absolute mouse position
  4630. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4631. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  4632. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  4633. )
  4634. };
  4635. },
  4636. _generatePosition: function(event) {
  4637. var top, left,
  4638. o = this.options,
  4639. pageX = event.pageX,
  4640. pageY = event.pageY,
  4641. 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);
  4642. // This is another very weird special case that only happens for relative elements:
  4643. // 1. If the css position is relative
  4644. // 2. and the scroll parent is the document or similar to the offset parent
  4645. // we have to refresh the relative offset during the scroll so there are no jumps
  4646. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== this.document[0] && this.scrollParent[0] !== this.offsetParent[0])) {
  4647. this.offset.relative = this._getRelativeOffset();
  4648. }
  4649. /*
  4650. * - Position constraining -
  4651. * Constrain the position to a mix of grid, containment.
  4652. */
  4653. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  4654. if(this.containment) {
  4655. if(event.pageX - this.offset.click.left < this.containment[0]) {
  4656. pageX = this.containment[0] + this.offset.click.left;
  4657. }
  4658. if(event.pageY - this.offset.click.top < this.containment[1]) {
  4659. pageY = this.containment[1] + this.offset.click.top;
  4660. }
  4661. if(event.pageX - this.offset.click.left > this.containment[2]) {
  4662. pageX = this.containment[2] + this.offset.click.left;
  4663. }
  4664. if(event.pageY - this.offset.click.top > this.containment[3]) {
  4665. pageY = this.containment[3] + this.offset.click.top;
  4666. }
  4667. }
  4668. if(o.grid) {
  4669. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  4670. 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;
  4671. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  4672. 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;
  4673. }
  4674. }
  4675. return {
  4676. top: (
  4677. pageY - // The absolute mouse position
  4678. this.offset.click.top - // Click offset (relative to the element)
  4679. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  4680. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  4681. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  4682. ),
  4683. left: (
  4684. pageX - // The absolute mouse position
  4685. this.offset.click.left - // Click offset (relative to the element)
  4686. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  4687. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  4688. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  4689. )
  4690. };
  4691. },
  4692. _rearrange: function(event, i, a, hardRefresh) {
  4693. 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));
  4694. //Various things done here to improve the performance:
  4695. // 1. we create a setTimeout, that calls refreshPositions
  4696. // 2. on the instance, we have a counter variable, that get's higher after every append
  4697. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  4698. // 4. this lets only the last addition to the timeout stack through
  4699. this.counter = this.counter ? ++this.counter : 1;
  4700. var counter = this.counter;
  4701. this._delay(function() {
  4702. if(counter === this.counter) {
  4703. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  4704. }
  4705. });
  4706. },
  4707. _clear: function(event, noPropagation) {
  4708. this.reverting = false;
  4709. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  4710. // everything else normalized again
  4711. var i,
  4712. delayedTriggers = [];
  4713. // We first have to update the dom position of the actual currentItem
  4714. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  4715. if(!this._noFinalSort && this.currentItem.parent().length) {
  4716. this.placeholder.before(this.currentItem);
  4717. }
  4718. this._noFinalSort = null;
  4719. if(this.helper[0] === this.currentItem[0]) {
  4720. for(i in this._storedCSS) {
  4721. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  4722. this._storedCSS[i] = "";
  4723. }
  4724. }
  4725. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  4726. } else {
  4727. this.currentItem.show();
  4728. }
  4729. if(this.fromOutside && !noPropagation) {
  4730. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  4731. }
  4732. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  4733. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  4734. }
  4735. // Check if the items Container has Changed and trigger appropriate
  4736. // events.
  4737. if (this !== this.currentContainer) {
  4738. if(!noPropagation) {
  4739. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  4740. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4741. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4742. }
  4743. }
  4744. //Post events to containers
  4745. function delayEvent( type, instance, container ) {
  4746. return function( event ) {
  4747. container._trigger( type, event, instance._uiHash( instance ) );
  4748. };
  4749. }
  4750. for (i = this.containers.length - 1; i >= 0; i--){
  4751. if (!noPropagation) {
  4752. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  4753. }
  4754. if(this.containers[i].containerCache.over) {
  4755. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  4756. this.containers[i].containerCache.over = 0;
  4757. }
  4758. }
  4759. //Do what was originally in plugins
  4760. if ( this.storedCursor ) {
  4761. this.document.find( "body" ).css( "cursor", this.storedCursor );
  4762. this.storedStylesheet.remove();
  4763. }
  4764. if(this._storedOpacity) {
  4765. this.helper.css("opacity", this._storedOpacity);
  4766. }
  4767. if(this._storedZIndex) {
  4768. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  4769. }
  4770. this.dragging = false;
  4771. if(!noPropagation) {
  4772. this._trigger("beforeStop", event, this._uiHash());
  4773. }
  4774. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  4775. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  4776. if ( !this.cancelHelperRemoval ) {
  4777. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  4778. this.helper.remove();
  4779. }
  4780. this.helper = null;
  4781. }
  4782. if(!noPropagation) {
  4783. for (i=0; i < delayedTriggers.length; i++) {
  4784. delayedTriggers[i].call(this, event);
  4785. } //Trigger all delayed events
  4786. this._trigger("stop", event, this._uiHash());
  4787. }
  4788. this.fromOutside = false;
  4789. return !this.cancelHelperRemoval;
  4790. },
  4791. _trigger: function() {
  4792. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  4793. this.cancel();
  4794. }
  4795. },
  4796. _uiHash: function(_inst) {
  4797. var inst = _inst || this;
  4798. return {
  4799. helper: inst.helper,
  4800. placeholder: inst.placeholder || $([]),
  4801. position: inst.position,
  4802. originalPosition: inst.originalPosition,
  4803. offset: inst.positionAbs,
  4804. item: inst.currentItem,
  4805. sender: _inst ? _inst.element : null
  4806. };
  4807. }
  4808. });
  4809. /*!
  4810. * jQuery UI Accordion 1.11.4
  4811. * http://jqueryui.com
  4812. *
  4813. * Copyright jQuery Foundation and other contributors
  4814. * Released under the MIT license.
  4815. * http://jquery.org/license
  4816. *
  4817. * http://api.jqueryui.com/accordion/
  4818. */
  4819. var accordion = $.widget( "ui.accordion", {
  4820. version: "1.11.4",
  4821. options: {
  4822. active: 0,
  4823. animate: {},
  4824. collapsible: false,
  4825. event: "click",
  4826. header: "> li > :first-child,> :not(li):even",
  4827. heightStyle: "auto",
  4828. icons: {
  4829. activeHeader: "ui-icon-triangle-1-s",
  4830. header: "ui-icon-triangle-1-e"
  4831. },
  4832. // callbacks
  4833. activate: null,
  4834. beforeActivate: null
  4835. },
  4836. hideProps: {
  4837. borderTopWidth: "hide",
  4838. borderBottomWidth: "hide",
  4839. paddingTop: "hide",
  4840. paddingBottom: "hide",
  4841. height: "hide"
  4842. },
  4843. showProps: {
  4844. borderTopWidth: "show",
  4845. borderBottomWidth: "show",
  4846. paddingTop: "show",
  4847. paddingBottom: "show",
  4848. height: "show"
  4849. },
  4850. _create: function() {
  4851. var options = this.options;
  4852. this.prevShow = this.prevHide = $();
  4853. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  4854. // ARIA
  4855. .attr( "role", "tablist" );
  4856. // don't allow collapsible: false and active: false / null
  4857. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  4858. options.active = 0;
  4859. }
  4860. this._processPanels();
  4861. // handle negative values
  4862. if ( options.active < 0 ) {
  4863. options.active += this.headers.length;
  4864. }
  4865. this._refresh();
  4866. },
  4867. _getCreateEventData: function() {
  4868. return {
  4869. header: this.active,
  4870. panel: !this.active.length ? $() : this.active.next()
  4871. };
  4872. },
  4873. _createIcons: function() {
  4874. var icons = this.options.icons;
  4875. if ( icons ) {
  4876. $( "<span>" )
  4877. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  4878. .prependTo( this.headers );
  4879. this.active.children( ".ui-accordion-header-icon" )
  4880. .removeClass( icons.header )
  4881. .addClass( icons.activeHeader );
  4882. this.headers.addClass( "ui-accordion-icons" );
  4883. }
  4884. },
  4885. _destroyIcons: function() {
  4886. this.headers
  4887. .removeClass( "ui-accordion-icons" )
  4888. .children( ".ui-accordion-header-icon" )
  4889. .remove();
  4890. },
  4891. _destroy: function() {
  4892. var contents;
  4893. // clean up main element
  4894. this.element
  4895. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  4896. .removeAttr( "role" );
  4897. // clean up headers
  4898. this.headers
  4899. .removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " +
  4900. "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
  4901. .removeAttr( "role" )
  4902. .removeAttr( "aria-expanded" )
  4903. .removeAttr( "aria-selected" )
  4904. .removeAttr( "aria-controls" )
  4905. .removeAttr( "tabIndex" )
  4906. .removeUniqueId();
  4907. this._destroyIcons();
  4908. // clean up content panels
  4909. contents = this.headers.next()
  4910. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " +
  4911. "ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  4912. .css( "display", "" )
  4913. .removeAttr( "role" )
  4914. .removeAttr( "aria-hidden" )
  4915. .removeAttr( "aria-labelledby" )
  4916. .removeUniqueId();
  4917. if ( this.options.heightStyle !== "content" ) {
  4918. contents.css( "height", "" );
  4919. }
  4920. },
  4921. _setOption: function( key, value ) {
  4922. if ( key === "active" ) {
  4923. // _activate() will handle invalid values and update this.options
  4924. this._activate( value );
  4925. return;
  4926. }
  4927. if ( key === "event" ) {
  4928. if ( this.options.event ) {
  4929. this._off( this.headers, this.options.event );
  4930. }
  4931. this._setupEvents( value );
  4932. }
  4933. this._super( key, value );
  4934. // setting collapsible: false while collapsed; open first panel
  4935. if ( key === "collapsible" && !value && this.options.active === false ) {
  4936. this._activate( 0 );
  4937. }
  4938. if ( key === "icons" ) {
  4939. this._destroyIcons();
  4940. if ( value ) {
  4941. this._createIcons();
  4942. }
  4943. }
  4944. // #5332 - opacity doesn't cascade to positioned elements in IE
  4945. // so we need to add the disabled class to the headers and panels
  4946. if ( key === "disabled" ) {
  4947. this.element
  4948. .toggleClass( "ui-state-disabled", !!value )
  4949. .attr( "aria-disabled", value );
  4950. this.headers.add( this.headers.next() )
  4951. .toggleClass( "ui-state-disabled", !!value );
  4952. }
  4953. },
  4954. _keydown: function( event ) {
  4955. if ( event.altKey || event.ctrlKey ) {
  4956. return;
  4957. }
  4958. var keyCode = $.ui.keyCode,
  4959. length = this.headers.length,
  4960. currentIndex = this.headers.index( event.target ),
  4961. toFocus = false;
  4962. switch ( event.keyCode ) {
  4963. case keyCode.RIGHT:
  4964. case keyCode.DOWN:
  4965. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  4966. break;
  4967. case keyCode.LEFT:
  4968. case keyCode.UP:
  4969. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  4970. break;
  4971. case keyCode.SPACE:
  4972. case keyCode.ENTER:
  4973. this._eventHandler( event );
  4974. break;
  4975. case keyCode.HOME:
  4976. toFocus = this.headers[ 0 ];
  4977. break;
  4978. case keyCode.END:
  4979. toFocus = this.headers[ length - 1 ];
  4980. break;
  4981. }
  4982. if ( toFocus ) {
  4983. $( event.target ).attr( "tabIndex", -1 );
  4984. $( toFocus ).attr( "tabIndex", 0 );
  4985. toFocus.focus();
  4986. event.preventDefault();
  4987. }
  4988. },
  4989. _panelKeyDown: function( event ) {
  4990. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  4991. $( event.currentTarget ).prev().focus();
  4992. }
  4993. },
  4994. refresh: function() {
  4995. var options = this.options;
  4996. this._processPanels();
  4997. // was collapsed or no panel
  4998. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  4999. options.active = false;
  5000. this.active = $();
  5001. // active false only when collapsible is true
  5002. } else if ( options.active === false ) {
  5003. this._activate( 0 );
  5004. // was active, but active panel is gone
  5005. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5006. // all remaining panel are disabled
  5007. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  5008. options.active = false;
  5009. this.active = $();
  5010. // activate previous panel
  5011. } else {
  5012. this._activate( Math.max( 0, options.active - 1 ) );
  5013. }
  5014. // was active, active panel still exists
  5015. } else {
  5016. // make sure active index is correct
  5017. options.active = this.headers.index( this.active );
  5018. }
  5019. this._destroyIcons();
  5020. this._refresh();
  5021. },
  5022. _processPanels: function() {
  5023. var prevHeaders = this.headers,
  5024. prevPanels = this.panels;
  5025. this.headers = this.element.find( this.options.header )
  5026. .addClass( "ui-accordion-header ui-state-default ui-corner-all" );
  5027. this.panels = this.headers.next()
  5028. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  5029. .filter( ":not(.ui-accordion-content-active)" )
  5030. .hide();
  5031. // Avoid memory leaks (#10056)
  5032. if ( prevPanels ) {
  5033. this._off( prevHeaders.not( this.headers ) );
  5034. this._off( prevPanels.not( this.panels ) );
  5035. }
  5036. },
  5037. _refresh: function() {
  5038. var maxHeight,
  5039. options = this.options,
  5040. heightStyle = options.heightStyle,
  5041. parent = this.element.parent();
  5042. this.active = this._findActive( options.active )
  5043. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  5044. .removeClass( "ui-corner-all" );
  5045. this.active.next()
  5046. .addClass( "ui-accordion-content-active" )
  5047. .show();
  5048. this.headers
  5049. .attr( "role", "tab" )
  5050. .each(function() {
  5051. var header = $( this ),
  5052. headerId = header.uniqueId().attr( "id" ),
  5053. panel = header.next(),
  5054. panelId = panel.uniqueId().attr( "id" );
  5055. header.attr( "aria-controls", panelId );
  5056. panel.attr( "aria-labelledby", headerId );
  5057. })
  5058. .next()
  5059. .attr( "role", "tabpanel" );
  5060. this.headers
  5061. .not( this.active )
  5062. .attr({
  5063. "aria-selected": "false",
  5064. "aria-expanded": "false",
  5065. tabIndex: -1
  5066. })
  5067. .next()
  5068. .attr({
  5069. "aria-hidden": "true"
  5070. })
  5071. .hide();
  5072. // make sure at least one header is in the tab order
  5073. if ( !this.active.length ) {
  5074. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  5075. } else {
  5076. this.active.attr({
  5077. "aria-selected": "true",
  5078. "aria-expanded": "true",
  5079. tabIndex: 0
  5080. })
  5081. .next()
  5082. .attr({
  5083. "aria-hidden": "false"
  5084. });
  5085. }
  5086. this._createIcons();
  5087. this._setupEvents( options.event );
  5088. if ( heightStyle === "fill" ) {
  5089. maxHeight = parent.height();
  5090. this.element.siblings( ":visible" ).each(function() {
  5091. var elem = $( this ),
  5092. position = elem.css( "position" );
  5093. if ( position === "absolute" || position === "fixed" ) {
  5094. return;
  5095. }
  5096. maxHeight -= elem.outerHeight( true );
  5097. });
  5098. this.headers.each(function() {
  5099. maxHeight -= $( this ).outerHeight( true );
  5100. });
  5101. this.headers.next()
  5102. .each(function() {
  5103. $( this ).height( Math.max( 0, maxHeight -
  5104. $( this ).innerHeight() + $( this ).height() ) );
  5105. })
  5106. .css( "overflow", "auto" );
  5107. } else if ( heightStyle === "auto" ) {
  5108. maxHeight = 0;
  5109. this.headers.next()
  5110. .each(function() {
  5111. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  5112. })
  5113. .height( maxHeight );
  5114. }
  5115. },
  5116. _activate: function( index ) {
  5117. var active = this._findActive( index )[ 0 ];
  5118. // trying to activate the already active panel
  5119. if ( active === this.active[ 0 ] ) {
  5120. return;
  5121. }
  5122. // trying to collapse, simulate a click on the currently active header
  5123. active = active || this.active[ 0 ];
  5124. this._eventHandler({
  5125. target: active,
  5126. currentTarget: active,
  5127. preventDefault: $.noop
  5128. });
  5129. },
  5130. _findActive: function( selector ) {
  5131. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  5132. },
  5133. _setupEvents: function( event ) {
  5134. var events = {
  5135. keydown: "_keydown"
  5136. };
  5137. if ( event ) {
  5138. $.each( event.split( " " ), function( index, eventName ) {
  5139. events[ eventName ] = "_eventHandler";
  5140. });
  5141. }
  5142. this._off( this.headers.add( this.headers.next() ) );
  5143. this._on( this.headers, events );
  5144. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  5145. this._hoverable( this.headers );
  5146. this._focusable( this.headers );
  5147. },
  5148. _eventHandler: function( event ) {
  5149. var options = this.options,
  5150. active = this.active,
  5151. clicked = $( event.currentTarget ),
  5152. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  5153. collapsing = clickedIsActive && options.collapsible,
  5154. toShow = collapsing ? $() : clicked.next(),
  5155. toHide = active.next(),
  5156. eventData = {
  5157. oldHeader: active,
  5158. oldPanel: toHide,
  5159. newHeader: collapsing ? $() : clicked,
  5160. newPanel: toShow
  5161. };
  5162. event.preventDefault();
  5163. if (
  5164. // click on active header, but not collapsible
  5165. ( clickedIsActive && !options.collapsible ) ||
  5166. // allow canceling activation
  5167. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  5168. return;
  5169. }
  5170. options.active = collapsing ? false : this.headers.index( clicked );
  5171. // when the call to ._toggle() comes after the class changes
  5172. // it causes a very odd bug in IE 8 (see #6720)
  5173. this.active = clickedIsActive ? $() : clicked;
  5174. this._toggle( eventData );
  5175. // switch classes
  5176. // corner classes on the previously active header stay after the animation
  5177. active.removeClass( "ui-accordion-header-active ui-state-active" );
  5178. if ( options.icons ) {
  5179. active.children( ".ui-accordion-header-icon" )
  5180. .removeClass( options.icons.activeHeader )
  5181. .addClass( options.icons.header );
  5182. }
  5183. if ( !clickedIsActive ) {
  5184. clicked
  5185. .removeClass( "ui-corner-all" )
  5186. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  5187. if ( options.icons ) {
  5188. clicked.children( ".ui-accordion-header-icon" )
  5189. .removeClass( options.icons.header )
  5190. .addClass( options.icons.activeHeader );
  5191. }
  5192. clicked
  5193. .next()
  5194. .addClass( "ui-accordion-content-active" );
  5195. }
  5196. },
  5197. _toggle: function( data ) {
  5198. var toShow = data.newPanel,
  5199. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  5200. // handle activating a panel during the animation for another activation
  5201. this.prevShow.add( this.prevHide ).stop( true, true );
  5202. this.prevShow = toShow;
  5203. this.prevHide = toHide;
  5204. if ( this.options.animate ) {
  5205. this._animate( toShow, toHide, data );
  5206. } else {
  5207. toHide.hide();
  5208. toShow.show();
  5209. this._toggleComplete( data );
  5210. }
  5211. toHide.attr({
  5212. "aria-hidden": "true"
  5213. });
  5214. toHide.prev().attr({
  5215. "aria-selected": "false",
  5216. "aria-expanded": "false"
  5217. });
  5218. // if we're switching panels, remove the old header from the tab order
  5219. // if we're opening from collapsed state, remove the previous header from the tab order
  5220. // if we're collapsing, then keep the collapsing header in the tab order
  5221. if ( toShow.length && toHide.length ) {
  5222. toHide.prev().attr({
  5223. "tabIndex": -1,
  5224. "aria-expanded": "false"
  5225. });
  5226. } else if ( toShow.length ) {
  5227. this.headers.filter(function() {
  5228. return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0;
  5229. })
  5230. .attr( "tabIndex", -1 );
  5231. }
  5232. toShow
  5233. .attr( "aria-hidden", "false" )
  5234. .prev()
  5235. .attr({
  5236. "aria-selected": "true",
  5237. "aria-expanded": "true",
  5238. tabIndex: 0
  5239. });
  5240. },
  5241. _animate: function( toShow, toHide, data ) {
  5242. var total, easing, duration,
  5243. that = this,
  5244. adjust = 0,
  5245. boxSizing = toShow.css( "box-sizing" ),
  5246. down = toShow.length &&
  5247. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  5248. animate = this.options.animate || {},
  5249. options = down && animate.down || animate,
  5250. complete = function() {
  5251. that._toggleComplete( data );
  5252. };
  5253. if ( typeof options === "number" ) {
  5254. duration = options;
  5255. }
  5256. if ( typeof options === "string" ) {
  5257. easing = options;
  5258. }
  5259. // fall back from options to animation in case of partial down settings
  5260. easing = easing || options.easing || animate.easing;
  5261. duration = duration || options.duration || animate.duration;
  5262. if ( !toHide.length ) {
  5263. return toShow.animate( this.showProps, duration, easing, complete );
  5264. }
  5265. if ( !toShow.length ) {
  5266. return toHide.animate( this.hideProps, duration, easing, complete );
  5267. }
  5268. total = toShow.show().outerHeight();
  5269. toHide.animate( this.hideProps, {
  5270. duration: duration,
  5271. easing: easing,
  5272. step: function( now, fx ) {
  5273. fx.now = Math.round( now );
  5274. }
  5275. });
  5276. toShow
  5277. .hide()
  5278. .animate( this.showProps, {
  5279. duration: duration,
  5280. easing: easing,
  5281. complete: complete,
  5282. step: function( now, fx ) {
  5283. fx.now = Math.round( now );
  5284. if ( fx.prop !== "height" ) {
  5285. if ( boxSizing === "content-box" ) {
  5286. adjust += fx.now;
  5287. }
  5288. } else if ( that.options.heightStyle !== "content" ) {
  5289. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  5290. adjust = 0;
  5291. }
  5292. }
  5293. });
  5294. },
  5295. _toggleComplete: function( data ) {
  5296. var toHide = data.oldPanel;
  5297. toHide
  5298. .removeClass( "ui-accordion-content-active" )
  5299. .prev()
  5300. .removeClass( "ui-corner-top" )
  5301. .addClass( "ui-corner-all" );
  5302. // Work around for rendering bug in IE (#5421)
  5303. if ( toHide.length ) {
  5304. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  5305. }
  5306. this._trigger( "activate", null, data );
  5307. }
  5308. });
  5309. /*!
  5310. * jQuery UI Menu 1.11.4
  5311. * http://jqueryui.com
  5312. *
  5313. * Copyright jQuery Foundation and other contributors
  5314. * Released under the MIT license.
  5315. * http://jquery.org/license
  5316. *
  5317. * http://api.jqueryui.com/menu/
  5318. */
  5319. var menu = $.widget( "ui.menu", {
  5320. version: "1.11.4",
  5321. defaultElement: "<ul>",
  5322. delay: 300,
  5323. options: {
  5324. icons: {
  5325. submenu: "ui-icon-carat-1-e"
  5326. },
  5327. items: "> *",
  5328. menus: "ul",
  5329. position: {
  5330. my: "left-1 top",
  5331. at: "right top"
  5332. },
  5333. role: "menu",
  5334. // callbacks
  5335. blur: null,
  5336. focus: null,
  5337. select: null
  5338. },
  5339. _create: function() {
  5340. this.activeMenu = this.element;
  5341. // Flag used to prevent firing of the click handler
  5342. // as the event bubbles up through nested menus
  5343. this.mouseHandled = false;
  5344. this.element
  5345. .uniqueId()
  5346. .addClass( "ui-menu ui-widget ui-widget-content" )
  5347. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  5348. .attr({
  5349. role: this.options.role,
  5350. tabIndex: 0
  5351. });
  5352. if ( this.options.disabled ) {
  5353. this.element
  5354. .addClass( "ui-state-disabled" )
  5355. .attr( "aria-disabled", "true" );
  5356. }
  5357. this._on({
  5358. // Prevent focus from sticking to links inside menu after clicking
  5359. // them (focus should always stay on UL during navigation).
  5360. "mousedown .ui-menu-item": function( event ) {
  5361. event.preventDefault();
  5362. },
  5363. "click .ui-menu-item": function( event ) {
  5364. var target = $( event.target );
  5365. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  5366. this.select( event );
  5367. // Only set the mouseHandled flag if the event will bubble, see #9469.
  5368. if ( !event.isPropagationStopped() ) {
  5369. this.mouseHandled = true;
  5370. }
  5371. // Open submenu on click
  5372. if ( target.has( ".ui-menu" ).length ) {
  5373. this.expand( event );
  5374. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  5375. // Redirect focus to the menu
  5376. this.element.trigger( "focus", [ true ] );
  5377. // If the active item is on the top level, let it stay active.
  5378. // Otherwise, blur the active item since it is no longer visible.
  5379. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  5380. clearTimeout( this.timer );
  5381. }
  5382. }
  5383. }
  5384. },
  5385. "mouseenter .ui-menu-item": function( event ) {
  5386. // Ignore mouse events while typeahead is active, see #10458.
  5387. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  5388. // is over an item in the menu
  5389. if ( this.previousFilter ) {
  5390. return;
  5391. }
  5392. var target = $( event.currentTarget );
  5393. // Remove ui-state-active class from siblings of the newly focused menu item
  5394. // to avoid a jump caused by adjacent elements both having a class with a border
  5395. target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
  5396. this.focus( event, target );
  5397. },
  5398. mouseleave: "collapseAll",
  5399. "mouseleave .ui-menu": "collapseAll",
  5400. focus: function( event, keepActiveItem ) {
  5401. // If there's already an active item, keep it active
  5402. // If not, activate the first item
  5403. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  5404. if ( !keepActiveItem ) {
  5405. this.focus( event, item );
  5406. }
  5407. },
  5408. blur: function( event ) {
  5409. this._delay(function() {
  5410. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  5411. this.collapseAll( event );
  5412. }
  5413. });
  5414. },
  5415. keydown: "_keydown"
  5416. });
  5417. this.refresh();
  5418. // Clicks outside of a menu collapse any open menus
  5419. this._on( this.document, {
  5420. click: function( event ) {
  5421. if ( this._closeOnDocumentClick( event ) ) {
  5422. this.collapseAll( event );
  5423. }
  5424. // Reset the mouseHandled flag
  5425. this.mouseHandled = false;
  5426. }
  5427. });
  5428. },
  5429. _destroy: function() {
  5430. // Destroy (sub)menus
  5431. this.element
  5432. .removeAttr( "aria-activedescendant" )
  5433. .find( ".ui-menu" ).addBack()
  5434. .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
  5435. .removeAttr( "role" )
  5436. .removeAttr( "tabIndex" )
  5437. .removeAttr( "aria-labelledby" )
  5438. .removeAttr( "aria-expanded" )
  5439. .removeAttr( "aria-hidden" )
  5440. .removeAttr( "aria-disabled" )
  5441. .removeUniqueId()
  5442. .show();
  5443. // Destroy menu items
  5444. this.element.find( ".ui-menu-item" )
  5445. .removeClass( "ui-menu-item" )
  5446. .removeAttr( "role" )
  5447. .removeAttr( "aria-disabled" )
  5448. .removeUniqueId()
  5449. .removeClass( "ui-state-hover" )
  5450. .removeAttr( "tabIndex" )
  5451. .removeAttr( "role" )
  5452. .removeAttr( "aria-haspopup" )
  5453. .children().each( function() {
  5454. var elem = $( this );
  5455. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  5456. elem.remove();
  5457. }
  5458. });
  5459. // Destroy menu dividers
  5460. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  5461. },
  5462. _keydown: function( event ) {
  5463. var match, prev, character, skip,
  5464. preventDefault = true;
  5465. switch ( event.keyCode ) {
  5466. case $.ui.keyCode.PAGE_UP:
  5467. this.previousPage( event );
  5468. break;
  5469. case $.ui.keyCode.PAGE_DOWN:
  5470. this.nextPage( event );
  5471. break;
  5472. case $.ui.keyCode.HOME:
  5473. this._move( "first", "first", event );
  5474. break;
  5475. case $.ui.keyCode.END:
  5476. this._move( "last", "last", event );
  5477. break;
  5478. case $.ui.keyCode.UP:
  5479. this.previous( event );
  5480. break;
  5481. case $.ui.keyCode.DOWN:
  5482. this.next( event );
  5483. break;
  5484. case $.ui.keyCode.LEFT:
  5485. this.collapse( event );
  5486. break;
  5487. case $.ui.keyCode.RIGHT:
  5488. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  5489. this.expand( event );
  5490. }
  5491. break;
  5492. case $.ui.keyCode.ENTER:
  5493. case $.ui.keyCode.SPACE:
  5494. this._activate( event );
  5495. break;
  5496. case $.ui.keyCode.ESCAPE:
  5497. this.collapse( event );
  5498. break;
  5499. default:
  5500. preventDefault = false;
  5501. prev = this.previousFilter || "";
  5502. character = String.fromCharCode( event.keyCode );
  5503. skip = false;
  5504. clearTimeout( this.filterTimer );
  5505. if ( character === prev ) {
  5506. skip = true;
  5507. } else {
  5508. character = prev + character;
  5509. }
  5510. match = this._filterMenuItems( character );
  5511. match = skip && match.index( this.active.next() ) !== -1 ?
  5512. this.active.nextAll( ".ui-menu-item" ) :
  5513. match;
  5514. // If no matches on the current filter, reset to the last character pressed
  5515. // to move down the menu to the first item that starts with that character
  5516. if ( !match.length ) {
  5517. character = String.fromCharCode( event.keyCode );
  5518. match = this._filterMenuItems( character );
  5519. }
  5520. if ( match.length ) {
  5521. this.focus( event, match );
  5522. this.previousFilter = character;
  5523. this.filterTimer = this._delay(function() {
  5524. delete this.previousFilter;
  5525. }, 1000 );
  5526. } else {
  5527. delete this.previousFilter;
  5528. }
  5529. }
  5530. if ( preventDefault ) {
  5531. event.preventDefault();
  5532. }
  5533. },
  5534. _activate: function( event ) {
  5535. if ( !this.active.is( ".ui-state-disabled" ) ) {
  5536. if ( this.active.is( "[aria-haspopup='true']" ) ) {
  5537. this.expand( event );
  5538. } else {
  5539. this.select( event );
  5540. }
  5541. }
  5542. },
  5543. refresh: function() {
  5544. var menus, items,
  5545. that = this,
  5546. icon = this.options.icons.submenu,
  5547. submenus = this.element.find( this.options.menus );
  5548. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  5549. // Initialize nested menus
  5550. submenus.filter( ":not(.ui-menu)" )
  5551. .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
  5552. .hide()
  5553. .attr({
  5554. role: this.options.role,
  5555. "aria-hidden": "true",
  5556. "aria-expanded": "false"
  5557. })
  5558. .each(function() {
  5559. var menu = $( this ),
  5560. item = menu.parent(),
  5561. submenuCarat = $( "<span>" )
  5562. .addClass( "ui-menu-icon ui-icon " + icon )
  5563. .data( "ui-menu-submenu-carat", true );
  5564. item
  5565. .attr( "aria-haspopup", "true" )
  5566. .prepend( submenuCarat );
  5567. menu.attr( "aria-labelledby", item.attr( "id" ) );
  5568. });
  5569. menus = submenus.add( this.element );
  5570. items = menus.find( this.options.items );
  5571. // Initialize menu-items containing spaces and/or dashes only as dividers
  5572. items.not( ".ui-menu-item" ).each(function() {
  5573. var item = $( this );
  5574. if ( that._isDivider( item ) ) {
  5575. item.addClass( "ui-widget-content ui-menu-divider" );
  5576. }
  5577. });
  5578. // Don't refresh list items that are already adapted
  5579. items.not( ".ui-menu-item, .ui-menu-divider" )
  5580. .addClass( "ui-menu-item" )
  5581. .uniqueId()
  5582. .attr({
  5583. tabIndex: -1,
  5584. role: this._itemRole()
  5585. });
  5586. // Add aria-disabled attribute to any disabled menu item
  5587. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  5588. // If the active item has been removed, blur the menu
  5589. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5590. this.blur();
  5591. }
  5592. },
  5593. _itemRole: function() {
  5594. return {
  5595. menu: "menuitem",
  5596. listbox: "option"
  5597. }[ this.options.role ];
  5598. },
  5599. _setOption: function( key, value ) {
  5600. if ( key === "icons" ) {
  5601. this.element.find( ".ui-menu-icon" )
  5602. .removeClass( this.options.icons.submenu )
  5603. .addClass( value.submenu );
  5604. }
  5605. if ( key === "disabled" ) {
  5606. this.element
  5607. .toggleClass( "ui-state-disabled", !!value )
  5608. .attr( "aria-disabled", value );
  5609. }
  5610. this._super( key, value );
  5611. },
  5612. focus: function( event, item ) {
  5613. var nested, focused;
  5614. this.blur( event, event && event.type === "focus" );
  5615. this._scrollIntoView( item );
  5616. this.active = item.first();
  5617. focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
  5618. // Only update aria-activedescendant if there's a role
  5619. // otherwise we assume focus is managed elsewhere
  5620. if ( this.options.role ) {
  5621. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  5622. }
  5623. // Highlight active parent menu item, if any
  5624. this.active
  5625. .parent()
  5626. .closest( ".ui-menu-item" )
  5627. .addClass( "ui-state-active" );
  5628. if ( event && event.type === "keydown" ) {
  5629. this._close();
  5630. } else {
  5631. this.timer = this._delay(function() {
  5632. this._close();
  5633. }, this.delay );
  5634. }
  5635. nested = item.children( ".ui-menu" );
  5636. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  5637. this._startOpening(nested);
  5638. }
  5639. this.activeMenu = item.parent();
  5640. this._trigger( "focus", event, { item: item } );
  5641. },
  5642. _scrollIntoView: function( item ) {
  5643. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  5644. if ( this._hasScroll() ) {
  5645. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  5646. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  5647. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  5648. scroll = this.activeMenu.scrollTop();
  5649. elementHeight = this.activeMenu.height();
  5650. itemHeight = item.outerHeight();
  5651. if ( offset < 0 ) {
  5652. this.activeMenu.scrollTop( scroll + offset );
  5653. } else if ( offset + itemHeight > elementHeight ) {
  5654. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  5655. }
  5656. }
  5657. },
  5658. blur: function( event, fromFocus ) {
  5659. if ( !fromFocus ) {
  5660. clearTimeout( this.timer );
  5661. }
  5662. if ( !this.active ) {
  5663. return;
  5664. }
  5665. this.active.removeClass( "ui-state-focus" );
  5666. this.active = null;
  5667. this._trigger( "blur", event, { item: this.active } );
  5668. },
  5669. _startOpening: function( submenu ) {
  5670. clearTimeout( this.timer );
  5671. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  5672. // shift in the submenu position when mousing over the carat icon
  5673. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  5674. return;
  5675. }
  5676. this.timer = this._delay(function() {
  5677. this._close();
  5678. this._open( submenu );
  5679. }, this.delay );
  5680. },
  5681. _open: function( submenu ) {
  5682. var position = $.extend({
  5683. of: this.active
  5684. }, this.options.position );
  5685. clearTimeout( this.timer );
  5686. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  5687. .hide()
  5688. .attr( "aria-hidden", "true" );
  5689. submenu
  5690. .show()
  5691. .removeAttr( "aria-hidden" )
  5692. .attr( "aria-expanded", "true" )
  5693. .position( position );
  5694. },
  5695. collapseAll: function( event, all ) {
  5696. clearTimeout( this.timer );
  5697. this.timer = this._delay(function() {
  5698. // If we were passed an event, look for the submenu that contains the event
  5699. var currentMenu = all ? this.element :
  5700. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  5701. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  5702. if ( !currentMenu.length ) {
  5703. currentMenu = this.element;
  5704. }
  5705. this._close( currentMenu );
  5706. this.blur( event );
  5707. this.activeMenu = currentMenu;
  5708. }, this.delay );
  5709. },
  5710. // With no arguments, closes the currently active menu - if nothing is active
  5711. // it closes all menus. If passed an argument, it will search for menus BELOW
  5712. _close: function( startMenu ) {
  5713. if ( !startMenu ) {
  5714. startMenu = this.active ? this.active.parent() : this.element;
  5715. }
  5716. startMenu
  5717. .find( ".ui-menu" )
  5718. .hide()
  5719. .attr( "aria-hidden", "true" )
  5720. .attr( "aria-expanded", "false" )
  5721. .end()
  5722. .find( ".ui-state-active" ).not( ".ui-state-focus" )
  5723. .removeClass( "ui-state-active" );
  5724. },
  5725. _closeOnDocumentClick: function( event ) {
  5726. return !$( event.target ).closest( ".ui-menu" ).length;
  5727. },
  5728. _isDivider: function( item ) {
  5729. // Match hyphen, em dash, en dash
  5730. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  5731. },
  5732. collapse: function( event ) {
  5733. var newItem = this.active &&
  5734. this.active.parent().closest( ".ui-menu-item", this.element );
  5735. if ( newItem && newItem.length ) {
  5736. this._close();
  5737. this.focus( event, newItem );
  5738. }
  5739. },
  5740. expand: function( event ) {
  5741. var newItem = this.active &&
  5742. this.active
  5743. .children( ".ui-menu " )
  5744. .find( this.options.items )
  5745. .first();
  5746. if ( newItem && newItem.length ) {
  5747. this._open( newItem.parent() );
  5748. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  5749. this._delay(function() {
  5750. this.focus( event, newItem );
  5751. });
  5752. }
  5753. },
  5754. next: function( event ) {
  5755. this._move( "next", "first", event );
  5756. },
  5757. previous: function( event ) {
  5758. this._move( "prev", "last", event );
  5759. },
  5760. isFirstItem: function() {
  5761. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  5762. },
  5763. isLastItem: function() {
  5764. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  5765. },
  5766. _move: function( direction, filter, event ) {
  5767. var next;
  5768. if ( this.active ) {
  5769. if ( direction === "first" || direction === "last" ) {
  5770. next = this.active
  5771. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  5772. .eq( -1 );
  5773. } else {
  5774. next = this.active
  5775. [ direction + "All" ]( ".ui-menu-item" )
  5776. .eq( 0 );
  5777. }
  5778. }
  5779. if ( !next || !next.length || !this.active ) {
  5780. next = this.activeMenu.find( this.options.items )[ filter ]();
  5781. }
  5782. this.focus( event, next );
  5783. },
  5784. nextPage: function( event ) {
  5785. var item, base, height;
  5786. if ( !this.active ) {
  5787. this.next( event );
  5788. return;
  5789. }
  5790. if ( this.isLastItem() ) {
  5791. return;
  5792. }
  5793. if ( this._hasScroll() ) {
  5794. base = this.active.offset().top;
  5795. height = this.element.height();
  5796. this.active.nextAll( ".ui-menu-item" ).each(function() {
  5797. item = $( this );
  5798. return item.offset().top - base - height < 0;
  5799. });
  5800. this.focus( event, item );
  5801. } else {
  5802. this.focus( event, this.activeMenu.find( this.options.items )
  5803. [ !this.active ? "first" : "last" ]() );
  5804. }
  5805. },
  5806. previousPage: function( event ) {
  5807. var item, base, height;
  5808. if ( !this.active ) {
  5809. this.next( event );
  5810. return;
  5811. }
  5812. if ( this.isFirstItem() ) {
  5813. return;
  5814. }
  5815. if ( this._hasScroll() ) {
  5816. base = this.active.offset().top;
  5817. height = this.element.height();
  5818. this.active.prevAll( ".ui-menu-item" ).each(function() {
  5819. item = $( this );
  5820. return item.offset().top - base + height > 0;
  5821. });
  5822. this.focus( event, item );
  5823. } else {
  5824. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  5825. }
  5826. },
  5827. _hasScroll: function() {
  5828. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  5829. },
  5830. select: function( event ) {
  5831. // TODO: It should never be possible to not have an active item at this
  5832. // point, but the tests don't trigger mouseenter before click.
  5833. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  5834. var ui = { item: this.active };
  5835. if ( !this.active.has( ".ui-menu" ).length ) {
  5836. this.collapseAll( event, true );
  5837. }
  5838. this._trigger( "select", event, ui );
  5839. },
  5840. _filterMenuItems: function(character) {
  5841. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  5842. regex = new RegExp( "^" + escapedCharacter, "i" );
  5843. return this.activeMenu
  5844. .find( this.options.items )
  5845. // Only match on items, not dividers or other content (#10571)
  5846. .filter( ".ui-menu-item" )
  5847. .filter(function() {
  5848. return regex.test( $.trim( $( this ).text() ) );
  5849. });
  5850. }
  5851. });
  5852. /*!
  5853. * jQuery UI Autocomplete 1.11.4
  5854. * http://jqueryui.com
  5855. *
  5856. * Copyright jQuery Foundation and other contributors
  5857. * Released under the MIT license.
  5858. * http://jquery.org/license
  5859. *
  5860. * http://api.jqueryui.com/autocomplete/
  5861. */
  5862. $.widget( "ui.autocomplete", {
  5863. version: "1.11.4",
  5864. defaultElement: "<input>",
  5865. options: {
  5866. appendTo: null,
  5867. autoFocus: false,
  5868. delay: 300,
  5869. minLength: 1,
  5870. position: {
  5871. my: "left top",
  5872. at: "left bottom",
  5873. collision: "none"
  5874. },
  5875. source: null,
  5876. // callbacks
  5877. change: null,
  5878. close: null,
  5879. focus: null,
  5880. open: null,
  5881. response: null,
  5882. search: null,
  5883. select: null
  5884. },
  5885. requestIndex: 0,
  5886. pending: 0,
  5887. _create: function() {
  5888. // Some browsers only repeat keydown events, not keypress events,
  5889. // so we use the suppressKeyPress flag to determine if we've already
  5890. // handled the keydown event. #7269
  5891. // Unfortunately the code for & in keypress is the same as the up arrow,
  5892. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  5893. // events when we know the keydown event was used to modify the
  5894. // search term. #7799
  5895. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  5896. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  5897. isTextarea = nodeName === "textarea",
  5898. isInput = nodeName === "input";
  5899. this.isMultiLine =
  5900. // Textareas are always multi-line
  5901. isTextarea ? true :
  5902. // Inputs are always single-line, even if inside a contentEditable element
  5903. // IE also treats inputs as contentEditable
  5904. isInput ? false :
  5905. // All other element types are determined by whether or not they're contentEditable
  5906. this.element.prop( "isContentEditable" );
  5907. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  5908. this.isNewMenu = true;
  5909. this.element
  5910. .addClass( "ui-autocomplete-input" )
  5911. .attr( "autocomplete", "off" );
  5912. this._on( this.element, {
  5913. keydown: function( event ) {
  5914. if ( this.element.prop( "readOnly" ) ) {
  5915. suppressKeyPress = true;
  5916. suppressInput = true;
  5917. suppressKeyPressRepeat = true;
  5918. return;
  5919. }
  5920. suppressKeyPress = false;
  5921. suppressInput = false;
  5922. suppressKeyPressRepeat = false;
  5923. var keyCode = $.ui.keyCode;
  5924. switch ( event.keyCode ) {
  5925. case keyCode.PAGE_UP:
  5926. suppressKeyPress = true;
  5927. this._move( "previousPage", event );
  5928. break;
  5929. case keyCode.PAGE_DOWN:
  5930. suppressKeyPress = true;
  5931. this._move( "nextPage", event );
  5932. break;
  5933. case keyCode.UP:
  5934. suppressKeyPress = true;
  5935. this._keyEvent( "previous", event );
  5936. break;
  5937. case keyCode.DOWN:
  5938. suppressKeyPress = true;
  5939. this._keyEvent( "next", event );
  5940. break;
  5941. case keyCode.ENTER:
  5942. // when menu is open and has focus
  5943. if ( this.menu.active ) {
  5944. // #6055 - Opera still allows the keypress to occur
  5945. // which causes forms to submit
  5946. suppressKeyPress = true;
  5947. event.preventDefault();
  5948. this.menu.select( event );
  5949. }
  5950. break;
  5951. case keyCode.TAB:
  5952. if ( this.menu.active ) {
  5953. this.menu.select( event );
  5954. }
  5955. break;
  5956. case keyCode.ESCAPE:
  5957. if ( this.menu.element.is( ":visible" ) ) {
  5958. if ( !this.isMultiLine ) {
  5959. this._value( this.term );
  5960. }
  5961. this.close( event );
  5962. // Different browsers have different default behavior for escape
  5963. // Single press can mean undo or clear
  5964. // Double press in IE means clear the whole form
  5965. event.preventDefault();
  5966. }
  5967. break;
  5968. default:
  5969. suppressKeyPressRepeat = true;
  5970. // search timeout should be triggered before the input value is changed
  5971. this._searchTimeout( event );
  5972. break;
  5973. }
  5974. },
  5975. keypress: function( event ) {
  5976. if ( suppressKeyPress ) {
  5977. suppressKeyPress = false;
  5978. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5979. event.preventDefault();
  5980. }
  5981. return;
  5982. }
  5983. if ( suppressKeyPressRepeat ) {
  5984. return;
  5985. }
  5986. // replicate some key handlers to allow them to repeat in Firefox and Opera
  5987. var keyCode = $.ui.keyCode;
  5988. switch ( event.keyCode ) {
  5989. case keyCode.PAGE_UP:
  5990. this._move( "previousPage", event );
  5991. break;
  5992. case keyCode.PAGE_DOWN:
  5993. this._move( "nextPage", event );
  5994. break;
  5995. case keyCode.UP:
  5996. this._keyEvent( "previous", event );
  5997. break;
  5998. case keyCode.DOWN:
  5999. this._keyEvent( "next", event );
  6000. break;
  6001. }
  6002. },
  6003. input: function( event ) {
  6004. if ( suppressInput ) {
  6005. suppressInput = false;
  6006. event.preventDefault();
  6007. return;
  6008. }
  6009. this._searchTimeout( event );
  6010. },
  6011. focus: function() {
  6012. this.selectedItem = null;
  6013. this.previous = this._value();
  6014. },
  6015. blur: function( event ) {
  6016. if ( this.cancelBlur ) {
  6017. delete this.cancelBlur;
  6018. return;
  6019. }
  6020. clearTimeout( this.searching );
  6021. this.close( event );
  6022. this._change( event );
  6023. }
  6024. });
  6025. this._initSource();
  6026. this.menu = $( "<ul>" )
  6027. .addClass( "ui-autocomplete ui-front" )
  6028. .appendTo( this._appendTo() )
  6029. .menu({
  6030. // disable ARIA support, the live region takes care of that
  6031. role: null
  6032. })
  6033. .hide()
  6034. .menu( "instance" );
  6035. this._on( this.menu.element, {
  6036. mousedown: function( event ) {
  6037. // prevent moving focus out of the text field
  6038. event.preventDefault();
  6039. // IE doesn't prevent moving focus even with event.preventDefault()
  6040. // so we set a flag to know when we should ignore the blur event
  6041. this.cancelBlur = true;
  6042. this._delay(function() {
  6043. delete this.cancelBlur;
  6044. });
  6045. // clicking on the scrollbar causes focus to shift to the body
  6046. // but we can't detect a mouseup or a click immediately afterward
  6047. // so we have to track the next mousedown and close the menu if
  6048. // the user clicks somewhere outside of the autocomplete
  6049. var menuElement = this.menu.element[ 0 ];
  6050. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  6051. this._delay(function() {
  6052. var that = this;
  6053. this.document.one( "mousedown", function( event ) {
  6054. if ( event.target !== that.element[ 0 ] &&
  6055. event.target !== menuElement &&
  6056. !$.contains( menuElement, event.target ) ) {
  6057. that.close();
  6058. }
  6059. });
  6060. });
  6061. }
  6062. },
  6063. menufocus: function( event, ui ) {
  6064. var label, item;
  6065. // support: Firefox
  6066. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  6067. if ( this.isNewMenu ) {
  6068. this.isNewMenu = false;
  6069. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  6070. this.menu.blur();
  6071. this.document.one( "mousemove", function() {
  6072. $( event.target ).trigger( event.originalEvent );
  6073. });
  6074. return;
  6075. }
  6076. }
  6077. item = ui.item.data( "ui-autocomplete-item" );
  6078. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  6079. // use value to match what will end up in the input, if it was a key event
  6080. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  6081. this._value( item.value );
  6082. }
  6083. }
  6084. // Announce the value in the liveRegion
  6085. label = ui.item.attr( "aria-label" ) || item.value;
  6086. if ( label && $.trim( label ).length ) {
  6087. this.liveRegion.children().hide();
  6088. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  6089. }
  6090. },
  6091. menuselect: function( event, ui ) {
  6092. var item = ui.item.data( "ui-autocomplete-item" ),
  6093. previous = this.previous;
  6094. // only trigger when focus was lost (click on menu)
  6095. if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
  6096. this.element.focus();
  6097. this.previous = previous;
  6098. // #6109 - IE triggers two focus events and the second
  6099. // is asynchronous, so we need to reset the previous
  6100. // term synchronously and asynchronously :-(
  6101. this._delay(function() {
  6102. this.previous = previous;
  6103. this.selectedItem = item;
  6104. });
  6105. }
  6106. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  6107. this._value( item.value );
  6108. }
  6109. // reset the term after the select event
  6110. // this allows custom select handling to work properly
  6111. this.term = this._value();
  6112. this.close( event );
  6113. this.selectedItem = item;
  6114. }
  6115. });
  6116. this.liveRegion = $( "<span>", {
  6117. role: "status",
  6118. "aria-live": "assertive",
  6119. "aria-relevant": "additions"
  6120. })
  6121. .addClass( "ui-helper-hidden-accessible" )
  6122. .appendTo( this.document[ 0 ].body );
  6123. // turning off autocomplete prevents the browser from remembering the
  6124. // value when navigating through history, so we re-enable autocomplete
  6125. // if the page is unloaded before the widget is destroyed. #7790
  6126. this._on( this.window, {
  6127. beforeunload: function() {
  6128. this.element.removeAttr( "autocomplete" );
  6129. }
  6130. });
  6131. },
  6132. _destroy: function() {
  6133. clearTimeout( this.searching );
  6134. this.element
  6135. .removeClass( "ui-autocomplete-input" )
  6136. .removeAttr( "autocomplete" );
  6137. this.menu.element.remove();
  6138. this.liveRegion.remove();
  6139. },
  6140. _setOption: function( key, value ) {
  6141. this._super( key, value );
  6142. if ( key === "source" ) {
  6143. this._initSource();
  6144. }
  6145. if ( key === "appendTo" ) {
  6146. this.menu.element.appendTo( this._appendTo() );
  6147. }
  6148. if ( key === "disabled" && value && this.xhr ) {
  6149. this.xhr.abort();
  6150. }
  6151. },
  6152. _appendTo: function() {
  6153. var element = this.options.appendTo;
  6154. if ( element ) {
  6155. element = element.jquery || element.nodeType ?
  6156. $( element ) :
  6157. this.document.find( element ).eq( 0 );
  6158. }
  6159. if ( !element || !element[ 0 ] ) {
  6160. element = this.element.closest( ".ui-front" );
  6161. }
  6162. if ( !element.length ) {
  6163. element = this.document[ 0 ].body;
  6164. }
  6165. return element;
  6166. },
  6167. _initSource: function() {
  6168. var array, url,
  6169. that = this;
  6170. if ( $.isArray( this.options.source ) ) {
  6171. array = this.options.source;
  6172. this.source = function( request, response ) {
  6173. response( $.ui.autocomplete.filter( array, request.term ) );
  6174. };
  6175. } else if ( typeof this.options.source === "string" ) {
  6176. url = this.options.source;
  6177. this.source = function( request, response ) {
  6178. if ( that.xhr ) {
  6179. that.xhr.abort();
  6180. }
  6181. that.xhr = $.ajax({
  6182. url: url,
  6183. data: request,
  6184. dataType: "json",
  6185. success: function( data ) {
  6186. response( data );
  6187. },
  6188. error: function() {
  6189. response([]);
  6190. }
  6191. });
  6192. };
  6193. } else {
  6194. this.source = this.options.source;
  6195. }
  6196. },
  6197. _searchTimeout: function( event ) {
  6198. clearTimeout( this.searching );
  6199. this.searching = this._delay(function() {
  6200. // Search if the value has changed, or if the user retypes the same value (see #7434)
  6201. var equalValues = this.term === this._value(),
  6202. menuVisible = this.menu.element.is( ":visible" ),
  6203. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  6204. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  6205. this.selectedItem = null;
  6206. this.search( null, event );
  6207. }
  6208. }, this.options.delay );
  6209. },
  6210. search: function( value, event ) {
  6211. value = value != null ? value : this._value();
  6212. // always save the actual value, not the one passed as an argument
  6213. this.term = this._value();
  6214. if ( value.length < this.options.minLength ) {
  6215. return this.close( event );
  6216. }
  6217. if ( this._trigger( "search", event ) === false ) {
  6218. return;
  6219. }
  6220. return this._search( value );
  6221. },
  6222. _search: function( value ) {
  6223. this.pending++;
  6224. this.element.addClass( "ui-autocomplete-loading" );
  6225. this.cancelSearch = false;
  6226. this.source( { term: value }, this._response() );
  6227. },
  6228. _response: function() {
  6229. var index = ++this.requestIndex;
  6230. return $.proxy(function( content ) {
  6231. if ( index === this.requestIndex ) {
  6232. this.__response( content );
  6233. }
  6234. this.pending--;
  6235. if ( !this.pending ) {
  6236. this.element.removeClass( "ui-autocomplete-loading" );
  6237. }
  6238. }, this );
  6239. },
  6240. __response: function( content ) {
  6241. if ( content ) {
  6242. content = this._normalize( content );
  6243. }
  6244. this._trigger( "response", null, { content: content } );
  6245. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  6246. this._suggest( content );
  6247. this._trigger( "open" );
  6248. } else {
  6249. // use ._close() instead of .close() so we don't cancel future searches
  6250. this._close();
  6251. }
  6252. },
  6253. close: function( event ) {
  6254. this.cancelSearch = true;
  6255. this._close( event );
  6256. },
  6257. _close: function( event ) {
  6258. if ( this.menu.element.is( ":visible" ) ) {
  6259. this.menu.element.hide();
  6260. this.menu.blur();
  6261. this.isNewMenu = true;
  6262. this._trigger( "close", event );
  6263. }
  6264. },
  6265. _change: function( event ) {
  6266. if ( this.previous !== this._value() ) {
  6267. this._trigger( "change", event, { item: this.selectedItem } );
  6268. }
  6269. },
  6270. _normalize: function( items ) {
  6271. // assume all items have the right format when the first item is complete
  6272. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  6273. return items;
  6274. }
  6275. return $.map( items, function( item ) {
  6276. if ( typeof item === "string" ) {
  6277. return {
  6278. label: item,
  6279. value: item
  6280. };
  6281. }
  6282. return $.extend( {}, item, {
  6283. label: item.label || item.value,
  6284. value: item.value || item.label
  6285. });
  6286. });
  6287. },
  6288. _suggest: function( items ) {
  6289. var ul = this.menu.element.empty();
  6290. this._renderMenu( ul, items );
  6291. this.isNewMenu = true;
  6292. this.menu.refresh();
  6293. // size and position menu
  6294. ul.show();
  6295. this._resizeMenu();
  6296. ul.position( $.extend({
  6297. of: this.element
  6298. }, this.options.position ) );
  6299. if ( this.options.autoFocus ) {
  6300. this.menu.next();
  6301. }
  6302. },
  6303. _resizeMenu: function() {
  6304. var ul = this.menu.element;
  6305. ul.outerWidth( Math.max(
  6306. // Firefox wraps long text (possibly a rounding bug)
  6307. // so we add 1px to avoid the wrapping (#7513)
  6308. ul.width( "" ).outerWidth() + 1,
  6309. this.element.outerWidth()
  6310. ) );
  6311. },
  6312. _renderMenu: function( ul, items ) {
  6313. var that = this;
  6314. $.each( items, function( index, item ) {
  6315. that._renderItemData( ul, item );
  6316. });
  6317. },
  6318. _renderItemData: function( ul, item ) {
  6319. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  6320. },
  6321. _renderItem: function( ul, item ) {
  6322. return $( "<li>" ).text( item.label ).appendTo( ul );
  6323. },
  6324. _move: function( direction, event ) {
  6325. if ( !this.menu.element.is( ":visible" ) ) {
  6326. this.search( null, event );
  6327. return;
  6328. }
  6329. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  6330. this.menu.isLastItem() && /^next/.test( direction ) ) {
  6331. if ( !this.isMultiLine ) {
  6332. this._value( this.term );
  6333. }
  6334. this.menu.blur();
  6335. return;
  6336. }
  6337. this.menu[ direction ]( event );
  6338. },
  6339. widget: function() {
  6340. return this.menu.element;
  6341. },
  6342. _value: function() {
  6343. return this.valueMethod.apply( this.element, arguments );
  6344. },
  6345. _keyEvent: function( keyEvent, event ) {
  6346. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  6347. this._move( keyEvent, event );
  6348. // prevents moving cursor to beginning/end of the text field in some browsers
  6349. event.preventDefault();
  6350. }
  6351. }
  6352. });
  6353. $.extend( $.ui.autocomplete, {
  6354. escapeRegex: function( value ) {
  6355. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  6356. },
  6357. filter: function( array, term ) {
  6358. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  6359. return $.grep( array, function( value ) {
  6360. return matcher.test( value.label || value.value || value );
  6361. });
  6362. }
  6363. });
  6364. // live region extension, adding a `messages` option
  6365. // NOTE: This is an experimental API. We are still investigating
  6366. // a full solution for string manipulation and internationalization.
  6367. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  6368. options: {
  6369. messages: {
  6370. noResults: "No search results.",
  6371. results: function( amount ) {
  6372. return amount + ( amount > 1 ? " results are" : " result is" ) +
  6373. " available, use up and down arrow keys to navigate.";
  6374. }
  6375. }
  6376. },
  6377. __response: function( content ) {
  6378. var message;
  6379. this._superApply( arguments );
  6380. if ( this.options.disabled || this.cancelSearch ) {
  6381. return;
  6382. }
  6383. if ( content && content.length ) {
  6384. message = this.options.messages.results( content.length );
  6385. } else {
  6386. message = this.options.messages.noResults;
  6387. }
  6388. this.liveRegion.children().hide();
  6389. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  6390. }
  6391. });
  6392. var autocomplete = $.ui.autocomplete;
  6393. /*!
  6394. * jQuery UI Button 1.11.4
  6395. * http://jqueryui.com
  6396. *
  6397. * Copyright jQuery Foundation and other contributors
  6398. * Released under the MIT license.
  6399. * http://jquery.org/license
  6400. *
  6401. * http://api.jqueryui.com/button/
  6402. */
  6403. var lastActive,
  6404. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  6405. 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",
  6406. formResetHandler = function() {
  6407. var form = $( this );
  6408. setTimeout(function() {
  6409. form.find( ":ui-button" ).button( "refresh" );
  6410. }, 1 );
  6411. },
  6412. radioGroup = function( radio ) {
  6413. var name = radio.name,
  6414. form = radio.form,
  6415. radios = $( [] );
  6416. if ( name ) {
  6417. name = name.replace( /'/g, "\\'" );
  6418. if ( form ) {
  6419. radios = $( form ).find( "[name='" + name + "'][type=radio]" );
  6420. } else {
  6421. radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
  6422. .filter(function() {
  6423. return !this.form;
  6424. });
  6425. }
  6426. }
  6427. return radios;
  6428. };
  6429. $.widget( "ui.button", {
  6430. version: "1.11.4",
  6431. defaultElement: "<button>",
  6432. options: {
  6433. disabled: null,
  6434. text: true,
  6435. label: null,
  6436. icons: {
  6437. primary: null,
  6438. secondary: null
  6439. }
  6440. },
  6441. _create: function() {
  6442. this.element.closest( "form" )
  6443. .unbind( "reset" + this.eventNamespace )
  6444. .bind( "reset" + this.eventNamespace, formResetHandler );
  6445. if ( typeof this.options.disabled !== "boolean" ) {
  6446. this.options.disabled = !!this.element.prop( "disabled" );
  6447. } else {
  6448. this.element.prop( "disabled", this.options.disabled );
  6449. }
  6450. this._determineButtonType();
  6451. this.hasTitle = !!this.buttonElement.attr( "title" );
  6452. var that = this,
  6453. options = this.options,
  6454. toggleButton = this.type === "checkbox" || this.type === "radio",
  6455. activeClass = !toggleButton ? "ui-state-active" : "";
  6456. if ( options.label === null ) {
  6457. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  6458. }
  6459. this._hoverable( this.buttonElement );
  6460. this.buttonElement
  6461. .addClass( baseClasses )
  6462. .attr( "role", "button" )
  6463. .bind( "mouseenter" + this.eventNamespace, function() {
  6464. if ( options.disabled ) {
  6465. return;
  6466. }
  6467. if ( this === lastActive ) {
  6468. $( this ).addClass( "ui-state-active" );
  6469. }
  6470. })
  6471. .bind( "mouseleave" + this.eventNamespace, function() {
  6472. if ( options.disabled ) {
  6473. return;
  6474. }
  6475. $( this ).removeClass( activeClass );
  6476. })
  6477. .bind( "click" + this.eventNamespace, function( event ) {
  6478. if ( options.disabled ) {
  6479. event.preventDefault();
  6480. event.stopImmediatePropagation();
  6481. }
  6482. });
  6483. // Can't use _focusable() because the element that receives focus
  6484. // and the element that gets the ui-state-focus class are different
  6485. this._on({
  6486. focus: function() {
  6487. this.buttonElement.addClass( "ui-state-focus" );
  6488. },
  6489. blur: function() {
  6490. this.buttonElement.removeClass( "ui-state-focus" );
  6491. }
  6492. });
  6493. if ( toggleButton ) {
  6494. this.element.bind( "change" + this.eventNamespace, function() {
  6495. that.refresh();
  6496. });
  6497. }
  6498. if ( this.type === "checkbox" ) {
  6499. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6500. if ( options.disabled ) {
  6501. return false;
  6502. }
  6503. });
  6504. } else if ( this.type === "radio" ) {
  6505. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6506. if ( options.disabled ) {
  6507. return false;
  6508. }
  6509. $( this ).addClass( "ui-state-active" );
  6510. that.buttonElement.attr( "aria-pressed", "true" );
  6511. var radio = that.element[ 0 ];
  6512. radioGroup( radio )
  6513. .not( radio )
  6514. .map(function() {
  6515. return $( this ).button( "widget" )[ 0 ];
  6516. })
  6517. .removeClass( "ui-state-active" )
  6518. .attr( "aria-pressed", "false" );
  6519. });
  6520. } else {
  6521. this.buttonElement
  6522. .bind( "mousedown" + this.eventNamespace, function() {
  6523. if ( options.disabled ) {
  6524. return false;
  6525. }
  6526. $( this ).addClass( "ui-state-active" );
  6527. lastActive = this;
  6528. that.document.one( "mouseup", function() {
  6529. lastActive = null;
  6530. });
  6531. })
  6532. .bind( "mouseup" + this.eventNamespace, function() {
  6533. if ( options.disabled ) {
  6534. return false;
  6535. }
  6536. $( this ).removeClass( "ui-state-active" );
  6537. })
  6538. .bind( "keydown" + this.eventNamespace, function(event) {
  6539. if ( options.disabled ) {
  6540. return false;
  6541. }
  6542. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  6543. $( this ).addClass( "ui-state-active" );
  6544. }
  6545. })
  6546. // see #8559, we bind to blur here in case the button element loses
  6547. // focus between keydown and keyup, it would be left in an "active" state
  6548. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  6549. $( this ).removeClass( "ui-state-active" );
  6550. });
  6551. if ( this.buttonElement.is("a") ) {
  6552. this.buttonElement.keyup(function(event) {
  6553. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  6554. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  6555. $( this ).click();
  6556. }
  6557. });
  6558. }
  6559. }
  6560. this._setOption( "disabled", options.disabled );
  6561. this._resetButton();
  6562. },
  6563. _determineButtonType: function() {
  6564. var ancestor, labelSelector, checked;
  6565. if ( this.element.is("[type=checkbox]") ) {
  6566. this.type = "checkbox";
  6567. } else if ( this.element.is("[type=radio]") ) {
  6568. this.type = "radio";
  6569. } else if ( this.element.is("input") ) {
  6570. this.type = "input";
  6571. } else {
  6572. this.type = "button";
  6573. }
  6574. if ( this.type === "checkbox" || this.type === "radio" ) {
  6575. // we don't search against the document in case the element
  6576. // is disconnected from the DOM
  6577. ancestor = this.element.parents().last();
  6578. labelSelector = "label[for='" + this.element.attr("id") + "']";
  6579. this.buttonElement = ancestor.find( labelSelector );
  6580. if ( !this.buttonElement.length ) {
  6581. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  6582. this.buttonElement = ancestor.filter( labelSelector );
  6583. if ( !this.buttonElement.length ) {
  6584. this.buttonElement = ancestor.find( labelSelector );
  6585. }
  6586. }
  6587. this.element.addClass( "ui-helper-hidden-accessible" );
  6588. checked = this.element.is( ":checked" );
  6589. if ( checked ) {
  6590. this.buttonElement.addClass( "ui-state-active" );
  6591. }
  6592. this.buttonElement.prop( "aria-pressed", checked );
  6593. } else {
  6594. this.buttonElement = this.element;
  6595. }
  6596. },
  6597. widget: function() {
  6598. return this.buttonElement;
  6599. },
  6600. _destroy: function() {
  6601. this.element
  6602. .removeClass( "ui-helper-hidden-accessible" );
  6603. this.buttonElement
  6604. .removeClass( baseClasses + " ui-state-active " + typeClasses )
  6605. .removeAttr( "role" )
  6606. .removeAttr( "aria-pressed" )
  6607. .html( this.buttonElement.find(".ui-button-text").html() );
  6608. if ( !this.hasTitle ) {
  6609. this.buttonElement.removeAttr( "title" );
  6610. }
  6611. },
  6612. _setOption: function( key, value ) {
  6613. this._super( key, value );
  6614. if ( key === "disabled" ) {
  6615. this.widget().toggleClass( "ui-state-disabled", !!value );
  6616. this.element.prop( "disabled", !!value );
  6617. if ( value ) {
  6618. if ( this.type === "checkbox" || this.type === "radio" ) {
  6619. this.buttonElement.removeClass( "ui-state-focus" );
  6620. } else {
  6621. this.buttonElement.removeClass( "ui-state-focus ui-state-active" );
  6622. }
  6623. }
  6624. return;
  6625. }
  6626. this._resetButton();
  6627. },
  6628. refresh: function() {
  6629. //See #8237 & #8828
  6630. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  6631. if ( isDisabled !== this.options.disabled ) {
  6632. this._setOption( "disabled", isDisabled );
  6633. }
  6634. if ( this.type === "radio" ) {
  6635. radioGroup( this.element[0] ).each(function() {
  6636. if ( $( this ).is( ":checked" ) ) {
  6637. $( this ).button( "widget" )
  6638. .addClass( "ui-state-active" )
  6639. .attr( "aria-pressed", "true" );
  6640. } else {
  6641. $( this ).button( "widget" )
  6642. .removeClass( "ui-state-active" )
  6643. .attr( "aria-pressed", "false" );
  6644. }
  6645. });
  6646. } else if ( this.type === "checkbox" ) {
  6647. if ( this.element.is( ":checked" ) ) {
  6648. this.buttonElement
  6649. .addClass( "ui-state-active" )
  6650. .attr( "aria-pressed", "true" );
  6651. } else {
  6652. this.buttonElement
  6653. .removeClass( "ui-state-active" )
  6654. .attr( "aria-pressed", "false" );
  6655. }
  6656. }
  6657. },
  6658. _resetButton: function() {
  6659. if ( this.type === "input" ) {
  6660. if ( this.options.label ) {
  6661. this.element.val( this.options.label );
  6662. }
  6663. return;
  6664. }
  6665. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  6666. buttonText = $( "<span></span>", this.document[0] )
  6667. .addClass( "ui-button-text" )
  6668. .html( this.options.label )
  6669. .appendTo( buttonElement.empty() )
  6670. .text(),
  6671. icons = this.options.icons,
  6672. multipleIcons = icons.primary && icons.secondary,
  6673. buttonClasses = [];
  6674. if ( icons.primary || icons.secondary ) {
  6675. if ( this.options.text ) {
  6676. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  6677. }
  6678. if ( icons.primary ) {
  6679. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  6680. }
  6681. if ( icons.secondary ) {
  6682. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  6683. }
  6684. if ( !this.options.text ) {
  6685. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  6686. if ( !this.hasTitle ) {
  6687. buttonElement.attr( "title", $.trim( buttonText ) );
  6688. }
  6689. }
  6690. } else {
  6691. buttonClasses.push( "ui-button-text-only" );
  6692. }
  6693. buttonElement.addClass( buttonClasses.join( " " ) );
  6694. }
  6695. });
  6696. $.widget( "ui.buttonset", {
  6697. version: "1.11.4",
  6698. options: {
  6699. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  6700. },
  6701. _create: function() {
  6702. this.element.addClass( "ui-buttonset" );
  6703. },
  6704. _init: function() {
  6705. this.refresh();
  6706. },
  6707. _setOption: function( key, value ) {
  6708. if ( key === "disabled" ) {
  6709. this.buttons.button( "option", key, value );
  6710. }
  6711. this._super( key, value );
  6712. },
  6713. refresh: function() {
  6714. var rtl = this.element.css( "direction" ) === "rtl",
  6715. allButtons = this.element.find( this.options.items ),
  6716. existingButtons = allButtons.filter( ":ui-button" );
  6717. // Initialize new buttons
  6718. allButtons.not( ":ui-button" ).button();
  6719. // Refresh existing buttons
  6720. existingButtons.button( "refresh" );
  6721. this.buttons = allButtons
  6722. .map(function() {
  6723. return $( this ).button( "widget" )[ 0 ];
  6724. })
  6725. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  6726. .filter( ":first" )
  6727. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  6728. .end()
  6729. .filter( ":last" )
  6730. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  6731. .end()
  6732. .end();
  6733. },
  6734. _destroy: function() {
  6735. this.element.removeClass( "ui-buttonset" );
  6736. this.buttons
  6737. .map(function() {
  6738. return $( this ).button( "widget" )[ 0 ];
  6739. })
  6740. .removeClass( "ui-corner-left ui-corner-right" )
  6741. .end()
  6742. .button( "destroy" );
  6743. }
  6744. });
  6745. var button = $.ui.button;
  6746. /*!
  6747. * jQuery UI Datepicker 1.11.4
  6748. * http://jqueryui.com
  6749. *
  6750. * Copyright jQuery Foundation and other contributors
  6751. * Released under the MIT license.
  6752. * http://jquery.org/license
  6753. *
  6754. * http://api.jqueryui.com/datepicker/
  6755. */
  6756. $.extend($.ui, { datepicker: { version: "1.11.4" } });
  6757. var datepicker_instActive;
  6758. function datepicker_getZindex( elem ) {
  6759. var position, value;
  6760. while ( elem.length && elem[ 0 ] !== document ) {
  6761. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  6762. // This makes behavior of this function consistent across browsers
  6763. // WebKit always returns auto if the element is positioned
  6764. position = elem.css( "position" );
  6765. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  6766. // IE returns 0 when zIndex is not specified
  6767. // other browsers return a string
  6768. // we ignore the case of nested elements with an explicit value of 0
  6769. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  6770. value = parseInt( elem.css( "zIndex" ), 10 );
  6771. if ( !isNaN( value ) && value !== 0 ) {
  6772. return value;
  6773. }
  6774. }
  6775. elem = elem.parent();
  6776. }
  6777. return 0;
  6778. }
  6779. /* Date picker manager.
  6780. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6781. Settings for (groups of) date pickers are maintained in an instance object,
  6782. allowing multiple different settings on the same page. */
  6783. function Datepicker() {
  6784. this._curInst = null; // The current instance in use
  6785. this._keyEvent = false; // If the last event was a key event
  6786. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6787. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6788. this._inDialog = false; // True if showing within a "dialog", false if not
  6789. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  6790. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  6791. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  6792. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  6793. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  6794. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  6795. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  6796. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  6797. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  6798. this.regional = []; // Available regional settings, indexed by language code
  6799. this.regional[""] = { // Default regional settings
  6800. closeText: "Done", // Display text for close link
  6801. prevText: "Prev", // Display text for previous month link
  6802. nextText: "Next", // Display text for next month link
  6803. currentText: "Today", // Display text for current month link
  6804. monthNames: ["January","February","March","April","May","June",
  6805. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  6806. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  6807. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  6808. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  6809. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  6810. weekHeader: "Wk", // Column header for week of the year
  6811. dateFormat: "mm/dd/yy", // See format options on parseDate
  6812. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6813. isRTL: false, // True if right-to-left language, false if left-to-right
  6814. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6815. yearSuffix: "" // Additional text to append to the year in the month headers
  6816. };
  6817. this._defaults = { // Global defaults for all the date picker instances
  6818. showOn: "focus", // "focus" for popup on focus,
  6819. // "button" for trigger button, or "both" for either
  6820. showAnim: "fadeIn", // Name of jQuery animation for popup
  6821. showOptions: {}, // Options for enhanced animations
  6822. defaultDate: null, // Used when field is blank: actual date,
  6823. // +/-number for offset from today, null for today
  6824. appendText: "", // Display text following the input box, e.g. showing the format
  6825. buttonText: "...", // Text for trigger button
  6826. buttonImage: "", // URL for trigger button image
  6827. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6828. hideIfNoPrevNext: false, // True to hide next/previous month links
  6829. // if not applicable, false to just disable them
  6830. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6831. gotoCurrent: false, // True if today link goes back to current selection instead
  6832. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6833. changeYear: false, // True if year can be selected directly, false if only prev/next
  6834. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  6835. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6836. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6837. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6838. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6839. showWeek: false, // True to show week of the year, false to not show it
  6840. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6841. // takes a Date and returns the number of the week for it
  6842. shortYearCutoff: "+10", // Short year values < this are in the current century,
  6843. // > this are in the previous century,
  6844. // string value starting with "+" for current year + value
  6845. minDate: null, // The earliest selectable date, or null for no limit
  6846. maxDate: null, // The latest selectable date, or null for no limit
  6847. duration: "fast", // Duration of display/closure
  6848. beforeShowDay: null, // Function that takes a date and returns an array with
  6849. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  6850. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6851. beforeShow: null, // Function that takes an input field and
  6852. // returns a set of custom settings for the date picker
  6853. onSelect: null, // Define a callback function when a date is selected
  6854. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6855. onClose: null, // Define a callback function when the datepicker is closed
  6856. numberOfMonths: 1, // Number of months to show at a time
  6857. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6858. stepMonths: 1, // Number of months to step back/forward
  6859. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6860. altField: "", // Selector for an alternate field to store selected dates into
  6861. altFormat: "", // The date format to use for the alternate field
  6862. constrainInput: true, // The input is constrained by the current date format
  6863. showButtonPanel: false, // True to show button panel, false to not show it
  6864. autoSize: false, // True to size the input for the date format, false to leave as is
  6865. disabled: false // The initial disabled state
  6866. };
  6867. $.extend(this._defaults, this.regional[""]);
  6868. this.regional.en = $.extend( true, {}, this.regional[ "" ]);
  6869. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  6870. this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  6871. }
  6872. $.extend(Datepicker.prototype, {
  6873. /* Class name added to elements to indicate already configured with a date picker. */
  6874. markerClassName: "hasDatepicker",
  6875. //Keep track of the maximum number of rows displayed (see #7043)
  6876. maxRows: 4,
  6877. // TODO rename to "widget" when switching to widget factory
  6878. _widgetDatepicker: function() {
  6879. return this.dpDiv;
  6880. },
  6881. /* Override the default settings for all instances of the date picker.
  6882. * @param settings object - the new settings to use as defaults (anonymous object)
  6883. * @return the manager object
  6884. */
  6885. setDefaults: function(settings) {
  6886. datepicker_extendRemove(this._defaults, settings || {});
  6887. return this;
  6888. },
  6889. /* Attach the date picker to a jQuery selection.
  6890. * @param target element - the target input field or division or span
  6891. * @param settings object - the new settings to use for this date picker instance (anonymous)
  6892. */
  6893. _attachDatepicker: function(target, settings) {
  6894. var nodeName, inline, inst;
  6895. nodeName = target.nodeName.toLowerCase();
  6896. inline = (nodeName === "div" || nodeName === "span");
  6897. if (!target.id) {
  6898. this.uuid += 1;
  6899. target.id = "dp" + this.uuid;
  6900. }
  6901. inst = this._newInst($(target), inline);
  6902. inst.settings = $.extend({}, settings || {});
  6903. if (nodeName === "input") {
  6904. this._connectDatepicker(target, inst);
  6905. } else if (inline) {
  6906. this._inlineDatepicker(target, inst);
  6907. }
  6908. },
  6909. /* Create a new instance object. */
  6910. _newInst: function(target, inline) {
  6911. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  6912. return {id: id, input: target, // associated target
  6913. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6914. drawMonth: 0, drawYear: 0, // month being drawn
  6915. inline: inline, // is datepicker inline or not
  6916. dpDiv: (!inline ? this.dpDiv : // presentation div
  6917. datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  6918. },
  6919. /* Attach the date picker to an input field. */
  6920. _connectDatepicker: function(target, inst) {
  6921. var input = $(target);
  6922. inst.append = $([]);
  6923. inst.trigger = $([]);
  6924. if (input.hasClass(this.markerClassName)) {
  6925. return;
  6926. }
  6927. this._attachments(input, inst);
  6928. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  6929. keypress(this._doKeyPress).keyup(this._doKeyUp);
  6930. this._autoSize(inst);
  6931. $.data(target, "datepicker", inst);
  6932. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  6933. if( inst.settings.disabled ) {
  6934. this._disableDatepicker( target );
  6935. }
  6936. },
  6937. /* Make attachments based on settings. */
  6938. _attachments: function(input, inst) {
  6939. var showOn, buttonText, buttonImage,
  6940. appendText = this._get(inst, "appendText"),
  6941. isRTL = this._get(inst, "isRTL");
  6942. if (inst.append) {
  6943. inst.append.remove();
  6944. }
  6945. if (appendText) {
  6946. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  6947. input[isRTL ? "before" : "after"](inst.append);
  6948. }
  6949. input.unbind("focus", this._showDatepicker);
  6950. if (inst.trigger) {
  6951. inst.trigger.remove();
  6952. }
  6953. showOn = this._get(inst, "showOn");
  6954. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  6955. input.focus(this._showDatepicker);
  6956. }
  6957. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  6958. buttonText = this._get(inst, "buttonText");
  6959. buttonImage = this._get(inst, "buttonImage");
  6960. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  6961. $("<img/>").addClass(this._triggerClass).
  6962. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  6963. $("<button type='button'></button>").addClass(this._triggerClass).
  6964. html(!buttonImage ? buttonText : $("<img/>").attr(
  6965. { src:buttonImage, alt:buttonText, title:buttonText })));
  6966. input[isRTL ? "before" : "after"](inst.trigger);
  6967. inst.trigger.click(function() {
  6968. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  6969. $.datepicker._hideDatepicker();
  6970. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  6971. $.datepicker._hideDatepicker();
  6972. $.datepicker._showDatepicker(input[0]);
  6973. } else {
  6974. $.datepicker._showDatepicker(input[0]);
  6975. }
  6976. return false;
  6977. });
  6978. }
  6979. },
  6980. /* Apply the maximum length for the date format. */
  6981. _autoSize: function(inst) {
  6982. if (this._get(inst, "autoSize") && !inst.inline) {
  6983. var findMax, max, maxI, i,
  6984. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  6985. dateFormat = this._get(inst, "dateFormat");
  6986. if (dateFormat.match(/[DM]/)) {
  6987. findMax = function(names) {
  6988. max = 0;
  6989. maxI = 0;
  6990. for (i = 0; i < names.length; i++) {
  6991. if (names[i].length > max) {
  6992. max = names[i].length;
  6993. maxI = i;
  6994. }
  6995. }
  6996. return maxI;
  6997. };
  6998. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  6999. "monthNames" : "monthNamesShort"))));
  7000. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  7001. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  7002. }
  7003. inst.input.attr("size", this._formatDate(inst, date).length);
  7004. }
  7005. },
  7006. /* Attach an inline date picker to a div. */
  7007. _inlineDatepicker: function(target, inst) {
  7008. var divSpan = $(target);
  7009. if (divSpan.hasClass(this.markerClassName)) {
  7010. return;
  7011. }
  7012. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  7013. $.data(target, "datepicker", inst);
  7014. this._setDate(inst, this._getDefaultDate(inst), true);
  7015. this._updateDatepicker(inst);
  7016. this._updateAlternate(inst);
  7017. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  7018. if( inst.settings.disabled ) {
  7019. this._disableDatepicker( target );
  7020. }
  7021. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  7022. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  7023. inst.dpDiv.css( "display", "block" );
  7024. },
  7025. /* Pop-up the date picker in a "dialog" box.
  7026. * @param input element - ignored
  7027. * @param date string or Date - the initial date to display
  7028. * @param onSelect function - the function to call when a date is selected
  7029. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  7030. * @param pos int[2] - coordinates for the dialog's position within the screen or
  7031. * event - with x/y coordinates or
  7032. * leave empty for default (screen centre)
  7033. * @return the manager object
  7034. */
  7035. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  7036. var id, browserWidth, browserHeight, scrollX, scrollY,
  7037. inst = this._dialogInst; // internal instance
  7038. if (!inst) {
  7039. this.uuid += 1;
  7040. id = "dp" + this.uuid;
  7041. this._dialogInput = $("<input type='text' id='" + id +
  7042. "' style='position: absolute; top: -100px; width: 0px;'/>");
  7043. this._dialogInput.keydown(this._doKeyDown);
  7044. $("body").append(this._dialogInput);
  7045. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  7046. inst.settings = {};
  7047. $.data(this._dialogInput[0], "datepicker", inst);
  7048. }
  7049. datepicker_extendRemove(inst.settings, settings || {});
  7050. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  7051. this._dialogInput.val(date);
  7052. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  7053. if (!this._pos) {
  7054. browserWidth = document.documentElement.clientWidth;
  7055. browserHeight = document.documentElement.clientHeight;
  7056. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  7057. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  7058. this._pos = // should use actual width/height below
  7059. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  7060. }
  7061. // move input on screen for focus, but hidden behind dialog
  7062. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  7063. inst.settings.onSelect = onSelect;
  7064. this._inDialog = true;
  7065. this.dpDiv.addClass(this._dialogClass);
  7066. this._showDatepicker(this._dialogInput[0]);
  7067. if ($.blockUI) {
  7068. $.blockUI(this.dpDiv);
  7069. }
  7070. $.data(this._dialogInput[0], "datepicker", inst);
  7071. return this;
  7072. },
  7073. /* Detach a datepicker from its control.
  7074. * @param target element - the target input field or division or span
  7075. */
  7076. _destroyDatepicker: function(target) {
  7077. var nodeName,
  7078. $target = $(target),
  7079. inst = $.data(target, "datepicker");
  7080. if (!$target.hasClass(this.markerClassName)) {
  7081. return;
  7082. }
  7083. nodeName = target.nodeName.toLowerCase();
  7084. $.removeData(target, "datepicker");
  7085. if (nodeName === "input") {
  7086. inst.append.remove();
  7087. inst.trigger.remove();
  7088. $target.removeClass(this.markerClassName).
  7089. unbind("focus", this._showDatepicker).
  7090. unbind("keydown", this._doKeyDown).
  7091. unbind("keypress", this._doKeyPress).
  7092. unbind("keyup", this._doKeyUp);
  7093. } else if (nodeName === "div" || nodeName === "span") {
  7094. $target.removeClass(this.markerClassName).empty();
  7095. }
  7096. if ( datepicker_instActive === inst ) {
  7097. datepicker_instActive = null;
  7098. }
  7099. },
  7100. /* Enable the date picker to a jQuery selection.
  7101. * @param target element - the target input field or division or span
  7102. */
  7103. _enableDatepicker: function(target) {
  7104. var nodeName, inline,
  7105. $target = $(target),
  7106. inst = $.data(target, "datepicker");
  7107. if (!$target.hasClass(this.markerClassName)) {
  7108. return;
  7109. }
  7110. nodeName = target.nodeName.toLowerCase();
  7111. if (nodeName === "input") {
  7112. target.disabled = false;
  7113. inst.trigger.filter("button").
  7114. each(function() { this.disabled = false; }).end().
  7115. filter("img").css({opacity: "1.0", cursor: ""});
  7116. } else if (nodeName === "div" || nodeName === "span") {
  7117. inline = $target.children("." + this._inlineClass);
  7118. inline.children().removeClass("ui-state-disabled");
  7119. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  7120. prop("disabled", false);
  7121. }
  7122. this._disabledInputs = $.map(this._disabledInputs,
  7123. function(value) { return (value === target ? null : value); }); // delete entry
  7124. },
  7125. /* Disable the date picker to a jQuery selection.
  7126. * @param target element - the target input field or division or span
  7127. */
  7128. _disableDatepicker: function(target) {
  7129. var nodeName, inline,
  7130. $target = $(target),
  7131. inst = $.data(target, "datepicker");
  7132. if (!$target.hasClass(this.markerClassName)) {
  7133. return;
  7134. }
  7135. nodeName = target.nodeName.toLowerCase();
  7136. if (nodeName === "input") {
  7137. target.disabled = true;
  7138. inst.trigger.filter("button").
  7139. each(function() { this.disabled = true; }).end().
  7140. filter("img").css({opacity: "0.5", cursor: "default"});
  7141. } else if (nodeName === "div" || nodeName === "span") {
  7142. inline = $target.children("." + this._inlineClass);
  7143. inline.children().addClass("ui-state-disabled");
  7144. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  7145. prop("disabled", true);
  7146. }
  7147. this._disabledInputs = $.map(this._disabledInputs,
  7148. function(value) { return (value === target ? null : value); }); // delete entry
  7149. this._disabledInputs[this._disabledInputs.length] = target;
  7150. },
  7151. /* Is the first field in a jQuery collection disabled as a datepicker?
  7152. * @param target element - the target input field or division or span
  7153. * @return boolean - true if disabled, false if enabled
  7154. */
  7155. _isDisabledDatepicker: function(target) {
  7156. if (!target) {
  7157. return false;
  7158. }
  7159. for (var i = 0; i < this._disabledInputs.length; i++) {
  7160. if (this._disabledInputs[i] === target) {
  7161. return true;
  7162. }
  7163. }
  7164. return false;
  7165. },
  7166. /* Retrieve the instance data for the target control.
  7167. * @param target element - the target input field or division or span
  7168. * @return object - the associated instance data
  7169. * @throws error if a jQuery problem getting data
  7170. */
  7171. _getInst: function(target) {
  7172. try {
  7173. return $.data(target, "datepicker");
  7174. }
  7175. catch (err) {
  7176. throw "Missing instance data for this datepicker";
  7177. }
  7178. },
  7179. /* Update or retrieve the settings for a date picker attached to an input field or division.
  7180. * @param target element - the target input field or division or span
  7181. * @param name object - the new settings to update or
  7182. * string - the name of the setting to change or retrieve,
  7183. * when retrieving also "all" for all instance settings or
  7184. * "defaults" for all global defaults
  7185. * @param value any - the new value for the setting
  7186. * (omit if above is an object or to retrieve a value)
  7187. */
  7188. _optionDatepicker: function(target, name, value) {
  7189. var settings, date, minDate, maxDate,
  7190. inst = this._getInst(target);
  7191. if (arguments.length === 2 && typeof name === "string") {
  7192. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  7193. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  7194. this._get(inst, name)) : null));
  7195. }
  7196. settings = name || {};
  7197. if (typeof name === "string") {
  7198. settings = {};
  7199. settings[name] = value;
  7200. }
  7201. if (inst) {
  7202. if (this._curInst === inst) {
  7203. this._hideDatepicker();
  7204. }
  7205. date = this._getDateDatepicker(target, true);
  7206. minDate = this._getMinMaxDate(inst, "min");
  7207. maxDate = this._getMinMaxDate(inst, "max");
  7208. datepicker_extendRemove(inst.settings, settings);
  7209. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  7210. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  7211. inst.settings.minDate = this._formatDate(inst, minDate);
  7212. }
  7213. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  7214. inst.settings.maxDate = this._formatDate(inst, maxDate);
  7215. }
  7216. if ( "disabled" in settings ) {
  7217. if ( settings.disabled ) {
  7218. this._disableDatepicker(target);
  7219. } else {
  7220. this._enableDatepicker(target);
  7221. }
  7222. }
  7223. this._attachments($(target), inst);
  7224. this._autoSize(inst);
  7225. this._setDate(inst, date);
  7226. this._updateAlternate(inst);
  7227. this._updateDatepicker(inst);
  7228. }
  7229. },
  7230. // change method deprecated
  7231. _changeDatepicker: function(target, name, value) {
  7232. this._optionDatepicker(target, name, value);
  7233. },
  7234. /* Redraw the date picker attached to an input field or division.
  7235. * @param target element - the target input field or division or span
  7236. */
  7237. _refreshDatepicker: function(target) {
  7238. var inst = this._getInst(target);
  7239. if (inst) {
  7240. this._updateDatepicker(inst);
  7241. }
  7242. },
  7243. /* Set the dates for a jQuery selection.
  7244. * @param target element - the target input field or division or span
  7245. * @param date Date - the new date
  7246. */
  7247. _setDateDatepicker: function(target, date) {
  7248. var inst = this._getInst(target);
  7249. if (inst) {
  7250. this._setDate(inst, date);
  7251. this._updateDatepicker(inst);
  7252. this._updateAlternate(inst);
  7253. }
  7254. },
  7255. /* Get the date(s) for the first entry in a jQuery selection.
  7256. * @param target element - the target input field or division or span
  7257. * @param noDefault boolean - true if no default date is to be used
  7258. * @return Date - the current date
  7259. */
  7260. _getDateDatepicker: function(target, noDefault) {
  7261. var inst = this._getInst(target);
  7262. if (inst && !inst.inline) {
  7263. this._setDateFromField(inst, noDefault);
  7264. }
  7265. return (inst ? this._getDate(inst) : null);
  7266. },
  7267. /* Handle keystrokes. */
  7268. _doKeyDown: function(event) {
  7269. var onSelect, dateStr, sel,
  7270. inst = $.datepicker._getInst(event.target),
  7271. handled = true,
  7272. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  7273. inst._keyEvent = true;
  7274. if ($.datepicker._datepickerShowing) {
  7275. switch (event.keyCode) {
  7276. case 9: $.datepicker._hideDatepicker();
  7277. handled = false;
  7278. break; // hide on tab out
  7279. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  7280. $.datepicker._currentClass + ")", inst.dpDiv);
  7281. if (sel[0]) {
  7282. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  7283. }
  7284. onSelect = $.datepicker._get(inst, "onSelect");
  7285. if (onSelect) {
  7286. dateStr = $.datepicker._formatDate(inst);
  7287. // trigger custom callback
  7288. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  7289. } else {
  7290. $.datepicker._hideDatepicker();
  7291. }
  7292. return false; // don't submit the form
  7293. case 27: $.datepicker._hideDatepicker();
  7294. break; // hide on escape
  7295. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7296. -$.datepicker._get(inst, "stepBigMonths") :
  7297. -$.datepicker._get(inst, "stepMonths")), "M");
  7298. break; // previous month/year on page up/+ ctrl
  7299. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7300. +$.datepicker._get(inst, "stepBigMonths") :
  7301. +$.datepicker._get(inst, "stepMonths")), "M");
  7302. break; // next month/year on page down/+ ctrl
  7303. case 35: if (event.ctrlKey || event.metaKey) {
  7304. $.datepicker._clearDate(event.target);
  7305. }
  7306. handled = event.ctrlKey || event.metaKey;
  7307. break; // clear on ctrl or command +end
  7308. case 36: if (event.ctrlKey || event.metaKey) {
  7309. $.datepicker._gotoToday(event.target);
  7310. }
  7311. handled = event.ctrlKey || event.metaKey;
  7312. break; // current on ctrl or command +home
  7313. case 37: if (event.ctrlKey || event.metaKey) {
  7314. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  7315. }
  7316. handled = event.ctrlKey || event.metaKey;
  7317. // -1 day on ctrl or command +left
  7318. if (event.originalEvent.altKey) {
  7319. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7320. -$.datepicker._get(inst, "stepBigMonths") :
  7321. -$.datepicker._get(inst, "stepMonths")), "M");
  7322. }
  7323. // next month/year on alt +left on Mac
  7324. break;
  7325. case 38: if (event.ctrlKey || event.metaKey) {
  7326. $.datepicker._adjustDate(event.target, -7, "D");
  7327. }
  7328. handled = event.ctrlKey || event.metaKey;
  7329. break; // -1 week on ctrl or command +up
  7330. case 39: if (event.ctrlKey || event.metaKey) {
  7331. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  7332. }
  7333. handled = event.ctrlKey || event.metaKey;
  7334. // +1 day on ctrl or command +right
  7335. if (event.originalEvent.altKey) {
  7336. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7337. +$.datepicker._get(inst, "stepBigMonths") :
  7338. +$.datepicker._get(inst, "stepMonths")), "M");
  7339. }
  7340. // next month/year on alt +right
  7341. break;
  7342. case 40: if (event.ctrlKey || event.metaKey) {
  7343. $.datepicker._adjustDate(event.target, +7, "D");
  7344. }
  7345. handled = event.ctrlKey || event.metaKey;
  7346. break; // +1 week on ctrl or command +down
  7347. default: handled = false;
  7348. }
  7349. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  7350. $.datepicker._showDatepicker(this);
  7351. } else {
  7352. handled = false;
  7353. }
  7354. if (handled) {
  7355. event.preventDefault();
  7356. event.stopPropagation();
  7357. }
  7358. },
  7359. /* Filter entered characters - based on date format. */
  7360. _doKeyPress: function(event) {
  7361. var chars, chr,
  7362. inst = $.datepicker._getInst(event.target);
  7363. if ($.datepicker._get(inst, "constrainInput")) {
  7364. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  7365. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  7366. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  7367. }
  7368. },
  7369. /* Synchronise manual entry and field/alternate field. */
  7370. _doKeyUp: function(event) {
  7371. var date,
  7372. inst = $.datepicker._getInst(event.target);
  7373. if (inst.input.val() !== inst.lastVal) {
  7374. try {
  7375. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7376. (inst.input ? inst.input.val() : null),
  7377. $.datepicker._getFormatConfig(inst));
  7378. if (date) { // only if valid
  7379. $.datepicker._setDateFromField(inst);
  7380. $.datepicker._updateAlternate(inst);
  7381. $.datepicker._updateDatepicker(inst);
  7382. }
  7383. }
  7384. catch (err) {
  7385. }
  7386. }
  7387. return true;
  7388. },
  7389. /* Pop-up the date picker for a given input field.
  7390. * If false returned from beforeShow event handler do not show.
  7391. * @param input element - the input field attached to the date picker or
  7392. * event - if triggered by focus
  7393. */
  7394. _showDatepicker: function(input) {
  7395. input = input.target || input;
  7396. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  7397. input = $("input", input.parentNode)[0];
  7398. }
  7399. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  7400. return;
  7401. }
  7402. var inst, beforeShow, beforeShowSettings, isFixed,
  7403. offset, showAnim, duration;
  7404. inst = $.datepicker._getInst(input);
  7405. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  7406. $.datepicker._curInst.dpDiv.stop(true, true);
  7407. if ( inst && $.datepicker._datepickerShowing ) {
  7408. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  7409. }
  7410. }
  7411. beforeShow = $.datepicker._get(inst, "beforeShow");
  7412. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  7413. if(beforeShowSettings === false){
  7414. return;
  7415. }
  7416. datepicker_extendRemove(inst.settings, beforeShowSettings);
  7417. inst.lastVal = null;
  7418. $.datepicker._lastInput = input;
  7419. $.datepicker._setDateFromField(inst);
  7420. if ($.datepicker._inDialog) { // hide cursor
  7421. input.value = "";
  7422. }
  7423. if (!$.datepicker._pos) { // position below input
  7424. $.datepicker._pos = $.datepicker._findPos(input);
  7425. $.datepicker._pos[1] += input.offsetHeight; // add the height
  7426. }
  7427. isFixed = false;
  7428. $(input).parents().each(function() {
  7429. isFixed |= $(this).css("position") === "fixed";
  7430. return !isFixed;
  7431. });
  7432. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  7433. $.datepicker._pos = null;
  7434. //to avoid flashes on Firefox
  7435. inst.dpDiv.empty();
  7436. // determine sizing offscreen
  7437. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  7438. $.datepicker._updateDatepicker(inst);
  7439. // fix width for dynamic number of date pickers
  7440. // and adjust position before showing
  7441. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  7442. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  7443. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  7444. left: offset.left + "px", top: offset.top + "px"});
  7445. if (!inst.inline) {
  7446. showAnim = $.datepicker._get(inst, "showAnim");
  7447. duration = $.datepicker._get(inst, "duration");
  7448. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  7449. $.datepicker._datepickerShowing = true;
  7450. if ( $.effects && $.effects.effect[ showAnim ] ) {
  7451. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  7452. } else {
  7453. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  7454. }
  7455. if ( $.datepicker._shouldFocusInput( inst ) ) {
  7456. inst.input.focus();
  7457. }
  7458. $.datepicker._curInst = inst;
  7459. }
  7460. },
  7461. /* Generate the date picker content. */
  7462. _updateDatepicker: function(inst) {
  7463. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  7464. datepicker_instActive = inst; // for delegate hover events
  7465. inst.dpDiv.empty().append(this._generateHTML(inst));
  7466. this._attachHandlers(inst);
  7467. var origyearshtml,
  7468. numMonths = this._getNumberOfMonths(inst),
  7469. cols = numMonths[1],
  7470. width = 17,
  7471. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
  7472. if ( activeCell.length > 0 ) {
  7473. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  7474. }
  7475. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  7476. if (cols > 1) {
  7477. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  7478. }
  7479. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  7480. "Class"]("ui-datepicker-multi");
  7481. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  7482. "Class"]("ui-datepicker-rtl");
  7483. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  7484. inst.input.focus();
  7485. }
  7486. // deffered render of the years select (to avoid flashes on Firefox)
  7487. if( inst.yearshtml ){
  7488. origyearshtml = inst.yearshtml;
  7489. setTimeout(function(){
  7490. //assure that inst.yearshtml didn't change.
  7491. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  7492. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  7493. }
  7494. origyearshtml = inst.yearshtml = null;
  7495. }, 0);
  7496. }
  7497. },
  7498. // #6694 - don't focus the input if it's already focused
  7499. // this breaks the change event in IE
  7500. // Support: IE and jQuery <1.9
  7501. _shouldFocusInput: function( inst ) {
  7502. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  7503. },
  7504. /* Check positioning to remain on screen. */
  7505. _checkOffset: function(inst, offset, isFixed) {
  7506. var dpWidth = inst.dpDiv.outerWidth(),
  7507. dpHeight = inst.dpDiv.outerHeight(),
  7508. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  7509. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  7510. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  7511. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  7512. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  7513. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  7514. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  7515. // now check if datepicker is showing outside window viewport - move to a better place if so.
  7516. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  7517. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  7518. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  7519. Math.abs(dpHeight + inputHeight) : 0);
  7520. return offset;
  7521. },
  7522. /* Find an object's position on the screen. */
  7523. _findPos: function(obj) {
  7524. var position,
  7525. inst = this._getInst(obj),
  7526. isRTL = this._get(inst, "isRTL");
  7527. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  7528. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  7529. }
  7530. position = $(obj).offset();
  7531. return [position.left, position.top];
  7532. },
  7533. /* Hide the date picker from view.
  7534. * @param input element - the input field attached to the date picker
  7535. */
  7536. _hideDatepicker: function(input) {
  7537. var showAnim, duration, postProcess, onClose,
  7538. inst = this._curInst;
  7539. if (!inst || (input && inst !== $.data(input, "datepicker"))) {
  7540. return;
  7541. }
  7542. if (this._datepickerShowing) {
  7543. showAnim = this._get(inst, "showAnim");
  7544. duration = this._get(inst, "duration");
  7545. postProcess = function() {
  7546. $.datepicker._tidyDialog(inst);
  7547. };
  7548. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  7549. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  7550. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  7551. } else {
  7552. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  7553. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  7554. }
  7555. if (!showAnim) {
  7556. postProcess();
  7557. }
  7558. this._datepickerShowing = false;
  7559. onClose = this._get(inst, "onClose");
  7560. if (onClose) {
  7561. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  7562. }
  7563. this._lastInput = null;
  7564. if (this._inDialog) {
  7565. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  7566. if ($.blockUI) {
  7567. $.unblockUI();
  7568. $("body").append(this.dpDiv);
  7569. }
  7570. }
  7571. this._inDialog = false;
  7572. }
  7573. },
  7574. /* Tidy up after a dialog display. */
  7575. _tidyDialog: function(inst) {
  7576. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  7577. },
  7578. /* Close date picker if clicked elsewhere. */
  7579. _checkExternalClick: function(event) {
  7580. if (!$.datepicker._curInst) {
  7581. return;
  7582. }
  7583. var $target = $(event.target),
  7584. inst = $.datepicker._getInst($target[0]);
  7585. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  7586. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  7587. !$target.hasClass($.datepicker.markerClassName) &&
  7588. !$target.closest("." + $.datepicker._triggerClass).length &&
  7589. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  7590. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  7591. $.datepicker._hideDatepicker();
  7592. }
  7593. },
  7594. /* Adjust one of the date sub-fields. */
  7595. _adjustDate: function(id, offset, period) {
  7596. var target = $(id),
  7597. inst = this._getInst(target[0]);
  7598. if (this._isDisabledDatepicker(target[0])) {
  7599. return;
  7600. }
  7601. this._adjustInstDate(inst, offset +
  7602. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  7603. period);
  7604. this._updateDatepicker(inst);
  7605. },
  7606. /* Action for current link. */
  7607. _gotoToday: function(id) {
  7608. var date,
  7609. target = $(id),
  7610. inst = this._getInst(target[0]);
  7611. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  7612. inst.selectedDay = inst.currentDay;
  7613. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  7614. inst.drawYear = inst.selectedYear = inst.currentYear;
  7615. } else {
  7616. date = new Date();
  7617. inst.selectedDay = date.getDate();
  7618. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7619. inst.drawYear = inst.selectedYear = date.getFullYear();
  7620. }
  7621. this._notifyChange(inst);
  7622. this._adjustDate(target);
  7623. },
  7624. /* Action for selecting a new month/year. */
  7625. _selectMonthYear: function(id, select, period) {
  7626. var target = $(id),
  7627. inst = this._getInst(target[0]);
  7628. inst["selected" + (period === "M" ? "Month" : "Year")] =
  7629. inst["draw" + (period === "M" ? "Month" : "Year")] =
  7630. parseInt(select.options[select.selectedIndex].value,10);
  7631. this._notifyChange(inst);
  7632. this._adjustDate(target);
  7633. },
  7634. /* Action for selecting a day. */
  7635. _selectDay: function(id, month, year, td) {
  7636. var inst,
  7637. target = $(id);
  7638. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  7639. return;
  7640. }
  7641. inst = this._getInst(target[0]);
  7642. inst.selectedDay = inst.currentDay = $("a", td).html();
  7643. inst.selectedMonth = inst.currentMonth = month;
  7644. inst.selectedYear = inst.currentYear = year;
  7645. this._selectDate(id, this._formatDate(inst,
  7646. inst.currentDay, inst.currentMonth, inst.currentYear));
  7647. },
  7648. /* Erase the input field and hide the date picker. */
  7649. _clearDate: function(id) {
  7650. var target = $(id);
  7651. this._selectDate(target, "");
  7652. },
  7653. /* Update the input field with the selected date. */
  7654. _selectDate: function(id, dateStr) {
  7655. var onSelect,
  7656. target = $(id),
  7657. inst = this._getInst(target[0]);
  7658. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  7659. if (inst.input) {
  7660. inst.input.val(dateStr);
  7661. }
  7662. this._updateAlternate(inst);
  7663. onSelect = this._get(inst, "onSelect");
  7664. if (onSelect) {
  7665. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  7666. } else if (inst.input) {
  7667. inst.input.trigger("change"); // fire the change event
  7668. }
  7669. if (inst.inline){
  7670. this._updateDatepicker(inst);
  7671. } else {
  7672. this._hideDatepicker();
  7673. this._lastInput = inst.input[0];
  7674. if (typeof(inst.input[0]) !== "object") {
  7675. inst.input.focus(); // restore focus
  7676. }
  7677. this._lastInput = null;
  7678. }
  7679. },
  7680. /* Update any alternate field to synchronise with the main field. */
  7681. _updateAlternate: function(inst) {
  7682. var altFormat, date, dateStr,
  7683. altField = this._get(inst, "altField");
  7684. if (altField) { // update alternate field too
  7685. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  7686. date = this._getDate(inst);
  7687. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  7688. $(altField).each(function() { $(this).val(dateStr); });
  7689. }
  7690. },
  7691. /* Set as beforeShowDay function to prevent selection of weekends.
  7692. * @param date Date - the date to customise
  7693. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  7694. */
  7695. noWeekends: function(date) {
  7696. var day = date.getDay();
  7697. return [(day > 0 && day < 6), ""];
  7698. },
  7699. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  7700. * @param date Date - the date to get the week for
  7701. * @return number - the number of the week within the year that contains this date
  7702. */
  7703. iso8601Week: function(date) {
  7704. var time,
  7705. checkDate = new Date(date.getTime());
  7706. // Find Thursday of this week starting on Monday
  7707. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  7708. time = checkDate.getTime();
  7709. checkDate.setMonth(0); // Compare with Jan 1
  7710. checkDate.setDate(1);
  7711. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  7712. },
  7713. /* Parse a string value into a date object.
  7714. * See formatDate below for the possible formats.
  7715. *
  7716. * @param format string - the expected format of the date
  7717. * @param value string - the date in the above format
  7718. * @param settings Object - attributes include:
  7719. * shortYearCutoff number - the cutoff year for determining the century (optional)
  7720. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7721. * dayNames string[7] - names of the days from Sunday (optional)
  7722. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7723. * monthNames string[12] - names of the months (optional)
  7724. * @return Date - the extracted date value or null if value is blank
  7725. */
  7726. parseDate: function (format, value, settings) {
  7727. if (format == null || value == null) {
  7728. throw "Invalid arguments";
  7729. }
  7730. value = (typeof value === "object" ? value.toString() : value + "");
  7731. if (value === "") {
  7732. return null;
  7733. }
  7734. var iFormat, dim, extra,
  7735. iValue = 0,
  7736. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  7737. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  7738. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  7739. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7740. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7741. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7742. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7743. year = -1,
  7744. month = -1,
  7745. day = -1,
  7746. doy = -1,
  7747. literal = false,
  7748. date,
  7749. // Check whether a format character is doubled
  7750. lookAhead = function(match) {
  7751. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7752. if (matches) {
  7753. iFormat++;
  7754. }
  7755. return matches;
  7756. },
  7757. // Extract a number from the string value
  7758. getNumber = function(match) {
  7759. var isDoubled = lookAhead(match),
  7760. size = (match === "@" ? 14 : (match === "!" ? 20 :
  7761. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  7762. minSize = (match === "y" ? size : 1),
  7763. digits = new RegExp("^\\d{" + minSize + "," + size + "}"),
  7764. num = value.substring(iValue).match(digits);
  7765. if (!num) {
  7766. throw "Missing number at position " + iValue;
  7767. }
  7768. iValue += num[0].length;
  7769. return parseInt(num[0], 10);
  7770. },
  7771. // Extract a name from the string value and convert to an index
  7772. getName = function(match, shortNames, longNames) {
  7773. var index = -1,
  7774. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  7775. return [ [k, v] ];
  7776. }).sort(function (a, b) {
  7777. return -(a[1].length - b[1].length);
  7778. });
  7779. $.each(names, function (i, pair) {
  7780. var name = pair[1];
  7781. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  7782. index = pair[0];
  7783. iValue += name.length;
  7784. return false;
  7785. }
  7786. });
  7787. if (index !== -1) {
  7788. return index + 1;
  7789. } else {
  7790. throw "Unknown name at position " + iValue;
  7791. }
  7792. },
  7793. // Confirm that a literal character matches the string value
  7794. checkLiteral = function() {
  7795. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  7796. throw "Unexpected literal at position " + iValue;
  7797. }
  7798. iValue++;
  7799. };
  7800. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7801. if (literal) {
  7802. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7803. literal = false;
  7804. } else {
  7805. checkLiteral();
  7806. }
  7807. } else {
  7808. switch (format.charAt(iFormat)) {
  7809. case "d":
  7810. day = getNumber("d");
  7811. break;
  7812. case "D":
  7813. getName("D", dayNamesShort, dayNames);
  7814. break;
  7815. case "o":
  7816. doy = getNumber("o");
  7817. break;
  7818. case "m":
  7819. month = getNumber("m");
  7820. break;
  7821. case "M":
  7822. month = getName("M", monthNamesShort, monthNames);
  7823. break;
  7824. case "y":
  7825. year = getNumber("y");
  7826. break;
  7827. case "@":
  7828. date = new Date(getNumber("@"));
  7829. year = date.getFullYear();
  7830. month = date.getMonth() + 1;
  7831. day = date.getDate();
  7832. break;
  7833. case "!":
  7834. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  7835. year = date.getFullYear();
  7836. month = date.getMonth() + 1;
  7837. day = date.getDate();
  7838. break;
  7839. case "'":
  7840. if (lookAhead("'")){
  7841. checkLiteral();
  7842. } else {
  7843. literal = true;
  7844. }
  7845. break;
  7846. default:
  7847. checkLiteral();
  7848. }
  7849. }
  7850. }
  7851. if (iValue < value.length){
  7852. extra = value.substr(iValue);
  7853. if (!/^\s+/.test(extra)) {
  7854. throw "Extra/unparsed characters found in date: " + extra;
  7855. }
  7856. }
  7857. if (year === -1) {
  7858. year = new Date().getFullYear();
  7859. } else if (year < 100) {
  7860. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7861. (year <= shortYearCutoff ? 0 : -100);
  7862. }
  7863. if (doy > -1) {
  7864. month = 1;
  7865. day = doy;
  7866. do {
  7867. dim = this._getDaysInMonth(year, month - 1);
  7868. if (day <= dim) {
  7869. break;
  7870. }
  7871. month++;
  7872. day -= dim;
  7873. } while (true);
  7874. }
  7875. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  7876. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  7877. throw "Invalid date"; // E.g. 31/02/00
  7878. }
  7879. return date;
  7880. },
  7881. /* Standard date formats. */
  7882. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  7883. COOKIE: "D, dd M yy",
  7884. ISO_8601: "yy-mm-dd",
  7885. RFC_822: "D, d M y",
  7886. RFC_850: "DD, dd-M-y",
  7887. RFC_1036: "D, d M y",
  7888. RFC_1123: "D, d M yy",
  7889. RFC_2822: "D, d M yy",
  7890. RSS: "D, d M y", // RFC 822
  7891. TICKS: "!",
  7892. TIMESTAMP: "@",
  7893. W3C: "yy-mm-dd", // ISO 8601
  7894. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  7895. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  7896. /* Format a date object into a string value.
  7897. * The format can be combinations of the following:
  7898. * d - day of month (no leading zero)
  7899. * dd - day of month (two digit)
  7900. * o - day of year (no leading zeros)
  7901. * oo - day of year (three digit)
  7902. * D - day name short
  7903. * DD - day name long
  7904. * m - month of year (no leading zero)
  7905. * mm - month of year (two digit)
  7906. * M - month name short
  7907. * MM - month name long
  7908. * y - year (two digit)
  7909. * yy - year (four digit)
  7910. * @ - Unix timestamp (ms since 01/01/1970)
  7911. * ! - Windows ticks (100ns since 01/01/0001)
  7912. * "..." - literal text
  7913. * '' - single quote
  7914. *
  7915. * @param format string - the desired format of the date
  7916. * @param date Date - the date value to format
  7917. * @param settings Object - attributes include:
  7918. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7919. * dayNames string[7] - names of the days from Sunday (optional)
  7920. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7921. * monthNames string[12] - names of the months (optional)
  7922. * @return string - the date in the above format
  7923. */
  7924. formatDate: function (format, date, settings) {
  7925. if (!date) {
  7926. return "";
  7927. }
  7928. var iFormat,
  7929. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7930. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7931. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7932. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7933. // Check whether a format character is doubled
  7934. lookAhead = function(match) {
  7935. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7936. if (matches) {
  7937. iFormat++;
  7938. }
  7939. return matches;
  7940. },
  7941. // Format a number, with leading zero if necessary
  7942. formatNumber = function(match, value, len) {
  7943. var num = "" + value;
  7944. if (lookAhead(match)) {
  7945. while (num.length < len) {
  7946. num = "0" + num;
  7947. }
  7948. }
  7949. return num;
  7950. },
  7951. // Format a name, short or long as requested
  7952. formatName = function(match, value, shortNames, longNames) {
  7953. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  7954. },
  7955. output = "",
  7956. literal = false;
  7957. if (date) {
  7958. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7959. if (literal) {
  7960. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7961. literal = false;
  7962. } else {
  7963. output += format.charAt(iFormat);
  7964. }
  7965. } else {
  7966. switch (format.charAt(iFormat)) {
  7967. case "d":
  7968. output += formatNumber("d", date.getDate(), 2);
  7969. break;
  7970. case "D":
  7971. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  7972. break;
  7973. case "o":
  7974. output += formatNumber("o",
  7975. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  7976. break;
  7977. case "m":
  7978. output += formatNumber("m", date.getMonth() + 1, 2);
  7979. break;
  7980. case "M":
  7981. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  7982. break;
  7983. case "y":
  7984. output += (lookAhead("y") ? date.getFullYear() :
  7985. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  7986. break;
  7987. case "@":
  7988. output += date.getTime();
  7989. break;
  7990. case "!":
  7991. output += date.getTime() * 10000 + this._ticksTo1970;
  7992. break;
  7993. case "'":
  7994. if (lookAhead("'")) {
  7995. output += "'";
  7996. } else {
  7997. literal = true;
  7998. }
  7999. break;
  8000. default:
  8001. output += format.charAt(iFormat);
  8002. }
  8003. }
  8004. }
  8005. }
  8006. return output;
  8007. },
  8008. /* Extract all possible characters from the date format. */
  8009. _possibleChars: function (format) {
  8010. var iFormat,
  8011. chars = "",
  8012. literal = false,
  8013. // Check whether a format character is doubled
  8014. lookAhead = function(match) {
  8015. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  8016. if (matches) {
  8017. iFormat++;
  8018. }
  8019. return matches;
  8020. };
  8021. for (iFormat = 0; iFormat < format.length; iFormat++) {
  8022. if (literal) {
  8023. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  8024. literal = false;
  8025. } else {
  8026. chars += format.charAt(iFormat);
  8027. }
  8028. } else {
  8029. switch (format.charAt(iFormat)) {
  8030. case "d": case "m": case "y": case "@":
  8031. chars += "0123456789";
  8032. break;
  8033. case "D": case "M":
  8034. return null; // Accept anything
  8035. case "'":
  8036. if (lookAhead("'")) {
  8037. chars += "'";
  8038. } else {
  8039. literal = true;
  8040. }
  8041. break;
  8042. default:
  8043. chars += format.charAt(iFormat);
  8044. }
  8045. }
  8046. }
  8047. return chars;
  8048. },
  8049. /* Get a setting value, defaulting if necessary. */
  8050. _get: function(inst, name) {
  8051. return inst.settings[name] !== undefined ?
  8052. inst.settings[name] : this._defaults[name];
  8053. },
  8054. /* Parse existing date and initialise date picker. */
  8055. _setDateFromField: function(inst, noDefault) {
  8056. if (inst.input.val() === inst.lastVal) {
  8057. return;
  8058. }
  8059. var dateFormat = this._get(inst, "dateFormat"),
  8060. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  8061. defaultDate = this._getDefaultDate(inst),
  8062. date = defaultDate,
  8063. settings = this._getFormatConfig(inst);
  8064. try {
  8065. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  8066. } catch (event) {
  8067. dates = (noDefault ? "" : dates);
  8068. }
  8069. inst.selectedDay = date.getDate();
  8070. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8071. inst.drawYear = inst.selectedYear = date.getFullYear();
  8072. inst.currentDay = (dates ? date.getDate() : 0);
  8073. inst.currentMonth = (dates ? date.getMonth() : 0);
  8074. inst.currentYear = (dates ? date.getFullYear() : 0);
  8075. this._adjustInstDate(inst);
  8076. },
  8077. /* Retrieve the default date shown on opening. */
  8078. _getDefaultDate: function(inst) {
  8079. return this._restrictMinMax(inst,
  8080. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  8081. },
  8082. /* A date may be specified as an exact value or a relative one. */
  8083. _determineDate: function(inst, date, defaultDate) {
  8084. var offsetNumeric = function(offset) {
  8085. var date = new Date();
  8086. date.setDate(date.getDate() + offset);
  8087. return date;
  8088. },
  8089. offsetString = function(offset) {
  8090. try {
  8091. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  8092. offset, $.datepicker._getFormatConfig(inst));
  8093. }
  8094. catch (e) {
  8095. // Ignore
  8096. }
  8097. var date = (offset.toLowerCase().match(/^c/) ?
  8098. $.datepicker._getDate(inst) : null) || new Date(),
  8099. year = date.getFullYear(),
  8100. month = date.getMonth(),
  8101. day = date.getDate(),
  8102. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  8103. matches = pattern.exec(offset);
  8104. while (matches) {
  8105. switch (matches[2] || "d") {
  8106. case "d" : case "D" :
  8107. day += parseInt(matches[1],10); break;
  8108. case "w" : case "W" :
  8109. day += parseInt(matches[1],10) * 7; break;
  8110. case "m" : case "M" :
  8111. month += parseInt(matches[1],10);
  8112. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  8113. break;
  8114. case "y": case "Y" :
  8115. year += parseInt(matches[1],10);
  8116. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  8117. break;
  8118. }
  8119. matches = pattern.exec(offset);
  8120. }
  8121. return new Date(year, month, day);
  8122. },
  8123. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  8124. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  8125. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  8126. if (newDate) {
  8127. newDate.setHours(0);
  8128. newDate.setMinutes(0);
  8129. newDate.setSeconds(0);
  8130. newDate.setMilliseconds(0);
  8131. }
  8132. return this._daylightSavingAdjust(newDate);
  8133. },
  8134. /* Handle switch to/from daylight saving.
  8135. * Hours may be non-zero on daylight saving cut-over:
  8136. * > 12 when midnight changeover, but then cannot generate
  8137. * midnight datetime, so jump to 1AM, otherwise reset.
  8138. * @param date (Date) the date to check
  8139. * @return (Date) the corrected date
  8140. */
  8141. _daylightSavingAdjust: function(date) {
  8142. if (!date) {
  8143. return null;
  8144. }
  8145. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  8146. return date;
  8147. },
  8148. /* Set the date(s) directly. */
  8149. _setDate: function(inst, date, noChange) {
  8150. var clear = !date,
  8151. origMonth = inst.selectedMonth,
  8152. origYear = inst.selectedYear,
  8153. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  8154. inst.selectedDay = inst.currentDay = newDate.getDate();
  8155. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  8156. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  8157. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  8158. this._notifyChange(inst);
  8159. }
  8160. this._adjustInstDate(inst);
  8161. if (inst.input) {
  8162. inst.input.val(clear ? "" : this._formatDate(inst));
  8163. }
  8164. },
  8165. /* Retrieve the date(s) directly. */
  8166. _getDate: function(inst) {
  8167. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  8168. this._daylightSavingAdjust(new Date(
  8169. inst.currentYear, inst.currentMonth, inst.currentDay)));
  8170. return startDate;
  8171. },
  8172. /* Attach the onxxx handlers. These are declared statically so
  8173. * they work with static code transformers like Caja.
  8174. */
  8175. _attachHandlers: function(inst) {
  8176. var stepMonths = this._get(inst, "stepMonths"),
  8177. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  8178. inst.dpDiv.find("[data-handler]").map(function () {
  8179. var handler = {
  8180. prev: function () {
  8181. $.datepicker._adjustDate(id, -stepMonths, "M");
  8182. },
  8183. next: function () {
  8184. $.datepicker._adjustDate(id, +stepMonths, "M");
  8185. },
  8186. hide: function () {
  8187. $.datepicker._hideDatepicker();
  8188. },
  8189. today: function () {
  8190. $.datepicker._gotoToday(id);
  8191. },
  8192. selectDay: function () {
  8193. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  8194. return false;
  8195. },
  8196. selectMonth: function () {
  8197. $.datepicker._selectMonthYear(id, this, "M");
  8198. return false;
  8199. },
  8200. selectYear: function () {
  8201. $.datepicker._selectMonthYear(id, this, "Y");
  8202. return false;
  8203. }
  8204. };
  8205. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  8206. });
  8207. },
  8208. /* Generate the HTML for the current state of the date picker. */
  8209. _generateHTML: function(inst) {
  8210. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  8211. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  8212. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  8213. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  8214. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  8215. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  8216. tempDate = new Date(),
  8217. today = this._daylightSavingAdjust(
  8218. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  8219. isRTL = this._get(inst, "isRTL"),
  8220. showButtonPanel = this._get(inst, "showButtonPanel"),
  8221. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  8222. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  8223. numMonths = this._getNumberOfMonths(inst),
  8224. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  8225. stepMonths = this._get(inst, "stepMonths"),
  8226. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  8227. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  8228. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  8229. minDate = this._getMinMaxDate(inst, "min"),
  8230. maxDate = this._getMinMaxDate(inst, "max"),
  8231. drawMonth = inst.drawMonth - showCurrentAtPos,
  8232. drawYear = inst.drawYear;
  8233. if (drawMonth < 0) {
  8234. drawMonth += 12;
  8235. drawYear--;
  8236. }
  8237. if (maxDate) {
  8238. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  8239. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  8240. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  8241. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  8242. drawMonth--;
  8243. if (drawMonth < 0) {
  8244. drawMonth = 11;
  8245. drawYear--;
  8246. }
  8247. }
  8248. }
  8249. inst.drawMonth = drawMonth;
  8250. inst.drawYear = drawYear;
  8251. prevText = this._get(inst, "prevText");
  8252. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  8253. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  8254. this._getFormatConfig(inst)));
  8255. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  8256. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  8257. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  8258. (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>"));
  8259. nextText = this._get(inst, "nextText");
  8260. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  8261. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  8262. this._getFormatConfig(inst)));
  8263. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  8264. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  8265. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  8266. (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>"));
  8267. currentText = this._get(inst, "currentText");
  8268. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  8269. currentText = (!navigationAsDateFormat ? currentText :
  8270. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  8271. 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'>" +
  8272. this._get(inst, "closeText") + "</button>" : "");
  8273. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  8274. (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'" +
  8275. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  8276. firstDay = parseInt(this._get(inst, "firstDay"),10);
  8277. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  8278. showWeek = this._get(inst, "showWeek");
  8279. dayNames = this._get(inst, "dayNames");
  8280. dayNamesMin = this._get(inst, "dayNamesMin");
  8281. monthNames = this._get(inst, "monthNames");
  8282. monthNamesShort = this._get(inst, "monthNamesShort");
  8283. beforeShowDay = this._get(inst, "beforeShowDay");
  8284. showOtherMonths = this._get(inst, "showOtherMonths");
  8285. selectOtherMonths = this._get(inst, "selectOtherMonths");
  8286. defaultDate = this._getDefaultDate(inst);
  8287. html = "";
  8288. dow;
  8289. for (row = 0; row < numMonths[0]; row++) {
  8290. group = "";
  8291. this.maxRows = 4;
  8292. for (col = 0; col < numMonths[1]; col++) {
  8293. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  8294. cornerClass = " ui-corner-all";
  8295. calender = "";
  8296. if (isMultiMonth) {
  8297. calender += "<div class='ui-datepicker-group";
  8298. if (numMonths[1] > 1) {
  8299. switch (col) {
  8300. case 0: calender += " ui-datepicker-group-first";
  8301. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  8302. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  8303. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  8304. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  8305. }
  8306. }
  8307. calender += "'>";
  8308. }
  8309. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  8310. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  8311. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  8312. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  8313. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  8314. "</div><table class='ui-datepicker-calendar'><thead>" +
  8315. "<tr>";
  8316. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  8317. for (dow = 0; dow < 7; dow++) { // days of the week
  8318. day = (dow + firstDay) % 7;
  8319. thead += "<th scope='col'" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  8320. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  8321. }
  8322. calender += thead + "</tr></thead><tbody>";
  8323. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  8324. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  8325. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  8326. }
  8327. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  8328. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  8329. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  8330. this.maxRows = numRows;
  8331. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  8332. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  8333. calender += "<tr>";
  8334. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  8335. this._get(inst, "calculateWeek")(printDate) + "</td>");
  8336. for (dow = 0; dow < 7; dow++) { // create date picker days
  8337. daySettings = (beforeShowDay ?
  8338. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  8339. otherMonth = (printDate.getMonth() !== drawMonth);
  8340. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  8341. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  8342. tbody += "<td class='" +
  8343. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  8344. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  8345. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  8346. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  8347. // or defaultDate is current printedDate and defaultDate is selectedDate
  8348. " " + this._dayOverClass : "") + // highlight selected day
  8349. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  8350. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  8351. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  8352. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  8353. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  8354. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  8355. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  8356. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  8357. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  8358. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  8359. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  8360. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  8361. printDate.setDate(printDate.getDate() + 1);
  8362. printDate = this._daylightSavingAdjust(printDate);
  8363. }
  8364. calender += tbody + "</tr>";
  8365. }
  8366. drawMonth++;
  8367. if (drawMonth > 11) {
  8368. drawMonth = 0;
  8369. drawYear++;
  8370. }
  8371. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  8372. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  8373. group += calender;
  8374. }
  8375. html += group;
  8376. }
  8377. html += buttonPanel;
  8378. inst._keyEvent = false;
  8379. return html;
  8380. },
  8381. /* Generate the month and year header. */
  8382. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  8383. secondary, monthNames, monthNamesShort) {
  8384. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  8385. changeMonth = this._get(inst, "changeMonth"),
  8386. changeYear = this._get(inst, "changeYear"),
  8387. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  8388. html = "<div class='ui-datepicker-title'>",
  8389. monthHtml = "";
  8390. // month selection
  8391. if (secondary || !changeMonth) {
  8392. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  8393. } else {
  8394. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  8395. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  8396. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  8397. for ( month = 0; month < 12; month++) {
  8398. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  8399. monthHtml += "<option value='" + month + "'" +
  8400. (month === drawMonth ? " selected='selected'" : "") +
  8401. ">" + monthNamesShort[month] + "</option>";
  8402. }
  8403. }
  8404. monthHtml += "</select>";
  8405. }
  8406. if (!showMonthAfterYear) {
  8407. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  8408. }
  8409. // year selection
  8410. if ( !inst.yearshtml ) {
  8411. inst.yearshtml = "";
  8412. if (secondary || !changeYear) {
  8413. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  8414. } else {
  8415. // determine range of years to display
  8416. years = this._get(inst, "yearRange").split(":");
  8417. thisYear = new Date().getFullYear();
  8418. determineYear = function(value) {
  8419. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  8420. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  8421. parseInt(value, 10)));
  8422. return (isNaN(year) ? thisYear : year);
  8423. };
  8424. year = determineYear(years[0]);
  8425. endYear = Math.max(year, determineYear(years[1] || ""));
  8426. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  8427. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  8428. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  8429. for (; year <= endYear; year++) {
  8430. inst.yearshtml += "<option value='" + year + "'" +
  8431. (year === drawYear ? " selected='selected'" : "") +
  8432. ">" + year + "</option>";
  8433. }
  8434. inst.yearshtml += "</select>";
  8435. html += inst.yearshtml;
  8436. inst.yearshtml = null;
  8437. }
  8438. }
  8439. html += this._get(inst, "yearSuffix");
  8440. if (showMonthAfterYear) {
  8441. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  8442. }
  8443. html += "</div>"; // Close datepicker_header
  8444. return html;
  8445. },
  8446. /* Adjust one of the date sub-fields. */
  8447. _adjustInstDate: function(inst, offset, period) {
  8448. var year = inst.drawYear + (period === "Y" ? offset : 0),
  8449. month = inst.drawMonth + (period === "M" ? offset : 0),
  8450. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  8451. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  8452. inst.selectedDay = date.getDate();
  8453. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8454. inst.drawYear = inst.selectedYear = date.getFullYear();
  8455. if (period === "M" || period === "Y") {
  8456. this._notifyChange(inst);
  8457. }
  8458. },
  8459. /* Ensure a date is within any min/max bounds. */
  8460. _restrictMinMax: function(inst, date) {
  8461. var minDate = this._getMinMaxDate(inst, "min"),
  8462. maxDate = this._getMinMaxDate(inst, "max"),
  8463. newDate = (minDate && date < minDate ? minDate : date);
  8464. return (maxDate && newDate > maxDate ? maxDate : newDate);
  8465. },
  8466. /* Notify change of month/year. */
  8467. _notifyChange: function(inst) {
  8468. var onChange = this._get(inst, "onChangeMonthYear");
  8469. if (onChange) {
  8470. onChange.apply((inst.input ? inst.input[0] : null),
  8471. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  8472. }
  8473. },
  8474. /* Determine the number of months to show. */
  8475. _getNumberOfMonths: function(inst) {
  8476. var numMonths = this._get(inst, "numberOfMonths");
  8477. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  8478. },
  8479. /* Determine the current maximum date - ensure no time components are set. */
  8480. _getMinMaxDate: function(inst, minMax) {
  8481. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  8482. },
  8483. /* Find the number of days in a given month. */
  8484. _getDaysInMonth: function(year, month) {
  8485. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  8486. },
  8487. /* Find the day of the week of the first of a month. */
  8488. _getFirstDayOfMonth: function(year, month) {
  8489. return new Date(year, month, 1).getDay();
  8490. },
  8491. /* Determines if we should allow a "next/prev" month display change. */
  8492. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  8493. var numMonths = this._getNumberOfMonths(inst),
  8494. date = this._daylightSavingAdjust(new Date(curYear,
  8495. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  8496. if (offset < 0) {
  8497. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  8498. }
  8499. return this._isInRange(inst, date);
  8500. },
  8501. /* Is the given date in the accepted range? */
  8502. _isInRange: function(inst, date) {
  8503. var yearSplit, currentYear,
  8504. minDate = this._getMinMaxDate(inst, "min"),
  8505. maxDate = this._getMinMaxDate(inst, "max"),
  8506. minYear = null,
  8507. maxYear = null,
  8508. years = this._get(inst, "yearRange");
  8509. if (years){
  8510. yearSplit = years.split(":");
  8511. currentYear = new Date().getFullYear();
  8512. minYear = parseInt(yearSplit[0], 10);
  8513. maxYear = parseInt(yearSplit[1], 10);
  8514. if ( yearSplit[0].match(/[+\-].*/) ) {
  8515. minYear += currentYear;
  8516. }
  8517. if ( yearSplit[1].match(/[+\-].*/) ) {
  8518. maxYear += currentYear;
  8519. }
  8520. }
  8521. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  8522. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  8523. (!minYear || date.getFullYear() >= minYear) &&
  8524. (!maxYear || date.getFullYear() <= maxYear));
  8525. },
  8526. /* Provide the configuration settings for formatting/parsing. */
  8527. _getFormatConfig: function(inst) {
  8528. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  8529. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  8530. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  8531. return {shortYearCutoff: shortYearCutoff,
  8532. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  8533. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  8534. },
  8535. /* Format the given date for display. */
  8536. _formatDate: function(inst, day, month, year) {
  8537. if (!day) {
  8538. inst.currentDay = inst.selectedDay;
  8539. inst.currentMonth = inst.selectedMonth;
  8540. inst.currentYear = inst.selectedYear;
  8541. }
  8542. var date = (day ? (typeof day === "object" ? day :
  8543. this._daylightSavingAdjust(new Date(year, month, day))) :
  8544. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  8545. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  8546. }
  8547. });
  8548. /*
  8549. * Bind hover events for datepicker elements.
  8550. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  8551. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  8552. */
  8553. function datepicker_bindHover(dpDiv) {
  8554. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  8555. return dpDiv.delegate(selector, "mouseout", function() {
  8556. $(this).removeClass("ui-state-hover");
  8557. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8558. $(this).removeClass("ui-datepicker-prev-hover");
  8559. }
  8560. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8561. $(this).removeClass("ui-datepicker-next-hover");
  8562. }
  8563. })
  8564. .delegate( selector, "mouseover", datepicker_handleMouseover );
  8565. }
  8566. function datepicker_handleMouseover() {
  8567. if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) {
  8568. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  8569. $(this).addClass("ui-state-hover");
  8570. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8571. $(this).addClass("ui-datepicker-prev-hover");
  8572. }
  8573. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8574. $(this).addClass("ui-datepicker-next-hover");
  8575. }
  8576. }
  8577. }
  8578. /* jQuery extend now ignores nulls! */
  8579. function datepicker_extendRemove(target, props) {
  8580. $.extend(target, props);
  8581. for (var name in props) {
  8582. if (props[name] == null) {
  8583. target[name] = props[name];
  8584. }
  8585. }
  8586. return target;
  8587. }
  8588. /* Invoke the datepicker functionality.
  8589. @param options string - a command, optionally followed by additional parameters or
  8590. Object - settings for attaching new datepicker functionality
  8591. @return jQuery object */
  8592. $.fn.datepicker = function(options){
  8593. /* Verify an empty collection wasn't passed - Fixes #6976 */
  8594. if ( !this.length ) {
  8595. return this;
  8596. }
  8597. /* Initialise the date picker. */
  8598. if (!$.datepicker.initialized) {
  8599. $(document).mousedown($.datepicker._checkExternalClick);
  8600. $.datepicker.initialized = true;
  8601. }
  8602. /* Append datepicker main container to body if not exist. */
  8603. if ($("#"+$.datepicker._mainDivId).length === 0) {
  8604. $("body").append($.datepicker.dpDiv);
  8605. }
  8606. var otherArgs = Array.prototype.slice.call(arguments, 1);
  8607. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  8608. return $.datepicker["_" + options + "Datepicker"].
  8609. apply($.datepicker, [this[0]].concat(otherArgs));
  8610. }
  8611. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  8612. return $.datepicker["_" + options + "Datepicker"].
  8613. apply($.datepicker, [this[0]].concat(otherArgs));
  8614. }
  8615. return this.each(function() {
  8616. typeof options === "string" ?
  8617. $.datepicker["_" + options + "Datepicker"].
  8618. apply($.datepicker, [this].concat(otherArgs)) :
  8619. $.datepicker._attachDatepicker(this, options);
  8620. });
  8621. };
  8622. $.datepicker = new Datepicker(); // singleton instance
  8623. $.datepicker.initialized = false;
  8624. $.datepicker.uuid = new Date().getTime();
  8625. $.datepicker.version = "1.11.4";
  8626. var datepicker = $.datepicker;
  8627. /*!
  8628. * jQuery UI Dialog 1.11.4
  8629. * http://jqueryui.com
  8630. *
  8631. * Copyright jQuery Foundation and other contributors
  8632. * Released under the MIT license.
  8633. * http://jquery.org/license
  8634. *
  8635. * http://api.jqueryui.com/dialog/
  8636. */
  8637. var dialog = $.widget( "ui.dialog", {
  8638. version: "1.11.4",
  8639. options: {
  8640. appendTo: "body",
  8641. autoOpen: true,
  8642. buttons: [],
  8643. closeOnEscape: true,
  8644. closeText: "Close",
  8645. dialogClass: "",
  8646. draggable: true,
  8647. hide: null,
  8648. height: "auto",
  8649. maxHeight: null,
  8650. maxWidth: null,
  8651. minHeight: 150,
  8652. minWidth: 150,
  8653. modal: false,
  8654. position: {
  8655. my: "center",
  8656. at: "center",
  8657. of: window,
  8658. collision: "fit",
  8659. // Ensure the titlebar is always visible
  8660. using: function( pos ) {
  8661. var topOffset = $( this ).css( pos ).offset().top;
  8662. if ( topOffset < 0 ) {
  8663. $( this ).css( "top", pos.top - topOffset );
  8664. }
  8665. }
  8666. },
  8667. resizable: true,
  8668. show: null,
  8669. title: null,
  8670. width: 300,
  8671. // callbacks
  8672. beforeClose: null,
  8673. close: null,
  8674. drag: null,
  8675. dragStart: null,
  8676. dragStop: null,
  8677. focus: null,
  8678. open: null,
  8679. resize: null,
  8680. resizeStart: null,
  8681. resizeStop: null
  8682. },
  8683. sizeRelatedOptions: {
  8684. buttons: true,
  8685. height: true,
  8686. maxHeight: true,
  8687. maxWidth: true,
  8688. minHeight: true,
  8689. minWidth: true,
  8690. width: true
  8691. },
  8692. resizableRelatedOptions: {
  8693. maxHeight: true,
  8694. maxWidth: true,
  8695. minHeight: true,
  8696. minWidth: true
  8697. },
  8698. _create: function() {
  8699. this.originalCss = {
  8700. display: this.element[ 0 ].style.display,
  8701. width: this.element[ 0 ].style.width,
  8702. minHeight: this.element[ 0 ].style.minHeight,
  8703. maxHeight: this.element[ 0 ].style.maxHeight,
  8704. height: this.element[ 0 ].style.height
  8705. };
  8706. this.originalPosition = {
  8707. parent: this.element.parent(),
  8708. index: this.element.parent().children().index( this.element )
  8709. };
  8710. this.originalTitle = this.element.attr( "title" );
  8711. this.options.title = this.options.title || this.originalTitle;
  8712. this._createWrapper();
  8713. this.element
  8714. .show()
  8715. .removeAttr( "title" )
  8716. .addClass( "ui-dialog-content ui-widget-content" )
  8717. .appendTo( this.uiDialog );
  8718. this._createTitlebar();
  8719. this._createButtonPane();
  8720. if ( this.options.draggable && $.fn.draggable ) {
  8721. this._makeDraggable();
  8722. }
  8723. if ( this.options.resizable && $.fn.resizable ) {
  8724. this._makeResizable();
  8725. }
  8726. this._isOpen = false;
  8727. this._trackFocus();
  8728. },
  8729. _init: function() {
  8730. if ( this.options.autoOpen ) {
  8731. this.open();
  8732. }
  8733. },
  8734. _appendTo: function() {
  8735. var element = this.options.appendTo;
  8736. if ( element && (element.jquery || element.nodeType) ) {
  8737. return $( element );
  8738. }
  8739. return this.document.find( element || "body" ).eq( 0 );
  8740. },
  8741. _destroy: function() {
  8742. var next,
  8743. originalPosition = this.originalPosition;
  8744. this._untrackInstance();
  8745. this._destroyOverlay();
  8746. this.element
  8747. .removeUniqueId()
  8748. .removeClass( "ui-dialog-content ui-widget-content" )
  8749. .css( this.originalCss )
  8750. // Without detaching first, the following becomes really slow
  8751. .detach();
  8752. this.uiDialog.stop( true, true ).remove();
  8753. if ( this.originalTitle ) {
  8754. this.element.attr( "title", this.originalTitle );
  8755. }
  8756. next = originalPosition.parent.children().eq( originalPosition.index );
  8757. // Don't try to place the dialog next to itself (#8613)
  8758. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  8759. next.before( this.element );
  8760. } else {
  8761. originalPosition.parent.append( this.element );
  8762. }
  8763. },
  8764. widget: function() {
  8765. return this.uiDialog;
  8766. },
  8767. disable: $.noop,
  8768. enable: $.noop,
  8769. close: function( event ) {
  8770. var activeElement,
  8771. that = this;
  8772. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  8773. return;
  8774. }
  8775. this._isOpen = false;
  8776. this._focusedElement = null;
  8777. this._destroyOverlay();
  8778. this._untrackInstance();
  8779. if ( !this.opener.filter( ":focusable" ).focus().length ) {
  8780. // support: IE9
  8781. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  8782. try {
  8783. activeElement = this.document[ 0 ].activeElement;
  8784. // Support: IE9, IE10
  8785. // If the <body> is blurred, IE will switch windows, see #4520
  8786. if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {
  8787. // Hiding a focused element doesn't trigger blur in WebKit
  8788. // so in case we have nothing to focus on, explicitly blur the active element
  8789. // https://bugs.webkit.org/show_bug.cgi?id=47182
  8790. $( activeElement ).blur();
  8791. }
  8792. } catch ( error ) {}
  8793. }
  8794. this._hide( this.uiDialog, this.options.hide, function() {
  8795. that._trigger( "close", event );
  8796. });
  8797. },
  8798. isOpen: function() {
  8799. return this._isOpen;
  8800. },
  8801. moveToTop: function() {
  8802. this._moveToTop();
  8803. },
  8804. _moveToTop: function( event, silent ) {
  8805. var moved = false,
  8806. zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map(function() {
  8807. return +$( this ).css( "z-index" );
  8808. }).get(),
  8809. zIndexMax = Math.max.apply( null, zIndices );
  8810. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  8811. this.uiDialog.css( "z-index", zIndexMax + 1 );
  8812. moved = true;
  8813. }
  8814. if ( moved && !silent ) {
  8815. this._trigger( "focus", event );
  8816. }
  8817. return moved;
  8818. },
  8819. open: function() {
  8820. var that = this;
  8821. if ( this._isOpen ) {
  8822. if ( this._moveToTop() ) {
  8823. this._focusTabbable();
  8824. }
  8825. return;
  8826. }
  8827. this._isOpen = true;
  8828. this.opener = $( this.document[ 0 ].activeElement );
  8829. this._size();
  8830. this._position();
  8831. this._createOverlay();
  8832. this._moveToTop( null, true );
  8833. // Ensure the overlay is moved to the top with the dialog, but only when
  8834. // opening. The overlay shouldn't move after the dialog is open so that
  8835. // modeless dialogs opened after the modal dialog stack properly.
  8836. if ( this.overlay ) {
  8837. this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
  8838. }
  8839. this._show( this.uiDialog, this.options.show, function() {
  8840. that._focusTabbable();
  8841. that._trigger( "focus" );
  8842. });
  8843. // Track the dialog immediately upon openening in case a focus event
  8844. // somehow occurs outside of the dialog before an element inside the
  8845. // dialog is focused (#10152)
  8846. this._makeFocusTarget();
  8847. this._trigger( "open" );
  8848. },
  8849. _focusTabbable: function() {
  8850. // Set focus to the first match:
  8851. // 1. An element that was focused previously
  8852. // 2. First element inside the dialog matching [autofocus]
  8853. // 3. Tabbable element inside the content element
  8854. // 4. Tabbable element inside the buttonpane
  8855. // 5. The close button
  8856. // 6. The dialog itself
  8857. var hasFocus = this._focusedElement;
  8858. if ( !hasFocus ) {
  8859. hasFocus = this.element.find( "[autofocus]" );
  8860. }
  8861. if ( !hasFocus.length ) {
  8862. hasFocus = this.element.find( ":tabbable" );
  8863. }
  8864. if ( !hasFocus.length ) {
  8865. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  8866. }
  8867. if ( !hasFocus.length ) {
  8868. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  8869. }
  8870. if ( !hasFocus.length ) {
  8871. hasFocus = this.uiDialog;
  8872. }
  8873. hasFocus.eq( 0 ).focus();
  8874. },
  8875. _keepFocus: function( event ) {
  8876. function checkFocus() {
  8877. var activeElement = this.document[0].activeElement,
  8878. isActive = this.uiDialog[0] === activeElement ||
  8879. $.contains( this.uiDialog[0], activeElement );
  8880. if ( !isActive ) {
  8881. this._focusTabbable();
  8882. }
  8883. }
  8884. event.preventDefault();
  8885. checkFocus.call( this );
  8886. // support: IE
  8887. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  8888. // so we check again later
  8889. this._delay( checkFocus );
  8890. },
  8891. _createWrapper: function() {
  8892. this.uiDialog = $("<div>")
  8893. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  8894. this.options.dialogClass )
  8895. .hide()
  8896. .attr({
  8897. // Setting tabIndex makes the div focusable
  8898. tabIndex: -1,
  8899. role: "dialog"
  8900. })
  8901. .appendTo( this._appendTo() );
  8902. this._on( this.uiDialog, {
  8903. keydown: function( event ) {
  8904. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  8905. event.keyCode === $.ui.keyCode.ESCAPE ) {
  8906. event.preventDefault();
  8907. this.close( event );
  8908. return;
  8909. }
  8910. // prevent tabbing out of dialogs
  8911. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  8912. return;
  8913. }
  8914. var tabbables = this.uiDialog.find( ":tabbable" ),
  8915. first = tabbables.filter( ":first" ),
  8916. last = tabbables.filter( ":last" );
  8917. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  8918. this._delay(function() {
  8919. first.focus();
  8920. });
  8921. event.preventDefault();
  8922. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  8923. this._delay(function() {
  8924. last.focus();
  8925. });
  8926. event.preventDefault();
  8927. }
  8928. },
  8929. mousedown: function( event ) {
  8930. if ( this._moveToTop( event ) ) {
  8931. this._focusTabbable();
  8932. }
  8933. }
  8934. });
  8935. // We assume that any existing aria-describedby attribute means
  8936. // that the dialog content is marked up properly
  8937. // otherwise we brute force the content as the description
  8938. if ( !this.element.find( "[aria-describedby]" ).length ) {
  8939. this.uiDialog.attr({
  8940. "aria-describedby": this.element.uniqueId().attr( "id" )
  8941. });
  8942. }
  8943. },
  8944. _createTitlebar: function() {
  8945. var uiDialogTitle;
  8946. this.uiDialogTitlebar = $( "<div>" )
  8947. .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" )
  8948. .prependTo( this.uiDialog );
  8949. this._on( this.uiDialogTitlebar, {
  8950. mousedown: function( event ) {
  8951. // Don't prevent click on close button (#8838)
  8952. // Focusing a dialog that is partially scrolled out of view
  8953. // causes the browser to scroll it into view, preventing the click event
  8954. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  8955. // Dialog isn't getting focus when dragging (#8063)
  8956. this.uiDialog.focus();
  8957. }
  8958. }
  8959. });
  8960. // support: IE
  8961. // Use type="button" to prevent enter keypresses in textboxes from closing the
  8962. // dialog in IE (#9312)
  8963. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  8964. .button({
  8965. label: this.options.closeText,
  8966. icons: {
  8967. primary: "ui-icon-closethick"
  8968. },
  8969. text: false
  8970. })
  8971. .addClass( "ui-dialog-titlebar-close" )
  8972. .appendTo( this.uiDialogTitlebar );
  8973. this._on( this.uiDialogTitlebarClose, {
  8974. click: function( event ) {
  8975. event.preventDefault();
  8976. this.close( event );
  8977. }
  8978. });
  8979. uiDialogTitle = $( "<span>" )
  8980. .uniqueId()
  8981. .addClass( "ui-dialog-title" )
  8982. .prependTo( this.uiDialogTitlebar );
  8983. this._title( uiDialogTitle );
  8984. this.uiDialog.attr({
  8985. "aria-labelledby": uiDialogTitle.attr( "id" )
  8986. });
  8987. },
  8988. _title: function( title ) {
  8989. if ( !this.options.title ) {
  8990. title.html( "&#160;" );
  8991. }
  8992. title.text( this.options.title );
  8993. },
  8994. _createButtonPane: function() {
  8995. this.uiDialogButtonPane = $( "<div>" )
  8996. .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
  8997. this.uiButtonSet = $( "<div>" )
  8998. .addClass( "ui-dialog-buttonset" )
  8999. .appendTo( this.uiDialogButtonPane );
  9000. this._createButtons();
  9001. },
  9002. _createButtons: function() {
  9003. var that = this,
  9004. buttons = this.options.buttons;
  9005. // if we already have a button pane, remove it
  9006. this.uiDialogButtonPane.remove();
  9007. this.uiButtonSet.empty();
  9008. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  9009. this.uiDialog.removeClass( "ui-dialog-buttons" );
  9010. return;
  9011. }
  9012. $.each( buttons, function( name, props ) {
  9013. var click, buttonOptions;
  9014. props = $.isFunction( props ) ?
  9015. { click: props, text: name } :
  9016. props;
  9017. // Default to a non-submitting button
  9018. props = $.extend( { type: "button" }, props );
  9019. // Change the context for the click callback to be the main element
  9020. click = props.click;
  9021. props.click = function() {
  9022. click.apply( that.element[ 0 ], arguments );
  9023. };
  9024. buttonOptions = {
  9025. icons: props.icons,
  9026. text: props.showText
  9027. };
  9028. delete props.icons;
  9029. delete props.showText;
  9030. $( "<button></button>", props )
  9031. .button( buttonOptions )
  9032. .appendTo( that.uiButtonSet );
  9033. });
  9034. this.uiDialog.addClass( "ui-dialog-buttons" );
  9035. this.uiDialogButtonPane.appendTo( this.uiDialog );
  9036. },
  9037. _makeDraggable: function() {
  9038. var that = this,
  9039. options = this.options;
  9040. function filteredUi( ui ) {
  9041. return {
  9042. position: ui.position,
  9043. offset: ui.offset
  9044. };
  9045. }
  9046. this.uiDialog.draggable({
  9047. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  9048. handle: ".ui-dialog-titlebar",
  9049. containment: "document",
  9050. start: function( event, ui ) {
  9051. $( this ).addClass( "ui-dialog-dragging" );
  9052. that._blockFrames();
  9053. that._trigger( "dragStart", event, filteredUi( ui ) );
  9054. },
  9055. drag: function( event, ui ) {
  9056. that._trigger( "drag", event, filteredUi( ui ) );
  9057. },
  9058. stop: function( event, ui ) {
  9059. var left = ui.offset.left - that.document.scrollLeft(),
  9060. top = ui.offset.top - that.document.scrollTop();
  9061. options.position = {
  9062. my: "left top",
  9063. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  9064. "top" + (top >= 0 ? "+" : "") + top,
  9065. of: that.window
  9066. };
  9067. $( this ).removeClass( "ui-dialog-dragging" );
  9068. that._unblockFrames();
  9069. that._trigger( "dragStop", event, filteredUi( ui ) );
  9070. }
  9071. });
  9072. },
  9073. _makeResizable: function() {
  9074. var that = this,
  9075. options = this.options,
  9076. handles = options.resizable,
  9077. // .ui-resizable has position: relative defined in the stylesheet
  9078. // but dialogs have to use absolute or fixed positioning
  9079. position = this.uiDialog.css("position"),
  9080. resizeHandles = typeof handles === "string" ?
  9081. handles :
  9082. "n,e,s,w,se,sw,ne,nw";
  9083. function filteredUi( ui ) {
  9084. return {
  9085. originalPosition: ui.originalPosition,
  9086. originalSize: ui.originalSize,
  9087. position: ui.position,
  9088. size: ui.size
  9089. };
  9090. }
  9091. this.uiDialog.resizable({
  9092. cancel: ".ui-dialog-content",
  9093. containment: "document",
  9094. alsoResize: this.element,
  9095. maxWidth: options.maxWidth,
  9096. maxHeight: options.maxHeight,
  9097. minWidth: options.minWidth,
  9098. minHeight: this._minHeight(),
  9099. handles: resizeHandles,
  9100. start: function( event, ui ) {
  9101. $( this ).addClass( "ui-dialog-resizing" );
  9102. that._blockFrames();
  9103. that._trigger( "resizeStart", event, filteredUi( ui ) );
  9104. },
  9105. resize: function( event, ui ) {
  9106. that._trigger( "resize", event, filteredUi( ui ) );
  9107. },
  9108. stop: function( event, ui ) {
  9109. var offset = that.uiDialog.offset(),
  9110. left = offset.left - that.document.scrollLeft(),
  9111. top = offset.top - that.document.scrollTop();
  9112. options.height = that.uiDialog.height();
  9113. options.width = that.uiDialog.width();
  9114. options.position = {
  9115. my: "left top",
  9116. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  9117. "top" + (top >= 0 ? "+" : "") + top,
  9118. of: that.window
  9119. };
  9120. $( this ).removeClass( "ui-dialog-resizing" );
  9121. that._unblockFrames();
  9122. that._trigger( "resizeStop", event, filteredUi( ui ) );
  9123. }
  9124. })
  9125. .css( "position", position );
  9126. },
  9127. _trackFocus: function() {
  9128. this._on( this.widget(), {
  9129. focusin: function( event ) {
  9130. this._makeFocusTarget();
  9131. this._focusedElement = $( event.target );
  9132. }
  9133. });
  9134. },
  9135. _makeFocusTarget: function() {
  9136. this._untrackInstance();
  9137. this._trackingInstances().unshift( this );
  9138. },
  9139. _untrackInstance: function() {
  9140. var instances = this._trackingInstances(),
  9141. exists = $.inArray( this, instances );
  9142. if ( exists !== -1 ) {
  9143. instances.splice( exists, 1 );
  9144. }
  9145. },
  9146. _trackingInstances: function() {
  9147. var instances = this.document.data( "ui-dialog-instances" );
  9148. if ( !instances ) {
  9149. instances = [];
  9150. this.document.data( "ui-dialog-instances", instances );
  9151. }
  9152. return instances;
  9153. },
  9154. _minHeight: function() {
  9155. var options = this.options;
  9156. return options.height === "auto" ?
  9157. options.minHeight :
  9158. Math.min( options.minHeight, options.height );
  9159. },
  9160. _position: function() {
  9161. // Need to show the dialog to get the actual offset in the position plugin
  9162. var isVisible = this.uiDialog.is( ":visible" );
  9163. if ( !isVisible ) {
  9164. this.uiDialog.show();
  9165. }
  9166. this.uiDialog.position( this.options.position );
  9167. if ( !isVisible ) {
  9168. this.uiDialog.hide();
  9169. }
  9170. },
  9171. _setOptions: function( options ) {
  9172. var that = this,
  9173. resize = false,
  9174. resizableOptions = {};
  9175. $.each( options, function( key, value ) {
  9176. that._setOption( key, value );
  9177. if ( key in that.sizeRelatedOptions ) {
  9178. resize = true;
  9179. }
  9180. if ( key in that.resizableRelatedOptions ) {
  9181. resizableOptions[ key ] = value;
  9182. }
  9183. });
  9184. if ( resize ) {
  9185. this._size();
  9186. this._position();
  9187. }
  9188. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  9189. this.uiDialog.resizable( "option", resizableOptions );
  9190. }
  9191. },
  9192. _setOption: function( key, value ) {
  9193. var isDraggable, isResizable,
  9194. uiDialog = this.uiDialog;
  9195. if ( key === "dialogClass" ) {
  9196. uiDialog
  9197. .removeClass( this.options.dialogClass )
  9198. .addClass( value );
  9199. }
  9200. if ( key === "disabled" ) {
  9201. return;
  9202. }
  9203. this._super( key, value );
  9204. if ( key === "appendTo" ) {
  9205. this.uiDialog.appendTo( this._appendTo() );
  9206. }
  9207. if ( key === "buttons" ) {
  9208. this._createButtons();
  9209. }
  9210. if ( key === "closeText" ) {
  9211. this.uiDialogTitlebarClose.button({
  9212. // Ensure that we always pass a string
  9213. label: "" + value
  9214. });
  9215. }
  9216. if ( key === "draggable" ) {
  9217. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  9218. if ( isDraggable && !value ) {
  9219. uiDialog.draggable( "destroy" );
  9220. }
  9221. if ( !isDraggable && value ) {
  9222. this._makeDraggable();
  9223. }
  9224. }
  9225. if ( key === "position" ) {
  9226. this._position();
  9227. }
  9228. if ( key === "resizable" ) {
  9229. // currently resizable, becoming non-resizable
  9230. isResizable = uiDialog.is( ":data(ui-resizable)" );
  9231. if ( isResizable && !value ) {
  9232. uiDialog.resizable( "destroy" );
  9233. }
  9234. // currently resizable, changing handles
  9235. if ( isResizable && typeof value === "string" ) {
  9236. uiDialog.resizable( "option", "handles", value );
  9237. }
  9238. // currently non-resizable, becoming resizable
  9239. if ( !isResizable && value !== false ) {
  9240. this._makeResizable();
  9241. }
  9242. }
  9243. if ( key === "title" ) {
  9244. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  9245. }
  9246. },
  9247. _size: function() {
  9248. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  9249. // divs will both have width and height set, so we need to reset them
  9250. var nonContentHeight, minContentHeight, maxContentHeight,
  9251. options = this.options;
  9252. // Reset content sizing
  9253. this.element.show().css({
  9254. width: "auto",
  9255. minHeight: 0,
  9256. maxHeight: "none",
  9257. height: 0
  9258. });
  9259. if ( options.minWidth > options.width ) {
  9260. options.width = options.minWidth;
  9261. }
  9262. // reset wrapper sizing
  9263. // determine the height of all the non-content elements
  9264. nonContentHeight = this.uiDialog.css({
  9265. height: "auto",
  9266. width: options.width
  9267. })
  9268. .outerHeight();
  9269. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  9270. maxContentHeight = typeof options.maxHeight === "number" ?
  9271. Math.max( 0, options.maxHeight - nonContentHeight ) :
  9272. "none";
  9273. if ( options.height === "auto" ) {
  9274. this.element.css({
  9275. minHeight: minContentHeight,
  9276. maxHeight: maxContentHeight,
  9277. height: "auto"
  9278. });
  9279. } else {
  9280. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  9281. }
  9282. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  9283. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  9284. }
  9285. },
  9286. _blockFrames: function() {
  9287. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  9288. var iframe = $( this );
  9289. return $( "<div>" )
  9290. .css({
  9291. position: "absolute",
  9292. width: iframe.outerWidth(),
  9293. height: iframe.outerHeight()
  9294. })
  9295. .appendTo( iframe.parent() )
  9296. .offset( iframe.offset() )[0];
  9297. });
  9298. },
  9299. _unblockFrames: function() {
  9300. if ( this.iframeBlocks ) {
  9301. this.iframeBlocks.remove();
  9302. delete this.iframeBlocks;
  9303. }
  9304. },
  9305. _allowInteraction: function( event ) {
  9306. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  9307. return true;
  9308. }
  9309. // TODO: Remove hack when datepicker implements
  9310. // the .ui-front logic (#8989)
  9311. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  9312. },
  9313. _createOverlay: function() {
  9314. if ( !this.options.modal ) {
  9315. return;
  9316. }
  9317. // We use a delay in case the overlay is created from an
  9318. // event that we're going to be cancelling (#2804)
  9319. var isOpening = true;
  9320. this._delay(function() {
  9321. isOpening = false;
  9322. });
  9323. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  9324. // Prevent use of anchors and inputs
  9325. // Using _on() for an event handler shared across many instances is
  9326. // safe because the dialogs stack and must be closed in reverse order
  9327. this._on( this.document, {
  9328. focusin: function( event ) {
  9329. if ( isOpening ) {
  9330. return;
  9331. }
  9332. if ( !this._allowInteraction( event ) ) {
  9333. event.preventDefault();
  9334. this._trackingInstances()[ 0 ]._focusTabbable();
  9335. }
  9336. }
  9337. });
  9338. }
  9339. this.overlay = $( "<div>" )
  9340. .addClass( "ui-widget-overlay ui-front" )
  9341. .appendTo( this._appendTo() );
  9342. this._on( this.overlay, {
  9343. mousedown: "_keepFocus"
  9344. });
  9345. this.document.data( "ui-dialog-overlays",
  9346. (this.document.data( "ui-dialog-overlays" ) || 0) + 1 );
  9347. },
  9348. _destroyOverlay: function() {
  9349. if ( !this.options.modal ) {
  9350. return;
  9351. }
  9352. if ( this.overlay ) {
  9353. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  9354. if ( !overlays ) {
  9355. this.document
  9356. .unbind( "focusin" )
  9357. .removeData( "ui-dialog-overlays" );
  9358. } else {
  9359. this.document.data( "ui-dialog-overlays", overlays );
  9360. }
  9361. this.overlay.remove();
  9362. this.overlay = null;
  9363. }
  9364. }
  9365. });
  9366. /*!
  9367. * jQuery UI Progressbar 1.11.4
  9368. * http://jqueryui.com
  9369. *
  9370. * Copyright jQuery Foundation and other contributors
  9371. * Released under the MIT license.
  9372. * http://jquery.org/license
  9373. *
  9374. * http://api.jqueryui.com/progressbar/
  9375. */
  9376. var progressbar = $.widget( "ui.progressbar", {
  9377. version: "1.11.4",
  9378. options: {
  9379. max: 100,
  9380. value: 0,
  9381. change: null,
  9382. complete: null
  9383. },
  9384. min: 0,
  9385. _create: function() {
  9386. // Constrain initial value
  9387. this.oldValue = this.options.value = this._constrainedValue();
  9388. this.element
  9389. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  9390. .attr({
  9391. // Only set static values, aria-valuenow and aria-valuemax are
  9392. // set inside _refreshValue()
  9393. role: "progressbar",
  9394. "aria-valuemin": this.min
  9395. });
  9396. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  9397. .appendTo( this.element );
  9398. this._refreshValue();
  9399. },
  9400. _destroy: function() {
  9401. this.element
  9402. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  9403. .removeAttr( "role" )
  9404. .removeAttr( "aria-valuemin" )
  9405. .removeAttr( "aria-valuemax" )
  9406. .removeAttr( "aria-valuenow" );
  9407. this.valueDiv.remove();
  9408. },
  9409. value: function( newValue ) {
  9410. if ( newValue === undefined ) {
  9411. return this.options.value;
  9412. }
  9413. this.options.value = this._constrainedValue( newValue );
  9414. this._refreshValue();
  9415. },
  9416. _constrainedValue: function( newValue ) {
  9417. if ( newValue === undefined ) {
  9418. newValue = this.options.value;
  9419. }
  9420. this.indeterminate = newValue === false;
  9421. // sanitize value
  9422. if ( typeof newValue !== "number" ) {
  9423. newValue = 0;
  9424. }
  9425. return this.indeterminate ? false :
  9426. Math.min( this.options.max, Math.max( this.min, newValue ) );
  9427. },
  9428. _setOptions: function( options ) {
  9429. // Ensure "value" option is set after other values (like max)
  9430. var value = options.value;
  9431. delete options.value;
  9432. this._super( options );
  9433. this.options.value = this._constrainedValue( value );
  9434. this._refreshValue();
  9435. },
  9436. _setOption: function( key, value ) {
  9437. if ( key === "max" ) {
  9438. // Don't allow a max less than min
  9439. value = Math.max( this.min, value );
  9440. }
  9441. if ( key === "disabled" ) {
  9442. this.element
  9443. .toggleClass( "ui-state-disabled", !!value )
  9444. .attr( "aria-disabled", value );
  9445. }
  9446. this._super( key, value );
  9447. },
  9448. _percentage: function() {
  9449. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  9450. },
  9451. _refreshValue: function() {
  9452. var value = this.options.value,
  9453. percentage = this._percentage();
  9454. this.valueDiv
  9455. .toggle( this.indeterminate || value > this.min )
  9456. .toggleClass( "ui-corner-right", value === this.options.max )
  9457. .width( percentage.toFixed(0) + "%" );
  9458. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  9459. if ( this.indeterminate ) {
  9460. this.element.removeAttr( "aria-valuenow" );
  9461. if ( !this.overlayDiv ) {
  9462. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  9463. }
  9464. } else {
  9465. this.element.attr({
  9466. "aria-valuemax": this.options.max,
  9467. "aria-valuenow": value
  9468. });
  9469. if ( this.overlayDiv ) {
  9470. this.overlayDiv.remove();
  9471. this.overlayDiv = null;
  9472. }
  9473. }
  9474. if ( this.oldValue !== value ) {
  9475. this.oldValue = value;
  9476. this._trigger( "change" );
  9477. }
  9478. if ( value === this.options.max ) {
  9479. this._trigger( "complete" );
  9480. }
  9481. }
  9482. });
  9483. /*!
  9484. * jQuery UI Selectmenu 1.11.4
  9485. * http://jqueryui.com
  9486. *
  9487. * Copyright jQuery Foundation and other contributors
  9488. * Released under the MIT license.
  9489. * http://jquery.org/license
  9490. *
  9491. * http://api.jqueryui.com/selectmenu
  9492. */
  9493. var selectmenu = $.widget( "ui.selectmenu", {
  9494. version: "1.11.4",
  9495. defaultElement: "<select>",
  9496. options: {
  9497. appendTo: null,
  9498. disabled: null,
  9499. icons: {
  9500. button: "ui-icon-triangle-1-s"
  9501. },
  9502. position: {
  9503. my: "left top",
  9504. at: "left bottom",
  9505. collision: "none"
  9506. },
  9507. width: null,
  9508. // callbacks
  9509. change: null,
  9510. close: null,
  9511. focus: null,
  9512. open: null,
  9513. select: null
  9514. },
  9515. _create: function() {
  9516. var selectmenuId = this.element.uniqueId().attr( "id" );
  9517. this.ids = {
  9518. element: selectmenuId,
  9519. button: selectmenuId + "-button",
  9520. menu: selectmenuId + "-menu"
  9521. };
  9522. this._drawButton();
  9523. this._drawMenu();
  9524. if ( this.options.disabled ) {
  9525. this.disable();
  9526. }
  9527. },
  9528. _drawButton: function() {
  9529. var that = this;
  9530. // Associate existing label with the new button
  9531. this.label = $( "label[for='" + this.ids.element + "']" ).attr( "for", this.ids.button );
  9532. this._on( this.label, {
  9533. click: function( event ) {
  9534. this.button.focus();
  9535. event.preventDefault();
  9536. }
  9537. });
  9538. // Hide original select element
  9539. this.element.hide();
  9540. // Create button
  9541. this.button = $( "<span>", {
  9542. "class": "ui-selectmenu-button ui-widget ui-state-default ui-corner-all",
  9543. tabindex: this.options.disabled ? -1 : 0,
  9544. id: this.ids.button,
  9545. role: "combobox",
  9546. "aria-expanded": "false",
  9547. "aria-autocomplete": "list",
  9548. "aria-owns": this.ids.menu,
  9549. "aria-haspopup": "true"
  9550. })
  9551. .insertAfter( this.element );
  9552. $( "<span>", {
  9553. "class": "ui-icon " + this.options.icons.button
  9554. })
  9555. .prependTo( this.button );
  9556. this.buttonText = $( "<span>", {
  9557. "class": "ui-selectmenu-text"
  9558. })
  9559. .appendTo( this.button );
  9560. this._setText( this.buttonText, this.element.find( "option:selected" ).text() );
  9561. this._resizeButton();
  9562. this._on( this.button, this._buttonEvents );
  9563. this.button.one( "focusin", function() {
  9564. // Delay rendering the menu items until the button receives focus.
  9565. // The menu may have already been rendered via a programmatic open.
  9566. if ( !that.menuItems ) {
  9567. that._refreshMenu();
  9568. }
  9569. });
  9570. this._hoverable( this.button );
  9571. this._focusable( this.button );
  9572. },
  9573. _drawMenu: function() {
  9574. var that = this;
  9575. // Create menu
  9576. this.menu = $( "<ul>", {
  9577. "aria-hidden": "true",
  9578. "aria-labelledby": this.ids.button,
  9579. id: this.ids.menu
  9580. });
  9581. // Wrap menu
  9582. this.menuWrap = $( "<div>", {
  9583. "class": "ui-selectmenu-menu ui-front"
  9584. })
  9585. .append( this.menu )
  9586. .appendTo( this._appendTo() );
  9587. // Initialize menu widget
  9588. this.menuInstance = this.menu
  9589. .menu({
  9590. role: "listbox",
  9591. select: function( event, ui ) {
  9592. event.preventDefault();
  9593. // support: IE8
  9594. // If the item was selected via a click, the text selection
  9595. // will be destroyed in IE
  9596. that._setSelection();
  9597. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  9598. },
  9599. focus: function( event, ui ) {
  9600. var item = ui.item.data( "ui-selectmenu-item" );
  9601. // Prevent inital focus from firing and check if its a newly focused item
  9602. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  9603. that._trigger( "focus", event, { item: item } );
  9604. if ( !that.isOpen ) {
  9605. that._select( item, event );
  9606. }
  9607. }
  9608. that.focusIndex = item.index;
  9609. that.button.attr( "aria-activedescendant",
  9610. that.menuItems.eq( item.index ).attr( "id" ) );
  9611. }
  9612. })
  9613. .menu( "instance" );
  9614. // Adjust menu styles to dropdown
  9615. this.menu
  9616. .addClass( "ui-corner-bottom" )
  9617. .removeClass( "ui-corner-all" );
  9618. // Don't close the menu on mouseleave
  9619. this.menuInstance._off( this.menu, "mouseleave" );
  9620. // Cancel the menu's collapseAll on document click
  9621. this.menuInstance._closeOnDocumentClick = function() {
  9622. return false;
  9623. };
  9624. // Selects often contain empty items, but never contain dividers
  9625. this.menuInstance._isDivider = function() {
  9626. return false;
  9627. };
  9628. },
  9629. refresh: function() {
  9630. this._refreshMenu();
  9631. this._setText( this.buttonText, this._getSelectedItem().text() );
  9632. if ( !this.options.width ) {
  9633. this._resizeButton();
  9634. }
  9635. },
  9636. _refreshMenu: function() {
  9637. this.menu.empty();
  9638. var item,
  9639. options = this.element.find( "option" );
  9640. if ( !options.length ) {
  9641. return;
  9642. }
  9643. this._parseOptions( options );
  9644. this._renderMenu( this.menu, this.items );
  9645. this.menuInstance.refresh();
  9646. this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" );
  9647. item = this._getSelectedItem();
  9648. // Update the menu to have the correct item focused
  9649. this.menuInstance.focus( null, item );
  9650. this._setAria( item.data( "ui-selectmenu-item" ) );
  9651. // Set disabled state
  9652. this._setOption( "disabled", this.element.prop( "disabled" ) );
  9653. },
  9654. open: function( event ) {
  9655. if ( this.options.disabled ) {
  9656. return;
  9657. }
  9658. // If this is the first time the menu is being opened, render the items
  9659. if ( !this.menuItems ) {
  9660. this._refreshMenu();
  9661. } else {
  9662. // Menu clears focus on close, reset focus to selected item
  9663. this.menu.find( ".ui-state-focus" ).removeClass( "ui-state-focus" );
  9664. this.menuInstance.focus( null, this._getSelectedItem() );
  9665. }
  9666. this.isOpen = true;
  9667. this._toggleAttr();
  9668. this._resizeMenu();
  9669. this._position();
  9670. this._on( this.document, this._documentClick );
  9671. this._trigger( "open", event );
  9672. },
  9673. _position: function() {
  9674. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  9675. },
  9676. close: function( event ) {
  9677. if ( !this.isOpen ) {
  9678. return;
  9679. }
  9680. this.isOpen = false;
  9681. this._toggleAttr();
  9682. this.range = null;
  9683. this._off( this.document );
  9684. this._trigger( "close", event );
  9685. },
  9686. widget: function() {
  9687. return this.button;
  9688. },
  9689. menuWidget: function() {
  9690. return this.menu;
  9691. },
  9692. _renderMenu: function( ul, items ) {
  9693. var that = this,
  9694. currentOptgroup = "";
  9695. $.each( items, function( index, item ) {
  9696. if ( item.optgroup !== currentOptgroup ) {
  9697. $( "<li>", {
  9698. "class": "ui-selectmenu-optgroup ui-menu-divider" +
  9699. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  9700. " ui-state-disabled" :
  9701. "" ),
  9702. text: item.optgroup
  9703. })
  9704. .appendTo( ul );
  9705. currentOptgroup = item.optgroup;
  9706. }
  9707. that._renderItemData( ul, item );
  9708. });
  9709. },
  9710. _renderItemData: function( ul, item ) {
  9711. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  9712. },
  9713. _renderItem: function( ul, item ) {
  9714. var li = $( "<li>" );
  9715. if ( item.disabled ) {
  9716. li.addClass( "ui-state-disabled" );
  9717. }
  9718. this._setText( li, item.label );
  9719. return li.appendTo( ul );
  9720. },
  9721. _setText: function( element, value ) {
  9722. if ( value ) {
  9723. element.text( value );
  9724. } else {
  9725. element.html( "&#160;" );
  9726. }
  9727. },
  9728. _move: function( direction, event ) {
  9729. var item, next,
  9730. filter = ".ui-menu-item";
  9731. if ( this.isOpen ) {
  9732. item = this.menuItems.eq( this.focusIndex );
  9733. } else {
  9734. item = this.menuItems.eq( this.element[ 0 ].selectedIndex );
  9735. filter += ":not(.ui-state-disabled)";
  9736. }
  9737. if ( direction === "first" || direction === "last" ) {
  9738. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  9739. } else {
  9740. next = item[ direction + "All" ]( filter ).eq( 0 );
  9741. }
  9742. if ( next.length ) {
  9743. this.menuInstance.focus( event, next );
  9744. }
  9745. },
  9746. _getSelectedItem: function() {
  9747. return this.menuItems.eq( this.element[ 0 ].selectedIndex );
  9748. },
  9749. _toggle: function( event ) {
  9750. this[ this.isOpen ? "close" : "open" ]( event );
  9751. },
  9752. _setSelection: function() {
  9753. var selection;
  9754. if ( !this.range ) {
  9755. return;
  9756. }
  9757. if ( window.getSelection ) {
  9758. selection = window.getSelection();
  9759. selection.removeAllRanges();
  9760. selection.addRange( this.range );
  9761. // support: IE8
  9762. } else {
  9763. this.range.select();
  9764. }
  9765. // support: IE
  9766. // Setting the text selection kills the button focus in IE, but
  9767. // restoring the focus doesn't kill the selection.
  9768. this.button.focus();
  9769. },
  9770. _documentClick: {
  9771. mousedown: function( event ) {
  9772. if ( !this.isOpen ) {
  9773. return;
  9774. }
  9775. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + this.ids.button ).length ) {
  9776. this.close( event );
  9777. }
  9778. }
  9779. },
  9780. _buttonEvents: {
  9781. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  9782. mousedown: function() {
  9783. var selection;
  9784. if ( window.getSelection ) {
  9785. selection = window.getSelection();
  9786. if ( selection.rangeCount ) {
  9787. this.range = selection.getRangeAt( 0 );
  9788. }
  9789. // support: IE8
  9790. } else {
  9791. this.range = document.selection.createRange();
  9792. }
  9793. },
  9794. click: function( event ) {
  9795. this._setSelection();
  9796. this._toggle( event );
  9797. },
  9798. keydown: function( event ) {
  9799. var preventDefault = true;
  9800. switch ( event.keyCode ) {
  9801. case $.ui.keyCode.TAB:
  9802. case $.ui.keyCode.ESCAPE:
  9803. this.close( event );
  9804. preventDefault = false;
  9805. break;
  9806. case $.ui.keyCode.ENTER:
  9807. if ( this.isOpen ) {
  9808. this._selectFocusedItem( event );
  9809. }
  9810. break;
  9811. case $.ui.keyCode.UP:
  9812. if ( event.altKey ) {
  9813. this._toggle( event );
  9814. } else {
  9815. this._move( "prev", event );
  9816. }
  9817. break;
  9818. case $.ui.keyCode.DOWN:
  9819. if ( event.altKey ) {
  9820. this._toggle( event );
  9821. } else {
  9822. this._move( "next", event );
  9823. }
  9824. break;
  9825. case $.ui.keyCode.SPACE:
  9826. if ( this.isOpen ) {
  9827. this._selectFocusedItem( event );
  9828. } else {
  9829. this._toggle( event );
  9830. }
  9831. break;
  9832. case $.ui.keyCode.LEFT:
  9833. this._move( "prev", event );
  9834. break;
  9835. case $.ui.keyCode.RIGHT:
  9836. this._move( "next", event );
  9837. break;
  9838. case $.ui.keyCode.HOME:
  9839. case $.ui.keyCode.PAGE_UP:
  9840. this._move( "first", event );
  9841. break;
  9842. case $.ui.keyCode.END:
  9843. case $.ui.keyCode.PAGE_DOWN:
  9844. this._move( "last", event );
  9845. break;
  9846. default:
  9847. this.menu.trigger( event );
  9848. preventDefault = false;
  9849. }
  9850. if ( preventDefault ) {
  9851. event.preventDefault();
  9852. }
  9853. }
  9854. },
  9855. _selectFocusedItem: function( event ) {
  9856. var item = this.menuItems.eq( this.focusIndex );
  9857. if ( !item.hasClass( "ui-state-disabled" ) ) {
  9858. this._select( item.data( "ui-selectmenu-item" ), event );
  9859. }
  9860. },
  9861. _select: function( item, event ) {
  9862. var oldIndex = this.element[ 0 ].selectedIndex;
  9863. // Change native select element
  9864. this.element[ 0 ].selectedIndex = item.index;
  9865. this._setText( this.buttonText, item.label );
  9866. this._setAria( item );
  9867. this._trigger( "select", event, { item: item } );
  9868. if ( item.index !== oldIndex ) {
  9869. this._trigger( "change", event, { item: item } );
  9870. }
  9871. this.close( event );
  9872. },
  9873. _setAria: function( item ) {
  9874. var id = this.menuItems.eq( item.index ).attr( "id" );
  9875. this.button.attr({
  9876. "aria-labelledby": id,
  9877. "aria-activedescendant": id
  9878. });
  9879. this.menu.attr( "aria-activedescendant", id );
  9880. },
  9881. _setOption: function( key, value ) {
  9882. if ( key === "icons" ) {
  9883. this.button.find( "span.ui-icon" )
  9884. .removeClass( this.options.icons.button )
  9885. .addClass( value.button );
  9886. }
  9887. this._super( key, value );
  9888. if ( key === "appendTo" ) {
  9889. this.menuWrap.appendTo( this._appendTo() );
  9890. }
  9891. if ( key === "disabled" ) {
  9892. this.menuInstance.option( "disabled", value );
  9893. this.button
  9894. .toggleClass( "ui-state-disabled", value )
  9895. .attr( "aria-disabled", value );
  9896. this.element.prop( "disabled", value );
  9897. if ( value ) {
  9898. this.button.attr( "tabindex", -1 );
  9899. this.close();
  9900. } else {
  9901. this.button.attr( "tabindex", 0 );
  9902. }
  9903. }
  9904. if ( key === "width" ) {
  9905. this._resizeButton();
  9906. }
  9907. },
  9908. _appendTo: function() {
  9909. var element = this.options.appendTo;
  9910. if ( element ) {
  9911. element = element.jquery || element.nodeType ?
  9912. $( element ) :
  9913. this.document.find( element ).eq( 0 );
  9914. }
  9915. if ( !element || !element[ 0 ] ) {
  9916. element = this.element.closest( ".ui-front" );
  9917. }
  9918. if ( !element.length ) {
  9919. element = this.document[ 0 ].body;
  9920. }
  9921. return element;
  9922. },
  9923. _toggleAttr: function() {
  9924. this.button
  9925. .toggleClass( "ui-corner-top", this.isOpen )
  9926. .toggleClass( "ui-corner-all", !this.isOpen )
  9927. .attr( "aria-expanded", this.isOpen );
  9928. this.menuWrap.toggleClass( "ui-selectmenu-open", this.isOpen );
  9929. this.menu.attr( "aria-hidden", !this.isOpen );
  9930. },
  9931. _resizeButton: function() {
  9932. var width = this.options.width;
  9933. if ( !width ) {
  9934. width = this.element.show().outerWidth();
  9935. this.element.hide();
  9936. }
  9937. this.button.outerWidth( width );
  9938. },
  9939. _resizeMenu: function() {
  9940. this.menu.outerWidth( Math.max(
  9941. this.button.outerWidth(),
  9942. // support: IE10
  9943. // IE10 wraps long text (possibly a rounding bug)
  9944. // so we add 1px to avoid the wrapping
  9945. this.menu.width( "" ).outerWidth() + 1
  9946. ) );
  9947. },
  9948. _getCreateOptions: function() {
  9949. return { disabled: this.element.prop( "disabled" ) };
  9950. },
  9951. _parseOptions: function( options ) {
  9952. var data = [];
  9953. options.each(function( index, item ) {
  9954. var option = $( item ),
  9955. optgroup = option.parent( "optgroup" );
  9956. data.push({
  9957. element: option,
  9958. index: index,
  9959. value: option.val(),
  9960. label: option.text(),
  9961. optgroup: optgroup.attr( "label" ) || "",
  9962. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  9963. });
  9964. });
  9965. this.items = data;
  9966. },
  9967. _destroy: function() {
  9968. this.menuWrap.remove();
  9969. this.button.remove();
  9970. this.element.show();
  9971. this.element.removeUniqueId();
  9972. this.label.attr( "for", this.ids.element );
  9973. }
  9974. });
  9975. /*!
  9976. * jQuery UI Slider 1.11.4
  9977. * http://jqueryui.com
  9978. *
  9979. * Copyright jQuery Foundation and other contributors
  9980. * Released under the MIT license.
  9981. * http://jquery.org/license
  9982. *
  9983. * http://api.jqueryui.com/slider/
  9984. */
  9985. var slider = $.widget( "ui.slider", $.ui.mouse, {
  9986. version: "1.11.4",
  9987. widgetEventPrefix: "slide",
  9988. options: {
  9989. animate: false,
  9990. distance: 0,
  9991. max: 100,
  9992. min: 0,
  9993. orientation: "horizontal",
  9994. range: false,
  9995. step: 1,
  9996. value: 0,
  9997. values: null,
  9998. // callbacks
  9999. change: null,
  10000. slide: null,
  10001. start: null,
  10002. stop: null
  10003. },
  10004. // number of pages in a slider
  10005. // (how many times can you page up/down to go through the whole range)
  10006. numPages: 5,
  10007. _create: function() {
  10008. this._keySliding = false;
  10009. this._mouseSliding = false;
  10010. this._animateOff = true;
  10011. this._handleIndex = null;
  10012. this._detectOrientation();
  10013. this._mouseInit();
  10014. this._calculateNewMax();
  10015. this.element
  10016. .addClass( "ui-slider" +
  10017. " ui-slider-" + this.orientation +
  10018. " ui-widget" +
  10019. " ui-widget-content" +
  10020. " ui-corner-all");
  10021. this._refresh();
  10022. this._setOption( "disabled", this.options.disabled );
  10023. this._animateOff = false;
  10024. },
  10025. _refresh: function() {
  10026. this._createRange();
  10027. this._createHandles();
  10028. this._setupEvents();
  10029. this._refreshValue();
  10030. },
  10031. _createHandles: function() {
  10032. var i, handleCount,
  10033. options = this.options,
  10034. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  10035. handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",
  10036. handles = [];
  10037. handleCount = ( options.values && options.values.length ) || 1;
  10038. if ( existingHandles.length > handleCount ) {
  10039. existingHandles.slice( handleCount ).remove();
  10040. existingHandles = existingHandles.slice( 0, handleCount );
  10041. }
  10042. for ( i = existingHandles.length; i < handleCount; i++ ) {
  10043. handles.push( handle );
  10044. }
  10045. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  10046. this.handle = this.handles.eq( 0 );
  10047. this.handles.each(function( i ) {
  10048. $( this ).data( "ui-slider-handle-index", i );
  10049. });
  10050. },
  10051. _createRange: function() {
  10052. var options = this.options,
  10053. classes = "";
  10054. if ( options.range ) {
  10055. if ( options.range === true ) {
  10056. if ( !options.values ) {
  10057. options.values = [ this._valueMin(), this._valueMin() ];
  10058. } else if ( options.values.length && options.values.length !== 2 ) {
  10059. options.values = [ options.values[0], options.values[0] ];
  10060. } else if ( $.isArray( options.values ) ) {
  10061. options.values = options.values.slice(0);
  10062. }
  10063. }
  10064. if ( !this.range || !this.range.length ) {
  10065. this.range = $( "<div></div>" )
  10066. .appendTo( this.element );
  10067. classes = "ui-slider-range" +
  10068. // note: this isn't the most fittingly semantic framework class for this element,
  10069. // but worked best visually with a variety of themes
  10070. " ui-widget-header ui-corner-all";
  10071. } else {
  10072. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  10073. // Handle range switching from true to min/max
  10074. .css({
  10075. "left": "",
  10076. "bottom": ""
  10077. });
  10078. }
  10079. this.range.addClass( classes +
  10080. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  10081. } else {
  10082. if ( this.range ) {
  10083. this.range.remove();
  10084. }
  10085. this.range = null;
  10086. }
  10087. },
  10088. _setupEvents: function() {
  10089. this._off( this.handles );
  10090. this._on( this.handles, this._handleEvents );
  10091. this._hoverable( this.handles );
  10092. this._focusable( this.handles );
  10093. },
  10094. _destroy: function() {
  10095. this.handles.remove();
  10096. if ( this.range ) {
  10097. this.range.remove();
  10098. }
  10099. this.element
  10100. .removeClass( "ui-slider" +
  10101. " ui-slider-horizontal" +
  10102. " ui-slider-vertical" +
  10103. " ui-widget" +
  10104. " ui-widget-content" +
  10105. " ui-corner-all" );
  10106. this._mouseDestroy();
  10107. },
  10108. _mouseCapture: function( event ) {
  10109. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  10110. that = this,
  10111. o = this.options;
  10112. if ( o.disabled ) {
  10113. return false;
  10114. }
  10115. this.elementSize = {
  10116. width: this.element.outerWidth(),
  10117. height: this.element.outerHeight()
  10118. };
  10119. this.elementOffset = this.element.offset();
  10120. position = { x: event.pageX, y: event.pageY };
  10121. normValue = this._normValueFromMouse( position );
  10122. distance = this._valueMax() - this._valueMin() + 1;
  10123. this.handles.each(function( i ) {
  10124. var thisDistance = Math.abs( normValue - that.values(i) );
  10125. if (( distance > thisDistance ) ||
  10126. ( distance === thisDistance &&
  10127. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  10128. distance = thisDistance;
  10129. closestHandle = $( this );
  10130. index = i;
  10131. }
  10132. });
  10133. allowed = this._start( event, index );
  10134. if ( allowed === false ) {
  10135. return false;
  10136. }
  10137. this._mouseSliding = true;
  10138. this._handleIndex = index;
  10139. closestHandle
  10140. .addClass( "ui-state-active" )
  10141. .focus();
  10142. offset = closestHandle.offset();
  10143. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  10144. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  10145. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  10146. top: event.pageY - offset.top -
  10147. ( closestHandle.height() / 2 ) -
  10148. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  10149. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  10150. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  10151. };
  10152. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  10153. this._slide( event, index, normValue );
  10154. }
  10155. this._animateOff = true;
  10156. return true;
  10157. },
  10158. _mouseStart: function() {
  10159. return true;
  10160. },
  10161. _mouseDrag: function( event ) {
  10162. var position = { x: event.pageX, y: event.pageY },
  10163. normValue = this._normValueFromMouse( position );
  10164. this._slide( event, this._handleIndex, normValue );
  10165. return false;
  10166. },
  10167. _mouseStop: function( event ) {
  10168. this.handles.removeClass( "ui-state-active" );
  10169. this._mouseSliding = false;
  10170. this._stop( event, this._handleIndex );
  10171. this._change( event, this._handleIndex );
  10172. this._handleIndex = null;
  10173. this._clickOffset = null;
  10174. this._animateOff = false;
  10175. return false;
  10176. },
  10177. _detectOrientation: function() {
  10178. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  10179. },
  10180. _normValueFromMouse: function( position ) {
  10181. var pixelTotal,
  10182. pixelMouse,
  10183. percentMouse,
  10184. valueTotal,
  10185. valueMouse;
  10186. if ( this.orientation === "horizontal" ) {
  10187. pixelTotal = this.elementSize.width;
  10188. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  10189. } else {
  10190. pixelTotal = this.elementSize.height;
  10191. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  10192. }
  10193. percentMouse = ( pixelMouse / pixelTotal );
  10194. if ( percentMouse > 1 ) {
  10195. percentMouse = 1;
  10196. }
  10197. if ( percentMouse < 0 ) {
  10198. percentMouse = 0;
  10199. }
  10200. if ( this.orientation === "vertical" ) {
  10201. percentMouse = 1 - percentMouse;
  10202. }
  10203. valueTotal = this._valueMax() - this._valueMin();
  10204. valueMouse = this._valueMin() + percentMouse * valueTotal;
  10205. return this._trimAlignValue( valueMouse );
  10206. },
  10207. _start: function( event, index ) {
  10208. var uiHash = {
  10209. handle: this.handles[ index ],
  10210. value: this.value()
  10211. };
  10212. if ( this.options.values && this.options.values.length ) {
  10213. uiHash.value = this.values( index );
  10214. uiHash.values = this.values();
  10215. }
  10216. return this._trigger( "start", event, uiHash );
  10217. },
  10218. _slide: function( event, index, newVal ) {
  10219. var otherVal,
  10220. newValues,
  10221. allowed;
  10222. if ( this.options.values && this.options.values.length ) {
  10223. otherVal = this.values( index ? 0 : 1 );
  10224. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  10225. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  10226. ) {
  10227. newVal = otherVal;
  10228. }
  10229. if ( newVal !== this.values( index ) ) {
  10230. newValues = this.values();
  10231. newValues[ index ] = newVal;
  10232. // A slide can be canceled by returning false from the slide callback
  10233. allowed = this._trigger( "slide", event, {
  10234. handle: this.handles[ index ],
  10235. value: newVal,
  10236. values: newValues
  10237. } );
  10238. otherVal = this.values( index ? 0 : 1 );
  10239. if ( allowed !== false ) {
  10240. this.values( index, newVal );
  10241. }
  10242. }
  10243. } else {
  10244. if ( newVal !== this.value() ) {
  10245. // A slide can be canceled by returning false from the slide callback
  10246. allowed = this._trigger( "slide", event, {
  10247. handle: this.handles[ index ],
  10248. value: newVal
  10249. } );
  10250. if ( allowed !== false ) {
  10251. this.value( newVal );
  10252. }
  10253. }
  10254. }
  10255. },
  10256. _stop: function( event, index ) {
  10257. var uiHash = {
  10258. handle: this.handles[ index ],
  10259. value: this.value()
  10260. };
  10261. if ( this.options.values && this.options.values.length ) {
  10262. uiHash.value = this.values( index );
  10263. uiHash.values = this.values();
  10264. }
  10265. this._trigger( "stop", event, uiHash );
  10266. },
  10267. _change: function( event, index ) {
  10268. if ( !this._keySliding && !this._mouseSliding ) {
  10269. var uiHash = {
  10270. handle: this.handles[ index ],
  10271. value: this.value()
  10272. };
  10273. if ( this.options.values && this.options.values.length ) {
  10274. uiHash.value = this.values( index );
  10275. uiHash.values = this.values();
  10276. }
  10277. //store the last changed value index for reference when handles overlap
  10278. this._lastChangedValue = index;
  10279. this._trigger( "change", event, uiHash );
  10280. }
  10281. },
  10282. value: function( newValue ) {
  10283. if ( arguments.length ) {
  10284. this.options.value = this._trimAlignValue( newValue );
  10285. this._refreshValue();
  10286. this._change( null, 0 );
  10287. return;
  10288. }
  10289. return this._value();
  10290. },
  10291. values: function( index, newValue ) {
  10292. var vals,
  10293. newValues,
  10294. i;
  10295. if ( arguments.length > 1 ) {
  10296. this.options.values[ index ] = this._trimAlignValue( newValue );
  10297. this._refreshValue();
  10298. this._change( null, index );
  10299. return;
  10300. }
  10301. if ( arguments.length ) {
  10302. if ( $.isArray( arguments[ 0 ] ) ) {
  10303. vals = this.options.values;
  10304. newValues = arguments[ 0 ];
  10305. for ( i = 0; i < vals.length; i += 1 ) {
  10306. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  10307. this._change( null, i );
  10308. }
  10309. this._refreshValue();
  10310. } else {
  10311. if ( this.options.values && this.options.values.length ) {
  10312. return this._values( index );
  10313. } else {
  10314. return this.value();
  10315. }
  10316. }
  10317. } else {
  10318. return this._values();
  10319. }
  10320. },
  10321. _setOption: function( key, value ) {
  10322. var i,
  10323. valsLength = 0;
  10324. if ( key === "range" && this.options.range === true ) {
  10325. if ( value === "min" ) {
  10326. this.options.value = this._values( 0 );
  10327. this.options.values = null;
  10328. } else if ( value === "max" ) {
  10329. this.options.value = this._values( this.options.values.length - 1 );
  10330. this.options.values = null;
  10331. }
  10332. }
  10333. if ( $.isArray( this.options.values ) ) {
  10334. valsLength = this.options.values.length;
  10335. }
  10336. if ( key === "disabled" ) {
  10337. this.element.toggleClass( "ui-state-disabled", !!value );
  10338. }
  10339. this._super( key, value );
  10340. switch ( key ) {
  10341. case "orientation":
  10342. this._detectOrientation();
  10343. this.element
  10344. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  10345. .addClass( "ui-slider-" + this.orientation );
  10346. this._refreshValue();
  10347. // Reset positioning from previous orientation
  10348. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  10349. break;
  10350. case "value":
  10351. this._animateOff = true;
  10352. this._refreshValue();
  10353. this._change( null, 0 );
  10354. this._animateOff = false;
  10355. break;
  10356. case "values":
  10357. this._animateOff = true;
  10358. this._refreshValue();
  10359. for ( i = 0; i < valsLength; i += 1 ) {
  10360. this._change( null, i );
  10361. }
  10362. this._animateOff = false;
  10363. break;
  10364. case "step":
  10365. case "min":
  10366. case "max":
  10367. this._animateOff = true;
  10368. this._calculateNewMax();
  10369. this._refreshValue();
  10370. this._animateOff = false;
  10371. break;
  10372. case "range":
  10373. this._animateOff = true;
  10374. this._refresh();
  10375. this._animateOff = false;
  10376. break;
  10377. }
  10378. },
  10379. //internal value getter
  10380. // _value() returns value trimmed by min and max, aligned by step
  10381. _value: function() {
  10382. var val = this.options.value;
  10383. val = this._trimAlignValue( val );
  10384. return val;
  10385. },
  10386. //internal values getter
  10387. // _values() returns array of values trimmed by min and max, aligned by step
  10388. // _values( index ) returns single value trimmed by min and max, aligned by step
  10389. _values: function( index ) {
  10390. var val,
  10391. vals,
  10392. i;
  10393. if ( arguments.length ) {
  10394. val = this.options.values[ index ];
  10395. val = this._trimAlignValue( val );
  10396. return val;
  10397. } else if ( this.options.values && this.options.values.length ) {
  10398. // .slice() creates a copy of the array
  10399. // this copy gets trimmed by min and max and then returned
  10400. vals = this.options.values.slice();
  10401. for ( i = 0; i < vals.length; i += 1) {
  10402. vals[ i ] = this._trimAlignValue( vals[ i ] );
  10403. }
  10404. return vals;
  10405. } else {
  10406. return [];
  10407. }
  10408. },
  10409. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  10410. _trimAlignValue: function( val ) {
  10411. if ( val <= this._valueMin() ) {
  10412. return this._valueMin();
  10413. }
  10414. if ( val >= this._valueMax() ) {
  10415. return this._valueMax();
  10416. }
  10417. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  10418. valModStep = (val - this._valueMin()) % step,
  10419. alignValue = val - valModStep;
  10420. if ( Math.abs(valModStep) * 2 >= step ) {
  10421. alignValue += ( valModStep > 0 ) ? step : ( -step );
  10422. }
  10423. // Since JavaScript has problems with large floats, round
  10424. // the final value to 5 digits after the decimal point (see #4124)
  10425. return parseFloat( alignValue.toFixed(5) );
  10426. },
  10427. _calculateNewMax: function() {
  10428. var max = this.options.max,
  10429. min = this._valueMin(),
  10430. step = this.options.step,
  10431. aboveMin = Math.floor( ( +( max - min ).toFixed( this._precision() ) ) / step ) * step;
  10432. max = aboveMin + min;
  10433. this.max = parseFloat( max.toFixed( this._precision() ) );
  10434. },
  10435. _precision: function() {
  10436. var precision = this._precisionOf( this.options.step );
  10437. if ( this.options.min !== null ) {
  10438. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  10439. }
  10440. return precision;
  10441. },
  10442. _precisionOf: function( num ) {
  10443. var str = num.toString(),
  10444. decimal = str.indexOf( "." );
  10445. return decimal === -1 ? 0 : str.length - decimal - 1;
  10446. },
  10447. _valueMin: function() {
  10448. return this.options.min;
  10449. },
  10450. _valueMax: function() {
  10451. return this.max;
  10452. },
  10453. _refreshValue: function() {
  10454. var lastValPercent, valPercent, value, valueMin, valueMax,
  10455. oRange = this.options.range,
  10456. o = this.options,
  10457. that = this,
  10458. animate = ( !this._animateOff ) ? o.animate : false,
  10459. _set = {};
  10460. if ( this.options.values && this.options.values.length ) {
  10461. this.handles.each(function( i ) {
  10462. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  10463. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  10464. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  10465. if ( that.options.range === true ) {
  10466. if ( that.orientation === "horizontal" ) {
  10467. if ( i === 0 ) {
  10468. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  10469. }
  10470. if ( i === 1 ) {
  10471. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  10472. }
  10473. } else {
  10474. if ( i === 0 ) {
  10475. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  10476. }
  10477. if ( i === 1 ) {
  10478. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  10479. }
  10480. }
  10481. }
  10482. lastValPercent = valPercent;
  10483. });
  10484. } else {
  10485. value = this.value();
  10486. valueMin = this._valueMin();
  10487. valueMax = this._valueMax();
  10488. valPercent = ( valueMax !== valueMin ) ?
  10489. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  10490. 0;
  10491. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  10492. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  10493. if ( oRange === "min" && this.orientation === "horizontal" ) {
  10494. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  10495. }
  10496. if ( oRange === "max" && this.orientation === "horizontal" ) {
  10497. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  10498. }
  10499. if ( oRange === "min" && this.orientation === "vertical" ) {
  10500. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  10501. }
  10502. if ( oRange === "max" && this.orientation === "vertical" ) {
  10503. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  10504. }
  10505. }
  10506. },
  10507. _handleEvents: {
  10508. keydown: function( event ) {
  10509. var allowed, curVal, newVal, step,
  10510. index = $( event.target ).data( "ui-slider-handle-index" );
  10511. switch ( event.keyCode ) {
  10512. case $.ui.keyCode.HOME:
  10513. case $.ui.keyCode.END:
  10514. case $.ui.keyCode.PAGE_UP:
  10515. case $.ui.keyCode.PAGE_DOWN:
  10516. case $.ui.keyCode.UP:
  10517. case $.ui.keyCode.RIGHT:
  10518. case $.ui.keyCode.DOWN:
  10519. case $.ui.keyCode.LEFT:
  10520. event.preventDefault();
  10521. if ( !this._keySliding ) {
  10522. this._keySliding = true;
  10523. $( event.target ).addClass( "ui-state-active" );
  10524. allowed = this._start( event, index );
  10525. if ( allowed === false ) {
  10526. return;
  10527. }
  10528. }
  10529. break;
  10530. }
  10531. step = this.options.step;
  10532. if ( this.options.values && this.options.values.length ) {
  10533. curVal = newVal = this.values( index );
  10534. } else {
  10535. curVal = newVal = this.value();
  10536. }
  10537. switch ( event.keyCode ) {
  10538. case $.ui.keyCode.HOME:
  10539. newVal = this._valueMin();
  10540. break;
  10541. case $.ui.keyCode.END:
  10542. newVal = this._valueMax();
  10543. break;
  10544. case $.ui.keyCode.PAGE_UP:
  10545. newVal = this._trimAlignValue(
  10546. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  10547. );
  10548. break;
  10549. case $.ui.keyCode.PAGE_DOWN:
  10550. newVal = this._trimAlignValue(
  10551. curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
  10552. break;
  10553. case $.ui.keyCode.UP:
  10554. case $.ui.keyCode.RIGHT:
  10555. if ( curVal === this._valueMax() ) {
  10556. return;
  10557. }
  10558. newVal = this._trimAlignValue( curVal + step );
  10559. break;
  10560. case $.ui.keyCode.DOWN:
  10561. case $.ui.keyCode.LEFT:
  10562. if ( curVal === this._valueMin() ) {
  10563. return;
  10564. }
  10565. newVal = this._trimAlignValue( curVal - step );
  10566. break;
  10567. }
  10568. this._slide( event, index, newVal );
  10569. },
  10570. keyup: function( event ) {
  10571. var index = $( event.target ).data( "ui-slider-handle-index" );
  10572. if ( this._keySliding ) {
  10573. this._keySliding = false;
  10574. this._stop( event, index );
  10575. this._change( event, index );
  10576. $( event.target ).removeClass( "ui-state-active" );
  10577. }
  10578. }
  10579. }
  10580. });
  10581. /*!
  10582. * jQuery UI Spinner 1.11.4
  10583. * http://jqueryui.com
  10584. *
  10585. * Copyright jQuery Foundation and other contributors
  10586. * Released under the MIT license.
  10587. * http://jquery.org/license
  10588. *
  10589. * http://api.jqueryui.com/spinner/
  10590. */
  10591. function spinner_modifier( fn ) {
  10592. return function() {
  10593. var previous = this.element.val();
  10594. fn.apply( this, arguments );
  10595. this._refresh();
  10596. if ( previous !== this.element.val() ) {
  10597. this._trigger( "change" );
  10598. }
  10599. };
  10600. }
  10601. var spinner = $.widget( "ui.spinner", {
  10602. version: "1.11.4",
  10603. defaultElement: "<input>",
  10604. widgetEventPrefix: "spin",
  10605. options: {
  10606. culture: null,
  10607. icons: {
  10608. down: "ui-icon-triangle-1-s",
  10609. up: "ui-icon-triangle-1-n"
  10610. },
  10611. incremental: true,
  10612. max: null,
  10613. min: null,
  10614. numberFormat: null,
  10615. page: 10,
  10616. step: 1,
  10617. change: null,
  10618. spin: null,
  10619. start: null,
  10620. stop: null
  10621. },
  10622. _create: function() {
  10623. // handle string values that need to be parsed
  10624. this._setOption( "max", this.options.max );
  10625. this._setOption( "min", this.options.min );
  10626. this._setOption( "step", this.options.step );
  10627. // Only format if there is a value, prevents the field from being marked
  10628. // as invalid in Firefox, see #9573.
  10629. if ( this.value() !== "" ) {
  10630. // Format the value, but don't constrain.
  10631. this._value( this.element.val(), true );
  10632. }
  10633. this._draw();
  10634. this._on( this._events );
  10635. this._refresh();
  10636. // turning off autocomplete prevents the browser from remembering the
  10637. // value when navigating through history, so we re-enable autocomplete
  10638. // if the page is unloaded before the widget is destroyed. #7790
  10639. this._on( this.window, {
  10640. beforeunload: function() {
  10641. this.element.removeAttr( "autocomplete" );
  10642. }
  10643. });
  10644. },
  10645. _getCreateOptions: function() {
  10646. var options = {},
  10647. element = this.element;
  10648. $.each( [ "min", "max", "step" ], function( i, option ) {
  10649. var value = element.attr( option );
  10650. if ( value !== undefined && value.length ) {
  10651. options[ option ] = value;
  10652. }
  10653. });
  10654. return options;
  10655. },
  10656. _events: {
  10657. keydown: function( event ) {
  10658. if ( this._start( event ) && this._keydown( event ) ) {
  10659. event.preventDefault();
  10660. }
  10661. },
  10662. keyup: "_stop",
  10663. focus: function() {
  10664. this.previous = this.element.val();
  10665. },
  10666. blur: function( event ) {
  10667. if ( this.cancelBlur ) {
  10668. delete this.cancelBlur;
  10669. return;
  10670. }
  10671. this._stop();
  10672. this._refresh();
  10673. if ( this.previous !== this.element.val() ) {
  10674. this._trigger( "change", event );
  10675. }
  10676. },
  10677. mousewheel: function( event, delta ) {
  10678. if ( !delta ) {
  10679. return;
  10680. }
  10681. if ( !this.spinning && !this._start( event ) ) {
  10682. return false;
  10683. }
  10684. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  10685. clearTimeout( this.mousewheelTimer );
  10686. this.mousewheelTimer = this._delay(function() {
  10687. if ( this.spinning ) {
  10688. this._stop( event );
  10689. }
  10690. }, 100 );
  10691. event.preventDefault();
  10692. },
  10693. "mousedown .ui-spinner-button": function( event ) {
  10694. var previous;
  10695. // We never want the buttons to have focus; whenever the user is
  10696. // interacting with the spinner, the focus should be on the input.
  10697. // If the input is focused then this.previous is properly set from
  10698. // when the input first received focus. If the input is not focused
  10699. // then we need to set this.previous based on the value before spinning.
  10700. previous = this.element[0] === this.document[0].activeElement ?
  10701. this.previous : this.element.val();
  10702. function checkFocus() {
  10703. var isActive = this.element[0] === this.document[0].activeElement;
  10704. if ( !isActive ) {
  10705. this.element.focus();
  10706. this.previous = previous;
  10707. // support: IE
  10708. // IE sets focus asynchronously, so we need to check if focus
  10709. // moved off of the input because the user clicked on the button.
  10710. this._delay(function() {
  10711. this.previous = previous;
  10712. });
  10713. }
  10714. }
  10715. // ensure focus is on (or stays on) the text field
  10716. event.preventDefault();
  10717. checkFocus.call( this );
  10718. // support: IE
  10719. // IE doesn't prevent moving focus even with event.preventDefault()
  10720. // so we set a flag to know when we should ignore the blur event
  10721. // and check (again) if focus moved off of the input.
  10722. this.cancelBlur = true;
  10723. this._delay(function() {
  10724. delete this.cancelBlur;
  10725. checkFocus.call( this );
  10726. });
  10727. if ( this._start( event ) === false ) {
  10728. return;
  10729. }
  10730. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  10731. },
  10732. "mouseup .ui-spinner-button": "_stop",
  10733. "mouseenter .ui-spinner-button": function( event ) {
  10734. // button will add ui-state-active if mouse was down while mouseleave and kept down
  10735. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  10736. return;
  10737. }
  10738. if ( this._start( event ) === false ) {
  10739. return false;
  10740. }
  10741. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  10742. },
  10743. // TODO: do we really want to consider this a stop?
  10744. // shouldn't we just stop the repeater and wait until mouseup before
  10745. // we trigger the stop event?
  10746. "mouseleave .ui-spinner-button": "_stop"
  10747. },
  10748. _draw: function() {
  10749. var uiSpinner = this.uiSpinner = this.element
  10750. .addClass( "ui-spinner-input" )
  10751. .attr( "autocomplete", "off" )
  10752. .wrap( this._uiSpinnerHtml() )
  10753. .parent()
  10754. // add buttons
  10755. .append( this._buttonHtml() );
  10756. this.element.attr( "role", "spinbutton" );
  10757. // button bindings
  10758. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  10759. .attr( "tabIndex", -1 )
  10760. .button()
  10761. .removeClass( "ui-corner-all" );
  10762. // IE 6 doesn't understand height: 50% for the buttons
  10763. // unless the wrapper has an explicit height
  10764. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  10765. uiSpinner.height() > 0 ) {
  10766. uiSpinner.height( uiSpinner.height() );
  10767. }
  10768. // disable spinner if element was already disabled
  10769. if ( this.options.disabled ) {
  10770. this.disable();
  10771. }
  10772. },
  10773. _keydown: function( event ) {
  10774. var options = this.options,
  10775. keyCode = $.ui.keyCode;
  10776. switch ( event.keyCode ) {
  10777. case keyCode.UP:
  10778. this._repeat( null, 1, event );
  10779. return true;
  10780. case keyCode.DOWN:
  10781. this._repeat( null, -1, event );
  10782. return true;
  10783. case keyCode.PAGE_UP:
  10784. this._repeat( null, options.page, event );
  10785. return true;
  10786. case keyCode.PAGE_DOWN:
  10787. this._repeat( null, -options.page, event );
  10788. return true;
  10789. }
  10790. return false;
  10791. },
  10792. _uiSpinnerHtml: function() {
  10793. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  10794. },
  10795. _buttonHtml: function() {
  10796. return "" +
  10797. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  10798. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  10799. "</a>" +
  10800. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  10801. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  10802. "</a>";
  10803. },
  10804. _start: function( event ) {
  10805. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  10806. return false;
  10807. }
  10808. if ( !this.counter ) {
  10809. this.counter = 1;
  10810. }
  10811. this.spinning = true;
  10812. return true;
  10813. },
  10814. _repeat: function( i, steps, event ) {
  10815. i = i || 500;
  10816. clearTimeout( this.timer );
  10817. this.timer = this._delay(function() {
  10818. this._repeat( 40, steps, event );
  10819. }, i );
  10820. this._spin( steps * this.options.step, event );
  10821. },
  10822. _spin: function( step, event ) {
  10823. var value = this.value() || 0;
  10824. if ( !this.counter ) {
  10825. this.counter = 1;
  10826. }
  10827. value = this._adjustValue( value + step * this._increment( this.counter ) );
  10828. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  10829. this._value( value );
  10830. this.counter++;
  10831. }
  10832. },
  10833. _increment: function( i ) {
  10834. var incremental = this.options.incremental;
  10835. if ( incremental ) {
  10836. return $.isFunction( incremental ) ?
  10837. incremental( i ) :
  10838. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  10839. }
  10840. return 1;
  10841. },
  10842. _precision: function() {
  10843. var precision = this._precisionOf( this.options.step );
  10844. if ( this.options.min !== null ) {
  10845. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  10846. }
  10847. return precision;
  10848. },
  10849. _precisionOf: function( num ) {
  10850. var str = num.toString(),
  10851. decimal = str.indexOf( "." );
  10852. return decimal === -1 ? 0 : str.length - decimal - 1;
  10853. },
  10854. _adjustValue: function( value ) {
  10855. var base, aboveMin,
  10856. options = this.options;
  10857. // make sure we're at a valid step
  10858. // - find out where we are relative to the base (min or 0)
  10859. base = options.min !== null ? options.min : 0;
  10860. aboveMin = value - base;
  10861. // - round to the nearest step
  10862. aboveMin = Math.round(aboveMin / options.step) * options.step;
  10863. // - rounding is based on 0, so adjust back to our base
  10864. value = base + aboveMin;
  10865. // fix precision from bad JS floating point math
  10866. value = parseFloat( value.toFixed( this._precision() ) );
  10867. // clamp the value
  10868. if ( options.max !== null && value > options.max) {
  10869. return options.max;
  10870. }
  10871. if ( options.min !== null && value < options.min ) {
  10872. return options.min;
  10873. }
  10874. return value;
  10875. },
  10876. _stop: function( event ) {
  10877. if ( !this.spinning ) {
  10878. return;
  10879. }
  10880. clearTimeout( this.timer );
  10881. clearTimeout( this.mousewheelTimer );
  10882. this.counter = 0;
  10883. this.spinning = false;
  10884. this._trigger( "stop", event );
  10885. },
  10886. _setOption: function( key, value ) {
  10887. if ( key === "culture" || key === "numberFormat" ) {
  10888. var prevValue = this._parse( this.element.val() );
  10889. this.options[ key ] = value;
  10890. this.element.val( this._format( prevValue ) );
  10891. return;
  10892. }
  10893. if ( key === "max" || key === "min" || key === "step" ) {
  10894. if ( typeof value === "string" ) {
  10895. value = this._parse( value );
  10896. }
  10897. }
  10898. if ( key === "icons" ) {
  10899. this.buttons.first().find( ".ui-icon" )
  10900. .removeClass( this.options.icons.up )
  10901. .addClass( value.up );
  10902. this.buttons.last().find( ".ui-icon" )
  10903. .removeClass( this.options.icons.down )
  10904. .addClass( value.down );
  10905. }
  10906. this._super( key, value );
  10907. if ( key === "disabled" ) {
  10908. this.widget().toggleClass( "ui-state-disabled", !!value );
  10909. this.element.prop( "disabled", !!value );
  10910. this.buttons.button( value ? "disable" : "enable" );
  10911. }
  10912. },
  10913. _setOptions: spinner_modifier(function( options ) {
  10914. this._super( options );
  10915. }),
  10916. _parse: function( val ) {
  10917. if ( typeof val === "string" && val !== "" ) {
  10918. val = window.Globalize && this.options.numberFormat ?
  10919. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  10920. }
  10921. return val === "" || isNaN( val ) ? null : val;
  10922. },
  10923. _format: function( value ) {
  10924. if ( value === "" ) {
  10925. return "";
  10926. }
  10927. return window.Globalize && this.options.numberFormat ?
  10928. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  10929. value;
  10930. },
  10931. _refresh: function() {
  10932. this.element.attr({
  10933. "aria-valuemin": this.options.min,
  10934. "aria-valuemax": this.options.max,
  10935. // TODO: what should we do with values that can't be parsed?
  10936. "aria-valuenow": this._parse( this.element.val() )
  10937. });
  10938. },
  10939. isValid: function() {
  10940. var value = this.value();
  10941. // null is invalid
  10942. if ( value === null ) {
  10943. return false;
  10944. }
  10945. // if value gets adjusted, it's invalid
  10946. return value === this._adjustValue( value );
  10947. },
  10948. // update the value without triggering change
  10949. _value: function( value, allowAny ) {
  10950. var parsed;
  10951. if ( value !== "" ) {
  10952. parsed = this._parse( value );
  10953. if ( parsed !== null ) {
  10954. if ( !allowAny ) {
  10955. parsed = this._adjustValue( parsed );
  10956. }
  10957. value = this._format( parsed );
  10958. }
  10959. }
  10960. this.element.val( value );
  10961. this._refresh();
  10962. },
  10963. _destroy: function() {
  10964. this.element
  10965. .removeClass( "ui-spinner-input" )
  10966. .prop( "disabled", false )
  10967. .removeAttr( "autocomplete" )
  10968. .removeAttr( "role" )
  10969. .removeAttr( "aria-valuemin" )
  10970. .removeAttr( "aria-valuemax" )
  10971. .removeAttr( "aria-valuenow" );
  10972. this.uiSpinner.replaceWith( this.element );
  10973. },
  10974. stepUp: spinner_modifier(function( steps ) {
  10975. this._stepUp( steps );
  10976. }),
  10977. _stepUp: function( steps ) {
  10978. if ( this._start() ) {
  10979. this._spin( (steps || 1) * this.options.step );
  10980. this._stop();
  10981. }
  10982. },
  10983. stepDown: spinner_modifier(function( steps ) {
  10984. this._stepDown( steps );
  10985. }),
  10986. _stepDown: function( steps ) {
  10987. if ( this._start() ) {
  10988. this._spin( (steps || 1) * -this.options.step );
  10989. this._stop();
  10990. }
  10991. },
  10992. pageUp: spinner_modifier(function( pages ) {
  10993. this._stepUp( (pages || 1) * this.options.page );
  10994. }),
  10995. pageDown: spinner_modifier(function( pages ) {
  10996. this._stepDown( (pages || 1) * this.options.page );
  10997. }),
  10998. value: function( newVal ) {
  10999. if ( !arguments.length ) {
  11000. return this._parse( this.element.val() );
  11001. }
  11002. spinner_modifier( this._value ).call( this, newVal );
  11003. },
  11004. widget: function() {
  11005. return this.uiSpinner;
  11006. }
  11007. });
  11008. /*!
  11009. * jQuery UI Tabs 1.11.4
  11010. * http://jqueryui.com
  11011. *
  11012. * Copyright jQuery Foundation and other contributors
  11013. * Released under the MIT license.
  11014. * http://jquery.org/license
  11015. *
  11016. * http://api.jqueryui.com/tabs/
  11017. */
  11018. var tabs = $.widget( "ui.tabs", {
  11019. version: "1.11.4",
  11020. delay: 300,
  11021. options: {
  11022. active: null,
  11023. collapsible: false,
  11024. event: "click",
  11025. heightStyle: "content",
  11026. hide: null,
  11027. show: null,
  11028. // callbacks
  11029. activate: null,
  11030. beforeActivate: null,
  11031. beforeLoad: null,
  11032. load: null
  11033. },
  11034. _isLocal: (function() {
  11035. var rhash = /#.*$/;
  11036. return function( anchor ) {
  11037. var anchorUrl, locationUrl;
  11038. // support: IE7
  11039. // IE7 doesn't normalize the href property when set via script (#9317)
  11040. anchor = anchor.cloneNode( false );
  11041. anchorUrl = anchor.href.replace( rhash, "" );
  11042. locationUrl = location.href.replace( rhash, "" );
  11043. // decoding may throw an error if the URL isn't UTF-8 (#9518)
  11044. try {
  11045. anchorUrl = decodeURIComponent( anchorUrl );
  11046. } catch ( error ) {}
  11047. try {
  11048. locationUrl = decodeURIComponent( locationUrl );
  11049. } catch ( error ) {}
  11050. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  11051. };
  11052. })(),
  11053. _create: function() {
  11054. var that = this,
  11055. options = this.options;
  11056. this.running = false;
  11057. this.element
  11058. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  11059. .toggleClass( "ui-tabs-collapsible", options.collapsible );
  11060. this._processTabs();
  11061. options.active = this._initialActive();
  11062. // Take disabling tabs via class attribute from HTML
  11063. // into account and update option properly.
  11064. if ( $.isArray( options.disabled ) ) {
  11065. options.disabled = $.unique( options.disabled.concat(
  11066. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  11067. return that.tabs.index( li );
  11068. })
  11069. ) ).sort();
  11070. }
  11071. // check for length avoids error when initializing empty list
  11072. if ( this.options.active !== false && this.anchors.length ) {
  11073. this.active = this._findActive( options.active );
  11074. } else {
  11075. this.active = $();
  11076. }
  11077. this._refresh();
  11078. if ( this.active.length ) {
  11079. this.load( options.active );
  11080. }
  11081. },
  11082. _initialActive: function() {
  11083. var active = this.options.active,
  11084. collapsible = this.options.collapsible,
  11085. locationHash = location.hash.substring( 1 );
  11086. if ( active === null ) {
  11087. // check the fragment identifier in the URL
  11088. if ( locationHash ) {
  11089. this.tabs.each(function( i, tab ) {
  11090. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  11091. active = i;
  11092. return false;
  11093. }
  11094. });
  11095. }
  11096. // check for a tab marked active via a class
  11097. if ( active === null ) {
  11098. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  11099. }
  11100. // no active tab, set to false
  11101. if ( active === null || active === -1 ) {
  11102. active = this.tabs.length ? 0 : false;
  11103. }
  11104. }
  11105. // handle numbers: negative, out of range
  11106. if ( active !== false ) {
  11107. active = this.tabs.index( this.tabs.eq( active ) );
  11108. if ( active === -1 ) {
  11109. active = collapsible ? false : 0;
  11110. }
  11111. }
  11112. // don't allow collapsible: false and active: false
  11113. if ( !collapsible && active === false && this.anchors.length ) {
  11114. active = 0;
  11115. }
  11116. return active;
  11117. },
  11118. _getCreateEventData: function() {
  11119. return {
  11120. tab: this.active,
  11121. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  11122. };
  11123. },
  11124. _tabKeydown: function( event ) {
  11125. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  11126. selectedIndex = this.tabs.index( focusedTab ),
  11127. goingForward = true;
  11128. if ( this._handlePageNav( event ) ) {
  11129. return;
  11130. }
  11131. switch ( event.keyCode ) {
  11132. case $.ui.keyCode.RIGHT:
  11133. case $.ui.keyCode.DOWN:
  11134. selectedIndex++;
  11135. break;
  11136. case $.ui.keyCode.UP:
  11137. case $.ui.keyCode.LEFT:
  11138. goingForward = false;
  11139. selectedIndex--;
  11140. break;
  11141. case $.ui.keyCode.END:
  11142. selectedIndex = this.anchors.length - 1;
  11143. break;
  11144. case $.ui.keyCode.HOME:
  11145. selectedIndex = 0;
  11146. break;
  11147. case $.ui.keyCode.SPACE:
  11148. // Activate only, no collapsing
  11149. event.preventDefault();
  11150. clearTimeout( this.activating );
  11151. this._activate( selectedIndex );
  11152. return;
  11153. case $.ui.keyCode.ENTER:
  11154. // Toggle (cancel delayed activation, allow collapsing)
  11155. event.preventDefault();
  11156. clearTimeout( this.activating );
  11157. // Determine if we should collapse or activate
  11158. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  11159. return;
  11160. default:
  11161. return;
  11162. }
  11163. // Focus the appropriate tab, based on which key was pressed
  11164. event.preventDefault();
  11165. clearTimeout( this.activating );
  11166. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  11167. // Navigating with control/command key will prevent automatic activation
  11168. if ( !event.ctrlKey && !event.metaKey ) {
  11169. // Update aria-selected immediately so that AT think the tab is already selected.
  11170. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  11171. // but the tab will already be activated by the time the announcement finishes.
  11172. focusedTab.attr( "aria-selected", "false" );
  11173. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  11174. this.activating = this._delay(function() {
  11175. this.option( "active", selectedIndex );
  11176. }, this.delay );
  11177. }
  11178. },
  11179. _panelKeydown: function( event ) {
  11180. if ( this._handlePageNav( event ) ) {
  11181. return;
  11182. }
  11183. // Ctrl+up moves focus to the current tab
  11184. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  11185. event.preventDefault();
  11186. this.active.focus();
  11187. }
  11188. },
  11189. // Alt+page up/down moves focus to the previous/next tab (and activates)
  11190. _handlePageNav: function( event ) {
  11191. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  11192. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  11193. return true;
  11194. }
  11195. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  11196. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  11197. return true;
  11198. }
  11199. },
  11200. _findNextTab: function( index, goingForward ) {
  11201. var lastTabIndex = this.tabs.length - 1;
  11202. function constrain() {
  11203. if ( index > lastTabIndex ) {
  11204. index = 0;
  11205. }
  11206. if ( index < 0 ) {
  11207. index = lastTabIndex;
  11208. }
  11209. return index;
  11210. }
  11211. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  11212. index = goingForward ? index + 1 : index - 1;
  11213. }
  11214. return index;
  11215. },
  11216. _focusNextTab: function( index, goingForward ) {
  11217. index = this._findNextTab( index, goingForward );
  11218. this.tabs.eq( index ).focus();
  11219. return index;
  11220. },
  11221. _setOption: function( key, value ) {
  11222. if ( key === "active" ) {
  11223. // _activate() will handle invalid values and update this.options
  11224. this._activate( value );
  11225. return;
  11226. }
  11227. if ( key === "disabled" ) {
  11228. // don't use the widget factory's disabled handling
  11229. this._setupDisabled( value );
  11230. return;
  11231. }
  11232. this._super( key, value);
  11233. if ( key === "collapsible" ) {
  11234. this.element.toggleClass( "ui-tabs-collapsible", value );
  11235. // Setting collapsible: false while collapsed; open first panel
  11236. if ( !value && this.options.active === false ) {
  11237. this._activate( 0 );
  11238. }
  11239. }
  11240. if ( key === "event" ) {
  11241. this._setupEvents( value );
  11242. }
  11243. if ( key === "heightStyle" ) {
  11244. this._setupHeightStyle( value );
  11245. }
  11246. },
  11247. _sanitizeSelector: function( hash ) {
  11248. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  11249. },
  11250. refresh: function() {
  11251. var options = this.options,
  11252. lis = this.tablist.children( ":has(a[href])" );
  11253. // get disabled tabs from class attribute from HTML
  11254. // this will get converted to a boolean if needed in _refresh()
  11255. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  11256. return lis.index( tab );
  11257. });
  11258. this._processTabs();
  11259. // was collapsed or no tabs
  11260. if ( options.active === false || !this.anchors.length ) {
  11261. options.active = false;
  11262. this.active = $();
  11263. // was active, but active tab is gone
  11264. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  11265. // all remaining tabs are disabled
  11266. if ( this.tabs.length === options.disabled.length ) {
  11267. options.active = false;
  11268. this.active = $();
  11269. // activate previous tab
  11270. } else {
  11271. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  11272. }
  11273. // was active, active tab still exists
  11274. } else {
  11275. // make sure active index is correct
  11276. options.active = this.tabs.index( this.active );
  11277. }
  11278. this._refresh();
  11279. },
  11280. _refresh: function() {
  11281. this._setupDisabled( this.options.disabled );
  11282. this._setupEvents( this.options.event );
  11283. this._setupHeightStyle( this.options.heightStyle );
  11284. this.tabs.not( this.active ).attr({
  11285. "aria-selected": "false",
  11286. "aria-expanded": "false",
  11287. tabIndex: -1
  11288. });
  11289. this.panels.not( this._getPanelForTab( this.active ) )
  11290. .hide()
  11291. .attr({
  11292. "aria-hidden": "true"
  11293. });
  11294. // Make sure one tab is in the tab order
  11295. if ( !this.active.length ) {
  11296. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  11297. } else {
  11298. this.active
  11299. .addClass( "ui-tabs-active ui-state-active" )
  11300. .attr({
  11301. "aria-selected": "true",
  11302. "aria-expanded": "true",
  11303. tabIndex: 0
  11304. });
  11305. this._getPanelForTab( this.active )
  11306. .show()
  11307. .attr({
  11308. "aria-hidden": "false"
  11309. });
  11310. }
  11311. },
  11312. _processTabs: function() {
  11313. var that = this,
  11314. prevTabs = this.tabs,
  11315. prevAnchors = this.anchors,
  11316. prevPanels = this.panels;
  11317. this.tablist = this._getList()
  11318. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  11319. .attr( "role", "tablist" )
  11320. // Prevent users from focusing disabled tabs via click
  11321. .delegate( "> li", "mousedown" + this.eventNamespace, function( event ) {
  11322. if ( $( this ).is( ".ui-state-disabled" ) ) {
  11323. event.preventDefault();
  11324. }
  11325. })
  11326. // support: IE <9
  11327. // Preventing the default action in mousedown doesn't prevent IE
  11328. // from focusing the element, so if the anchor gets focused, blur.
  11329. // We don't have to worry about focusing the previously focused
  11330. // element since clicking on a non-focusable element should focus
  11331. // the body anyway.
  11332. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  11333. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  11334. this.blur();
  11335. }
  11336. });
  11337. this.tabs = this.tablist.find( "> li:has(a[href])" )
  11338. .addClass( "ui-state-default ui-corner-top" )
  11339. .attr({
  11340. role: "tab",
  11341. tabIndex: -1
  11342. });
  11343. this.anchors = this.tabs.map(function() {
  11344. return $( "a", this )[ 0 ];
  11345. })
  11346. .addClass( "ui-tabs-anchor" )
  11347. .attr({
  11348. role: "presentation",
  11349. tabIndex: -1
  11350. });
  11351. this.panels = $();
  11352. this.anchors.each(function( i, anchor ) {
  11353. var selector, panel, panelId,
  11354. anchorId = $( anchor ).uniqueId().attr( "id" ),
  11355. tab = $( anchor ).closest( "li" ),
  11356. originalAriaControls = tab.attr( "aria-controls" );
  11357. // inline tab
  11358. if ( that._isLocal( anchor ) ) {
  11359. selector = anchor.hash;
  11360. panelId = selector.substring( 1 );
  11361. panel = that.element.find( that._sanitizeSelector( selector ) );
  11362. // remote tab
  11363. } else {
  11364. // If the tab doesn't already have aria-controls,
  11365. // generate an id by using a throw-away element
  11366. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  11367. selector = "#" + panelId;
  11368. panel = that.element.find( selector );
  11369. if ( !panel.length ) {
  11370. panel = that._createPanel( panelId );
  11371. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  11372. }
  11373. panel.attr( "aria-live", "polite" );
  11374. }
  11375. if ( panel.length) {
  11376. that.panels = that.panels.add( panel );
  11377. }
  11378. if ( originalAriaControls ) {
  11379. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  11380. }
  11381. tab.attr({
  11382. "aria-controls": panelId,
  11383. "aria-labelledby": anchorId
  11384. });
  11385. panel.attr( "aria-labelledby", anchorId );
  11386. });
  11387. this.panels
  11388. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  11389. .attr( "role", "tabpanel" );
  11390. // Avoid memory leaks (#10056)
  11391. if ( prevTabs ) {
  11392. this._off( prevTabs.not( this.tabs ) );
  11393. this._off( prevAnchors.not( this.anchors ) );
  11394. this._off( prevPanels.not( this.panels ) );
  11395. }
  11396. },
  11397. // allow overriding how to find the list for rare usage scenarios (#7715)
  11398. _getList: function() {
  11399. return this.tablist || this.element.find( "ol,ul" ).eq( 0 );
  11400. },
  11401. _createPanel: function( id ) {
  11402. return $( "<div>" )
  11403. .attr( "id", id )
  11404. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  11405. .data( "ui-tabs-destroy", true );
  11406. },
  11407. _setupDisabled: function( disabled ) {
  11408. if ( $.isArray( disabled ) ) {
  11409. if ( !disabled.length ) {
  11410. disabled = false;
  11411. } else if ( disabled.length === this.anchors.length ) {
  11412. disabled = true;
  11413. }
  11414. }
  11415. // disable tabs
  11416. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  11417. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  11418. $( li )
  11419. .addClass( "ui-state-disabled" )
  11420. .attr( "aria-disabled", "true" );
  11421. } else {
  11422. $( li )
  11423. .removeClass( "ui-state-disabled" )
  11424. .removeAttr( "aria-disabled" );
  11425. }
  11426. }
  11427. this.options.disabled = disabled;
  11428. },
  11429. _setupEvents: function( event ) {
  11430. var events = {};
  11431. if ( event ) {
  11432. $.each( event.split(" "), function( index, eventName ) {
  11433. events[ eventName ] = "_eventHandler";
  11434. });
  11435. }
  11436. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  11437. // Always prevent the default action, even when disabled
  11438. this._on( true, this.anchors, {
  11439. click: function( event ) {
  11440. event.preventDefault();
  11441. }
  11442. });
  11443. this._on( this.anchors, events );
  11444. this._on( this.tabs, { keydown: "_tabKeydown" } );
  11445. this._on( this.panels, { keydown: "_panelKeydown" } );
  11446. this._focusable( this.tabs );
  11447. this._hoverable( this.tabs );
  11448. },
  11449. _setupHeightStyle: function( heightStyle ) {
  11450. var maxHeight,
  11451. parent = this.element.parent();
  11452. if ( heightStyle === "fill" ) {
  11453. maxHeight = parent.height();
  11454. maxHeight -= this.element.outerHeight() - this.element.height();
  11455. this.element.siblings( ":visible" ).each(function() {
  11456. var elem = $( this ),
  11457. position = elem.css( "position" );
  11458. if ( position === "absolute" || position === "fixed" ) {
  11459. return;
  11460. }
  11461. maxHeight -= elem.outerHeight( true );
  11462. });
  11463. this.element.children().not( this.panels ).each(function() {
  11464. maxHeight -= $( this ).outerHeight( true );
  11465. });
  11466. this.panels.each(function() {
  11467. $( this ).height( Math.max( 0, maxHeight -
  11468. $( this ).innerHeight() + $( this ).height() ) );
  11469. })
  11470. .css( "overflow", "auto" );
  11471. } else if ( heightStyle === "auto" ) {
  11472. maxHeight = 0;
  11473. this.panels.each(function() {
  11474. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  11475. }).height( maxHeight );
  11476. }
  11477. },
  11478. _eventHandler: function( event ) {
  11479. var options = this.options,
  11480. active = this.active,
  11481. anchor = $( event.currentTarget ),
  11482. tab = anchor.closest( "li" ),
  11483. clickedIsActive = tab[ 0 ] === active[ 0 ],
  11484. collapsing = clickedIsActive && options.collapsible,
  11485. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  11486. toHide = !active.length ? $() : this._getPanelForTab( active ),
  11487. eventData = {
  11488. oldTab: active,
  11489. oldPanel: toHide,
  11490. newTab: collapsing ? $() : tab,
  11491. newPanel: toShow
  11492. };
  11493. event.preventDefault();
  11494. if ( tab.hasClass( "ui-state-disabled" ) ||
  11495. // tab is already loading
  11496. tab.hasClass( "ui-tabs-loading" ) ||
  11497. // can't switch durning an animation
  11498. this.running ||
  11499. // click on active header, but not collapsible
  11500. ( clickedIsActive && !options.collapsible ) ||
  11501. // allow canceling activation
  11502. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  11503. return;
  11504. }
  11505. options.active = collapsing ? false : this.tabs.index( tab );
  11506. this.active = clickedIsActive ? $() : tab;
  11507. if ( this.xhr ) {
  11508. this.xhr.abort();
  11509. }
  11510. if ( !toHide.length && !toShow.length ) {
  11511. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  11512. }
  11513. if ( toShow.length ) {
  11514. this.load( this.tabs.index( tab ), event );
  11515. }
  11516. this._toggle( event, eventData );
  11517. },
  11518. // handles show/hide for selecting tabs
  11519. _toggle: function( event, eventData ) {
  11520. var that = this,
  11521. toShow = eventData.newPanel,
  11522. toHide = eventData.oldPanel;
  11523. this.running = true;
  11524. function complete() {
  11525. that.running = false;
  11526. that._trigger( "activate", event, eventData );
  11527. }
  11528. function show() {
  11529. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  11530. if ( toShow.length && that.options.show ) {
  11531. that._show( toShow, that.options.show, complete );
  11532. } else {
  11533. toShow.show();
  11534. complete();
  11535. }
  11536. }
  11537. // start out by hiding, then showing, then completing
  11538. if ( toHide.length && this.options.hide ) {
  11539. this._hide( toHide, this.options.hide, function() {
  11540. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  11541. show();
  11542. });
  11543. } else {
  11544. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  11545. toHide.hide();
  11546. show();
  11547. }
  11548. toHide.attr( "aria-hidden", "true" );
  11549. eventData.oldTab.attr({
  11550. "aria-selected": "false",
  11551. "aria-expanded": "false"
  11552. });
  11553. // If we're switching tabs, remove the old tab from the tab order.
  11554. // If we're opening from collapsed state, remove the previous tab from the tab order.
  11555. // If we're collapsing, then keep the collapsing tab in the tab order.
  11556. if ( toShow.length && toHide.length ) {
  11557. eventData.oldTab.attr( "tabIndex", -1 );
  11558. } else if ( toShow.length ) {
  11559. this.tabs.filter(function() {
  11560. return $( this ).attr( "tabIndex" ) === 0;
  11561. })
  11562. .attr( "tabIndex", -1 );
  11563. }
  11564. toShow.attr( "aria-hidden", "false" );
  11565. eventData.newTab.attr({
  11566. "aria-selected": "true",
  11567. "aria-expanded": "true",
  11568. tabIndex: 0
  11569. });
  11570. },
  11571. _activate: function( index ) {
  11572. var anchor,
  11573. active = this._findActive( index );
  11574. // trying to activate the already active panel
  11575. if ( active[ 0 ] === this.active[ 0 ] ) {
  11576. return;
  11577. }
  11578. // trying to collapse, simulate a click on the current active header
  11579. if ( !active.length ) {
  11580. active = this.active;
  11581. }
  11582. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  11583. this._eventHandler({
  11584. target: anchor,
  11585. currentTarget: anchor,
  11586. preventDefault: $.noop
  11587. });
  11588. },
  11589. _findActive: function( index ) {
  11590. return index === false ? $() : this.tabs.eq( index );
  11591. },
  11592. _getIndex: function( index ) {
  11593. // meta-function to give users option to provide a href string instead of a numerical index.
  11594. if ( typeof index === "string" ) {
  11595. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  11596. }
  11597. return index;
  11598. },
  11599. _destroy: function() {
  11600. if ( this.xhr ) {
  11601. this.xhr.abort();
  11602. }
  11603. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  11604. this.tablist
  11605. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  11606. .removeAttr( "role" );
  11607. this.anchors
  11608. .removeClass( "ui-tabs-anchor" )
  11609. .removeAttr( "role" )
  11610. .removeAttr( "tabIndex" )
  11611. .removeUniqueId();
  11612. this.tablist.unbind( this.eventNamespace );
  11613. this.tabs.add( this.panels ).each(function() {
  11614. if ( $.data( this, "ui-tabs-destroy" ) ) {
  11615. $( this ).remove();
  11616. } else {
  11617. $( this )
  11618. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  11619. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  11620. .removeAttr( "tabIndex" )
  11621. .removeAttr( "aria-live" )
  11622. .removeAttr( "aria-busy" )
  11623. .removeAttr( "aria-selected" )
  11624. .removeAttr( "aria-labelledby" )
  11625. .removeAttr( "aria-hidden" )
  11626. .removeAttr( "aria-expanded" )
  11627. .removeAttr( "role" );
  11628. }
  11629. });
  11630. this.tabs.each(function() {
  11631. var li = $( this ),
  11632. prev = li.data( "ui-tabs-aria-controls" );
  11633. if ( prev ) {
  11634. li
  11635. .attr( "aria-controls", prev )
  11636. .removeData( "ui-tabs-aria-controls" );
  11637. } else {
  11638. li.removeAttr( "aria-controls" );
  11639. }
  11640. });
  11641. this.panels.show();
  11642. if ( this.options.heightStyle !== "content" ) {
  11643. this.panels.css( "height", "" );
  11644. }
  11645. },
  11646. enable: function( index ) {
  11647. var disabled = this.options.disabled;
  11648. if ( disabled === false ) {
  11649. return;
  11650. }
  11651. if ( index === undefined ) {
  11652. disabled = false;
  11653. } else {
  11654. index = this._getIndex( index );
  11655. if ( $.isArray( disabled ) ) {
  11656. disabled = $.map( disabled, function( num ) {
  11657. return num !== index ? num : null;
  11658. });
  11659. } else {
  11660. disabled = $.map( this.tabs, function( li, num ) {
  11661. return num !== index ? num : null;
  11662. });
  11663. }
  11664. }
  11665. this._setupDisabled( disabled );
  11666. },
  11667. disable: function( index ) {
  11668. var disabled = this.options.disabled;
  11669. if ( disabled === true ) {
  11670. return;
  11671. }
  11672. if ( index === undefined ) {
  11673. disabled = true;
  11674. } else {
  11675. index = this._getIndex( index );
  11676. if ( $.inArray( index, disabled ) !== -1 ) {
  11677. return;
  11678. }
  11679. if ( $.isArray( disabled ) ) {
  11680. disabled = $.merge( [ index ], disabled ).sort();
  11681. } else {
  11682. disabled = [ index ];
  11683. }
  11684. }
  11685. this._setupDisabled( disabled );
  11686. },
  11687. load: function( index, event ) {
  11688. index = this._getIndex( index );
  11689. var that = this,
  11690. tab = this.tabs.eq( index ),
  11691. anchor = tab.find( ".ui-tabs-anchor" ),
  11692. panel = this._getPanelForTab( tab ),
  11693. eventData = {
  11694. tab: tab,
  11695. panel: panel
  11696. },
  11697. complete = function( jqXHR, status ) {
  11698. if ( status === "abort" ) {
  11699. that.panels.stop( false, true );
  11700. }
  11701. tab.removeClass( "ui-tabs-loading" );
  11702. panel.removeAttr( "aria-busy" );
  11703. if ( jqXHR === that.xhr ) {
  11704. delete that.xhr;
  11705. }
  11706. };
  11707. // not remote
  11708. if ( this._isLocal( anchor[ 0 ] ) ) {
  11709. return;
  11710. }
  11711. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  11712. // support: jQuery <1.8
  11713. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  11714. // but as of 1.8, $.ajax() always returns a jqXHR object.
  11715. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  11716. tab.addClass( "ui-tabs-loading" );
  11717. panel.attr( "aria-busy", "true" );
  11718. this.xhr
  11719. .done(function( response, status, jqXHR ) {
  11720. // support: jQuery <1.8
  11721. // http://bugs.jquery.com/ticket/11778
  11722. setTimeout(function() {
  11723. panel.html( response );
  11724. that._trigger( "load", event, eventData );
  11725. complete( jqXHR, status );
  11726. }, 1 );
  11727. })
  11728. .fail(function( jqXHR, status ) {
  11729. // support: jQuery <1.8
  11730. // http://bugs.jquery.com/ticket/11778
  11731. setTimeout(function() {
  11732. complete( jqXHR, status );
  11733. }, 1 );
  11734. });
  11735. }
  11736. },
  11737. _ajaxSettings: function( anchor, event, eventData ) {
  11738. var that = this;
  11739. return {
  11740. url: anchor.attr( "href" ),
  11741. beforeSend: function( jqXHR, settings ) {
  11742. return that._trigger( "beforeLoad", event,
  11743. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  11744. }
  11745. };
  11746. },
  11747. _getPanelForTab: function( tab ) {
  11748. var id = $( tab ).attr( "aria-controls" );
  11749. return this.element.find( this._sanitizeSelector( "#" + id ) );
  11750. }
  11751. });
  11752. /*!
  11753. * jQuery UI Effects 1.11.4
  11754. * http://jqueryui.com
  11755. *
  11756. * Copyright jQuery Foundation and other contributors
  11757. * Released under the MIT license.
  11758. * http://jquery.org/license
  11759. *
  11760. * http://api.jqueryui.com/category/effects-core/
  11761. */
  11762. var dataSpace = "ui-effects-",
  11763. // Create a local jQuery because jQuery Color relies on it and the
  11764. // global may not exist with AMD and a custom build (#10199)
  11765. jQuery = $;
  11766. $.effects = {
  11767. effect: {}
  11768. };
  11769. /*!
  11770. * jQuery Color Animations v2.1.2
  11771. * https://github.com/jquery/jquery-color
  11772. *
  11773. * Copyright 2014 jQuery Foundation and other contributors
  11774. * Released under the MIT license.
  11775. * http://jquery.org/license
  11776. *
  11777. * Date: Wed Jan 16 08:47:09 2013 -0600
  11778. */
  11779. (function( jQuery, undefined ) {
  11780. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  11781. // plusequals test for += 100 -= 100
  11782. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  11783. // a set of RE's that can match strings and generate color tuples.
  11784. stringParsers = [ {
  11785. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  11786. parse: function( execResult ) {
  11787. return [
  11788. execResult[ 1 ],
  11789. execResult[ 2 ],
  11790. execResult[ 3 ],
  11791. execResult[ 4 ]
  11792. ];
  11793. }
  11794. }, {
  11795. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  11796. parse: function( execResult ) {
  11797. return [
  11798. execResult[ 1 ] * 2.55,
  11799. execResult[ 2 ] * 2.55,
  11800. execResult[ 3 ] * 2.55,
  11801. execResult[ 4 ]
  11802. ];
  11803. }
  11804. }, {
  11805. // this regex ignores A-F because it's compared against an already lowercased string
  11806. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  11807. parse: function( execResult ) {
  11808. return [
  11809. parseInt( execResult[ 1 ], 16 ),
  11810. parseInt( execResult[ 2 ], 16 ),
  11811. parseInt( execResult[ 3 ], 16 )
  11812. ];
  11813. }
  11814. }, {
  11815. // this regex ignores A-F because it's compared against an already lowercased string
  11816. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  11817. parse: function( execResult ) {
  11818. return [
  11819. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  11820. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  11821. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  11822. ];
  11823. }
  11824. }, {
  11825. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  11826. space: "hsla",
  11827. parse: function( execResult ) {
  11828. return [
  11829. execResult[ 1 ],
  11830. execResult[ 2 ] / 100,
  11831. execResult[ 3 ] / 100,
  11832. execResult[ 4 ]
  11833. ];
  11834. }
  11835. } ],
  11836. // jQuery.Color( )
  11837. color = jQuery.Color = function( color, green, blue, alpha ) {
  11838. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  11839. },
  11840. spaces = {
  11841. rgba: {
  11842. props: {
  11843. red: {
  11844. idx: 0,
  11845. type: "byte"
  11846. },
  11847. green: {
  11848. idx: 1,
  11849. type: "byte"
  11850. },
  11851. blue: {
  11852. idx: 2,
  11853. type: "byte"
  11854. }
  11855. }
  11856. },
  11857. hsla: {
  11858. props: {
  11859. hue: {
  11860. idx: 0,
  11861. type: "degrees"
  11862. },
  11863. saturation: {
  11864. idx: 1,
  11865. type: "percent"
  11866. },
  11867. lightness: {
  11868. idx: 2,
  11869. type: "percent"
  11870. }
  11871. }
  11872. }
  11873. },
  11874. propTypes = {
  11875. "byte": {
  11876. floor: true,
  11877. max: 255
  11878. },
  11879. "percent": {
  11880. max: 1
  11881. },
  11882. "degrees": {
  11883. mod: 360,
  11884. floor: true
  11885. }
  11886. },
  11887. support = color.support = {},
  11888. // element for support tests
  11889. supportElem = jQuery( "<p>" )[ 0 ],
  11890. // colors = jQuery.Color.names
  11891. colors,
  11892. // local aliases of functions called often
  11893. each = jQuery.each;
  11894. // determine rgba support immediately
  11895. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  11896. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  11897. // define cache name and alpha properties
  11898. // for rgba and hsla spaces
  11899. each( spaces, function( spaceName, space ) {
  11900. space.cache = "_" + spaceName;
  11901. space.props.alpha = {
  11902. idx: 3,
  11903. type: "percent",
  11904. def: 1
  11905. };
  11906. });
  11907. function clamp( value, prop, allowEmpty ) {
  11908. var type = propTypes[ prop.type ] || {};
  11909. if ( value == null ) {
  11910. return (allowEmpty || !prop.def) ? null : prop.def;
  11911. }
  11912. // ~~ is an short way of doing floor for positive numbers
  11913. value = type.floor ? ~~value : parseFloat( value );
  11914. // IE will pass in empty strings as value for alpha,
  11915. // which will hit this case
  11916. if ( isNaN( value ) ) {
  11917. return prop.def;
  11918. }
  11919. if ( type.mod ) {
  11920. // we add mod before modding to make sure that negatives values
  11921. // get converted properly: -10 -> 350
  11922. return (value + type.mod) % type.mod;
  11923. }
  11924. // for now all property types without mod have min and max
  11925. return 0 > value ? 0 : type.max < value ? type.max : value;
  11926. }
  11927. function stringParse( string ) {
  11928. var inst = color(),
  11929. rgba = inst._rgba = [];
  11930. string = string.toLowerCase();
  11931. each( stringParsers, function( i, parser ) {
  11932. var parsed,
  11933. match = parser.re.exec( string ),
  11934. values = match && parser.parse( match ),
  11935. spaceName = parser.space || "rgba";
  11936. if ( values ) {
  11937. parsed = inst[ spaceName ]( values );
  11938. // if this was an rgba parse the assignment might happen twice
  11939. // oh well....
  11940. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  11941. rgba = inst._rgba = parsed._rgba;
  11942. // exit each( stringParsers ) here because we matched
  11943. return false;
  11944. }
  11945. });
  11946. // Found a stringParser that handled it
  11947. if ( rgba.length ) {
  11948. // if this came from a parsed string, force "transparent" when alpha is 0
  11949. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  11950. if ( rgba.join() === "0,0,0,0" ) {
  11951. jQuery.extend( rgba, colors.transparent );
  11952. }
  11953. return inst;
  11954. }
  11955. // named colors
  11956. return colors[ string ];
  11957. }
  11958. color.fn = jQuery.extend( color.prototype, {
  11959. parse: function( red, green, blue, alpha ) {
  11960. if ( red === undefined ) {
  11961. this._rgba = [ null, null, null, null ];
  11962. return this;
  11963. }
  11964. if ( red.jquery || red.nodeType ) {
  11965. red = jQuery( red ).css( green );
  11966. green = undefined;
  11967. }
  11968. var inst = this,
  11969. type = jQuery.type( red ),
  11970. rgba = this._rgba = [];
  11971. // more than 1 argument specified - assume ( red, green, blue, alpha )
  11972. if ( green !== undefined ) {
  11973. red = [ red, green, blue, alpha ];
  11974. type = "array";
  11975. }
  11976. if ( type === "string" ) {
  11977. return this.parse( stringParse( red ) || colors._default );
  11978. }
  11979. if ( type === "array" ) {
  11980. each( spaces.rgba.props, function( key, prop ) {
  11981. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  11982. });
  11983. return this;
  11984. }
  11985. if ( type === "object" ) {
  11986. if ( red instanceof color ) {
  11987. each( spaces, function( spaceName, space ) {
  11988. if ( red[ space.cache ] ) {
  11989. inst[ space.cache ] = red[ space.cache ].slice();
  11990. }
  11991. });
  11992. } else {
  11993. each( spaces, function( spaceName, space ) {
  11994. var cache = space.cache;
  11995. each( space.props, function( key, prop ) {
  11996. // if the cache doesn't exist, and we know how to convert
  11997. if ( !inst[ cache ] && space.to ) {
  11998. // if the value was null, we don't need to copy it
  11999. // if the key was alpha, we don't need to copy it either
  12000. if ( key === "alpha" || red[ key ] == null ) {
  12001. return;
  12002. }
  12003. inst[ cache ] = space.to( inst._rgba );
  12004. }
  12005. // this is the only case where we allow nulls for ALL properties.
  12006. // call clamp with alwaysAllowEmpty
  12007. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  12008. });
  12009. // everything defined but alpha?
  12010. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  12011. // use the default of 1
  12012. inst[ cache ][ 3 ] = 1;
  12013. if ( space.from ) {
  12014. inst._rgba = space.from( inst[ cache ] );
  12015. }
  12016. }
  12017. });
  12018. }
  12019. return this;
  12020. }
  12021. },
  12022. is: function( compare ) {
  12023. var is = color( compare ),
  12024. same = true,
  12025. inst = this;
  12026. each( spaces, function( _, space ) {
  12027. var localCache,
  12028. isCache = is[ space.cache ];
  12029. if (isCache) {
  12030. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  12031. each( space.props, function( _, prop ) {
  12032. if ( isCache[ prop.idx ] != null ) {
  12033. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  12034. return same;
  12035. }
  12036. });
  12037. }
  12038. return same;
  12039. });
  12040. return same;
  12041. },
  12042. _space: function() {
  12043. var used = [],
  12044. inst = this;
  12045. each( spaces, function( spaceName, space ) {
  12046. if ( inst[ space.cache ] ) {
  12047. used.push( spaceName );
  12048. }
  12049. });
  12050. return used.pop();
  12051. },
  12052. transition: function( other, distance ) {
  12053. var end = color( other ),
  12054. spaceName = end._space(),
  12055. space = spaces[ spaceName ],
  12056. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  12057. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  12058. result = start.slice();
  12059. end = end[ space.cache ];
  12060. each( space.props, function( key, prop ) {
  12061. var index = prop.idx,
  12062. startValue = start[ index ],
  12063. endValue = end[ index ],
  12064. type = propTypes[ prop.type ] || {};
  12065. // if null, don't override start value
  12066. if ( endValue === null ) {
  12067. return;
  12068. }
  12069. // if null - use end
  12070. if ( startValue === null ) {
  12071. result[ index ] = endValue;
  12072. } else {
  12073. if ( type.mod ) {
  12074. if ( endValue - startValue > type.mod / 2 ) {
  12075. startValue += type.mod;
  12076. } else if ( startValue - endValue > type.mod / 2 ) {
  12077. startValue -= type.mod;
  12078. }
  12079. }
  12080. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  12081. }
  12082. });
  12083. return this[ spaceName ]( result );
  12084. },
  12085. blend: function( opaque ) {
  12086. // if we are already opaque - return ourself
  12087. if ( this._rgba[ 3 ] === 1 ) {
  12088. return this;
  12089. }
  12090. var rgb = this._rgba.slice(),
  12091. a = rgb.pop(),
  12092. blend = color( opaque )._rgba;
  12093. return color( jQuery.map( rgb, function( v, i ) {
  12094. return ( 1 - a ) * blend[ i ] + a * v;
  12095. }));
  12096. },
  12097. toRgbaString: function() {
  12098. var prefix = "rgba(",
  12099. rgba = jQuery.map( this._rgba, function( v, i ) {
  12100. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  12101. });
  12102. if ( rgba[ 3 ] === 1 ) {
  12103. rgba.pop();
  12104. prefix = "rgb(";
  12105. }
  12106. return prefix + rgba.join() + ")";
  12107. },
  12108. toHslaString: function() {
  12109. var prefix = "hsla(",
  12110. hsla = jQuery.map( this.hsla(), function( v, i ) {
  12111. if ( v == null ) {
  12112. v = i > 2 ? 1 : 0;
  12113. }
  12114. // catch 1 and 2
  12115. if ( i && i < 3 ) {
  12116. v = Math.round( v * 100 ) + "%";
  12117. }
  12118. return v;
  12119. });
  12120. if ( hsla[ 3 ] === 1 ) {
  12121. hsla.pop();
  12122. prefix = "hsl(";
  12123. }
  12124. return prefix + hsla.join() + ")";
  12125. },
  12126. toHexString: function( includeAlpha ) {
  12127. var rgba = this._rgba.slice(),
  12128. alpha = rgba.pop();
  12129. if ( includeAlpha ) {
  12130. rgba.push( ~~( alpha * 255 ) );
  12131. }
  12132. return "#" + jQuery.map( rgba, function( v ) {
  12133. // default to 0 when nulls exist
  12134. v = ( v || 0 ).toString( 16 );
  12135. return v.length === 1 ? "0" + v : v;
  12136. }).join("");
  12137. },
  12138. toString: function() {
  12139. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  12140. }
  12141. });
  12142. color.fn.parse.prototype = color.fn;
  12143. // hsla conversions adapted from:
  12144. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  12145. function hue2rgb( p, q, h ) {
  12146. h = ( h + 1 ) % 1;
  12147. if ( h * 6 < 1 ) {
  12148. return p + ( q - p ) * h * 6;
  12149. }
  12150. if ( h * 2 < 1) {
  12151. return q;
  12152. }
  12153. if ( h * 3 < 2 ) {
  12154. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  12155. }
  12156. return p;
  12157. }
  12158. spaces.hsla.to = function( rgba ) {
  12159. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  12160. return [ null, null, null, rgba[ 3 ] ];
  12161. }
  12162. var r = rgba[ 0 ] / 255,
  12163. g = rgba[ 1 ] / 255,
  12164. b = rgba[ 2 ] / 255,
  12165. a = rgba[ 3 ],
  12166. max = Math.max( r, g, b ),
  12167. min = Math.min( r, g, b ),
  12168. diff = max - min,
  12169. add = max + min,
  12170. l = add * 0.5,
  12171. h, s;
  12172. if ( min === max ) {
  12173. h = 0;
  12174. } else if ( r === max ) {
  12175. h = ( 60 * ( g - b ) / diff ) + 360;
  12176. } else if ( g === max ) {
  12177. h = ( 60 * ( b - r ) / diff ) + 120;
  12178. } else {
  12179. h = ( 60 * ( r - g ) / diff ) + 240;
  12180. }
  12181. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  12182. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  12183. if ( diff === 0 ) {
  12184. s = 0;
  12185. } else if ( l <= 0.5 ) {
  12186. s = diff / add;
  12187. } else {
  12188. s = diff / ( 2 - add );
  12189. }
  12190. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  12191. };
  12192. spaces.hsla.from = function( hsla ) {
  12193. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  12194. return [ null, null, null, hsla[ 3 ] ];
  12195. }
  12196. var h = hsla[ 0 ] / 360,
  12197. s = hsla[ 1 ],
  12198. l = hsla[ 2 ],
  12199. a = hsla[ 3 ],
  12200. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  12201. p = 2 * l - q;
  12202. return [
  12203. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  12204. Math.round( hue2rgb( p, q, h ) * 255 ),
  12205. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  12206. a
  12207. ];
  12208. };
  12209. each( spaces, function( spaceName, space ) {
  12210. var props = space.props,
  12211. cache = space.cache,
  12212. to = space.to,
  12213. from = space.from;
  12214. // makes rgba() and hsla()
  12215. color.fn[ spaceName ] = function( value ) {
  12216. // generate a cache for this space if it doesn't exist
  12217. if ( to && !this[ cache ] ) {
  12218. this[ cache ] = to( this._rgba );
  12219. }
  12220. if ( value === undefined ) {
  12221. return this[ cache ].slice();
  12222. }
  12223. var ret,
  12224. type = jQuery.type( value ),
  12225. arr = ( type === "array" || type === "object" ) ? value : arguments,
  12226. local = this[ cache ].slice();
  12227. each( props, function( key, prop ) {
  12228. var val = arr[ type === "object" ? key : prop.idx ];
  12229. if ( val == null ) {
  12230. val = local[ prop.idx ];
  12231. }
  12232. local[ prop.idx ] = clamp( val, prop );
  12233. });
  12234. if ( from ) {
  12235. ret = color( from( local ) );
  12236. ret[ cache ] = local;
  12237. return ret;
  12238. } else {
  12239. return color( local );
  12240. }
  12241. };
  12242. // makes red() green() blue() alpha() hue() saturation() lightness()
  12243. each( props, function( key, prop ) {
  12244. // alpha is included in more than one space
  12245. if ( color.fn[ key ] ) {
  12246. return;
  12247. }
  12248. color.fn[ key ] = function( value ) {
  12249. var vtype = jQuery.type( value ),
  12250. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  12251. local = this[ fn ](),
  12252. cur = local[ prop.idx ],
  12253. match;
  12254. if ( vtype === "undefined" ) {
  12255. return cur;
  12256. }
  12257. if ( vtype === "function" ) {
  12258. value = value.call( this, cur );
  12259. vtype = jQuery.type( value );
  12260. }
  12261. if ( value == null && prop.empty ) {
  12262. return this;
  12263. }
  12264. if ( vtype === "string" ) {
  12265. match = rplusequals.exec( value );
  12266. if ( match ) {
  12267. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  12268. }
  12269. }
  12270. local[ prop.idx ] = value;
  12271. return this[ fn ]( local );
  12272. };
  12273. });
  12274. });
  12275. // add cssHook and .fx.step function for each named hook.
  12276. // accept a space separated string of properties
  12277. color.hook = function( hook ) {
  12278. var hooks = hook.split( " " );
  12279. each( hooks, function( i, hook ) {
  12280. jQuery.cssHooks[ hook ] = {
  12281. set: function( elem, value ) {
  12282. var parsed, curElem,
  12283. backgroundColor = "";
  12284. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  12285. value = color( parsed || value );
  12286. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  12287. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  12288. while (
  12289. (backgroundColor === "" || backgroundColor === "transparent") &&
  12290. curElem && curElem.style
  12291. ) {
  12292. try {
  12293. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  12294. curElem = curElem.parentNode;
  12295. } catch ( e ) {
  12296. }
  12297. }
  12298. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  12299. backgroundColor :
  12300. "_default" );
  12301. }
  12302. value = value.toRgbaString();
  12303. }
  12304. try {
  12305. elem.style[ hook ] = value;
  12306. } catch ( e ) {
  12307. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  12308. }
  12309. }
  12310. };
  12311. jQuery.fx.step[ hook ] = function( fx ) {
  12312. if ( !fx.colorInit ) {
  12313. fx.start = color( fx.elem, hook );
  12314. fx.end = color( fx.end );
  12315. fx.colorInit = true;
  12316. }
  12317. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  12318. };
  12319. });
  12320. };
  12321. color.hook( stepHooks );
  12322. jQuery.cssHooks.borderColor = {
  12323. expand: function( value ) {
  12324. var expanded = {};
  12325. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  12326. expanded[ "border" + part + "Color" ] = value;
  12327. });
  12328. return expanded;
  12329. }
  12330. };
  12331. // Basic color names only.
  12332. // Usage of any of the other color names requires adding yourself or including
  12333. // jquery.color.svg-names.js.
  12334. colors = jQuery.Color.names = {
  12335. // 4.1. Basic color keywords
  12336. aqua: "#00ffff",
  12337. black: "#000000",
  12338. blue: "#0000ff",
  12339. fuchsia: "#ff00ff",
  12340. gray: "#808080",
  12341. green: "#008000",
  12342. lime: "#00ff00",
  12343. maroon: "#800000",
  12344. navy: "#000080",
  12345. olive: "#808000",
  12346. purple: "#800080",
  12347. red: "#ff0000",
  12348. silver: "#c0c0c0",
  12349. teal: "#008080",
  12350. white: "#ffffff",
  12351. yellow: "#ffff00",
  12352. // 4.2.3. "transparent" color keyword
  12353. transparent: [ null, null, null, 0 ],
  12354. _default: "#ffffff"
  12355. };
  12356. })( jQuery );
  12357. /******************************************************************************/
  12358. /****************************** CLASS ANIMATIONS ******************************/
  12359. /******************************************************************************/
  12360. (function() {
  12361. var classAnimationActions = [ "add", "remove", "toggle" ],
  12362. shorthandStyles = {
  12363. border: 1,
  12364. borderBottom: 1,
  12365. borderColor: 1,
  12366. borderLeft: 1,
  12367. borderRight: 1,
  12368. borderTop: 1,
  12369. borderWidth: 1,
  12370. margin: 1,
  12371. padding: 1
  12372. };
  12373. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  12374. $.fx.step[ prop ] = function( fx ) {
  12375. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  12376. jQuery.style( fx.elem, prop, fx.end );
  12377. fx.setAttr = true;
  12378. }
  12379. };
  12380. });
  12381. function getElementStyles( elem ) {
  12382. var key, len,
  12383. style = elem.ownerDocument.defaultView ?
  12384. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  12385. elem.currentStyle,
  12386. styles = {};
  12387. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  12388. len = style.length;
  12389. while ( len-- ) {
  12390. key = style[ len ];
  12391. if ( typeof style[ key ] === "string" ) {
  12392. styles[ $.camelCase( key ) ] = style[ key ];
  12393. }
  12394. }
  12395. // support: Opera, IE <9
  12396. } else {
  12397. for ( key in style ) {
  12398. if ( typeof style[ key ] === "string" ) {
  12399. styles[ key ] = style[ key ];
  12400. }
  12401. }
  12402. }
  12403. return styles;
  12404. }
  12405. function styleDifference( oldStyle, newStyle ) {
  12406. var diff = {},
  12407. name, value;
  12408. for ( name in newStyle ) {
  12409. value = newStyle[ name ];
  12410. if ( oldStyle[ name ] !== value ) {
  12411. if ( !shorthandStyles[ name ] ) {
  12412. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  12413. diff[ name ] = value;
  12414. }
  12415. }
  12416. }
  12417. }
  12418. return diff;
  12419. }
  12420. // support: jQuery <1.8
  12421. if ( !$.fn.addBack ) {
  12422. $.fn.addBack = function( selector ) {
  12423. return this.add( selector == null ?
  12424. this.prevObject : this.prevObject.filter( selector )
  12425. );
  12426. };
  12427. }
  12428. $.effects.animateClass = function( value, duration, easing, callback ) {
  12429. var o = $.speed( duration, easing, callback );
  12430. return this.queue( function() {
  12431. var animated = $( this ),
  12432. baseClass = animated.attr( "class" ) || "",
  12433. applyClassChange,
  12434. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  12435. // map the animated objects to store the original styles.
  12436. allAnimations = allAnimations.map(function() {
  12437. var el = $( this );
  12438. return {
  12439. el: el,
  12440. start: getElementStyles( this )
  12441. };
  12442. });
  12443. // apply class change
  12444. applyClassChange = function() {
  12445. $.each( classAnimationActions, function(i, action) {
  12446. if ( value[ action ] ) {
  12447. animated[ action + "Class" ]( value[ action ] );
  12448. }
  12449. });
  12450. };
  12451. applyClassChange();
  12452. // map all animated objects again - calculate new styles and diff
  12453. allAnimations = allAnimations.map(function() {
  12454. this.end = getElementStyles( this.el[ 0 ] );
  12455. this.diff = styleDifference( this.start, this.end );
  12456. return this;
  12457. });
  12458. // apply original class
  12459. animated.attr( "class", baseClass );
  12460. // map all animated objects again - this time collecting a promise
  12461. allAnimations = allAnimations.map(function() {
  12462. var styleInfo = this,
  12463. dfd = $.Deferred(),
  12464. opts = $.extend({}, o, {
  12465. queue: false,
  12466. complete: function() {
  12467. dfd.resolve( styleInfo );
  12468. }
  12469. });
  12470. this.el.animate( this.diff, opts );
  12471. return dfd.promise();
  12472. });
  12473. // once all animations have completed:
  12474. $.when.apply( $, allAnimations.get() ).done(function() {
  12475. // set the final class
  12476. applyClassChange();
  12477. // for each animated element,
  12478. // clear all css properties that were animated
  12479. $.each( arguments, function() {
  12480. var el = this.el;
  12481. $.each( this.diff, function(key) {
  12482. el.css( key, "" );
  12483. });
  12484. });
  12485. // this is guarnteed to be there if you use jQuery.speed()
  12486. // it also handles dequeuing the next anim...
  12487. o.complete.call( animated[ 0 ] );
  12488. });
  12489. });
  12490. };
  12491. $.fn.extend({
  12492. addClass: (function( orig ) {
  12493. return function( classNames, speed, easing, callback ) {
  12494. return speed ?
  12495. $.effects.animateClass.call( this,
  12496. { add: classNames }, speed, easing, callback ) :
  12497. orig.apply( this, arguments );
  12498. };
  12499. })( $.fn.addClass ),
  12500. removeClass: (function( orig ) {
  12501. return function( classNames, speed, easing, callback ) {
  12502. return arguments.length > 1 ?
  12503. $.effects.animateClass.call( this,
  12504. { remove: classNames }, speed, easing, callback ) :
  12505. orig.apply( this, arguments );
  12506. };
  12507. })( $.fn.removeClass ),
  12508. toggleClass: (function( orig ) {
  12509. return function( classNames, force, speed, easing, callback ) {
  12510. if ( typeof force === "boolean" || force === undefined ) {
  12511. if ( !speed ) {
  12512. // without speed parameter
  12513. return orig.apply( this, arguments );
  12514. } else {
  12515. return $.effects.animateClass.call( this,
  12516. (force ? { add: classNames } : { remove: classNames }),
  12517. speed, easing, callback );
  12518. }
  12519. } else {
  12520. // without force parameter
  12521. return $.effects.animateClass.call( this,
  12522. { toggle: classNames }, force, speed, easing );
  12523. }
  12524. };
  12525. })( $.fn.toggleClass ),
  12526. switchClass: function( remove, add, speed, easing, callback) {
  12527. return $.effects.animateClass.call( this, {
  12528. add: add,
  12529. remove: remove
  12530. }, speed, easing, callback );
  12531. }
  12532. });
  12533. })();
  12534. /******************************************************************************/
  12535. /*********************************** EFFECTS **********************************/
  12536. /******************************************************************************/
  12537. (function() {
  12538. $.extend( $.effects, {
  12539. version: "1.11.4",
  12540. // Saves a set of properties in a data storage
  12541. save: function( element, set ) {
  12542. for ( var i = 0; i < set.length; i++ ) {
  12543. if ( set[ i ] !== null ) {
  12544. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  12545. }
  12546. }
  12547. },
  12548. // Restores a set of previously saved properties from a data storage
  12549. restore: function( element, set ) {
  12550. var val, i;
  12551. for ( i = 0; i < set.length; i++ ) {
  12552. if ( set[ i ] !== null ) {
  12553. val = element.data( dataSpace + set[ i ] );
  12554. // support: jQuery 1.6.2
  12555. // http://bugs.jquery.com/ticket/9917
  12556. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  12557. // We can't differentiate between "" and 0 here, so we just assume
  12558. // empty string since it's likely to be a more common value...
  12559. if ( val === undefined ) {
  12560. val = "";
  12561. }
  12562. element.css( set[ i ], val );
  12563. }
  12564. }
  12565. },
  12566. setMode: function( el, mode ) {
  12567. if (mode === "toggle") {
  12568. mode = el.is( ":hidden" ) ? "show" : "hide";
  12569. }
  12570. return mode;
  12571. },
  12572. // Translates a [top,left] array into a baseline value
  12573. // this should be a little more flexible in the future to handle a string & hash
  12574. getBaseline: function( origin, original ) {
  12575. var y, x;
  12576. switch ( origin[ 0 ] ) {
  12577. case "top": y = 0; break;
  12578. case "middle": y = 0.5; break;
  12579. case "bottom": y = 1; break;
  12580. default: y = origin[ 0 ] / original.height;
  12581. }
  12582. switch ( origin[ 1 ] ) {
  12583. case "left": x = 0; break;
  12584. case "center": x = 0.5; break;
  12585. case "right": x = 1; break;
  12586. default: x = origin[ 1 ] / original.width;
  12587. }
  12588. return {
  12589. x: x,
  12590. y: y
  12591. };
  12592. },
  12593. // Wraps the element around a wrapper that copies position properties
  12594. createWrapper: function( element ) {
  12595. // if the element is already wrapped, return it
  12596. if ( element.parent().is( ".ui-effects-wrapper" )) {
  12597. return element.parent();
  12598. }
  12599. // wrap the element
  12600. var props = {
  12601. width: element.outerWidth(true),
  12602. height: element.outerHeight(true),
  12603. "float": element.css( "float" )
  12604. },
  12605. wrapper = $( "<div></div>" )
  12606. .addClass( "ui-effects-wrapper" )
  12607. .css({
  12608. fontSize: "100%",
  12609. background: "transparent",
  12610. border: "none",
  12611. margin: 0,
  12612. padding: 0
  12613. }),
  12614. // Store the size in case width/height are defined in % - Fixes #5245
  12615. size = {
  12616. width: element.width(),
  12617. height: element.height()
  12618. },
  12619. active = document.activeElement;
  12620. // support: Firefox
  12621. // Firefox incorrectly exposes anonymous content
  12622. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  12623. try {
  12624. active.id;
  12625. } catch ( e ) {
  12626. active = document.body;
  12627. }
  12628. element.wrap( wrapper );
  12629. // Fixes #7595 - Elements lose focus when wrapped.
  12630. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  12631. $( active ).focus();
  12632. }
  12633. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  12634. // transfer positioning properties to the wrapper
  12635. if ( element.css( "position" ) === "static" ) {
  12636. wrapper.css({ position: "relative" });
  12637. element.css({ position: "relative" });
  12638. } else {
  12639. $.extend( props, {
  12640. position: element.css( "position" ),
  12641. zIndex: element.css( "z-index" )
  12642. });
  12643. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  12644. props[ pos ] = element.css( pos );
  12645. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  12646. props[ pos ] = "auto";
  12647. }
  12648. });
  12649. element.css({
  12650. position: "relative",
  12651. top: 0,
  12652. left: 0,
  12653. right: "auto",
  12654. bottom: "auto"
  12655. });
  12656. }
  12657. element.css(size);
  12658. return wrapper.css( props ).show();
  12659. },
  12660. removeWrapper: function( element ) {
  12661. var active = document.activeElement;
  12662. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  12663. element.parent().replaceWith( element );
  12664. // Fixes #7595 - Elements lose focus when wrapped.
  12665. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  12666. $( active ).focus();
  12667. }
  12668. }
  12669. return element;
  12670. },
  12671. setTransition: function( element, list, factor, value ) {
  12672. value = value || {};
  12673. $.each( list, function( i, x ) {
  12674. var unit = element.cssUnit( x );
  12675. if ( unit[ 0 ] > 0 ) {
  12676. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  12677. }
  12678. });
  12679. return value;
  12680. }
  12681. });
  12682. // return an effect options object for the given parameters:
  12683. function _normalizeArguments( effect, options, speed, callback ) {
  12684. // allow passing all options as the first parameter
  12685. if ( $.isPlainObject( effect ) ) {
  12686. options = effect;
  12687. effect = effect.effect;
  12688. }
  12689. // convert to an object
  12690. effect = { effect: effect };
  12691. // catch (effect, null, ...)
  12692. if ( options == null ) {
  12693. options = {};
  12694. }
  12695. // catch (effect, callback)
  12696. if ( $.isFunction( options ) ) {
  12697. callback = options;
  12698. speed = null;
  12699. options = {};
  12700. }
  12701. // catch (effect, speed, ?)
  12702. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  12703. callback = speed;
  12704. speed = options;
  12705. options = {};
  12706. }
  12707. // catch (effect, options, callback)
  12708. if ( $.isFunction( speed ) ) {
  12709. callback = speed;
  12710. speed = null;
  12711. }
  12712. // add options to effect
  12713. if ( options ) {
  12714. $.extend( effect, options );
  12715. }
  12716. speed = speed || options.duration;
  12717. effect.duration = $.fx.off ? 0 :
  12718. typeof speed === "number" ? speed :
  12719. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  12720. $.fx.speeds._default;
  12721. effect.complete = callback || options.complete;
  12722. return effect;
  12723. }
  12724. function standardAnimationOption( option ) {
  12725. // Valid standard speeds (nothing, number, named speed)
  12726. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  12727. return true;
  12728. }
  12729. // Invalid strings - treat as "normal" speed
  12730. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  12731. return true;
  12732. }
  12733. // Complete callback
  12734. if ( $.isFunction( option ) ) {
  12735. return true;
  12736. }
  12737. // Options hash (but not naming an effect)
  12738. if ( typeof option === "object" && !option.effect ) {
  12739. return true;
  12740. }
  12741. // Didn't match any standard API
  12742. return false;
  12743. }
  12744. $.fn.extend({
  12745. effect: function( /* effect, options, speed, callback */ ) {
  12746. var args = _normalizeArguments.apply( this, arguments ),
  12747. mode = args.mode,
  12748. queue = args.queue,
  12749. effectMethod = $.effects.effect[ args.effect ];
  12750. if ( $.fx.off || !effectMethod ) {
  12751. // delegate to the original method (e.g., .show()) if possible
  12752. if ( mode ) {
  12753. return this[ mode ]( args.duration, args.complete );
  12754. } else {
  12755. return this.each( function() {
  12756. if ( args.complete ) {
  12757. args.complete.call( this );
  12758. }
  12759. });
  12760. }
  12761. }
  12762. function run( next ) {
  12763. var elem = $( this ),
  12764. complete = args.complete,
  12765. mode = args.mode;
  12766. function done() {
  12767. if ( $.isFunction( complete ) ) {
  12768. complete.call( elem[0] );
  12769. }
  12770. if ( $.isFunction( next ) ) {
  12771. next();
  12772. }
  12773. }
  12774. // If the element already has the correct final state, delegate to
  12775. // the core methods so the internal tracking of "olddisplay" works.
  12776. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  12777. elem[ mode ]();
  12778. done();
  12779. } else {
  12780. effectMethod.call( elem[0], args, done );
  12781. }
  12782. }
  12783. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  12784. },
  12785. show: (function( orig ) {
  12786. return function( option ) {
  12787. if ( standardAnimationOption( option ) ) {
  12788. return orig.apply( this, arguments );
  12789. } else {
  12790. var args = _normalizeArguments.apply( this, arguments );
  12791. args.mode = "show";
  12792. return this.effect.call( this, args );
  12793. }
  12794. };
  12795. })( $.fn.show ),
  12796. hide: (function( orig ) {
  12797. return function( option ) {
  12798. if ( standardAnimationOption( option ) ) {
  12799. return orig.apply( this, arguments );
  12800. } else {
  12801. var args = _normalizeArguments.apply( this, arguments );
  12802. args.mode = "hide";
  12803. return this.effect.call( this, args );
  12804. }
  12805. };
  12806. })( $.fn.hide ),
  12807. toggle: (function( orig ) {
  12808. return function( option ) {
  12809. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  12810. return orig.apply( this, arguments );
  12811. } else {
  12812. var args = _normalizeArguments.apply( this, arguments );
  12813. args.mode = "toggle";
  12814. return this.effect.call( this, args );
  12815. }
  12816. };
  12817. })( $.fn.toggle ),
  12818. // helper functions
  12819. cssUnit: function(key) {
  12820. var style = this.css( key ),
  12821. val = [];
  12822. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  12823. if ( style.indexOf( unit ) > 0 ) {
  12824. val = [ parseFloat( style ), unit ];
  12825. }
  12826. });
  12827. return val;
  12828. }
  12829. });
  12830. })();
  12831. /******************************************************************************/
  12832. /*********************************** EASING ***********************************/
  12833. /******************************************************************************/
  12834. (function() {
  12835. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  12836. var baseEasings = {};
  12837. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  12838. baseEasings[ name ] = function( p ) {
  12839. return Math.pow( p, i + 2 );
  12840. };
  12841. });
  12842. $.extend( baseEasings, {
  12843. Sine: function( p ) {
  12844. return 1 - Math.cos( p * Math.PI / 2 );
  12845. },
  12846. Circ: function( p ) {
  12847. return 1 - Math.sqrt( 1 - p * p );
  12848. },
  12849. Elastic: function( p ) {
  12850. return p === 0 || p === 1 ? p :
  12851. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  12852. },
  12853. Back: function( p ) {
  12854. return p * p * ( 3 * p - 2 );
  12855. },
  12856. Bounce: function( p ) {
  12857. var pow2,
  12858. bounce = 4;
  12859. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  12860. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  12861. }
  12862. });
  12863. $.each( baseEasings, function( name, easeIn ) {
  12864. $.easing[ "easeIn" + name ] = easeIn;
  12865. $.easing[ "easeOut" + name ] = function( p ) {
  12866. return 1 - easeIn( 1 - p );
  12867. };
  12868. $.easing[ "easeInOut" + name ] = function( p ) {
  12869. return p < 0.5 ?
  12870. easeIn( p * 2 ) / 2 :
  12871. 1 - easeIn( p * -2 + 2 ) / 2;
  12872. };
  12873. });
  12874. })();
  12875. var effect = $.effects;
  12876. /*!
  12877. * jQuery UI Effects Blind 1.11.4
  12878. * http://jqueryui.com
  12879. *
  12880. * Copyright jQuery Foundation and other contributors
  12881. * Released under the MIT license.
  12882. * http://jquery.org/license
  12883. *
  12884. * http://api.jqueryui.com/blind-effect/
  12885. */
  12886. var effectBlind = $.effects.effect.blind = function( o, done ) {
  12887. // Create element
  12888. var el = $( this ),
  12889. rvertical = /up|down|vertical/,
  12890. rpositivemotion = /up|left|vertical|horizontal/,
  12891. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12892. mode = $.effects.setMode( el, o.mode || "hide" ),
  12893. direction = o.direction || "up",
  12894. vertical = rvertical.test( direction ),
  12895. ref = vertical ? "height" : "width",
  12896. ref2 = vertical ? "top" : "left",
  12897. motion = rpositivemotion.test( direction ),
  12898. animation = {},
  12899. show = mode === "show",
  12900. wrapper, distance, margin;
  12901. // if already wrapped, the wrapper's properties are my property. #6245
  12902. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  12903. $.effects.save( el.parent(), props );
  12904. } else {
  12905. $.effects.save( el, props );
  12906. }
  12907. el.show();
  12908. wrapper = $.effects.createWrapper( el ).css({
  12909. overflow: "hidden"
  12910. });
  12911. distance = wrapper[ ref ]();
  12912. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  12913. animation[ ref ] = show ? distance : 0;
  12914. if ( !motion ) {
  12915. el
  12916. .css( vertical ? "bottom" : "right", 0 )
  12917. .css( vertical ? "top" : "left", "auto" )
  12918. .css({ position: "absolute" });
  12919. animation[ ref2 ] = show ? margin : distance + margin;
  12920. }
  12921. // start at 0 if we are showing
  12922. if ( show ) {
  12923. wrapper.css( ref, 0 );
  12924. if ( !motion ) {
  12925. wrapper.css( ref2, margin + distance );
  12926. }
  12927. }
  12928. // Animate
  12929. wrapper.animate( animation, {
  12930. duration: o.duration,
  12931. easing: o.easing,
  12932. queue: false,
  12933. complete: function() {
  12934. if ( mode === "hide" ) {
  12935. el.hide();
  12936. }
  12937. $.effects.restore( el, props );
  12938. $.effects.removeWrapper( el );
  12939. done();
  12940. }
  12941. });
  12942. };
  12943. /*!
  12944. * jQuery UI Effects Bounce 1.11.4
  12945. * http://jqueryui.com
  12946. *
  12947. * Copyright jQuery Foundation and other contributors
  12948. * Released under the MIT license.
  12949. * http://jquery.org/license
  12950. *
  12951. * http://api.jqueryui.com/bounce-effect/
  12952. */
  12953. var effectBounce = $.effects.effect.bounce = function( o, done ) {
  12954. var el = $( this ),
  12955. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12956. // defaults:
  12957. mode = $.effects.setMode( el, o.mode || "effect" ),
  12958. hide = mode === "hide",
  12959. show = mode === "show",
  12960. direction = o.direction || "up",
  12961. distance = o.distance,
  12962. times = o.times || 5,
  12963. // number of internal animations
  12964. anims = times * 2 + ( show || hide ? 1 : 0 ),
  12965. speed = o.duration / anims,
  12966. easing = o.easing,
  12967. // utility:
  12968. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  12969. motion = ( direction === "up" || direction === "left" ),
  12970. i,
  12971. upAnim,
  12972. downAnim,
  12973. // we will need to re-assemble the queue to stack our animations in place
  12974. queue = el.queue(),
  12975. queuelen = queue.length;
  12976. // Avoid touching opacity to prevent clearType and PNG issues in IE
  12977. if ( show || hide ) {
  12978. props.push( "opacity" );
  12979. }
  12980. $.effects.save( el, props );
  12981. el.show();
  12982. $.effects.createWrapper( el ); // Create Wrapper
  12983. // default distance for the BIGGEST bounce is the outer Distance / 3
  12984. if ( !distance ) {
  12985. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  12986. }
  12987. if ( show ) {
  12988. downAnim = { opacity: 1 };
  12989. downAnim[ ref ] = 0;
  12990. // if we are showing, force opacity 0 and set the initial position
  12991. // then do the "first" animation
  12992. el.css( "opacity", 0 )
  12993. .css( ref, motion ? -distance * 2 : distance * 2 )
  12994. .animate( downAnim, speed, easing );
  12995. }
  12996. // start at the smallest distance if we are hiding
  12997. if ( hide ) {
  12998. distance = distance / Math.pow( 2, times - 1 );
  12999. }
  13000. downAnim = {};
  13001. downAnim[ ref ] = 0;
  13002. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  13003. for ( i = 0; i < times; i++ ) {
  13004. upAnim = {};
  13005. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  13006. el.animate( upAnim, speed, easing )
  13007. .animate( downAnim, speed, easing );
  13008. distance = hide ? distance * 2 : distance / 2;
  13009. }
  13010. // Last Bounce when Hiding
  13011. if ( hide ) {
  13012. upAnim = { opacity: 0 };
  13013. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  13014. el.animate( upAnim, speed, easing );
  13015. }
  13016. el.queue(function() {
  13017. if ( hide ) {
  13018. el.hide();
  13019. }
  13020. $.effects.restore( el, props );
  13021. $.effects.removeWrapper( el );
  13022. done();
  13023. });
  13024. // inject all the animations we just queued to be first in line (after "inprogress")
  13025. if ( queuelen > 1) {
  13026. queue.splice.apply( queue,
  13027. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  13028. }
  13029. el.dequeue();
  13030. };
  13031. /*!
  13032. * jQuery UI Effects Clip 1.11.4
  13033. * http://jqueryui.com
  13034. *
  13035. * Copyright jQuery Foundation and other contributors
  13036. * Released under the MIT license.
  13037. * http://jquery.org/license
  13038. *
  13039. * http://api.jqueryui.com/clip-effect/
  13040. */
  13041. var effectClip = $.effects.effect.clip = function( o, done ) {
  13042. // Create element
  13043. var el = $( this ),
  13044. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13045. mode = $.effects.setMode( el, o.mode || "hide" ),
  13046. show = mode === "show",
  13047. direction = o.direction || "vertical",
  13048. vert = direction === "vertical",
  13049. size = vert ? "height" : "width",
  13050. position = vert ? "top" : "left",
  13051. animation = {},
  13052. wrapper, animate, distance;
  13053. // Save & Show
  13054. $.effects.save( el, props );
  13055. el.show();
  13056. // Create Wrapper
  13057. wrapper = $.effects.createWrapper( el ).css({
  13058. overflow: "hidden"
  13059. });
  13060. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  13061. distance = animate[ size ]();
  13062. // Shift
  13063. if ( show ) {
  13064. animate.css( size, 0 );
  13065. animate.css( position, distance / 2 );
  13066. }
  13067. // Create Animation Object:
  13068. animation[ size ] = show ? distance : 0;
  13069. animation[ position ] = show ? 0 : distance / 2;
  13070. // Animate
  13071. animate.animate( animation, {
  13072. queue: false,
  13073. duration: o.duration,
  13074. easing: o.easing,
  13075. complete: function() {
  13076. if ( !show ) {
  13077. el.hide();
  13078. }
  13079. $.effects.restore( el, props );
  13080. $.effects.removeWrapper( el );
  13081. done();
  13082. }
  13083. });
  13084. };
  13085. /*!
  13086. * jQuery UI Effects Drop 1.11.4
  13087. * http://jqueryui.com
  13088. *
  13089. * Copyright jQuery Foundation and other contributors
  13090. * Released under the MIT license.
  13091. * http://jquery.org/license
  13092. *
  13093. * http://api.jqueryui.com/drop-effect/
  13094. */
  13095. var effectDrop = $.effects.effect.drop = function( o, done ) {
  13096. var el = $( this ),
  13097. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  13098. mode = $.effects.setMode( el, o.mode || "hide" ),
  13099. show = mode === "show",
  13100. direction = o.direction || "left",
  13101. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  13102. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  13103. animation = {
  13104. opacity: show ? 1 : 0
  13105. },
  13106. distance;
  13107. // Adjust
  13108. $.effects.save( el, props );
  13109. el.show();
  13110. $.effects.createWrapper( el );
  13111. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  13112. if ( show ) {
  13113. el
  13114. .css( "opacity", 0 )
  13115. .css( ref, motion === "pos" ? -distance : distance );
  13116. }
  13117. // Animation
  13118. animation[ ref ] = ( show ?
  13119. ( motion === "pos" ? "+=" : "-=" ) :
  13120. ( motion === "pos" ? "-=" : "+=" ) ) +
  13121. distance;
  13122. // Animate
  13123. el.animate( animation, {
  13124. queue: false,
  13125. duration: o.duration,
  13126. easing: o.easing,
  13127. complete: function() {
  13128. if ( mode === "hide" ) {
  13129. el.hide();
  13130. }
  13131. $.effects.restore( el, props );
  13132. $.effects.removeWrapper( el );
  13133. done();
  13134. }
  13135. });
  13136. };
  13137. /*!
  13138. * jQuery UI Effects Explode 1.11.4
  13139. * http://jqueryui.com
  13140. *
  13141. * Copyright jQuery Foundation and other contributors
  13142. * Released under the MIT license.
  13143. * http://jquery.org/license
  13144. *
  13145. * http://api.jqueryui.com/explode-effect/
  13146. */
  13147. var effectExplode = $.effects.effect.explode = function( o, done ) {
  13148. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  13149. cells = rows,
  13150. el = $( this ),
  13151. mode = $.effects.setMode( el, o.mode || "hide" ),
  13152. show = mode === "show",
  13153. // show and then visibility:hidden the element before calculating offset
  13154. offset = el.show().css( "visibility", "hidden" ).offset(),
  13155. // width and height of a piece
  13156. width = Math.ceil( el.outerWidth() / cells ),
  13157. height = Math.ceil( el.outerHeight() / rows ),
  13158. pieces = [],
  13159. // loop
  13160. i, j, left, top, mx, my;
  13161. // children animate complete:
  13162. function childComplete() {
  13163. pieces.push( this );
  13164. if ( pieces.length === rows * cells ) {
  13165. animComplete();
  13166. }
  13167. }
  13168. // clone the element for each row and cell.
  13169. for ( i = 0; i < rows ; i++ ) { // ===>
  13170. top = offset.top + i * height;
  13171. my = i - ( rows - 1 ) / 2 ;
  13172. for ( j = 0; j < cells ; j++ ) { // |||
  13173. left = offset.left + j * width;
  13174. mx = j - ( cells - 1 ) / 2 ;
  13175. // Create a clone of the now hidden main element that will be absolute positioned
  13176. // within a wrapper div off the -left and -top equal to size of our pieces
  13177. el
  13178. .clone()
  13179. .appendTo( "body" )
  13180. .wrap( "<div></div>" )
  13181. .css({
  13182. position: "absolute",
  13183. visibility: "visible",
  13184. left: -j * width,
  13185. top: -i * height
  13186. })
  13187. // select the wrapper - make it overflow: hidden and absolute positioned based on
  13188. // where the original was located +left and +top equal to the size of pieces
  13189. .parent()
  13190. .addClass( "ui-effects-explode" )
  13191. .css({
  13192. position: "absolute",
  13193. overflow: "hidden",
  13194. width: width,
  13195. height: height,
  13196. left: left + ( show ? mx * width : 0 ),
  13197. top: top + ( show ? my * height : 0 ),
  13198. opacity: show ? 0 : 1
  13199. }).animate({
  13200. left: left + ( show ? 0 : mx * width ),
  13201. top: top + ( show ? 0 : my * height ),
  13202. opacity: show ? 1 : 0
  13203. }, o.duration || 500, o.easing, childComplete );
  13204. }
  13205. }
  13206. function animComplete() {
  13207. el.css({
  13208. visibility: "visible"
  13209. });
  13210. $( pieces ).remove();
  13211. if ( !show ) {
  13212. el.hide();
  13213. }
  13214. done();
  13215. }
  13216. };
  13217. /*!
  13218. * jQuery UI Effects Fade 1.11.4
  13219. * http://jqueryui.com
  13220. *
  13221. * Copyright jQuery Foundation and other contributors
  13222. * Released under the MIT license.
  13223. * http://jquery.org/license
  13224. *
  13225. * http://api.jqueryui.com/fade-effect/
  13226. */
  13227. var effectFade = $.effects.effect.fade = function( o, done ) {
  13228. var el = $( this ),
  13229. mode = $.effects.setMode( el, o.mode || "toggle" );
  13230. el.animate({
  13231. opacity: mode
  13232. }, {
  13233. queue: false,
  13234. duration: o.duration,
  13235. easing: o.easing,
  13236. complete: done
  13237. });
  13238. };
  13239. /*!
  13240. * jQuery UI Effects Fold 1.11.4
  13241. * http://jqueryui.com
  13242. *
  13243. * Copyright jQuery Foundation and other contributors
  13244. * Released under the MIT license.
  13245. * http://jquery.org/license
  13246. *
  13247. * http://api.jqueryui.com/fold-effect/
  13248. */
  13249. var effectFold = $.effects.effect.fold = function( o, done ) {
  13250. // Create element
  13251. var el = $( this ),
  13252. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13253. mode = $.effects.setMode( el, o.mode || "hide" ),
  13254. show = mode === "show",
  13255. hide = mode === "hide",
  13256. size = o.size || 15,
  13257. percent = /([0-9]+)%/.exec( size ),
  13258. horizFirst = !!o.horizFirst,
  13259. widthFirst = show !== horizFirst,
  13260. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  13261. duration = o.duration / 2,
  13262. wrapper, distance,
  13263. animation1 = {},
  13264. animation2 = {};
  13265. $.effects.save( el, props );
  13266. el.show();
  13267. // Create Wrapper
  13268. wrapper = $.effects.createWrapper( el ).css({
  13269. overflow: "hidden"
  13270. });
  13271. distance = widthFirst ?
  13272. [ wrapper.width(), wrapper.height() ] :
  13273. [ wrapper.height(), wrapper.width() ];
  13274. if ( percent ) {
  13275. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  13276. }
  13277. if ( show ) {
  13278. wrapper.css( horizFirst ? {
  13279. height: 0,
  13280. width: size
  13281. } : {
  13282. height: size,
  13283. width: 0
  13284. });
  13285. }
  13286. // Animation
  13287. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  13288. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  13289. // Animate
  13290. wrapper
  13291. .animate( animation1, duration, o.easing )
  13292. .animate( animation2, duration, o.easing, function() {
  13293. if ( hide ) {
  13294. el.hide();
  13295. }
  13296. $.effects.restore( el, props );
  13297. $.effects.removeWrapper( el );
  13298. done();
  13299. });
  13300. };
  13301. /*!
  13302. * jQuery UI Effects Highlight 1.11.4
  13303. * http://jqueryui.com
  13304. *
  13305. * Copyright jQuery Foundation and other contributors
  13306. * Released under the MIT license.
  13307. * http://jquery.org/license
  13308. *
  13309. * http://api.jqueryui.com/highlight-effect/
  13310. */
  13311. var effectHighlight = $.effects.effect.highlight = function( o, done ) {
  13312. var elem = $( this ),
  13313. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  13314. mode = $.effects.setMode( elem, o.mode || "show" ),
  13315. animation = {
  13316. backgroundColor: elem.css( "backgroundColor" )
  13317. };
  13318. if (mode === "hide") {
  13319. animation.opacity = 0;
  13320. }
  13321. $.effects.save( elem, props );
  13322. elem
  13323. .show()
  13324. .css({
  13325. backgroundImage: "none",
  13326. backgroundColor: o.color || "#ffff99"
  13327. })
  13328. .animate( animation, {
  13329. queue: false,
  13330. duration: o.duration,
  13331. easing: o.easing,
  13332. complete: function() {
  13333. if ( mode === "hide" ) {
  13334. elem.hide();
  13335. }
  13336. $.effects.restore( elem, props );
  13337. done();
  13338. }
  13339. });
  13340. };
  13341. /*!
  13342. * jQuery UI Effects Size 1.11.4
  13343. * http://jqueryui.com
  13344. *
  13345. * Copyright jQuery Foundation and other contributors
  13346. * Released under the MIT license.
  13347. * http://jquery.org/license
  13348. *
  13349. * http://api.jqueryui.com/size-effect/
  13350. */
  13351. var effectSize = $.effects.effect.size = function( o, done ) {
  13352. // Create element
  13353. var original, baseline, factor,
  13354. el = $( this ),
  13355. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  13356. // Always restore
  13357. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  13358. // Copy for children
  13359. props2 = [ "width", "height", "overflow" ],
  13360. cProps = [ "fontSize" ],
  13361. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  13362. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  13363. // Set options
  13364. mode = $.effects.setMode( el, o.mode || "effect" ),
  13365. restore = o.restore || mode !== "effect",
  13366. scale = o.scale || "both",
  13367. origin = o.origin || [ "middle", "center" ],
  13368. position = el.css( "position" ),
  13369. props = restore ? props0 : props1,
  13370. zero = {
  13371. height: 0,
  13372. width: 0,
  13373. outerHeight: 0,
  13374. outerWidth: 0
  13375. };
  13376. if ( mode === "show" ) {
  13377. el.show();
  13378. }
  13379. original = {
  13380. height: el.height(),
  13381. width: el.width(),
  13382. outerHeight: el.outerHeight(),
  13383. outerWidth: el.outerWidth()
  13384. };
  13385. if ( o.mode === "toggle" && mode === "show" ) {
  13386. el.from = o.to || zero;
  13387. el.to = o.from || original;
  13388. } else {
  13389. el.from = o.from || ( mode === "show" ? zero : original );
  13390. el.to = o.to || ( mode === "hide" ? zero : original );
  13391. }
  13392. // Set scaling factor
  13393. factor = {
  13394. from: {
  13395. y: el.from.height / original.height,
  13396. x: el.from.width / original.width
  13397. },
  13398. to: {
  13399. y: el.to.height / original.height,
  13400. x: el.to.width / original.width
  13401. }
  13402. };
  13403. // Scale the css box
  13404. if ( scale === "box" || scale === "both" ) {
  13405. // Vertical props scaling
  13406. if ( factor.from.y !== factor.to.y ) {
  13407. props = props.concat( vProps );
  13408. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  13409. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  13410. }
  13411. // Horizontal props scaling
  13412. if ( factor.from.x !== factor.to.x ) {
  13413. props = props.concat( hProps );
  13414. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  13415. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  13416. }
  13417. }
  13418. // Scale the content
  13419. if ( scale === "content" || scale === "both" ) {
  13420. // Vertical props scaling
  13421. if ( factor.from.y !== factor.to.y ) {
  13422. props = props.concat( cProps ).concat( props2 );
  13423. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  13424. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  13425. }
  13426. }
  13427. $.effects.save( el, props );
  13428. el.show();
  13429. $.effects.createWrapper( el );
  13430. el.css( "overflow", "hidden" ).css( el.from );
  13431. // Adjust
  13432. if (origin) { // Calculate baseline shifts
  13433. baseline = $.effects.getBaseline( origin, original );
  13434. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  13435. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  13436. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  13437. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  13438. }
  13439. el.css( el.from ); // set top & left
  13440. // Animate
  13441. if ( scale === "content" || scale === "both" ) { // Scale the children
  13442. // Add margins/font-size
  13443. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  13444. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  13445. props2 = props0.concat(vProps).concat(hProps);
  13446. el.find( "*[width]" ).each( function() {
  13447. var child = $( this ),
  13448. c_original = {
  13449. height: child.height(),
  13450. width: child.width(),
  13451. outerHeight: child.outerHeight(),
  13452. outerWidth: child.outerWidth()
  13453. };
  13454. if (restore) {
  13455. $.effects.save(child, props2);
  13456. }
  13457. child.from = {
  13458. height: c_original.height * factor.from.y,
  13459. width: c_original.width * factor.from.x,
  13460. outerHeight: c_original.outerHeight * factor.from.y,
  13461. outerWidth: c_original.outerWidth * factor.from.x
  13462. };
  13463. child.to = {
  13464. height: c_original.height * factor.to.y,
  13465. width: c_original.width * factor.to.x,
  13466. outerHeight: c_original.height * factor.to.y,
  13467. outerWidth: c_original.width * factor.to.x
  13468. };
  13469. // Vertical props scaling
  13470. if ( factor.from.y !== factor.to.y ) {
  13471. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  13472. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  13473. }
  13474. // Horizontal props scaling
  13475. if ( factor.from.x !== factor.to.x ) {
  13476. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  13477. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  13478. }
  13479. // Animate children
  13480. child.css( child.from );
  13481. child.animate( child.to, o.duration, o.easing, function() {
  13482. // Restore children
  13483. if ( restore ) {
  13484. $.effects.restore( child, props2 );
  13485. }
  13486. });
  13487. });
  13488. }
  13489. // Animate
  13490. el.animate( el.to, {
  13491. queue: false,
  13492. duration: o.duration,
  13493. easing: o.easing,
  13494. complete: function() {
  13495. if ( el.to.opacity === 0 ) {
  13496. el.css( "opacity", el.from.opacity );
  13497. }
  13498. if ( mode === "hide" ) {
  13499. el.hide();
  13500. }
  13501. $.effects.restore( el, props );
  13502. if ( !restore ) {
  13503. // we need to calculate our new positioning based on the scaling
  13504. if ( position === "static" ) {
  13505. el.css({
  13506. position: "relative",
  13507. top: el.to.top,
  13508. left: el.to.left
  13509. });
  13510. } else {
  13511. $.each([ "top", "left" ], function( idx, pos ) {
  13512. el.css( pos, function( _, str ) {
  13513. var val = parseInt( str, 10 ),
  13514. toRef = idx ? el.to.left : el.to.top;
  13515. // if original was "auto", recalculate the new value from wrapper
  13516. if ( str === "auto" ) {
  13517. return toRef + "px";
  13518. }
  13519. return val + toRef + "px";
  13520. });
  13521. });
  13522. }
  13523. }
  13524. $.effects.removeWrapper( el );
  13525. done();
  13526. }
  13527. });
  13528. };
  13529. /*!
  13530. * jQuery UI Effects Scale 1.11.4
  13531. * http://jqueryui.com
  13532. *
  13533. * Copyright jQuery Foundation and other contributors
  13534. * Released under the MIT license.
  13535. * http://jquery.org/license
  13536. *
  13537. * http://api.jqueryui.com/scale-effect/
  13538. */
  13539. var effectScale = $.effects.effect.scale = function( o, done ) {
  13540. // Create element
  13541. var el = $( this ),
  13542. options = $.extend( true, {}, o ),
  13543. mode = $.effects.setMode( el, o.mode || "effect" ),
  13544. percent = parseInt( o.percent, 10 ) ||
  13545. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  13546. direction = o.direction || "both",
  13547. origin = o.origin,
  13548. original = {
  13549. height: el.height(),
  13550. width: el.width(),
  13551. outerHeight: el.outerHeight(),
  13552. outerWidth: el.outerWidth()
  13553. },
  13554. factor = {
  13555. y: direction !== "horizontal" ? (percent / 100) : 1,
  13556. x: direction !== "vertical" ? (percent / 100) : 1
  13557. };
  13558. // We are going to pass this effect to the size effect:
  13559. options.effect = "size";
  13560. options.queue = false;
  13561. options.complete = done;
  13562. // Set default origin and restore for show/hide
  13563. if ( mode !== "effect" ) {
  13564. options.origin = origin || [ "middle", "center" ];
  13565. options.restore = true;
  13566. }
  13567. options.from = o.from || ( mode === "show" ? {
  13568. height: 0,
  13569. width: 0,
  13570. outerHeight: 0,
  13571. outerWidth: 0
  13572. } : original );
  13573. options.to = {
  13574. height: original.height * factor.y,
  13575. width: original.width * factor.x,
  13576. outerHeight: original.outerHeight * factor.y,
  13577. outerWidth: original.outerWidth * factor.x
  13578. };
  13579. // Fade option to support puff
  13580. if ( options.fade ) {
  13581. if ( mode === "show" ) {
  13582. options.from.opacity = 0;
  13583. options.to.opacity = 1;
  13584. }
  13585. if ( mode === "hide" ) {
  13586. options.from.opacity = 1;
  13587. options.to.opacity = 0;
  13588. }
  13589. }
  13590. // Animate
  13591. el.effect( options );
  13592. };
  13593. /*!
  13594. * jQuery UI Effects Puff 1.11.4
  13595. * http://jqueryui.com
  13596. *
  13597. * Copyright jQuery Foundation and other contributors
  13598. * Released under the MIT license.
  13599. * http://jquery.org/license
  13600. *
  13601. * http://api.jqueryui.com/puff-effect/
  13602. */
  13603. var effectPuff = $.effects.effect.puff = function( o, done ) {
  13604. var elem = $( this ),
  13605. mode = $.effects.setMode( elem, o.mode || "hide" ),
  13606. hide = mode === "hide",
  13607. percent = parseInt( o.percent, 10 ) || 150,
  13608. factor = percent / 100,
  13609. original = {
  13610. height: elem.height(),
  13611. width: elem.width(),
  13612. outerHeight: elem.outerHeight(),
  13613. outerWidth: elem.outerWidth()
  13614. };
  13615. $.extend( o, {
  13616. effect: "scale",
  13617. queue: false,
  13618. fade: true,
  13619. mode: mode,
  13620. complete: done,
  13621. percent: hide ? percent : 100,
  13622. from: hide ?
  13623. original :
  13624. {
  13625. height: original.height * factor,
  13626. width: original.width * factor,
  13627. outerHeight: original.outerHeight * factor,
  13628. outerWidth: original.outerWidth * factor
  13629. }
  13630. });
  13631. elem.effect( o );
  13632. };
  13633. /*!
  13634. * jQuery UI Effects Pulsate 1.11.4
  13635. * http://jqueryui.com
  13636. *
  13637. * Copyright jQuery Foundation and other contributors
  13638. * Released under the MIT license.
  13639. * http://jquery.org/license
  13640. *
  13641. * http://api.jqueryui.com/pulsate-effect/
  13642. */
  13643. var effectPulsate = $.effects.effect.pulsate = function( o, done ) {
  13644. var elem = $( this ),
  13645. mode = $.effects.setMode( elem, o.mode || "show" ),
  13646. show = mode === "show",
  13647. hide = mode === "hide",
  13648. showhide = ( show || mode === "hide" ),
  13649. // showing or hiding leaves of the "last" animation
  13650. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  13651. duration = o.duration / anims,
  13652. animateTo = 0,
  13653. queue = elem.queue(),
  13654. queuelen = queue.length,
  13655. i;
  13656. if ( show || !elem.is(":visible")) {
  13657. elem.css( "opacity", 0 ).show();
  13658. animateTo = 1;
  13659. }
  13660. // anims - 1 opacity "toggles"
  13661. for ( i = 1; i < anims; i++ ) {
  13662. elem.animate({
  13663. opacity: animateTo
  13664. }, duration, o.easing );
  13665. animateTo = 1 - animateTo;
  13666. }
  13667. elem.animate({
  13668. opacity: animateTo
  13669. }, duration, o.easing);
  13670. elem.queue(function() {
  13671. if ( hide ) {
  13672. elem.hide();
  13673. }
  13674. done();
  13675. });
  13676. // We just queued up "anims" animations, we need to put them next in the queue
  13677. if ( queuelen > 1 ) {
  13678. queue.splice.apply( queue,
  13679. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  13680. }
  13681. elem.dequeue();
  13682. };
  13683. /*!
  13684. * jQuery UI Effects Shake 1.11.4
  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/shake-effect/
  13692. */
  13693. var effectShake = $.effects.effect.shake = function( o, done ) {
  13694. var el = $( this ),
  13695. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13696. mode = $.effects.setMode( el, o.mode || "effect" ),
  13697. direction = o.direction || "left",
  13698. distance = o.distance || 20,
  13699. times = o.times || 3,
  13700. anims = times * 2 + 1,
  13701. speed = Math.round( o.duration / anims ),
  13702. ref = (direction === "up" || direction === "down") ? "top" : "left",
  13703. positiveMotion = (direction === "up" || direction === "left"),
  13704. animation = {},
  13705. animation1 = {},
  13706. animation2 = {},
  13707. i,
  13708. // we will need to re-assemble the queue to stack our animations in place
  13709. queue = el.queue(),
  13710. queuelen = queue.length;
  13711. $.effects.save( el, props );
  13712. el.show();
  13713. $.effects.createWrapper( el );
  13714. // Animation
  13715. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  13716. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  13717. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  13718. // Animate
  13719. el.animate( animation, speed, o.easing );
  13720. // Shakes
  13721. for ( i = 1; i < times; i++ ) {
  13722. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  13723. }
  13724. el
  13725. .animate( animation1, speed, o.easing )
  13726. .animate( animation, speed / 2, o.easing )
  13727. .queue(function() {
  13728. if ( mode === "hide" ) {
  13729. el.hide();
  13730. }
  13731. $.effects.restore( el, props );
  13732. $.effects.removeWrapper( el );
  13733. done();
  13734. });
  13735. // inject all the animations we just queued to be first in line (after "inprogress")
  13736. if ( queuelen > 1) {
  13737. queue.splice.apply( queue,
  13738. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  13739. }
  13740. el.dequeue();
  13741. };
  13742. /*!
  13743. * jQuery UI Effects Slide 1.11.4
  13744. * http://jqueryui.com
  13745. *
  13746. * Copyright jQuery Foundation and other contributors
  13747. * Released under the MIT license.
  13748. * http://jquery.org/license
  13749. *
  13750. * http://api.jqueryui.com/slide-effect/
  13751. */
  13752. var effectSlide = $.effects.effect.slide = function( o, done ) {
  13753. // Create element
  13754. var el = $( this ),
  13755. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  13756. mode = $.effects.setMode( el, o.mode || "show" ),
  13757. show = mode === "show",
  13758. direction = o.direction || "left",
  13759. ref = (direction === "up" || direction === "down") ? "top" : "left",
  13760. positiveMotion = (direction === "up" || direction === "left"),
  13761. distance,
  13762. animation = {};
  13763. // Adjust
  13764. $.effects.save( el, props );
  13765. el.show();
  13766. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  13767. $.effects.createWrapper( el ).css({
  13768. overflow: "hidden"
  13769. });
  13770. if ( show ) {
  13771. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  13772. }
  13773. // Animation
  13774. animation[ ref ] = ( show ?
  13775. ( positiveMotion ? "+=" : "-=") :
  13776. ( positiveMotion ? "-=" : "+=")) +
  13777. distance;
  13778. // Animate
  13779. el.animate( animation, {
  13780. queue: false,
  13781. duration: o.duration,
  13782. easing: o.easing,
  13783. complete: function() {
  13784. if ( mode === "hide" ) {
  13785. el.hide();
  13786. }
  13787. $.effects.restore( el, props );
  13788. $.effects.removeWrapper( el );
  13789. done();
  13790. }
  13791. });
  13792. };
  13793. /*!
  13794. * jQuery UI Effects Transfer 1.11.4
  13795. * http://jqueryui.com
  13796. *
  13797. * Copyright jQuery Foundation and other contributors
  13798. * Released under the MIT license.
  13799. * http://jquery.org/license
  13800. *
  13801. * http://api.jqueryui.com/transfer-effect/
  13802. */
  13803. var effectTransfer = $.effects.effect.transfer = function( o, done ) {
  13804. var elem = $( this ),
  13805. target = $( o.to ),
  13806. targetFixed = target.css( "position" ) === "fixed",
  13807. body = $("body"),
  13808. fixTop = targetFixed ? body.scrollTop() : 0,
  13809. fixLeft = targetFixed ? body.scrollLeft() : 0,
  13810. endPosition = target.offset(),
  13811. animation = {
  13812. top: endPosition.top - fixTop,
  13813. left: endPosition.left - fixLeft,
  13814. height: target.innerHeight(),
  13815. width: target.innerWidth()
  13816. },
  13817. startPosition = elem.offset(),
  13818. transfer = $( "<div class='ui-effects-transfer'></div>" )
  13819. .appendTo( document.body )
  13820. .addClass( o.className )
  13821. .css({
  13822. top: startPosition.top - fixTop,
  13823. left: startPosition.left - fixLeft,
  13824. height: elem.innerHeight(),
  13825. width: elem.innerWidth(),
  13826. position: targetFixed ? "fixed" : "absolute"
  13827. })
  13828. .animate( animation, o.duration, o.easing, function() {
  13829. transfer.remove();
  13830. done();
  13831. });
  13832. };
  13833. }));