jquery-ui.js 460 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617
  1. /*! jQuery UI - v1.11.4 - 2016-04-05
  2. * http://jqueryui.com
  3. * Includes: core.js, widget.js, mouse.js, position.js, draggable.js, droppable.js, resizable.js, selectable.js, sortable.js, accordion.js, autocomplete.js, button.js, datepicker.js, dialog.js, menu.js, progressbar.js, selectmenu.js, slider.js, spinner.js, tabs.js, tooltip.js, effect.js, effect-blind.js, effect-bounce.js, effect-clip.js, effect-drop.js, effect-explode.js, effect-fade.js, effect-fold.js, effect-highlight.js, effect-puff.js, effect-pulsate.js, effect-scale.js, effect-shake.js, effect-size.js, effect-slide.js, effect-transfer.js
  4. * Copyright 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 Tooltip 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/tooltip/
  11761. */
  11762. var tooltip = $.widget( "ui.tooltip", {
  11763. version: "1.11.4",
  11764. options: {
  11765. content: function() {
  11766. // support: IE<9, Opera in jQuery <1.7
  11767. // .text() can't accept undefined, so coerce to a string
  11768. var title = $( this ).attr( "title" ) || "";
  11769. // Escape title, since we're going from an attribute to raw HTML
  11770. return $( "<a>" ).text( title ).html();
  11771. },
  11772. hide: true,
  11773. // Disabled elements have inconsistent behavior across browsers (#8661)
  11774. items: "[title]:not([disabled])",
  11775. position: {
  11776. my: "left top+15",
  11777. at: "left bottom",
  11778. collision: "flipfit flip"
  11779. },
  11780. show: true,
  11781. tooltipClass: null,
  11782. track: false,
  11783. // callbacks
  11784. close: null,
  11785. open: null
  11786. },
  11787. _addDescribedBy: function( elem, id ) {
  11788. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  11789. describedby.push( id );
  11790. elem
  11791. .data( "ui-tooltip-id", id )
  11792. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  11793. },
  11794. _removeDescribedBy: function( elem ) {
  11795. var id = elem.data( "ui-tooltip-id" ),
  11796. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  11797. index = $.inArray( id, describedby );
  11798. if ( index !== -1 ) {
  11799. describedby.splice( index, 1 );
  11800. }
  11801. elem.removeData( "ui-tooltip-id" );
  11802. describedby = $.trim( describedby.join( " " ) );
  11803. if ( describedby ) {
  11804. elem.attr( "aria-describedby", describedby );
  11805. } else {
  11806. elem.removeAttr( "aria-describedby" );
  11807. }
  11808. },
  11809. _create: function() {
  11810. this._on({
  11811. mouseover: "open",
  11812. focusin: "open"
  11813. });
  11814. // IDs of generated tooltips, needed for destroy
  11815. this.tooltips = {};
  11816. // IDs of parent tooltips where we removed the title attribute
  11817. this.parents = {};
  11818. if ( this.options.disabled ) {
  11819. this._disable();
  11820. }
  11821. // Append the aria-live region so tooltips announce correctly
  11822. this.liveRegion = $( "<div>" )
  11823. .attr({
  11824. role: "log",
  11825. "aria-live": "assertive",
  11826. "aria-relevant": "additions"
  11827. })
  11828. .addClass( "ui-helper-hidden-accessible" )
  11829. .appendTo( this.document[ 0 ].body );
  11830. },
  11831. _setOption: function( key, value ) {
  11832. var that = this;
  11833. if ( key === "disabled" ) {
  11834. this[ value ? "_disable" : "_enable" ]();
  11835. this.options[ key ] = value;
  11836. // disable element style changes
  11837. return;
  11838. }
  11839. this._super( key, value );
  11840. if ( key === "content" ) {
  11841. $.each( this.tooltips, function( id, tooltipData ) {
  11842. that._updateContent( tooltipData.element );
  11843. });
  11844. }
  11845. },
  11846. _disable: function() {
  11847. var that = this;
  11848. // close open tooltips
  11849. $.each( this.tooltips, function( id, tooltipData ) {
  11850. var event = $.Event( "blur" );
  11851. event.target = event.currentTarget = tooltipData.element[ 0 ];
  11852. that.close( event, true );
  11853. });
  11854. // remove title attributes to prevent native tooltips
  11855. this.element.find( this.options.items ).addBack().each(function() {
  11856. var element = $( this );
  11857. if ( element.is( "[title]" ) ) {
  11858. element
  11859. .data( "ui-tooltip-title", element.attr( "title" ) )
  11860. .removeAttr( "title" );
  11861. }
  11862. });
  11863. },
  11864. _enable: function() {
  11865. // restore title attributes
  11866. this.element.find( this.options.items ).addBack().each(function() {
  11867. var element = $( this );
  11868. if ( element.data( "ui-tooltip-title" ) ) {
  11869. element.attr( "title", element.data( "ui-tooltip-title" ) );
  11870. }
  11871. });
  11872. },
  11873. open: function( event ) {
  11874. var that = this,
  11875. target = $( event ? event.target : this.element )
  11876. // we need closest here due to mouseover bubbling,
  11877. // but always pointing at the same event target
  11878. .closest( this.options.items );
  11879. // No element to show a tooltip for or the tooltip is already open
  11880. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  11881. return;
  11882. }
  11883. if ( target.attr( "title" ) ) {
  11884. target.data( "ui-tooltip-title", target.attr( "title" ) );
  11885. }
  11886. target.data( "ui-tooltip-open", true );
  11887. // kill parent tooltips, custom or native, for hover
  11888. if ( event && event.type === "mouseover" ) {
  11889. target.parents().each(function() {
  11890. var parent = $( this ),
  11891. blurEvent;
  11892. if ( parent.data( "ui-tooltip-open" ) ) {
  11893. blurEvent = $.Event( "blur" );
  11894. blurEvent.target = blurEvent.currentTarget = this;
  11895. that.close( blurEvent, true );
  11896. }
  11897. if ( parent.attr( "title" ) ) {
  11898. parent.uniqueId();
  11899. that.parents[ this.id ] = {
  11900. element: this,
  11901. title: parent.attr( "title" )
  11902. };
  11903. parent.attr( "title", "" );
  11904. }
  11905. });
  11906. }
  11907. this._registerCloseHandlers( event, target );
  11908. this._updateContent( target, event );
  11909. },
  11910. _updateContent: function( target, event ) {
  11911. var content,
  11912. contentOption = this.options.content,
  11913. that = this,
  11914. eventType = event ? event.type : null;
  11915. if ( typeof contentOption === "string" ) {
  11916. return this._open( event, target, contentOption );
  11917. }
  11918. content = contentOption.call( target[0], function( response ) {
  11919. // IE may instantly serve a cached response for ajax requests
  11920. // delay this call to _open so the other call to _open runs first
  11921. that._delay(function() {
  11922. // Ignore async response if tooltip was closed already
  11923. if ( !target.data( "ui-tooltip-open" ) ) {
  11924. return;
  11925. }
  11926. // jQuery creates a special event for focusin when it doesn't
  11927. // exist natively. To improve performance, the native event
  11928. // object is reused and the type is changed. Therefore, we can't
  11929. // rely on the type being correct after the event finished
  11930. // bubbling, so we set it back to the previous value. (#8740)
  11931. if ( event ) {
  11932. event.type = eventType;
  11933. }
  11934. this._open( event, target, response );
  11935. });
  11936. });
  11937. if ( content ) {
  11938. this._open( event, target, content );
  11939. }
  11940. },
  11941. _open: function( event, target, content ) {
  11942. var tooltipData, tooltip, delayedShow, a11yContent,
  11943. positionOption = $.extend( {}, this.options.position );
  11944. if ( !content ) {
  11945. return;
  11946. }
  11947. // Content can be updated multiple times. If the tooltip already
  11948. // exists, then just update the content and bail.
  11949. tooltipData = this._find( target );
  11950. if ( tooltipData ) {
  11951. tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
  11952. return;
  11953. }
  11954. // if we have a title, clear it to prevent the native tooltip
  11955. // we have to check first to avoid defining a title if none exists
  11956. // (we don't want to cause an element to start matching [title])
  11957. //
  11958. // We use removeAttr only for key events, to allow IE to export the correct
  11959. // accessible attributes. For mouse events, set to empty string to avoid
  11960. // native tooltip showing up (happens only when removing inside mouseover).
  11961. if ( target.is( "[title]" ) ) {
  11962. if ( event && event.type === "mouseover" ) {
  11963. target.attr( "title", "" );
  11964. } else {
  11965. target.removeAttr( "title" );
  11966. }
  11967. }
  11968. tooltipData = this._tooltip( target );
  11969. tooltip = tooltipData.tooltip;
  11970. this._addDescribedBy( target, tooltip.attr( "id" ) );
  11971. tooltip.find( ".ui-tooltip-content" ).html( content );
  11972. // Support: Voiceover on OS X, JAWS on IE <= 9
  11973. // JAWS announces deletions even when aria-relevant="additions"
  11974. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  11975. this.liveRegion.children().hide();
  11976. if ( content.clone ) {
  11977. a11yContent = content.clone();
  11978. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  11979. } else {
  11980. a11yContent = content;
  11981. }
  11982. $( "<div>" ).html( a11yContent ).appendTo( this.liveRegion );
  11983. function position( event ) {
  11984. positionOption.of = event;
  11985. if ( tooltip.is( ":hidden" ) ) {
  11986. return;
  11987. }
  11988. tooltip.position( positionOption );
  11989. }
  11990. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  11991. this._on( this.document, {
  11992. mousemove: position
  11993. });
  11994. // trigger once to override element-relative positioning
  11995. position( event );
  11996. } else {
  11997. tooltip.position( $.extend({
  11998. of: target
  11999. }, this.options.position ) );
  12000. }
  12001. tooltip.hide();
  12002. this._show( tooltip, this.options.show );
  12003. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  12004. // as the tooltip is visible, position the tooltip using the most recent
  12005. // event.
  12006. if ( this.options.show && this.options.show.delay ) {
  12007. delayedShow = this.delayedShow = setInterval(function() {
  12008. if ( tooltip.is( ":visible" ) ) {
  12009. position( positionOption.of );
  12010. clearInterval( delayedShow );
  12011. }
  12012. }, $.fx.interval );
  12013. }
  12014. this._trigger( "open", event, { tooltip: tooltip } );
  12015. },
  12016. _registerCloseHandlers: function( event, target ) {
  12017. var events = {
  12018. keyup: function( event ) {
  12019. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  12020. var fakeEvent = $.Event(event);
  12021. fakeEvent.currentTarget = target[0];
  12022. this.close( fakeEvent, true );
  12023. }
  12024. }
  12025. };
  12026. // Only bind remove handler for delegated targets. Non-delegated
  12027. // tooltips will handle this in destroy.
  12028. if ( target[ 0 ] !== this.element[ 0 ] ) {
  12029. events.remove = function() {
  12030. this._removeTooltip( this._find( target ).tooltip );
  12031. };
  12032. }
  12033. if ( !event || event.type === "mouseover" ) {
  12034. events.mouseleave = "close";
  12035. }
  12036. if ( !event || event.type === "focusin" ) {
  12037. events.focusout = "close";
  12038. }
  12039. this._on( true, target, events );
  12040. },
  12041. close: function( event ) {
  12042. var tooltip,
  12043. that = this,
  12044. target = $( event ? event.currentTarget : this.element ),
  12045. tooltipData = this._find( target );
  12046. // The tooltip may already be closed
  12047. if ( !tooltipData ) {
  12048. // We set ui-tooltip-open immediately upon open (in open()), but only set the
  12049. // additional data once there's actually content to show (in _open()). So even if the
  12050. // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in
  12051. // the period between open() and _open().
  12052. target.removeData( "ui-tooltip-open" );
  12053. return;
  12054. }
  12055. tooltip = tooltipData.tooltip;
  12056. // disabling closes the tooltip, so we need to track when we're closing
  12057. // to avoid an infinite loop in case the tooltip becomes disabled on close
  12058. if ( tooltipData.closing ) {
  12059. return;
  12060. }
  12061. // Clear the interval for delayed tracking tooltips
  12062. clearInterval( this.delayedShow );
  12063. // only set title if we had one before (see comment in _open())
  12064. // If the title attribute has changed since open(), don't restore
  12065. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  12066. target.attr( "title", target.data( "ui-tooltip-title" ) );
  12067. }
  12068. this._removeDescribedBy( target );
  12069. tooltipData.hiding = true;
  12070. tooltip.stop( true );
  12071. this._hide( tooltip, this.options.hide, function() {
  12072. that._removeTooltip( $( this ) );
  12073. });
  12074. target.removeData( "ui-tooltip-open" );
  12075. this._off( target, "mouseleave focusout keyup" );
  12076. // Remove 'remove' binding only on delegated targets
  12077. if ( target[ 0 ] !== this.element[ 0 ] ) {
  12078. this._off( target, "remove" );
  12079. }
  12080. this._off( this.document, "mousemove" );
  12081. if ( event && event.type === "mouseleave" ) {
  12082. $.each( this.parents, function( id, parent ) {
  12083. $( parent.element ).attr( "title", parent.title );
  12084. delete that.parents[ id ];
  12085. });
  12086. }
  12087. tooltipData.closing = true;
  12088. this._trigger( "close", event, { tooltip: tooltip } );
  12089. if ( !tooltipData.hiding ) {
  12090. tooltipData.closing = false;
  12091. }
  12092. },
  12093. _tooltip: function( element ) {
  12094. var tooltip = $( "<div>" )
  12095. .attr( "role", "tooltip" )
  12096. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  12097. ( this.options.tooltipClass || "" ) ),
  12098. id = tooltip.uniqueId().attr( "id" );
  12099. $( "<div>" )
  12100. .addClass( "ui-tooltip-content" )
  12101. .appendTo( tooltip );
  12102. tooltip.appendTo( this.document[0].body );
  12103. return this.tooltips[ id ] = {
  12104. element: element,
  12105. tooltip: tooltip
  12106. };
  12107. },
  12108. _find: function( target ) {
  12109. var id = target.data( "ui-tooltip-id" );
  12110. return id ? this.tooltips[ id ] : null;
  12111. },
  12112. _removeTooltip: function( tooltip ) {
  12113. tooltip.remove();
  12114. delete this.tooltips[ tooltip.attr( "id" ) ];
  12115. },
  12116. _destroy: function() {
  12117. var that = this;
  12118. // close open tooltips
  12119. $.each( this.tooltips, function( id, tooltipData ) {
  12120. // Delegate to close method to handle common cleanup
  12121. var event = $.Event( "blur" ),
  12122. element = tooltipData.element;
  12123. event.target = event.currentTarget = element[ 0 ];
  12124. that.close( event, true );
  12125. // Remove immediately; destroying an open tooltip doesn't use the
  12126. // hide animation
  12127. $( "#" + id ).remove();
  12128. // Restore the title
  12129. if ( element.data( "ui-tooltip-title" ) ) {
  12130. // If the title attribute has changed since open(), don't restore
  12131. if ( !element.attr( "title" ) ) {
  12132. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12133. }
  12134. element.removeData( "ui-tooltip-title" );
  12135. }
  12136. });
  12137. this.liveRegion.remove();
  12138. }
  12139. });
  12140. /*!
  12141. * jQuery UI Effects 1.11.4
  12142. * http://jqueryui.com
  12143. *
  12144. * Copyright jQuery Foundation and other contributors
  12145. * Released under the MIT license.
  12146. * http://jquery.org/license
  12147. *
  12148. * http://api.jqueryui.com/category/effects-core/
  12149. */
  12150. var dataSpace = "ui-effects-",
  12151. // Create a local jQuery because jQuery Color relies on it and the
  12152. // global may not exist with AMD and a custom build (#10199)
  12153. jQuery = $;
  12154. $.effects = {
  12155. effect: {}
  12156. };
  12157. /*!
  12158. * jQuery Color Animations v2.1.2
  12159. * https://github.com/jquery/jquery-color
  12160. *
  12161. * Copyright 2014 jQuery Foundation and other contributors
  12162. * Released under the MIT license.
  12163. * http://jquery.org/license
  12164. *
  12165. * Date: Wed Jan 16 08:47:09 2013 -0600
  12166. */
  12167. (function( jQuery, undefined ) {
  12168. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  12169. // plusequals test for += 100 -= 100
  12170. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  12171. // a set of RE's that can match strings and generate color tuples.
  12172. stringParsers = [ {
  12173. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  12174. parse: function( execResult ) {
  12175. return [
  12176. execResult[ 1 ],
  12177. execResult[ 2 ],
  12178. execResult[ 3 ],
  12179. execResult[ 4 ]
  12180. ];
  12181. }
  12182. }, {
  12183. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  12184. parse: function( execResult ) {
  12185. return [
  12186. execResult[ 1 ] * 2.55,
  12187. execResult[ 2 ] * 2.55,
  12188. execResult[ 3 ] * 2.55,
  12189. execResult[ 4 ]
  12190. ];
  12191. }
  12192. }, {
  12193. // this regex ignores A-F because it's compared against an already lowercased string
  12194. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  12195. parse: function( execResult ) {
  12196. return [
  12197. parseInt( execResult[ 1 ], 16 ),
  12198. parseInt( execResult[ 2 ], 16 ),
  12199. parseInt( execResult[ 3 ], 16 )
  12200. ];
  12201. }
  12202. }, {
  12203. // this regex ignores A-F because it's compared against an already lowercased string
  12204. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  12205. parse: function( execResult ) {
  12206. return [
  12207. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  12208. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  12209. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  12210. ];
  12211. }
  12212. }, {
  12213. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  12214. space: "hsla",
  12215. parse: function( execResult ) {
  12216. return [
  12217. execResult[ 1 ],
  12218. execResult[ 2 ] / 100,
  12219. execResult[ 3 ] / 100,
  12220. execResult[ 4 ]
  12221. ];
  12222. }
  12223. } ],
  12224. // jQuery.Color( )
  12225. color = jQuery.Color = function( color, green, blue, alpha ) {
  12226. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  12227. },
  12228. spaces = {
  12229. rgba: {
  12230. props: {
  12231. red: {
  12232. idx: 0,
  12233. type: "byte"
  12234. },
  12235. green: {
  12236. idx: 1,
  12237. type: "byte"
  12238. },
  12239. blue: {
  12240. idx: 2,
  12241. type: "byte"
  12242. }
  12243. }
  12244. },
  12245. hsla: {
  12246. props: {
  12247. hue: {
  12248. idx: 0,
  12249. type: "degrees"
  12250. },
  12251. saturation: {
  12252. idx: 1,
  12253. type: "percent"
  12254. },
  12255. lightness: {
  12256. idx: 2,
  12257. type: "percent"
  12258. }
  12259. }
  12260. }
  12261. },
  12262. propTypes = {
  12263. "byte": {
  12264. floor: true,
  12265. max: 255
  12266. },
  12267. "percent": {
  12268. max: 1
  12269. },
  12270. "degrees": {
  12271. mod: 360,
  12272. floor: true
  12273. }
  12274. },
  12275. support = color.support = {},
  12276. // element for support tests
  12277. supportElem = jQuery( "<p>" )[ 0 ],
  12278. // colors = jQuery.Color.names
  12279. colors,
  12280. // local aliases of functions called often
  12281. each = jQuery.each;
  12282. // determine rgba support immediately
  12283. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  12284. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  12285. // define cache name and alpha properties
  12286. // for rgba and hsla spaces
  12287. each( spaces, function( spaceName, space ) {
  12288. space.cache = "_" + spaceName;
  12289. space.props.alpha = {
  12290. idx: 3,
  12291. type: "percent",
  12292. def: 1
  12293. };
  12294. });
  12295. function clamp( value, prop, allowEmpty ) {
  12296. var type = propTypes[ prop.type ] || {};
  12297. if ( value == null ) {
  12298. return (allowEmpty || !prop.def) ? null : prop.def;
  12299. }
  12300. // ~~ is an short way of doing floor for positive numbers
  12301. value = type.floor ? ~~value : parseFloat( value );
  12302. // IE will pass in empty strings as value for alpha,
  12303. // which will hit this case
  12304. if ( isNaN( value ) ) {
  12305. return prop.def;
  12306. }
  12307. if ( type.mod ) {
  12308. // we add mod before modding to make sure that negatives values
  12309. // get converted properly: -10 -> 350
  12310. return (value + type.mod) % type.mod;
  12311. }
  12312. // for now all property types without mod have min and max
  12313. return 0 > value ? 0 : type.max < value ? type.max : value;
  12314. }
  12315. function stringParse( string ) {
  12316. var inst = color(),
  12317. rgba = inst._rgba = [];
  12318. string = string.toLowerCase();
  12319. each( stringParsers, function( i, parser ) {
  12320. var parsed,
  12321. match = parser.re.exec( string ),
  12322. values = match && parser.parse( match ),
  12323. spaceName = parser.space || "rgba";
  12324. if ( values ) {
  12325. parsed = inst[ spaceName ]( values );
  12326. // if this was an rgba parse the assignment might happen twice
  12327. // oh well....
  12328. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  12329. rgba = inst._rgba = parsed._rgba;
  12330. // exit each( stringParsers ) here because we matched
  12331. return false;
  12332. }
  12333. });
  12334. // Found a stringParser that handled it
  12335. if ( rgba.length ) {
  12336. // if this came from a parsed string, force "transparent" when alpha is 0
  12337. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  12338. if ( rgba.join() === "0,0,0,0" ) {
  12339. jQuery.extend( rgba, colors.transparent );
  12340. }
  12341. return inst;
  12342. }
  12343. // named colors
  12344. return colors[ string ];
  12345. }
  12346. color.fn = jQuery.extend( color.prototype, {
  12347. parse: function( red, green, blue, alpha ) {
  12348. if ( red === undefined ) {
  12349. this._rgba = [ null, null, null, null ];
  12350. return this;
  12351. }
  12352. if ( red.jquery || red.nodeType ) {
  12353. red = jQuery( red ).css( green );
  12354. green = undefined;
  12355. }
  12356. var inst = this,
  12357. type = jQuery.type( red ),
  12358. rgba = this._rgba = [];
  12359. // more than 1 argument specified - assume ( red, green, blue, alpha )
  12360. if ( green !== undefined ) {
  12361. red = [ red, green, blue, alpha ];
  12362. type = "array";
  12363. }
  12364. if ( type === "string" ) {
  12365. return this.parse( stringParse( red ) || colors._default );
  12366. }
  12367. if ( type === "array" ) {
  12368. each( spaces.rgba.props, function( key, prop ) {
  12369. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  12370. });
  12371. return this;
  12372. }
  12373. if ( type === "object" ) {
  12374. if ( red instanceof color ) {
  12375. each( spaces, function( spaceName, space ) {
  12376. if ( red[ space.cache ] ) {
  12377. inst[ space.cache ] = red[ space.cache ].slice();
  12378. }
  12379. });
  12380. } else {
  12381. each( spaces, function( spaceName, space ) {
  12382. var cache = space.cache;
  12383. each( space.props, function( key, prop ) {
  12384. // if the cache doesn't exist, and we know how to convert
  12385. if ( !inst[ cache ] && space.to ) {
  12386. // if the value was null, we don't need to copy it
  12387. // if the key was alpha, we don't need to copy it either
  12388. if ( key === "alpha" || red[ key ] == null ) {
  12389. return;
  12390. }
  12391. inst[ cache ] = space.to( inst._rgba );
  12392. }
  12393. // this is the only case where we allow nulls for ALL properties.
  12394. // call clamp with alwaysAllowEmpty
  12395. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  12396. });
  12397. // everything defined but alpha?
  12398. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  12399. // use the default of 1
  12400. inst[ cache ][ 3 ] = 1;
  12401. if ( space.from ) {
  12402. inst._rgba = space.from( inst[ cache ] );
  12403. }
  12404. }
  12405. });
  12406. }
  12407. return this;
  12408. }
  12409. },
  12410. is: function( compare ) {
  12411. var is = color( compare ),
  12412. same = true,
  12413. inst = this;
  12414. each( spaces, function( _, space ) {
  12415. var localCache,
  12416. isCache = is[ space.cache ];
  12417. if (isCache) {
  12418. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  12419. each( space.props, function( _, prop ) {
  12420. if ( isCache[ prop.idx ] != null ) {
  12421. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  12422. return same;
  12423. }
  12424. });
  12425. }
  12426. return same;
  12427. });
  12428. return same;
  12429. },
  12430. _space: function() {
  12431. var used = [],
  12432. inst = this;
  12433. each( spaces, function( spaceName, space ) {
  12434. if ( inst[ space.cache ] ) {
  12435. used.push( spaceName );
  12436. }
  12437. });
  12438. return used.pop();
  12439. },
  12440. transition: function( other, distance ) {
  12441. var end = color( other ),
  12442. spaceName = end._space(),
  12443. space = spaces[ spaceName ],
  12444. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  12445. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  12446. result = start.slice();
  12447. end = end[ space.cache ];
  12448. each( space.props, function( key, prop ) {
  12449. var index = prop.idx,
  12450. startValue = start[ index ],
  12451. endValue = end[ index ],
  12452. type = propTypes[ prop.type ] || {};
  12453. // if null, don't override start value
  12454. if ( endValue === null ) {
  12455. return;
  12456. }
  12457. // if null - use end
  12458. if ( startValue === null ) {
  12459. result[ index ] = endValue;
  12460. } else {
  12461. if ( type.mod ) {
  12462. if ( endValue - startValue > type.mod / 2 ) {
  12463. startValue += type.mod;
  12464. } else if ( startValue - endValue > type.mod / 2 ) {
  12465. startValue -= type.mod;
  12466. }
  12467. }
  12468. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  12469. }
  12470. });
  12471. return this[ spaceName ]( result );
  12472. },
  12473. blend: function( opaque ) {
  12474. // if we are already opaque - return ourself
  12475. if ( this._rgba[ 3 ] === 1 ) {
  12476. return this;
  12477. }
  12478. var rgb = this._rgba.slice(),
  12479. a = rgb.pop(),
  12480. blend = color( opaque )._rgba;
  12481. return color( jQuery.map( rgb, function( v, i ) {
  12482. return ( 1 - a ) * blend[ i ] + a * v;
  12483. }));
  12484. },
  12485. toRgbaString: function() {
  12486. var prefix = "rgba(",
  12487. rgba = jQuery.map( this._rgba, function( v, i ) {
  12488. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  12489. });
  12490. if ( rgba[ 3 ] === 1 ) {
  12491. rgba.pop();
  12492. prefix = "rgb(";
  12493. }
  12494. return prefix + rgba.join() + ")";
  12495. },
  12496. toHslaString: function() {
  12497. var prefix = "hsla(",
  12498. hsla = jQuery.map( this.hsla(), function( v, i ) {
  12499. if ( v == null ) {
  12500. v = i > 2 ? 1 : 0;
  12501. }
  12502. // catch 1 and 2
  12503. if ( i && i < 3 ) {
  12504. v = Math.round( v * 100 ) + "%";
  12505. }
  12506. return v;
  12507. });
  12508. if ( hsla[ 3 ] === 1 ) {
  12509. hsla.pop();
  12510. prefix = "hsl(";
  12511. }
  12512. return prefix + hsla.join() + ")";
  12513. },
  12514. toHexString: function( includeAlpha ) {
  12515. var rgba = this._rgba.slice(),
  12516. alpha = rgba.pop();
  12517. if ( includeAlpha ) {
  12518. rgba.push( ~~( alpha * 255 ) );
  12519. }
  12520. return "#" + jQuery.map( rgba, function( v ) {
  12521. // default to 0 when nulls exist
  12522. v = ( v || 0 ).toString( 16 );
  12523. return v.length === 1 ? "0" + v : v;
  12524. }).join("");
  12525. },
  12526. toString: function() {
  12527. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  12528. }
  12529. });
  12530. color.fn.parse.prototype = color.fn;
  12531. // hsla conversions adapted from:
  12532. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  12533. function hue2rgb( p, q, h ) {
  12534. h = ( h + 1 ) % 1;
  12535. if ( h * 6 < 1 ) {
  12536. return p + ( q - p ) * h * 6;
  12537. }
  12538. if ( h * 2 < 1) {
  12539. return q;
  12540. }
  12541. if ( h * 3 < 2 ) {
  12542. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  12543. }
  12544. return p;
  12545. }
  12546. spaces.hsla.to = function( rgba ) {
  12547. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  12548. return [ null, null, null, rgba[ 3 ] ];
  12549. }
  12550. var r = rgba[ 0 ] / 255,
  12551. g = rgba[ 1 ] / 255,
  12552. b = rgba[ 2 ] / 255,
  12553. a = rgba[ 3 ],
  12554. max = Math.max( r, g, b ),
  12555. min = Math.min( r, g, b ),
  12556. diff = max - min,
  12557. add = max + min,
  12558. l = add * 0.5,
  12559. h, s;
  12560. if ( min === max ) {
  12561. h = 0;
  12562. } else if ( r === max ) {
  12563. h = ( 60 * ( g - b ) / diff ) + 360;
  12564. } else if ( g === max ) {
  12565. h = ( 60 * ( b - r ) / diff ) + 120;
  12566. } else {
  12567. h = ( 60 * ( r - g ) / diff ) + 240;
  12568. }
  12569. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  12570. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  12571. if ( diff === 0 ) {
  12572. s = 0;
  12573. } else if ( l <= 0.5 ) {
  12574. s = diff / add;
  12575. } else {
  12576. s = diff / ( 2 - add );
  12577. }
  12578. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  12579. };
  12580. spaces.hsla.from = function( hsla ) {
  12581. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  12582. return [ null, null, null, hsla[ 3 ] ];
  12583. }
  12584. var h = hsla[ 0 ] / 360,
  12585. s = hsla[ 1 ],
  12586. l = hsla[ 2 ],
  12587. a = hsla[ 3 ],
  12588. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  12589. p = 2 * l - q;
  12590. return [
  12591. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  12592. Math.round( hue2rgb( p, q, h ) * 255 ),
  12593. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  12594. a
  12595. ];
  12596. };
  12597. each( spaces, function( spaceName, space ) {
  12598. var props = space.props,
  12599. cache = space.cache,
  12600. to = space.to,
  12601. from = space.from;
  12602. // makes rgba() and hsla()
  12603. color.fn[ spaceName ] = function( value ) {
  12604. // generate a cache for this space if it doesn't exist
  12605. if ( to && !this[ cache ] ) {
  12606. this[ cache ] = to( this._rgba );
  12607. }
  12608. if ( value === undefined ) {
  12609. return this[ cache ].slice();
  12610. }
  12611. var ret,
  12612. type = jQuery.type( value ),
  12613. arr = ( type === "array" || type === "object" ) ? value : arguments,
  12614. local = this[ cache ].slice();
  12615. each( props, function( key, prop ) {
  12616. var val = arr[ type === "object" ? key : prop.idx ];
  12617. if ( val == null ) {
  12618. val = local[ prop.idx ];
  12619. }
  12620. local[ prop.idx ] = clamp( val, prop );
  12621. });
  12622. if ( from ) {
  12623. ret = color( from( local ) );
  12624. ret[ cache ] = local;
  12625. return ret;
  12626. } else {
  12627. return color( local );
  12628. }
  12629. };
  12630. // makes red() green() blue() alpha() hue() saturation() lightness()
  12631. each( props, function( key, prop ) {
  12632. // alpha is included in more than one space
  12633. if ( color.fn[ key ] ) {
  12634. return;
  12635. }
  12636. color.fn[ key ] = function( value ) {
  12637. var vtype = jQuery.type( value ),
  12638. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  12639. local = this[ fn ](),
  12640. cur = local[ prop.idx ],
  12641. match;
  12642. if ( vtype === "undefined" ) {
  12643. return cur;
  12644. }
  12645. if ( vtype === "function" ) {
  12646. value = value.call( this, cur );
  12647. vtype = jQuery.type( value );
  12648. }
  12649. if ( value == null && prop.empty ) {
  12650. return this;
  12651. }
  12652. if ( vtype === "string" ) {
  12653. match = rplusequals.exec( value );
  12654. if ( match ) {
  12655. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  12656. }
  12657. }
  12658. local[ prop.idx ] = value;
  12659. return this[ fn ]( local );
  12660. };
  12661. });
  12662. });
  12663. // add cssHook and .fx.step function for each named hook.
  12664. // accept a space separated string of properties
  12665. color.hook = function( hook ) {
  12666. var hooks = hook.split( " " );
  12667. each( hooks, function( i, hook ) {
  12668. jQuery.cssHooks[ hook ] = {
  12669. set: function( elem, value ) {
  12670. var parsed, curElem,
  12671. backgroundColor = "";
  12672. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  12673. value = color( parsed || value );
  12674. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  12675. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  12676. while (
  12677. (backgroundColor === "" || backgroundColor === "transparent") &&
  12678. curElem && curElem.style
  12679. ) {
  12680. try {
  12681. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  12682. curElem = curElem.parentNode;
  12683. } catch ( e ) {
  12684. }
  12685. }
  12686. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  12687. backgroundColor :
  12688. "_default" );
  12689. }
  12690. value = value.toRgbaString();
  12691. }
  12692. try {
  12693. elem.style[ hook ] = value;
  12694. } catch ( e ) {
  12695. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  12696. }
  12697. }
  12698. };
  12699. jQuery.fx.step[ hook ] = function( fx ) {
  12700. if ( !fx.colorInit ) {
  12701. fx.start = color( fx.elem, hook );
  12702. fx.end = color( fx.end );
  12703. fx.colorInit = true;
  12704. }
  12705. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  12706. };
  12707. });
  12708. };
  12709. color.hook( stepHooks );
  12710. jQuery.cssHooks.borderColor = {
  12711. expand: function( value ) {
  12712. var expanded = {};
  12713. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  12714. expanded[ "border" + part + "Color" ] = value;
  12715. });
  12716. return expanded;
  12717. }
  12718. };
  12719. // Basic color names only.
  12720. // Usage of any of the other color names requires adding yourself or including
  12721. // jquery.color.svg-names.js.
  12722. colors = jQuery.Color.names = {
  12723. // 4.1. Basic color keywords
  12724. aqua: "#00ffff",
  12725. black: "#000000",
  12726. blue: "#0000ff",
  12727. fuchsia: "#ff00ff",
  12728. gray: "#808080",
  12729. green: "#008000",
  12730. lime: "#00ff00",
  12731. maroon: "#800000",
  12732. navy: "#000080",
  12733. olive: "#808000",
  12734. purple: "#800080",
  12735. red: "#ff0000",
  12736. silver: "#c0c0c0",
  12737. teal: "#008080",
  12738. white: "#ffffff",
  12739. yellow: "#ffff00",
  12740. // 4.2.3. "transparent" color keyword
  12741. transparent: [ null, null, null, 0 ],
  12742. _default: "#ffffff"
  12743. };
  12744. })( jQuery );
  12745. /******************************************************************************/
  12746. /****************************** CLASS ANIMATIONS ******************************/
  12747. /******************************************************************************/
  12748. (function() {
  12749. var classAnimationActions = [ "add", "remove", "toggle" ],
  12750. shorthandStyles = {
  12751. border: 1,
  12752. borderBottom: 1,
  12753. borderColor: 1,
  12754. borderLeft: 1,
  12755. borderRight: 1,
  12756. borderTop: 1,
  12757. borderWidth: 1,
  12758. margin: 1,
  12759. padding: 1
  12760. };
  12761. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  12762. $.fx.step[ prop ] = function( fx ) {
  12763. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  12764. jQuery.style( fx.elem, prop, fx.end );
  12765. fx.setAttr = true;
  12766. }
  12767. };
  12768. });
  12769. function getElementStyles( elem ) {
  12770. var key, len,
  12771. style = elem.ownerDocument.defaultView ?
  12772. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  12773. elem.currentStyle,
  12774. styles = {};
  12775. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  12776. len = style.length;
  12777. while ( len-- ) {
  12778. key = style[ len ];
  12779. if ( typeof style[ key ] === "string" ) {
  12780. styles[ $.camelCase( key ) ] = style[ key ];
  12781. }
  12782. }
  12783. // support: Opera, IE <9
  12784. } else {
  12785. for ( key in style ) {
  12786. if ( typeof style[ key ] === "string" ) {
  12787. styles[ key ] = style[ key ];
  12788. }
  12789. }
  12790. }
  12791. return styles;
  12792. }
  12793. function styleDifference( oldStyle, newStyle ) {
  12794. var diff = {},
  12795. name, value;
  12796. for ( name in newStyle ) {
  12797. value = newStyle[ name ];
  12798. if ( oldStyle[ name ] !== value ) {
  12799. if ( !shorthandStyles[ name ] ) {
  12800. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  12801. diff[ name ] = value;
  12802. }
  12803. }
  12804. }
  12805. }
  12806. return diff;
  12807. }
  12808. // support: jQuery <1.8
  12809. if ( !$.fn.addBack ) {
  12810. $.fn.addBack = function( selector ) {
  12811. return this.add( selector == null ?
  12812. this.prevObject : this.prevObject.filter( selector )
  12813. );
  12814. };
  12815. }
  12816. $.effects.animateClass = function( value, duration, easing, callback ) {
  12817. var o = $.speed( duration, easing, callback );
  12818. return this.queue( function() {
  12819. var animated = $( this ),
  12820. baseClass = animated.attr( "class" ) || "",
  12821. applyClassChange,
  12822. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  12823. // map the animated objects to store the original styles.
  12824. allAnimations = allAnimations.map(function() {
  12825. var el = $( this );
  12826. return {
  12827. el: el,
  12828. start: getElementStyles( this )
  12829. };
  12830. });
  12831. // apply class change
  12832. applyClassChange = function() {
  12833. $.each( classAnimationActions, function(i, action) {
  12834. if ( value[ action ] ) {
  12835. animated[ action + "Class" ]( value[ action ] );
  12836. }
  12837. });
  12838. };
  12839. applyClassChange();
  12840. // map all animated objects again - calculate new styles and diff
  12841. allAnimations = allAnimations.map(function() {
  12842. this.end = getElementStyles( this.el[ 0 ] );
  12843. this.diff = styleDifference( this.start, this.end );
  12844. return this;
  12845. });
  12846. // apply original class
  12847. animated.attr( "class", baseClass );
  12848. // map all animated objects again - this time collecting a promise
  12849. allAnimations = allAnimations.map(function() {
  12850. var styleInfo = this,
  12851. dfd = $.Deferred(),
  12852. opts = $.extend({}, o, {
  12853. queue: false,
  12854. complete: function() {
  12855. dfd.resolve( styleInfo );
  12856. }
  12857. });
  12858. this.el.animate( this.diff, opts );
  12859. return dfd.promise();
  12860. });
  12861. // once all animations have completed:
  12862. $.when.apply( $, allAnimations.get() ).done(function() {
  12863. // set the final class
  12864. applyClassChange();
  12865. // for each animated element,
  12866. // clear all css properties that were animated
  12867. $.each( arguments, function() {
  12868. var el = this.el;
  12869. $.each( this.diff, function(key) {
  12870. el.css( key, "" );
  12871. });
  12872. });
  12873. // this is guarnteed to be there if you use jQuery.speed()
  12874. // it also handles dequeuing the next anim...
  12875. o.complete.call( animated[ 0 ] );
  12876. });
  12877. });
  12878. };
  12879. $.fn.extend({
  12880. addClass: (function( orig ) {
  12881. return function( classNames, speed, easing, callback ) {
  12882. return speed ?
  12883. $.effects.animateClass.call( this,
  12884. { add: classNames }, speed, easing, callback ) :
  12885. orig.apply( this, arguments );
  12886. };
  12887. })( $.fn.addClass ),
  12888. removeClass: (function( orig ) {
  12889. return function( classNames, speed, easing, callback ) {
  12890. return arguments.length > 1 ?
  12891. $.effects.animateClass.call( this,
  12892. { remove: classNames }, speed, easing, callback ) :
  12893. orig.apply( this, arguments );
  12894. };
  12895. })( $.fn.removeClass ),
  12896. toggleClass: (function( orig ) {
  12897. return function( classNames, force, speed, easing, callback ) {
  12898. if ( typeof force === "boolean" || force === undefined ) {
  12899. if ( !speed ) {
  12900. // without speed parameter
  12901. return orig.apply( this, arguments );
  12902. } else {
  12903. return $.effects.animateClass.call( this,
  12904. (force ? { add: classNames } : { remove: classNames }),
  12905. speed, easing, callback );
  12906. }
  12907. } else {
  12908. // without force parameter
  12909. return $.effects.animateClass.call( this,
  12910. { toggle: classNames }, force, speed, easing );
  12911. }
  12912. };
  12913. })( $.fn.toggleClass ),
  12914. switchClass: function( remove, add, speed, easing, callback) {
  12915. return $.effects.animateClass.call( this, {
  12916. add: add,
  12917. remove: remove
  12918. }, speed, easing, callback );
  12919. }
  12920. });
  12921. })();
  12922. /******************************************************************************/
  12923. /*********************************** EFFECTS **********************************/
  12924. /******************************************************************************/
  12925. (function() {
  12926. $.extend( $.effects, {
  12927. version: "1.11.4",
  12928. // Saves a set of properties in a data storage
  12929. save: function( element, set ) {
  12930. for ( var i = 0; i < set.length; i++ ) {
  12931. if ( set[ i ] !== null ) {
  12932. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  12933. }
  12934. }
  12935. },
  12936. // Restores a set of previously saved properties from a data storage
  12937. restore: function( element, set ) {
  12938. var val, i;
  12939. for ( i = 0; i < set.length; i++ ) {
  12940. if ( set[ i ] !== null ) {
  12941. val = element.data( dataSpace + set[ i ] );
  12942. // support: jQuery 1.6.2
  12943. // http://bugs.jquery.com/ticket/9917
  12944. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  12945. // We can't differentiate between "" and 0 here, so we just assume
  12946. // empty string since it's likely to be a more common value...
  12947. if ( val === undefined ) {
  12948. val = "";
  12949. }
  12950. element.css( set[ i ], val );
  12951. }
  12952. }
  12953. },
  12954. setMode: function( el, mode ) {
  12955. if (mode === "toggle") {
  12956. mode = el.is( ":hidden" ) ? "show" : "hide";
  12957. }
  12958. return mode;
  12959. },
  12960. // Translates a [top,left] array into a baseline value
  12961. // this should be a little more flexible in the future to handle a string & hash
  12962. getBaseline: function( origin, original ) {
  12963. var y, x;
  12964. switch ( origin[ 0 ] ) {
  12965. case "top": y = 0; break;
  12966. case "middle": y = 0.5; break;
  12967. case "bottom": y = 1; break;
  12968. default: y = origin[ 0 ] / original.height;
  12969. }
  12970. switch ( origin[ 1 ] ) {
  12971. case "left": x = 0; break;
  12972. case "center": x = 0.5; break;
  12973. case "right": x = 1; break;
  12974. default: x = origin[ 1 ] / original.width;
  12975. }
  12976. return {
  12977. x: x,
  12978. y: y
  12979. };
  12980. },
  12981. // Wraps the element around a wrapper that copies position properties
  12982. createWrapper: function( element ) {
  12983. // if the element is already wrapped, return it
  12984. if ( element.parent().is( ".ui-effects-wrapper" )) {
  12985. return element.parent();
  12986. }
  12987. // wrap the element
  12988. var props = {
  12989. width: element.outerWidth(true),
  12990. height: element.outerHeight(true),
  12991. "float": element.css( "float" )
  12992. },
  12993. wrapper = $( "<div></div>" )
  12994. .addClass( "ui-effects-wrapper" )
  12995. .css({
  12996. fontSize: "100%",
  12997. background: "transparent",
  12998. border: "none",
  12999. margin: 0,
  13000. padding: 0
  13001. }),
  13002. // Store the size in case width/height are defined in % - Fixes #5245
  13003. size = {
  13004. width: element.width(),
  13005. height: element.height()
  13006. },
  13007. active = document.activeElement;
  13008. // support: Firefox
  13009. // Firefox incorrectly exposes anonymous content
  13010. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  13011. try {
  13012. active.id;
  13013. } catch ( e ) {
  13014. active = document.body;
  13015. }
  13016. element.wrap( wrapper );
  13017. // Fixes #7595 - Elements lose focus when wrapped.
  13018. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  13019. $( active ).focus();
  13020. }
  13021. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  13022. // transfer positioning properties to the wrapper
  13023. if ( element.css( "position" ) === "static" ) {
  13024. wrapper.css({ position: "relative" });
  13025. element.css({ position: "relative" });
  13026. } else {
  13027. $.extend( props, {
  13028. position: element.css( "position" ),
  13029. zIndex: element.css( "z-index" )
  13030. });
  13031. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  13032. props[ pos ] = element.css( pos );
  13033. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  13034. props[ pos ] = "auto";
  13035. }
  13036. });
  13037. element.css({
  13038. position: "relative",
  13039. top: 0,
  13040. left: 0,
  13041. right: "auto",
  13042. bottom: "auto"
  13043. });
  13044. }
  13045. element.css(size);
  13046. return wrapper.css( props ).show();
  13047. },
  13048. removeWrapper: function( element ) {
  13049. var active = document.activeElement;
  13050. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  13051. element.parent().replaceWith( element );
  13052. // Fixes #7595 - Elements lose focus when wrapped.
  13053. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  13054. $( active ).focus();
  13055. }
  13056. }
  13057. return element;
  13058. },
  13059. setTransition: function( element, list, factor, value ) {
  13060. value = value || {};
  13061. $.each( list, function( i, x ) {
  13062. var unit = element.cssUnit( x );
  13063. if ( unit[ 0 ] > 0 ) {
  13064. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  13065. }
  13066. });
  13067. return value;
  13068. }
  13069. });
  13070. // return an effect options object for the given parameters:
  13071. function _normalizeArguments( effect, options, speed, callback ) {
  13072. // allow passing all options as the first parameter
  13073. if ( $.isPlainObject( effect ) ) {
  13074. options = effect;
  13075. effect = effect.effect;
  13076. }
  13077. // convert to an object
  13078. effect = { effect: effect };
  13079. // catch (effect, null, ...)
  13080. if ( options == null ) {
  13081. options = {};
  13082. }
  13083. // catch (effect, callback)
  13084. if ( $.isFunction( options ) ) {
  13085. callback = options;
  13086. speed = null;
  13087. options = {};
  13088. }
  13089. // catch (effect, speed, ?)
  13090. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  13091. callback = speed;
  13092. speed = options;
  13093. options = {};
  13094. }
  13095. // catch (effect, options, callback)
  13096. if ( $.isFunction( speed ) ) {
  13097. callback = speed;
  13098. speed = null;
  13099. }
  13100. // add options to effect
  13101. if ( options ) {
  13102. $.extend( effect, options );
  13103. }
  13104. speed = speed || options.duration;
  13105. effect.duration = $.fx.off ? 0 :
  13106. typeof speed === "number" ? speed :
  13107. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  13108. $.fx.speeds._default;
  13109. effect.complete = callback || options.complete;
  13110. return effect;
  13111. }
  13112. function standardAnimationOption( option ) {
  13113. // Valid standard speeds (nothing, number, named speed)
  13114. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  13115. return true;
  13116. }
  13117. // Invalid strings - treat as "normal" speed
  13118. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  13119. return true;
  13120. }
  13121. // Complete callback
  13122. if ( $.isFunction( option ) ) {
  13123. return true;
  13124. }
  13125. // Options hash (but not naming an effect)
  13126. if ( typeof option === "object" && !option.effect ) {
  13127. return true;
  13128. }
  13129. // Didn't match any standard API
  13130. return false;
  13131. }
  13132. $.fn.extend({
  13133. effect: function( /* effect, options, speed, callback */ ) {
  13134. var args = _normalizeArguments.apply( this, arguments ),
  13135. mode = args.mode,
  13136. queue = args.queue,
  13137. effectMethod = $.effects.effect[ args.effect ];
  13138. if ( $.fx.off || !effectMethod ) {
  13139. // delegate to the original method (e.g., .show()) if possible
  13140. if ( mode ) {
  13141. return this[ mode ]( args.duration, args.complete );
  13142. } else {
  13143. return this.each( function() {
  13144. if ( args.complete ) {
  13145. args.complete.call( this );
  13146. }
  13147. });
  13148. }
  13149. }
  13150. function run( next ) {
  13151. var elem = $( this ),
  13152. complete = args.complete,
  13153. mode = args.mode;
  13154. function done() {
  13155. if ( $.isFunction( complete ) ) {
  13156. complete.call( elem[0] );
  13157. }
  13158. if ( $.isFunction( next ) ) {
  13159. next();
  13160. }
  13161. }
  13162. // If the element already has the correct final state, delegate to
  13163. // the core methods so the internal tracking of "olddisplay" works.
  13164. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  13165. elem[ mode ]();
  13166. done();
  13167. } else {
  13168. effectMethod.call( elem[0], args, done );
  13169. }
  13170. }
  13171. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  13172. },
  13173. show: (function( orig ) {
  13174. return function( option ) {
  13175. if ( standardAnimationOption( option ) ) {
  13176. return orig.apply( this, arguments );
  13177. } else {
  13178. var args = _normalizeArguments.apply( this, arguments );
  13179. args.mode = "show";
  13180. return this.effect.call( this, args );
  13181. }
  13182. };
  13183. })( $.fn.show ),
  13184. hide: (function( orig ) {
  13185. return function( option ) {
  13186. if ( standardAnimationOption( option ) ) {
  13187. return orig.apply( this, arguments );
  13188. } else {
  13189. var args = _normalizeArguments.apply( this, arguments );
  13190. args.mode = "hide";
  13191. return this.effect.call( this, args );
  13192. }
  13193. };
  13194. })( $.fn.hide ),
  13195. toggle: (function( orig ) {
  13196. return function( option ) {
  13197. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  13198. return orig.apply( this, arguments );
  13199. } else {
  13200. var args = _normalizeArguments.apply( this, arguments );
  13201. args.mode = "toggle";
  13202. return this.effect.call( this, args );
  13203. }
  13204. };
  13205. })( $.fn.toggle ),
  13206. // helper functions
  13207. cssUnit: function(key) {
  13208. var style = this.css( key ),
  13209. val = [];
  13210. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  13211. if ( style.indexOf( unit ) > 0 ) {
  13212. val = [ parseFloat( style ), unit ];
  13213. }
  13214. });
  13215. return val;
  13216. }
  13217. });
  13218. })();
  13219. /******************************************************************************/
  13220. /*********************************** EASING ***********************************/
  13221. /******************************************************************************/
  13222. (function() {
  13223. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  13224. var baseEasings = {};
  13225. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  13226. baseEasings[ name ] = function( p ) {
  13227. return Math.pow( p, i + 2 );
  13228. };
  13229. });
  13230. $.extend( baseEasings, {
  13231. Sine: function( p ) {
  13232. return 1 - Math.cos( p * Math.PI / 2 );
  13233. },
  13234. Circ: function( p ) {
  13235. return 1 - Math.sqrt( 1 - p * p );
  13236. },
  13237. Elastic: function( p ) {
  13238. return p === 0 || p === 1 ? p :
  13239. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  13240. },
  13241. Back: function( p ) {
  13242. return p * p * ( 3 * p - 2 );
  13243. },
  13244. Bounce: function( p ) {
  13245. var pow2,
  13246. bounce = 4;
  13247. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  13248. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  13249. }
  13250. });
  13251. $.each( baseEasings, function( name, easeIn ) {
  13252. $.easing[ "easeIn" + name ] = easeIn;
  13253. $.easing[ "easeOut" + name ] = function( p ) {
  13254. return 1 - easeIn( 1 - p );
  13255. };
  13256. $.easing[ "easeInOut" + name ] = function( p ) {
  13257. return p < 0.5 ?
  13258. easeIn( p * 2 ) / 2 :
  13259. 1 - easeIn( p * -2 + 2 ) / 2;
  13260. };
  13261. });
  13262. })();
  13263. var effect = $.effects;
  13264. /*!
  13265. * jQuery UI Effects Blind 1.11.4
  13266. * http://jqueryui.com
  13267. *
  13268. * Copyright jQuery Foundation and other contributors
  13269. * Released under the MIT license.
  13270. * http://jquery.org/license
  13271. *
  13272. * http://api.jqueryui.com/blind-effect/
  13273. */
  13274. var effectBlind = $.effects.effect.blind = function( o, done ) {
  13275. // Create element
  13276. var el = $( this ),
  13277. rvertical = /up|down|vertical/,
  13278. rpositivemotion = /up|left|vertical|horizontal/,
  13279. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13280. mode = $.effects.setMode( el, o.mode || "hide" ),
  13281. direction = o.direction || "up",
  13282. vertical = rvertical.test( direction ),
  13283. ref = vertical ? "height" : "width",
  13284. ref2 = vertical ? "top" : "left",
  13285. motion = rpositivemotion.test( direction ),
  13286. animation = {},
  13287. show = mode === "show",
  13288. wrapper, distance, margin;
  13289. // if already wrapped, the wrapper's properties are my property. #6245
  13290. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  13291. $.effects.save( el.parent(), props );
  13292. } else {
  13293. $.effects.save( el, props );
  13294. }
  13295. el.show();
  13296. wrapper = $.effects.createWrapper( el ).css({
  13297. overflow: "hidden"
  13298. });
  13299. distance = wrapper[ ref ]();
  13300. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  13301. animation[ ref ] = show ? distance : 0;
  13302. if ( !motion ) {
  13303. el
  13304. .css( vertical ? "bottom" : "right", 0 )
  13305. .css( vertical ? "top" : "left", "auto" )
  13306. .css({ position: "absolute" });
  13307. animation[ ref2 ] = show ? margin : distance + margin;
  13308. }
  13309. // start at 0 if we are showing
  13310. if ( show ) {
  13311. wrapper.css( ref, 0 );
  13312. if ( !motion ) {
  13313. wrapper.css( ref2, margin + distance );
  13314. }
  13315. }
  13316. // Animate
  13317. wrapper.animate( animation, {
  13318. duration: o.duration,
  13319. easing: o.easing,
  13320. queue: false,
  13321. complete: function() {
  13322. if ( mode === "hide" ) {
  13323. el.hide();
  13324. }
  13325. $.effects.restore( el, props );
  13326. $.effects.removeWrapper( el );
  13327. done();
  13328. }
  13329. });
  13330. };
  13331. /*!
  13332. * jQuery UI Effects Bounce 1.11.4
  13333. * http://jqueryui.com
  13334. *
  13335. * Copyright jQuery Foundation and other contributors
  13336. * Released under the MIT license.
  13337. * http://jquery.org/license
  13338. *
  13339. * http://api.jqueryui.com/bounce-effect/
  13340. */
  13341. var effectBounce = $.effects.effect.bounce = function( o, done ) {
  13342. var el = $( this ),
  13343. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13344. // defaults:
  13345. mode = $.effects.setMode( el, o.mode || "effect" ),
  13346. hide = mode === "hide",
  13347. show = mode === "show",
  13348. direction = o.direction || "up",
  13349. distance = o.distance,
  13350. times = o.times || 5,
  13351. // number of internal animations
  13352. anims = times * 2 + ( show || hide ? 1 : 0 ),
  13353. speed = o.duration / anims,
  13354. easing = o.easing,
  13355. // utility:
  13356. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  13357. motion = ( direction === "up" || direction === "left" ),
  13358. i,
  13359. upAnim,
  13360. downAnim,
  13361. // we will need to re-assemble the queue to stack our animations in place
  13362. queue = el.queue(),
  13363. queuelen = queue.length;
  13364. // Avoid touching opacity to prevent clearType and PNG issues in IE
  13365. if ( show || hide ) {
  13366. props.push( "opacity" );
  13367. }
  13368. $.effects.save( el, props );
  13369. el.show();
  13370. $.effects.createWrapper( el ); // Create Wrapper
  13371. // default distance for the BIGGEST bounce is the outer Distance / 3
  13372. if ( !distance ) {
  13373. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  13374. }
  13375. if ( show ) {
  13376. downAnim = { opacity: 1 };
  13377. downAnim[ ref ] = 0;
  13378. // if we are showing, force opacity 0 and set the initial position
  13379. // then do the "first" animation
  13380. el.css( "opacity", 0 )
  13381. .css( ref, motion ? -distance * 2 : distance * 2 )
  13382. .animate( downAnim, speed, easing );
  13383. }
  13384. // start at the smallest distance if we are hiding
  13385. if ( hide ) {
  13386. distance = distance / Math.pow( 2, times - 1 );
  13387. }
  13388. downAnim = {};
  13389. downAnim[ ref ] = 0;
  13390. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  13391. for ( i = 0; i < times; i++ ) {
  13392. upAnim = {};
  13393. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  13394. el.animate( upAnim, speed, easing )
  13395. .animate( downAnim, speed, easing );
  13396. distance = hide ? distance * 2 : distance / 2;
  13397. }
  13398. // Last Bounce when Hiding
  13399. if ( hide ) {
  13400. upAnim = { opacity: 0 };
  13401. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  13402. el.animate( upAnim, speed, easing );
  13403. }
  13404. el.queue(function() {
  13405. if ( hide ) {
  13406. el.hide();
  13407. }
  13408. $.effects.restore( el, props );
  13409. $.effects.removeWrapper( el );
  13410. done();
  13411. });
  13412. // inject all the animations we just queued to be first in line (after "inprogress")
  13413. if ( queuelen > 1) {
  13414. queue.splice.apply( queue,
  13415. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  13416. }
  13417. el.dequeue();
  13418. };
  13419. /*!
  13420. * jQuery UI Effects Clip 1.11.4
  13421. * http://jqueryui.com
  13422. *
  13423. * Copyright jQuery Foundation and other contributors
  13424. * Released under the MIT license.
  13425. * http://jquery.org/license
  13426. *
  13427. * http://api.jqueryui.com/clip-effect/
  13428. */
  13429. var effectClip = $.effects.effect.clip = function( o, done ) {
  13430. // Create element
  13431. var el = $( this ),
  13432. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13433. mode = $.effects.setMode( el, o.mode || "hide" ),
  13434. show = mode === "show",
  13435. direction = o.direction || "vertical",
  13436. vert = direction === "vertical",
  13437. size = vert ? "height" : "width",
  13438. position = vert ? "top" : "left",
  13439. animation = {},
  13440. wrapper, animate, distance;
  13441. // Save & Show
  13442. $.effects.save( el, props );
  13443. el.show();
  13444. // Create Wrapper
  13445. wrapper = $.effects.createWrapper( el ).css({
  13446. overflow: "hidden"
  13447. });
  13448. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  13449. distance = animate[ size ]();
  13450. // Shift
  13451. if ( show ) {
  13452. animate.css( size, 0 );
  13453. animate.css( position, distance / 2 );
  13454. }
  13455. // Create Animation Object:
  13456. animation[ size ] = show ? distance : 0;
  13457. animation[ position ] = show ? 0 : distance / 2;
  13458. // Animate
  13459. animate.animate( animation, {
  13460. queue: false,
  13461. duration: o.duration,
  13462. easing: o.easing,
  13463. complete: function() {
  13464. if ( !show ) {
  13465. el.hide();
  13466. }
  13467. $.effects.restore( el, props );
  13468. $.effects.removeWrapper( el );
  13469. done();
  13470. }
  13471. });
  13472. };
  13473. /*!
  13474. * jQuery UI Effects Drop 1.11.4
  13475. * http://jqueryui.com
  13476. *
  13477. * Copyright jQuery Foundation and other contributors
  13478. * Released under the MIT license.
  13479. * http://jquery.org/license
  13480. *
  13481. * http://api.jqueryui.com/drop-effect/
  13482. */
  13483. var effectDrop = $.effects.effect.drop = function( o, done ) {
  13484. var el = $( this ),
  13485. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  13486. mode = $.effects.setMode( el, o.mode || "hide" ),
  13487. show = mode === "show",
  13488. direction = o.direction || "left",
  13489. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  13490. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  13491. animation = {
  13492. opacity: show ? 1 : 0
  13493. },
  13494. distance;
  13495. // Adjust
  13496. $.effects.save( el, props );
  13497. el.show();
  13498. $.effects.createWrapper( el );
  13499. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  13500. if ( show ) {
  13501. el
  13502. .css( "opacity", 0 )
  13503. .css( ref, motion === "pos" ? -distance : distance );
  13504. }
  13505. // Animation
  13506. animation[ ref ] = ( show ?
  13507. ( motion === "pos" ? "+=" : "-=" ) :
  13508. ( motion === "pos" ? "-=" : "+=" ) ) +
  13509. distance;
  13510. // Animate
  13511. el.animate( animation, {
  13512. queue: false,
  13513. duration: o.duration,
  13514. easing: o.easing,
  13515. complete: function() {
  13516. if ( mode === "hide" ) {
  13517. el.hide();
  13518. }
  13519. $.effects.restore( el, props );
  13520. $.effects.removeWrapper( el );
  13521. done();
  13522. }
  13523. });
  13524. };
  13525. /*!
  13526. * jQuery UI Effects Explode 1.11.4
  13527. * http://jqueryui.com
  13528. *
  13529. * Copyright jQuery Foundation and other contributors
  13530. * Released under the MIT license.
  13531. * http://jquery.org/license
  13532. *
  13533. * http://api.jqueryui.com/explode-effect/
  13534. */
  13535. var effectExplode = $.effects.effect.explode = function( o, done ) {
  13536. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  13537. cells = rows,
  13538. el = $( this ),
  13539. mode = $.effects.setMode( el, o.mode || "hide" ),
  13540. show = mode === "show",
  13541. // show and then visibility:hidden the element before calculating offset
  13542. offset = el.show().css( "visibility", "hidden" ).offset(),
  13543. // width and height of a piece
  13544. width = Math.ceil( el.outerWidth() / cells ),
  13545. height = Math.ceil( el.outerHeight() / rows ),
  13546. pieces = [],
  13547. // loop
  13548. i, j, left, top, mx, my;
  13549. // children animate complete:
  13550. function childComplete() {
  13551. pieces.push( this );
  13552. if ( pieces.length === rows * cells ) {
  13553. animComplete();
  13554. }
  13555. }
  13556. // clone the element for each row and cell.
  13557. for ( i = 0; i < rows ; i++ ) { // ===>
  13558. top = offset.top + i * height;
  13559. my = i - ( rows - 1 ) / 2 ;
  13560. for ( j = 0; j < cells ; j++ ) { // |||
  13561. left = offset.left + j * width;
  13562. mx = j - ( cells - 1 ) / 2 ;
  13563. // Create a clone of the now hidden main element that will be absolute positioned
  13564. // within a wrapper div off the -left and -top equal to size of our pieces
  13565. el
  13566. .clone()
  13567. .appendTo( "body" )
  13568. .wrap( "<div></div>" )
  13569. .css({
  13570. position: "absolute",
  13571. visibility: "visible",
  13572. left: -j * width,
  13573. top: -i * height
  13574. })
  13575. // select the wrapper - make it overflow: hidden and absolute positioned based on
  13576. // where the original was located +left and +top equal to the size of pieces
  13577. .parent()
  13578. .addClass( "ui-effects-explode" )
  13579. .css({
  13580. position: "absolute",
  13581. overflow: "hidden",
  13582. width: width,
  13583. height: height,
  13584. left: left + ( show ? mx * width : 0 ),
  13585. top: top + ( show ? my * height : 0 ),
  13586. opacity: show ? 0 : 1
  13587. }).animate({
  13588. left: left + ( show ? 0 : mx * width ),
  13589. top: top + ( show ? 0 : my * height ),
  13590. opacity: show ? 1 : 0
  13591. }, o.duration || 500, o.easing, childComplete );
  13592. }
  13593. }
  13594. function animComplete() {
  13595. el.css({
  13596. visibility: "visible"
  13597. });
  13598. $( pieces ).remove();
  13599. if ( !show ) {
  13600. el.hide();
  13601. }
  13602. done();
  13603. }
  13604. };
  13605. /*!
  13606. * jQuery UI Effects Fade 1.11.4
  13607. * http://jqueryui.com
  13608. *
  13609. * Copyright jQuery Foundation and other contributors
  13610. * Released under the MIT license.
  13611. * http://jquery.org/license
  13612. *
  13613. * http://api.jqueryui.com/fade-effect/
  13614. */
  13615. var effectFade = $.effects.effect.fade = function( o, done ) {
  13616. var el = $( this ),
  13617. mode = $.effects.setMode( el, o.mode || "toggle" );
  13618. el.animate({
  13619. opacity: mode
  13620. }, {
  13621. queue: false,
  13622. duration: o.duration,
  13623. easing: o.easing,
  13624. complete: done
  13625. });
  13626. };
  13627. /*!
  13628. * jQuery UI Effects Fold 1.11.4
  13629. * http://jqueryui.com
  13630. *
  13631. * Copyright jQuery Foundation and other contributors
  13632. * Released under the MIT license.
  13633. * http://jquery.org/license
  13634. *
  13635. * http://api.jqueryui.com/fold-effect/
  13636. */
  13637. var effectFold = $.effects.effect.fold = function( o, done ) {
  13638. // Create element
  13639. var el = $( this ),
  13640. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13641. mode = $.effects.setMode( el, o.mode || "hide" ),
  13642. show = mode === "show",
  13643. hide = mode === "hide",
  13644. size = o.size || 15,
  13645. percent = /([0-9]+)%/.exec( size ),
  13646. horizFirst = !!o.horizFirst,
  13647. widthFirst = show !== horizFirst,
  13648. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  13649. duration = o.duration / 2,
  13650. wrapper, distance,
  13651. animation1 = {},
  13652. animation2 = {};
  13653. $.effects.save( el, props );
  13654. el.show();
  13655. // Create Wrapper
  13656. wrapper = $.effects.createWrapper( el ).css({
  13657. overflow: "hidden"
  13658. });
  13659. distance = widthFirst ?
  13660. [ wrapper.width(), wrapper.height() ] :
  13661. [ wrapper.height(), wrapper.width() ];
  13662. if ( percent ) {
  13663. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  13664. }
  13665. if ( show ) {
  13666. wrapper.css( horizFirst ? {
  13667. height: 0,
  13668. width: size
  13669. } : {
  13670. height: size,
  13671. width: 0
  13672. });
  13673. }
  13674. // Animation
  13675. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  13676. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  13677. // Animate
  13678. wrapper
  13679. .animate( animation1, duration, o.easing )
  13680. .animate( animation2, duration, o.easing, function() {
  13681. if ( hide ) {
  13682. el.hide();
  13683. }
  13684. $.effects.restore( el, props );
  13685. $.effects.removeWrapper( el );
  13686. done();
  13687. });
  13688. };
  13689. /*!
  13690. * jQuery UI Effects Highlight 1.11.4
  13691. * http://jqueryui.com
  13692. *
  13693. * Copyright jQuery Foundation and other contributors
  13694. * Released under the MIT license.
  13695. * http://jquery.org/license
  13696. *
  13697. * http://api.jqueryui.com/highlight-effect/
  13698. */
  13699. var effectHighlight = $.effects.effect.highlight = function( o, done ) {
  13700. var elem = $( this ),
  13701. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  13702. mode = $.effects.setMode( elem, o.mode || "show" ),
  13703. animation = {
  13704. backgroundColor: elem.css( "backgroundColor" )
  13705. };
  13706. if (mode === "hide") {
  13707. animation.opacity = 0;
  13708. }
  13709. $.effects.save( elem, props );
  13710. elem
  13711. .show()
  13712. .css({
  13713. backgroundImage: "none",
  13714. backgroundColor: o.color || "#ffff99"
  13715. })
  13716. .animate( animation, {
  13717. queue: false,
  13718. duration: o.duration,
  13719. easing: o.easing,
  13720. complete: function() {
  13721. if ( mode === "hide" ) {
  13722. elem.hide();
  13723. }
  13724. $.effects.restore( elem, props );
  13725. done();
  13726. }
  13727. });
  13728. };
  13729. /*!
  13730. * jQuery UI Effects Size 1.11.4
  13731. * http://jqueryui.com
  13732. *
  13733. * Copyright jQuery Foundation and other contributors
  13734. * Released under the MIT license.
  13735. * http://jquery.org/license
  13736. *
  13737. * http://api.jqueryui.com/size-effect/
  13738. */
  13739. var effectSize = $.effects.effect.size = function( o, done ) {
  13740. // Create element
  13741. var original, baseline, factor,
  13742. el = $( this ),
  13743. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  13744. // Always restore
  13745. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  13746. // Copy for children
  13747. props2 = [ "width", "height", "overflow" ],
  13748. cProps = [ "fontSize" ],
  13749. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  13750. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  13751. // Set options
  13752. mode = $.effects.setMode( el, o.mode || "effect" ),
  13753. restore = o.restore || mode !== "effect",
  13754. scale = o.scale || "both",
  13755. origin = o.origin || [ "middle", "center" ],
  13756. position = el.css( "position" ),
  13757. props = restore ? props0 : props1,
  13758. zero = {
  13759. height: 0,
  13760. width: 0,
  13761. outerHeight: 0,
  13762. outerWidth: 0
  13763. };
  13764. if ( mode === "show" ) {
  13765. el.show();
  13766. }
  13767. original = {
  13768. height: el.height(),
  13769. width: el.width(),
  13770. outerHeight: el.outerHeight(),
  13771. outerWidth: el.outerWidth()
  13772. };
  13773. if ( o.mode === "toggle" && mode === "show" ) {
  13774. el.from = o.to || zero;
  13775. el.to = o.from || original;
  13776. } else {
  13777. el.from = o.from || ( mode === "show" ? zero : original );
  13778. el.to = o.to || ( mode === "hide" ? zero : original );
  13779. }
  13780. // Set scaling factor
  13781. factor = {
  13782. from: {
  13783. y: el.from.height / original.height,
  13784. x: el.from.width / original.width
  13785. },
  13786. to: {
  13787. y: el.to.height / original.height,
  13788. x: el.to.width / original.width
  13789. }
  13790. };
  13791. // Scale the css box
  13792. if ( scale === "box" || scale === "both" ) {
  13793. // Vertical props scaling
  13794. if ( factor.from.y !== factor.to.y ) {
  13795. props = props.concat( vProps );
  13796. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  13797. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  13798. }
  13799. // Horizontal props scaling
  13800. if ( factor.from.x !== factor.to.x ) {
  13801. props = props.concat( hProps );
  13802. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  13803. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  13804. }
  13805. }
  13806. // Scale the content
  13807. if ( scale === "content" || scale === "both" ) {
  13808. // Vertical props scaling
  13809. if ( factor.from.y !== factor.to.y ) {
  13810. props = props.concat( cProps ).concat( props2 );
  13811. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  13812. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  13813. }
  13814. }
  13815. $.effects.save( el, props );
  13816. el.show();
  13817. $.effects.createWrapper( el );
  13818. el.css( "overflow", "hidden" ).css( el.from );
  13819. // Adjust
  13820. if (origin) { // Calculate baseline shifts
  13821. baseline = $.effects.getBaseline( origin, original );
  13822. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  13823. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  13824. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  13825. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  13826. }
  13827. el.css( el.from ); // set top & left
  13828. // Animate
  13829. if ( scale === "content" || scale === "both" ) { // Scale the children
  13830. // Add margins/font-size
  13831. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  13832. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  13833. props2 = props0.concat(vProps).concat(hProps);
  13834. el.find( "*[width]" ).each( function() {
  13835. var child = $( this ),
  13836. c_original = {
  13837. height: child.height(),
  13838. width: child.width(),
  13839. outerHeight: child.outerHeight(),
  13840. outerWidth: child.outerWidth()
  13841. };
  13842. if (restore) {
  13843. $.effects.save(child, props2);
  13844. }
  13845. child.from = {
  13846. height: c_original.height * factor.from.y,
  13847. width: c_original.width * factor.from.x,
  13848. outerHeight: c_original.outerHeight * factor.from.y,
  13849. outerWidth: c_original.outerWidth * factor.from.x
  13850. };
  13851. child.to = {
  13852. height: c_original.height * factor.to.y,
  13853. width: c_original.width * factor.to.x,
  13854. outerHeight: c_original.height * factor.to.y,
  13855. outerWidth: c_original.width * factor.to.x
  13856. };
  13857. // Vertical props scaling
  13858. if ( factor.from.y !== factor.to.y ) {
  13859. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  13860. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  13861. }
  13862. // Horizontal props scaling
  13863. if ( factor.from.x !== factor.to.x ) {
  13864. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  13865. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  13866. }
  13867. // Animate children
  13868. child.css( child.from );
  13869. child.animate( child.to, o.duration, o.easing, function() {
  13870. // Restore children
  13871. if ( restore ) {
  13872. $.effects.restore( child, props2 );
  13873. }
  13874. });
  13875. });
  13876. }
  13877. // Animate
  13878. el.animate( el.to, {
  13879. queue: false,
  13880. duration: o.duration,
  13881. easing: o.easing,
  13882. complete: function() {
  13883. if ( el.to.opacity === 0 ) {
  13884. el.css( "opacity", el.from.opacity );
  13885. }
  13886. if ( mode === "hide" ) {
  13887. el.hide();
  13888. }
  13889. $.effects.restore( el, props );
  13890. if ( !restore ) {
  13891. // we need to calculate our new positioning based on the scaling
  13892. if ( position === "static" ) {
  13893. el.css({
  13894. position: "relative",
  13895. top: el.to.top,
  13896. left: el.to.left
  13897. });
  13898. } else {
  13899. $.each([ "top", "left" ], function( idx, pos ) {
  13900. el.css( pos, function( _, str ) {
  13901. var val = parseInt( str, 10 ),
  13902. toRef = idx ? el.to.left : el.to.top;
  13903. // if original was "auto", recalculate the new value from wrapper
  13904. if ( str === "auto" ) {
  13905. return toRef + "px";
  13906. }
  13907. return val + toRef + "px";
  13908. });
  13909. });
  13910. }
  13911. }
  13912. $.effects.removeWrapper( el );
  13913. done();
  13914. }
  13915. });
  13916. };
  13917. /*!
  13918. * jQuery UI Effects Scale 1.11.4
  13919. * http://jqueryui.com
  13920. *
  13921. * Copyright jQuery Foundation and other contributors
  13922. * Released under the MIT license.
  13923. * http://jquery.org/license
  13924. *
  13925. * http://api.jqueryui.com/scale-effect/
  13926. */
  13927. var effectScale = $.effects.effect.scale = function( o, done ) {
  13928. // Create element
  13929. var el = $( this ),
  13930. options = $.extend( true, {}, o ),
  13931. mode = $.effects.setMode( el, o.mode || "effect" ),
  13932. percent = parseInt( o.percent, 10 ) ||
  13933. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  13934. direction = o.direction || "both",
  13935. origin = o.origin,
  13936. original = {
  13937. height: el.height(),
  13938. width: el.width(),
  13939. outerHeight: el.outerHeight(),
  13940. outerWidth: el.outerWidth()
  13941. },
  13942. factor = {
  13943. y: direction !== "horizontal" ? (percent / 100) : 1,
  13944. x: direction !== "vertical" ? (percent / 100) : 1
  13945. };
  13946. // We are going to pass this effect to the size effect:
  13947. options.effect = "size";
  13948. options.queue = false;
  13949. options.complete = done;
  13950. // Set default origin and restore for show/hide
  13951. if ( mode !== "effect" ) {
  13952. options.origin = origin || [ "middle", "center" ];
  13953. options.restore = true;
  13954. }
  13955. options.from = o.from || ( mode === "show" ? {
  13956. height: 0,
  13957. width: 0,
  13958. outerHeight: 0,
  13959. outerWidth: 0
  13960. } : original );
  13961. options.to = {
  13962. height: original.height * factor.y,
  13963. width: original.width * factor.x,
  13964. outerHeight: original.outerHeight * factor.y,
  13965. outerWidth: original.outerWidth * factor.x
  13966. };
  13967. // Fade option to support puff
  13968. if ( options.fade ) {
  13969. if ( mode === "show" ) {
  13970. options.from.opacity = 0;
  13971. options.to.opacity = 1;
  13972. }
  13973. if ( mode === "hide" ) {
  13974. options.from.opacity = 1;
  13975. options.to.opacity = 0;
  13976. }
  13977. }
  13978. // Animate
  13979. el.effect( options );
  13980. };
  13981. /*!
  13982. * jQuery UI Effects Puff 1.11.4
  13983. * http://jqueryui.com
  13984. *
  13985. * Copyright jQuery Foundation and other contributors
  13986. * Released under the MIT license.
  13987. * http://jquery.org/license
  13988. *
  13989. * http://api.jqueryui.com/puff-effect/
  13990. */
  13991. var effectPuff = $.effects.effect.puff = function( o, done ) {
  13992. var elem = $( this ),
  13993. mode = $.effects.setMode( elem, o.mode || "hide" ),
  13994. hide = mode === "hide",
  13995. percent = parseInt( o.percent, 10 ) || 150,
  13996. factor = percent / 100,
  13997. original = {
  13998. height: elem.height(),
  13999. width: elem.width(),
  14000. outerHeight: elem.outerHeight(),
  14001. outerWidth: elem.outerWidth()
  14002. };
  14003. $.extend( o, {
  14004. effect: "scale",
  14005. queue: false,
  14006. fade: true,
  14007. mode: mode,
  14008. complete: done,
  14009. percent: hide ? percent : 100,
  14010. from: hide ?
  14011. original :
  14012. {
  14013. height: original.height * factor,
  14014. width: original.width * factor,
  14015. outerHeight: original.outerHeight * factor,
  14016. outerWidth: original.outerWidth * factor
  14017. }
  14018. });
  14019. elem.effect( o );
  14020. };
  14021. /*!
  14022. * jQuery UI Effects Pulsate 1.11.4
  14023. * http://jqueryui.com
  14024. *
  14025. * Copyright jQuery Foundation and other contributors
  14026. * Released under the MIT license.
  14027. * http://jquery.org/license
  14028. *
  14029. * http://api.jqueryui.com/pulsate-effect/
  14030. */
  14031. var effectPulsate = $.effects.effect.pulsate = function( o, done ) {
  14032. var elem = $( this ),
  14033. mode = $.effects.setMode( elem, o.mode || "show" ),
  14034. show = mode === "show",
  14035. hide = mode === "hide",
  14036. showhide = ( show || mode === "hide" ),
  14037. // showing or hiding leaves of the "last" animation
  14038. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  14039. duration = o.duration / anims,
  14040. animateTo = 0,
  14041. queue = elem.queue(),
  14042. queuelen = queue.length,
  14043. i;
  14044. if ( show || !elem.is(":visible")) {
  14045. elem.css( "opacity", 0 ).show();
  14046. animateTo = 1;
  14047. }
  14048. // anims - 1 opacity "toggles"
  14049. for ( i = 1; i < anims; i++ ) {
  14050. elem.animate({
  14051. opacity: animateTo
  14052. }, duration, o.easing );
  14053. animateTo = 1 - animateTo;
  14054. }
  14055. elem.animate({
  14056. opacity: animateTo
  14057. }, duration, o.easing);
  14058. elem.queue(function() {
  14059. if ( hide ) {
  14060. elem.hide();
  14061. }
  14062. done();
  14063. });
  14064. // We just queued up "anims" animations, we need to put them next in the queue
  14065. if ( queuelen > 1 ) {
  14066. queue.splice.apply( queue,
  14067. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  14068. }
  14069. elem.dequeue();
  14070. };
  14071. /*!
  14072. * jQuery UI Effects Shake 1.11.4
  14073. * http://jqueryui.com
  14074. *
  14075. * Copyright jQuery Foundation and other contributors
  14076. * Released under the MIT license.
  14077. * http://jquery.org/license
  14078. *
  14079. * http://api.jqueryui.com/shake-effect/
  14080. */
  14081. var effectShake = $.effects.effect.shake = function( o, done ) {
  14082. var el = $( this ),
  14083. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  14084. mode = $.effects.setMode( el, o.mode || "effect" ),
  14085. direction = o.direction || "left",
  14086. distance = o.distance || 20,
  14087. times = o.times || 3,
  14088. anims = times * 2 + 1,
  14089. speed = Math.round( o.duration / anims ),
  14090. ref = (direction === "up" || direction === "down") ? "top" : "left",
  14091. positiveMotion = (direction === "up" || direction === "left"),
  14092. animation = {},
  14093. animation1 = {},
  14094. animation2 = {},
  14095. i,
  14096. // we will need to re-assemble the queue to stack our animations in place
  14097. queue = el.queue(),
  14098. queuelen = queue.length;
  14099. $.effects.save( el, props );
  14100. el.show();
  14101. $.effects.createWrapper( el );
  14102. // Animation
  14103. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  14104. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  14105. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  14106. // Animate
  14107. el.animate( animation, speed, o.easing );
  14108. // Shakes
  14109. for ( i = 1; i < times; i++ ) {
  14110. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  14111. }
  14112. el
  14113. .animate( animation1, speed, o.easing )
  14114. .animate( animation, speed / 2, o.easing )
  14115. .queue(function() {
  14116. if ( mode === "hide" ) {
  14117. el.hide();
  14118. }
  14119. $.effects.restore( el, props );
  14120. $.effects.removeWrapper( el );
  14121. done();
  14122. });
  14123. // inject all the animations we just queued to be first in line (after "inprogress")
  14124. if ( queuelen > 1) {
  14125. queue.splice.apply( queue,
  14126. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  14127. }
  14128. el.dequeue();
  14129. };
  14130. /*!
  14131. * jQuery UI Effects Slide 1.11.4
  14132. * http://jqueryui.com
  14133. *
  14134. * Copyright jQuery Foundation and other contributors
  14135. * Released under the MIT license.
  14136. * http://jquery.org/license
  14137. *
  14138. * http://api.jqueryui.com/slide-effect/
  14139. */
  14140. var effectSlide = $.effects.effect.slide = function( o, done ) {
  14141. // Create element
  14142. var el = $( this ),
  14143. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  14144. mode = $.effects.setMode( el, o.mode || "show" ),
  14145. show = mode === "show",
  14146. direction = o.direction || "left",
  14147. ref = (direction === "up" || direction === "down") ? "top" : "left",
  14148. positiveMotion = (direction === "up" || direction === "left"),
  14149. distance,
  14150. animation = {};
  14151. // Adjust
  14152. $.effects.save( el, props );
  14153. el.show();
  14154. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  14155. $.effects.createWrapper( el ).css({
  14156. overflow: "hidden"
  14157. });
  14158. if ( show ) {
  14159. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  14160. }
  14161. // Animation
  14162. animation[ ref ] = ( show ?
  14163. ( positiveMotion ? "+=" : "-=") :
  14164. ( positiveMotion ? "-=" : "+=")) +
  14165. distance;
  14166. // Animate
  14167. el.animate( animation, {
  14168. queue: false,
  14169. duration: o.duration,
  14170. easing: o.easing,
  14171. complete: function() {
  14172. if ( mode === "hide" ) {
  14173. el.hide();
  14174. }
  14175. $.effects.restore( el, props );
  14176. $.effects.removeWrapper( el );
  14177. done();
  14178. }
  14179. });
  14180. };
  14181. /*!
  14182. * jQuery UI Effects Transfer 1.11.4
  14183. * http://jqueryui.com
  14184. *
  14185. * Copyright jQuery Foundation and other contributors
  14186. * Released under the MIT license.
  14187. * http://jquery.org/license
  14188. *
  14189. * http://api.jqueryui.com/transfer-effect/
  14190. */
  14191. var effectTransfer = $.effects.effect.transfer = function( o, done ) {
  14192. var elem = $( this ),
  14193. target = $( o.to ),
  14194. targetFixed = target.css( "position" ) === "fixed",
  14195. body = $("body"),
  14196. fixTop = targetFixed ? body.scrollTop() : 0,
  14197. fixLeft = targetFixed ? body.scrollLeft() : 0,
  14198. endPosition = target.offset(),
  14199. animation = {
  14200. top: endPosition.top - fixTop,
  14201. left: endPosition.left - fixLeft,
  14202. height: target.innerHeight(),
  14203. width: target.innerWidth()
  14204. },
  14205. startPosition = elem.offset(),
  14206. transfer = $( "<div class='ui-effects-transfer'></div>" )
  14207. .appendTo( document.body )
  14208. .addClass( o.className )
  14209. .css({
  14210. top: startPosition.top - fixTop,
  14211. left: startPosition.left - fixLeft,
  14212. height: elem.innerHeight(),
  14213. width: elem.innerWidth(),
  14214. position: targetFixed ? "fixed" : "absolute"
  14215. })
  14216. .animate( animation, o.duration, o.easing, function() {
  14217. transfer.remove();
  14218. done();
  14219. });
  14220. };
  14221. }));