jquery-ui.js 458 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582
  1. /*! jQuery UI - v1.11.2 - 2014-10-26
  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 2014 jQuery Foundation and other contributors; Licensed MIT */
  5. (function( factory ) {
  6. if ( typeof define === "function" && define.amd ) {
  7. // AMD. Register as an anonymous module.
  8. define([ "jquery" ], factory );
  9. } else {
  10. // Browser globals
  11. factory( jQuery );
  12. }
  13. }(function( $ ) {
  14. /*!
  15. * jQuery UI Core 1.11.2
  16. * http://jqueryui.com
  17. *
  18. * Copyright 2014 jQuery Foundation and other contributors
  19. * Released under the MIT license.
  20. * http://jquery.org/license
  21. *
  22. * http://api.jqueryui.com/category/ui-core/
  23. */
  24. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  25. $.ui = $.ui || {};
  26. $.extend( $.ui, {
  27. version: "1.11.2",
  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.2
  274. * http://jqueryui.com
  275. *
  276. * Copyright 2014 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. // allow multiple hashes to be passed on init
  432. options = !isMethodCall && args.length ?
  433. $.widget.extend.apply( null, [ options ].concat(args) ) :
  434. options;
  435. if ( isMethodCall ) {
  436. this.each(function() {
  437. var methodValue,
  438. instance = $.data( this, fullName );
  439. if ( options === "instance" ) {
  440. returnValue = instance;
  441. return false;
  442. }
  443. if ( !instance ) {
  444. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  445. "attempted to call method '" + options + "'" );
  446. }
  447. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  448. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  449. }
  450. methodValue = instance[ options ].apply( instance, args );
  451. if ( methodValue !== instance && methodValue !== undefined ) {
  452. returnValue = methodValue && methodValue.jquery ?
  453. returnValue.pushStack( methodValue.get() ) :
  454. methodValue;
  455. return false;
  456. }
  457. });
  458. } else {
  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.2
  756. * http://jqueryui.com
  757. *
  758. * Copyright 2014 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.2",
  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.2
  908. * http://jqueryui.com
  909. *
  910. * Copyright 2014 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 ( ( position.top + myOffset + atOffset + offset) > overTop && ( 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 ( ( position.top + myOffset + atOffset + offset) > overBottom && ( 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.2
  1368. * http://jqueryui.com
  1369. *
  1370. * Copyright 2014 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.2",
  1378. widgetEventPrefix: "drag",
  1379. options: {
  1380. addClasses: true,
  1381. appendTo: "parent",
  1382. axis: false,
  1383. connectToSortable: false,
  1384. containment: false,
  1385. cursor: "auto",
  1386. cursorAt: false,
  1387. grid: false,
  1388. handle: false,
  1389. helper: "original",
  1390. iframeFix: false,
  1391. opacity: false,
  1392. refreshPositions: false,
  1393. revert: false,
  1394. revertDuration: 500,
  1395. scope: "default",
  1396. scroll: true,
  1397. scrollSensitivity: 20,
  1398. scrollSpeed: 20,
  1399. snap: false,
  1400. snapMode: "both",
  1401. snapTolerance: 20,
  1402. stack: false,
  1403. zIndex: false,
  1404. // callbacks
  1405. drag: null,
  1406. start: null,
  1407. stop: null
  1408. },
  1409. _create: function() {
  1410. if ( this.options.helper === "original" ) {
  1411. this._setPositionRelative();
  1412. }
  1413. if (this.options.addClasses){
  1414. this.element.addClass("ui-draggable");
  1415. }
  1416. if (this.options.disabled){
  1417. this.element.addClass("ui-draggable-disabled");
  1418. }
  1419. this._setHandleClassName();
  1420. this._mouseInit();
  1421. },
  1422. _setOption: function( key, value ) {
  1423. this._super( key, value );
  1424. if ( key === "handle" ) {
  1425. this._removeHandleClassName();
  1426. this._setHandleClassName();
  1427. }
  1428. },
  1429. _destroy: function() {
  1430. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  1431. this.destroyOnClear = true;
  1432. return;
  1433. }
  1434. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  1435. this._removeHandleClassName();
  1436. this._mouseDestroy();
  1437. },
  1438. _mouseCapture: function(event) {
  1439. var o = this.options;
  1440. this._blurActiveElement( event );
  1441. // among others, prevent a drag on a resizable-handle
  1442. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  1443. return false;
  1444. }
  1445. //Quit if we're not on a valid handle
  1446. this.handle = this._getHandle(event);
  1447. if (!this.handle) {
  1448. return false;
  1449. }
  1450. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  1451. return true;
  1452. },
  1453. _blockFrames: function( selector ) {
  1454. this.iframeBlocks = this.document.find( selector ).map(function() {
  1455. var iframe = $( this );
  1456. return $( "<div>" )
  1457. .css( "position", "absolute" )
  1458. .appendTo( iframe.parent() )
  1459. .outerWidth( iframe.outerWidth() )
  1460. .outerHeight( iframe.outerHeight() )
  1461. .offset( iframe.offset() )[ 0 ];
  1462. });
  1463. },
  1464. _unblockFrames: function() {
  1465. if ( this.iframeBlocks ) {
  1466. this.iframeBlocks.remove();
  1467. delete this.iframeBlocks;
  1468. }
  1469. },
  1470. _blurActiveElement: function( event ) {
  1471. var document = this.document[ 0 ];
  1472. // Only need to blur if the event occurred on the draggable itself, see #10527
  1473. if ( !this.handleElement.is( event.target ) ) {
  1474. return;
  1475. }
  1476. // support: IE9
  1477. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  1478. try {
  1479. // Support: IE9, IE10
  1480. // If the <body> is blurred, IE will switch windows, see #9520
  1481. if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
  1482. // Blur any element that currently has focus, see #4261
  1483. $( document.activeElement ).blur();
  1484. }
  1485. } catch ( error ) {}
  1486. },
  1487. _mouseStart: function(event) {
  1488. var o = this.options;
  1489. //Create and append the visible helper
  1490. this.helper = this._createHelper(event);
  1491. this.helper.addClass("ui-draggable-dragging");
  1492. //Cache the helper size
  1493. this._cacheHelperProportions();
  1494. //If ddmanager is used for droppables, set the global draggable
  1495. if ($.ui.ddmanager) {
  1496. $.ui.ddmanager.current = this;
  1497. }
  1498. /*
  1499. * - Position generation -
  1500. * This block generates everything position related - it's the core of draggables.
  1501. */
  1502. //Cache the margins of the original element
  1503. this._cacheMargins();
  1504. //Store the helper's css position
  1505. this.cssPosition = this.helper.css( "position" );
  1506. this.scrollParent = this.helper.scrollParent( true );
  1507. this.offsetParent = this.helper.offsetParent();
  1508. this.hasFixedAncestor = this.helper.parents().filter(function() {
  1509. return $( this ).css( "position" ) === "fixed";
  1510. }).length > 0;
  1511. //The element's absolute position on the page minus margins
  1512. this.positionAbs = this.element.offset();
  1513. this._refreshOffsets( event );
  1514. //Generate the original position
  1515. this.originalPosition = this.position = this._generatePosition( event, false );
  1516. this.originalPageX = event.pageX;
  1517. this.originalPageY = event.pageY;
  1518. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1519. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  1520. //Set a containment if given in the options
  1521. this._setContainment();
  1522. //Trigger event + callbacks
  1523. if (this._trigger("start", event) === false) {
  1524. this._clear();
  1525. return false;
  1526. }
  1527. //Recache the helper size
  1528. this._cacheHelperProportions();
  1529. //Prepare the droppable offsets
  1530. if ($.ui.ddmanager && !o.dropBehaviour) {
  1531. $.ui.ddmanager.prepareOffsets(this, event);
  1532. }
  1533. // Reset helper's right/bottom css if they're set and set explicit width/height instead
  1534. // as this prevents resizing of elements with right/bottom set (see #7772)
  1535. this._normalizeRightBottom();
  1536. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  1537. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  1538. if ( $.ui.ddmanager ) {
  1539. $.ui.ddmanager.dragStart(this, event);
  1540. }
  1541. return true;
  1542. },
  1543. _refreshOffsets: function( event ) {
  1544. this.offset = {
  1545. top: this.positionAbs.top - this.margins.top,
  1546. left: this.positionAbs.left - this.margins.left,
  1547. scroll: false,
  1548. parent: this._getParentOffset(),
  1549. relative: this._getRelativeOffset()
  1550. };
  1551. this.offset.click = {
  1552. left: event.pageX - this.offset.left,
  1553. top: event.pageY - this.offset.top
  1554. };
  1555. },
  1556. _mouseDrag: function(event, noPropagation) {
  1557. // reset any necessary cached properties (see #5009)
  1558. if ( this.hasFixedAncestor ) {
  1559. this.offset.parent = this._getParentOffset();
  1560. }
  1561. //Compute the helpers position
  1562. this.position = this._generatePosition( event, true );
  1563. this.positionAbs = this._convertPositionTo("absolute");
  1564. //Call plugins and callbacks and use the resulting position if something is returned
  1565. if (!noPropagation) {
  1566. var ui = this._uiHash();
  1567. if (this._trigger("drag", event, ui) === false) {
  1568. this._mouseUp({});
  1569. return false;
  1570. }
  1571. this.position = ui.position;
  1572. }
  1573. this.helper[ 0 ].style.left = this.position.left + "px";
  1574. this.helper[ 0 ].style.top = this.position.top + "px";
  1575. if ($.ui.ddmanager) {
  1576. $.ui.ddmanager.drag(this, event);
  1577. }
  1578. return false;
  1579. },
  1580. _mouseStop: function(event) {
  1581. //If we are using droppables, inform the manager about the drop
  1582. var that = this,
  1583. dropped = false;
  1584. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1585. dropped = $.ui.ddmanager.drop(this, event);
  1586. }
  1587. //if a drop comes from outside (a sortable)
  1588. if (this.dropped) {
  1589. dropped = this.dropped;
  1590. this.dropped = false;
  1591. }
  1592. if ((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
  1593. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1594. if (that._trigger("stop", event) !== false) {
  1595. that._clear();
  1596. }
  1597. });
  1598. } else {
  1599. if (this._trigger("stop", event) !== false) {
  1600. this._clear();
  1601. }
  1602. }
  1603. return false;
  1604. },
  1605. _mouseUp: function( event ) {
  1606. this._unblockFrames();
  1607. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1608. if ( $.ui.ddmanager ) {
  1609. $.ui.ddmanager.dragStop(this, event);
  1610. }
  1611. // Only need to focus if the event occurred on the draggable itself, see #10527
  1612. if ( this.handleElement.is( event.target ) ) {
  1613. // The interaction is over; whether or not the click resulted in a drag, focus the element
  1614. this.element.focus();
  1615. }
  1616. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1617. },
  1618. cancel: function() {
  1619. if (this.helper.is(".ui-draggable-dragging")) {
  1620. this._mouseUp({});
  1621. } else {
  1622. this._clear();
  1623. }
  1624. return this;
  1625. },
  1626. _getHandle: function(event) {
  1627. return this.options.handle ?
  1628. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1629. true;
  1630. },
  1631. _setHandleClassName: function() {
  1632. this.handleElement = this.options.handle ?
  1633. this.element.find( this.options.handle ) : this.element;
  1634. this.handleElement.addClass( "ui-draggable-handle" );
  1635. },
  1636. _removeHandleClassName: function() {
  1637. this.handleElement.removeClass( "ui-draggable-handle" );
  1638. },
  1639. _createHelper: function(event) {
  1640. var o = this.options,
  1641. helperIsFunction = $.isFunction( o.helper ),
  1642. helper = helperIsFunction ?
  1643. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  1644. ( o.helper === "clone" ?
  1645. this.element.clone().removeAttr( "id" ) :
  1646. this.element );
  1647. if (!helper.parents("body").length) {
  1648. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1649. }
  1650. // http://bugs.jqueryui.com/ticket/9446
  1651. // a helper function can return the original element
  1652. // which wouldn't have been set to relative in _create
  1653. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  1654. this._setPositionRelative();
  1655. }
  1656. if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1657. helper.css("position", "absolute");
  1658. }
  1659. return helper;
  1660. },
  1661. _setPositionRelative: function() {
  1662. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  1663. this.element[ 0 ].style.position = "relative";
  1664. }
  1665. },
  1666. _adjustOffsetFromHelper: function(obj) {
  1667. if (typeof obj === "string") {
  1668. obj = obj.split(" ");
  1669. }
  1670. if ($.isArray(obj)) {
  1671. obj = { left: +obj[0], top: +obj[1] || 0 };
  1672. }
  1673. if ("left" in obj) {
  1674. this.offset.click.left = obj.left + this.margins.left;
  1675. }
  1676. if ("right" in obj) {
  1677. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1678. }
  1679. if ("top" in obj) {
  1680. this.offset.click.top = obj.top + this.margins.top;
  1681. }
  1682. if ("bottom" in obj) {
  1683. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1684. }
  1685. },
  1686. _isRootNode: function( element ) {
  1687. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  1688. },
  1689. _getParentOffset: function() {
  1690. //Get the offsetParent and cache its position
  1691. var po = this.offsetParent.offset(),
  1692. document = this.document[ 0 ];
  1693. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1694. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1695. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1696. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1697. if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1698. po.left += this.scrollParent.scrollLeft();
  1699. po.top += this.scrollParent.scrollTop();
  1700. }
  1701. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  1702. po = { top: 0, left: 0 };
  1703. }
  1704. return {
  1705. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
  1706. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
  1707. };
  1708. },
  1709. _getRelativeOffset: function() {
  1710. if ( this.cssPosition !== "relative" ) {
  1711. return { top: 0, left: 0 };
  1712. }
  1713. var p = this.element.position(),
  1714. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  1715. return {
  1716. top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  1717. left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  1718. };
  1719. },
  1720. _cacheMargins: function() {
  1721. this.margins = {
  1722. left: (parseInt(this.element.css("marginLeft"), 10) || 0),
  1723. top: (parseInt(this.element.css("marginTop"), 10) || 0),
  1724. right: (parseInt(this.element.css("marginRight"), 10) || 0),
  1725. bottom: (parseInt(this.element.css("marginBottom"), 10) || 0)
  1726. };
  1727. },
  1728. _cacheHelperProportions: function() {
  1729. this.helperProportions = {
  1730. width: this.helper.outerWidth(),
  1731. height: this.helper.outerHeight()
  1732. };
  1733. },
  1734. _setContainment: function() {
  1735. var isUserScrollable, c, ce,
  1736. o = this.options,
  1737. document = this.document[ 0 ];
  1738. this.relativeContainer = null;
  1739. if ( !o.containment ) {
  1740. this.containment = null;
  1741. return;
  1742. }
  1743. if ( o.containment === "window" ) {
  1744. this.containment = [
  1745. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1746. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1747. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  1748. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1749. ];
  1750. return;
  1751. }
  1752. if ( o.containment === "document") {
  1753. this.containment = [
  1754. 0,
  1755. 0,
  1756. $( document ).width() - this.helperProportions.width - this.margins.left,
  1757. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1758. ];
  1759. return;
  1760. }
  1761. if ( o.containment.constructor === Array ) {
  1762. this.containment = o.containment;
  1763. return;
  1764. }
  1765. if ( o.containment === "parent" ) {
  1766. o.containment = this.helper[ 0 ].parentNode;
  1767. }
  1768. c = $( o.containment );
  1769. ce = c[ 0 ];
  1770. if ( !ce ) {
  1771. return;
  1772. }
  1773. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  1774. this.containment = [
  1775. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  1776. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  1777. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  1778. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  1779. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  1780. this.helperProportions.width -
  1781. this.margins.left -
  1782. this.margins.right,
  1783. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  1784. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  1785. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  1786. this.helperProportions.height -
  1787. this.margins.top -
  1788. this.margins.bottom
  1789. ];
  1790. this.relativeContainer = c;
  1791. },
  1792. _convertPositionTo: function(d, pos) {
  1793. if (!pos) {
  1794. pos = this.position;
  1795. }
  1796. var mod = d === "absolute" ? 1 : -1,
  1797. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  1798. return {
  1799. top: (
  1800. pos.top + // The absolute mouse position
  1801. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1802. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1803. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
  1804. ),
  1805. left: (
  1806. pos.left + // The absolute mouse position
  1807. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1808. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1809. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod)
  1810. )
  1811. };
  1812. },
  1813. _generatePosition: function( event, constrainPosition ) {
  1814. var containment, co, top, left,
  1815. o = this.options,
  1816. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  1817. pageX = event.pageX,
  1818. pageY = event.pageY;
  1819. // Cache the scroll
  1820. if ( !scrollIsRootNode || !this.offset.scroll ) {
  1821. this.offset.scroll = {
  1822. top: this.scrollParent.scrollTop(),
  1823. left: this.scrollParent.scrollLeft()
  1824. };
  1825. }
  1826. /*
  1827. * - Position constraining -
  1828. * Constrain the position to a mix of grid, containment.
  1829. */
  1830. // If we are not dragging yet, we won't check for options
  1831. if ( constrainPosition ) {
  1832. if ( this.containment ) {
  1833. if ( this.relativeContainer ){
  1834. co = this.relativeContainer.offset();
  1835. containment = [
  1836. this.containment[ 0 ] + co.left,
  1837. this.containment[ 1 ] + co.top,
  1838. this.containment[ 2 ] + co.left,
  1839. this.containment[ 3 ] + co.top
  1840. ];
  1841. } else {
  1842. containment = this.containment;
  1843. }
  1844. if (event.pageX - this.offset.click.left < containment[0]) {
  1845. pageX = containment[0] + this.offset.click.left;
  1846. }
  1847. if (event.pageY - this.offset.click.top < containment[1]) {
  1848. pageY = containment[1] + this.offset.click.top;
  1849. }
  1850. if (event.pageX - this.offset.click.left > containment[2]) {
  1851. pageX = containment[2] + this.offset.click.left;
  1852. }
  1853. if (event.pageY - this.offset.click.top > containment[3]) {
  1854. pageY = containment[3] + this.offset.click.top;
  1855. }
  1856. }
  1857. if (o.grid) {
  1858. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1859. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1860. pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
  1861. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1862. pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
  1863. }
  1864. if ( o.axis === "y" ) {
  1865. pageX = this.originalPageX;
  1866. }
  1867. if ( o.axis === "x" ) {
  1868. pageY = this.originalPageY;
  1869. }
  1870. }
  1871. return {
  1872. top: (
  1873. pageY - // The absolute mouse position
  1874. this.offset.click.top - // Click offset (relative to the element)
  1875. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1876. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1877. ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  1878. ),
  1879. left: (
  1880. pageX - // The absolute mouse position
  1881. this.offset.click.left - // Click offset (relative to the element)
  1882. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1883. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1884. ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  1885. )
  1886. };
  1887. },
  1888. _clear: function() {
  1889. this.helper.removeClass("ui-draggable-dragging");
  1890. if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1891. this.helper.remove();
  1892. }
  1893. this.helper = null;
  1894. this.cancelHelperRemoval = false;
  1895. if ( this.destroyOnClear ) {
  1896. this.destroy();
  1897. }
  1898. },
  1899. _normalizeRightBottom: function() {
  1900. if ( this.options.axis !== "y" && this.helper.css( "right" ) !== "auto" ) {
  1901. this.helper.width( this.helper.width() );
  1902. this.helper.css( "right", "auto" );
  1903. }
  1904. if ( this.options.axis !== "x" && this.helper.css( "bottom" ) !== "auto" ) {
  1905. this.helper.height( this.helper.height() );
  1906. this.helper.css( "bottom", "auto" );
  1907. }
  1908. },
  1909. // From now on bulk stuff - mainly helpers
  1910. _trigger: function( type, event, ui ) {
  1911. ui = ui || this._uiHash();
  1912. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  1913. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  1914. if ( /^(drag|start|stop)/.test( type ) ) {
  1915. this.positionAbs = this._convertPositionTo( "absolute" );
  1916. ui.offset = this.positionAbs;
  1917. }
  1918. return $.Widget.prototype._trigger.call( this, type, event, ui );
  1919. },
  1920. plugins: {},
  1921. _uiHash: function() {
  1922. return {
  1923. helper: this.helper,
  1924. position: this.position,
  1925. originalPosition: this.originalPosition,
  1926. offset: this.positionAbs
  1927. };
  1928. }
  1929. });
  1930. $.ui.plugin.add( "draggable", "connectToSortable", {
  1931. start: function( event, ui, draggable ) {
  1932. var uiSortable = $.extend( {}, ui, {
  1933. item: draggable.element
  1934. });
  1935. draggable.sortables = [];
  1936. $( draggable.options.connectToSortable ).each(function() {
  1937. var sortable = $( this ).sortable( "instance" );
  1938. if ( sortable && !sortable.options.disabled ) {
  1939. draggable.sortables.push( sortable );
  1940. // refreshPositions is called at drag start to refresh the containerCache
  1941. // which is used in drag. This ensures it's initialized and synchronized
  1942. // with any changes that might have happened on the page since initialization.
  1943. sortable.refreshPositions();
  1944. sortable._trigger("activate", event, uiSortable);
  1945. }
  1946. });
  1947. },
  1948. stop: function( event, ui, draggable ) {
  1949. var uiSortable = $.extend( {}, ui, {
  1950. item: draggable.element
  1951. });
  1952. draggable.cancelHelperRemoval = false;
  1953. $.each( draggable.sortables, function() {
  1954. var sortable = this;
  1955. if ( sortable.isOver ) {
  1956. sortable.isOver = 0;
  1957. // Allow this sortable to handle removing the helper
  1958. draggable.cancelHelperRemoval = true;
  1959. sortable.cancelHelperRemoval = false;
  1960. // Use _storedCSS To restore properties in the sortable,
  1961. // as this also handles revert (#9675) since the draggable
  1962. // may have modified them in unexpected ways (#8809)
  1963. sortable._storedCSS = {
  1964. position: sortable.placeholder.css( "position" ),
  1965. top: sortable.placeholder.css( "top" ),
  1966. left: sortable.placeholder.css( "left" )
  1967. };
  1968. sortable._mouseStop(event);
  1969. // Once drag has ended, the sortable should return to using
  1970. // its original helper, not the shared helper from draggable
  1971. sortable.options.helper = sortable.options._helper;
  1972. } else {
  1973. // Prevent this Sortable from removing the helper.
  1974. // However, don't set the draggable to remove the helper
  1975. // either as another connected Sortable may yet handle the removal.
  1976. sortable.cancelHelperRemoval = true;
  1977. sortable._trigger( "deactivate", event, uiSortable );
  1978. }
  1979. });
  1980. },
  1981. drag: function( event, ui, draggable ) {
  1982. $.each( draggable.sortables, function() {
  1983. var innermostIntersecting = false,
  1984. sortable = this;
  1985. // Copy over variables that sortable's _intersectsWith uses
  1986. sortable.positionAbs = draggable.positionAbs;
  1987. sortable.helperProportions = draggable.helperProportions;
  1988. sortable.offset.click = draggable.offset.click;
  1989. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  1990. innermostIntersecting = true;
  1991. $.each( draggable.sortables, function() {
  1992. // Copy over variables that sortable's _intersectsWith uses
  1993. this.positionAbs = draggable.positionAbs;
  1994. this.helperProportions = draggable.helperProportions;
  1995. this.offset.click = draggable.offset.click;
  1996. if ( this !== sortable &&
  1997. this._intersectsWith( this.containerCache ) &&
  1998. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  1999. innermostIntersecting = false;
  2000. }
  2001. return innermostIntersecting;
  2002. });
  2003. }
  2004. if ( innermostIntersecting ) {
  2005. // If it intersects, we use a little isOver variable and set it once,
  2006. // so that the move-in stuff gets fired only once.
  2007. if ( !sortable.isOver ) {
  2008. sortable.isOver = 1;
  2009. sortable.currentItem = ui.helper
  2010. .appendTo( sortable.element )
  2011. .data( "ui-sortable-item", true );
  2012. // Store helper option to later restore it
  2013. sortable.options._helper = sortable.options.helper;
  2014. sortable.options.helper = function() {
  2015. return ui.helper[ 0 ];
  2016. };
  2017. // Fire the start events of the sortable with our passed browser event,
  2018. // and our own helper (so it doesn't create a new one)
  2019. event.target = sortable.currentItem[ 0 ];
  2020. sortable._mouseCapture( event, true );
  2021. sortable._mouseStart( event, true, true );
  2022. // Because the browser event is way off the new appended portlet,
  2023. // modify necessary variables to reflect the changes
  2024. sortable.offset.click.top = draggable.offset.click.top;
  2025. sortable.offset.click.left = draggable.offset.click.left;
  2026. sortable.offset.parent.left -= draggable.offset.parent.left -
  2027. sortable.offset.parent.left;
  2028. sortable.offset.parent.top -= draggable.offset.parent.top -
  2029. sortable.offset.parent.top;
  2030. draggable._trigger( "toSortable", event );
  2031. // Inform draggable that the helper is in a valid drop zone,
  2032. // used solely in the revert option to handle "valid/invalid".
  2033. draggable.dropped = sortable.element;
  2034. // Need to refreshPositions of all sortables in the case that
  2035. // adding to one sortable changes the location of the other sortables (#9675)
  2036. $.each( draggable.sortables, function() {
  2037. this.refreshPositions();
  2038. });
  2039. // hack so receive/update callbacks work (mostly)
  2040. draggable.currentItem = draggable.element;
  2041. sortable.fromOutside = draggable;
  2042. }
  2043. if ( sortable.currentItem ) {
  2044. sortable._mouseDrag( event );
  2045. // Copy the sortable's position because the draggable's can potentially reflect
  2046. // a relative position, while sortable is always absolute, which the dragged
  2047. // element has now become. (#8809)
  2048. ui.position = sortable.position;
  2049. }
  2050. } else {
  2051. // If it doesn't intersect with the sortable, and it intersected before,
  2052. // we fake the drag stop of the sortable, but make sure it doesn't remove
  2053. // the helper by using cancelHelperRemoval.
  2054. if ( sortable.isOver ) {
  2055. sortable.isOver = 0;
  2056. sortable.cancelHelperRemoval = true;
  2057. // Calling sortable's mouseStop would trigger a revert,
  2058. // so revert must be temporarily false until after mouseStop is called.
  2059. sortable.options._revert = sortable.options.revert;
  2060. sortable.options.revert = false;
  2061. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  2062. sortable._mouseStop( event, true );
  2063. // restore sortable behaviors that were modfied
  2064. // when the draggable entered the sortable area (#9481)
  2065. sortable.options.revert = sortable.options._revert;
  2066. sortable.options.helper = sortable.options._helper;
  2067. if ( sortable.placeholder ) {
  2068. sortable.placeholder.remove();
  2069. }
  2070. // Recalculate the draggable's offset considering the sortable
  2071. // may have modified them in unexpected ways (#8809)
  2072. draggable._refreshOffsets( event );
  2073. ui.position = draggable._generatePosition( event, true );
  2074. draggable._trigger( "fromSortable", event );
  2075. // Inform draggable that the helper is no longer in a valid drop zone
  2076. draggable.dropped = false;
  2077. // Need to refreshPositions of all sortables just in case removing
  2078. // from one sortable changes the location of other sortables (#9675)
  2079. $.each( draggable.sortables, function() {
  2080. this.refreshPositions();
  2081. });
  2082. }
  2083. }
  2084. });
  2085. }
  2086. });
  2087. $.ui.plugin.add("draggable", "cursor", {
  2088. start: function( event, ui, instance ) {
  2089. var t = $( "body" ),
  2090. o = instance.options;
  2091. if (t.css("cursor")) {
  2092. o._cursor = t.css("cursor");
  2093. }
  2094. t.css("cursor", o.cursor);
  2095. },
  2096. stop: function( event, ui, instance ) {
  2097. var o = instance.options;
  2098. if (o._cursor) {
  2099. $("body").css("cursor", o._cursor);
  2100. }
  2101. }
  2102. });
  2103. $.ui.plugin.add("draggable", "opacity", {
  2104. start: function( event, ui, instance ) {
  2105. var t = $( ui.helper ),
  2106. o = instance.options;
  2107. if (t.css("opacity")) {
  2108. o._opacity = t.css("opacity");
  2109. }
  2110. t.css("opacity", o.opacity);
  2111. },
  2112. stop: function( event, ui, instance ) {
  2113. var o = instance.options;
  2114. if (o._opacity) {
  2115. $(ui.helper).css("opacity", o._opacity);
  2116. }
  2117. }
  2118. });
  2119. $.ui.plugin.add("draggable", "scroll", {
  2120. start: function( event, ui, i ) {
  2121. if ( !i.scrollParentNotHidden ) {
  2122. i.scrollParentNotHidden = i.helper.scrollParent( false );
  2123. }
  2124. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  2125. i.overflowOffset = i.scrollParentNotHidden.offset();
  2126. }
  2127. },
  2128. drag: function( event, ui, i ) {
  2129. var o = i.options,
  2130. scrolled = false,
  2131. scrollParent = i.scrollParentNotHidden[ 0 ],
  2132. document = i.document[ 0 ];
  2133. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  2134. if ( !o.axis || o.axis !== "x" ) {
  2135. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) {
  2136. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  2137. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  2138. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  2139. }
  2140. }
  2141. if ( !o.axis || o.axis !== "y" ) {
  2142. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) {
  2143. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  2144. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  2145. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  2146. }
  2147. }
  2148. } else {
  2149. if (!o.axis || o.axis !== "x") {
  2150. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  2151. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  2152. } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  2153. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  2154. }
  2155. }
  2156. if (!o.axis || o.axis !== "y") {
  2157. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  2158. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  2159. } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  2160. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  2161. }
  2162. }
  2163. }
  2164. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  2165. $.ui.ddmanager.prepareOffsets(i, event);
  2166. }
  2167. }
  2168. });
  2169. $.ui.plugin.add("draggable", "snap", {
  2170. start: function( event, ui, i ) {
  2171. var o = i.options;
  2172. i.snapElements = [];
  2173. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  2174. var $t = $(this),
  2175. $o = $t.offset();
  2176. if (this !== i.element[0]) {
  2177. i.snapElements.push({
  2178. item: this,
  2179. width: $t.outerWidth(), height: $t.outerHeight(),
  2180. top: $o.top, left: $o.left
  2181. });
  2182. }
  2183. });
  2184. },
  2185. drag: function( event, ui, inst ) {
  2186. var ts, bs, ls, rs, l, r, t, b, i, first,
  2187. o = inst.options,
  2188. d = o.snapTolerance,
  2189. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  2190. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  2191. for (i = inst.snapElements.length - 1; i >= 0; i--){
  2192. l = inst.snapElements[i].left - inst.margins.left;
  2193. r = l + inst.snapElements[i].width;
  2194. t = inst.snapElements[i].top - inst.margins.top;
  2195. b = t + inst.snapElements[i].height;
  2196. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  2197. if (inst.snapElements[i].snapping) {
  2198. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2199. }
  2200. inst.snapElements[i].snapping = false;
  2201. continue;
  2202. }
  2203. if (o.snapMode !== "inner") {
  2204. ts = Math.abs(t - y2) <= d;
  2205. bs = Math.abs(b - y1) <= d;
  2206. ls = Math.abs(l - x2) <= d;
  2207. rs = Math.abs(r - x1) <= d;
  2208. if (ts) {
  2209. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
  2210. }
  2211. if (bs) {
  2212. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
  2213. }
  2214. if (ls) {
  2215. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
  2216. }
  2217. if (rs) {
  2218. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
  2219. }
  2220. }
  2221. first = (ts || bs || ls || rs);
  2222. if (o.snapMode !== "outer") {
  2223. ts = Math.abs(t - y1) <= d;
  2224. bs = Math.abs(b - y2) <= d;
  2225. ls = Math.abs(l - x1) <= d;
  2226. rs = Math.abs(r - x2) <= d;
  2227. if (ts) {
  2228. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
  2229. }
  2230. if (bs) {
  2231. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
  2232. }
  2233. if (ls) {
  2234. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
  2235. }
  2236. if (rs) {
  2237. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
  2238. }
  2239. }
  2240. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  2241. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2242. }
  2243. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  2244. }
  2245. }
  2246. });
  2247. $.ui.plugin.add("draggable", "stack", {
  2248. start: function( event, ui, instance ) {
  2249. var min,
  2250. o = instance.options,
  2251. group = $.makeArray($(o.stack)).sort(function(a, b) {
  2252. return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
  2253. });
  2254. if (!group.length) { return; }
  2255. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  2256. $(group).each(function(i) {
  2257. $(this).css("zIndex", min + i);
  2258. });
  2259. this.css("zIndex", (min + group.length));
  2260. }
  2261. });
  2262. $.ui.plugin.add("draggable", "zIndex", {
  2263. start: function( event, ui, instance ) {
  2264. var t = $( ui.helper ),
  2265. o = instance.options;
  2266. if (t.css("zIndex")) {
  2267. o._zIndex = t.css("zIndex");
  2268. }
  2269. t.css("zIndex", o.zIndex);
  2270. },
  2271. stop: function( event, ui, instance ) {
  2272. var o = instance.options;
  2273. if (o._zIndex) {
  2274. $(ui.helper).css("zIndex", o._zIndex);
  2275. }
  2276. }
  2277. });
  2278. var draggable = $.ui.draggable;
  2279. /*!
  2280. * jQuery UI Droppable 1.11.2
  2281. * http://jqueryui.com
  2282. *
  2283. * Copyright 2014 jQuery Foundation and other contributors
  2284. * Released under the MIT license.
  2285. * http://jquery.org/license
  2286. *
  2287. * http://api.jqueryui.com/droppable/
  2288. */
  2289. $.widget( "ui.droppable", {
  2290. version: "1.11.2",
  2291. widgetEventPrefix: "drop",
  2292. options: {
  2293. accept: "*",
  2294. activeClass: false,
  2295. addClasses: true,
  2296. greedy: false,
  2297. hoverClass: false,
  2298. scope: "default",
  2299. tolerance: "intersect",
  2300. // callbacks
  2301. activate: null,
  2302. deactivate: null,
  2303. drop: null,
  2304. out: null,
  2305. over: null
  2306. },
  2307. _create: function() {
  2308. var proportions,
  2309. o = this.options,
  2310. accept = o.accept;
  2311. this.isover = false;
  2312. this.isout = true;
  2313. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  2314. return d.is( accept );
  2315. };
  2316. this.proportions = function( /* valueToWrite */ ) {
  2317. if ( arguments.length ) {
  2318. // Store the droppable's proportions
  2319. proportions = arguments[ 0 ];
  2320. } else {
  2321. // Retrieve or derive the droppable's proportions
  2322. return proportions ?
  2323. proportions :
  2324. proportions = {
  2325. width: this.element[ 0 ].offsetWidth,
  2326. height: this.element[ 0 ].offsetHeight
  2327. };
  2328. }
  2329. };
  2330. this._addToManager( o.scope );
  2331. o.addClasses && this.element.addClass( "ui-droppable" );
  2332. },
  2333. _addToManager: function( scope ) {
  2334. // Add the reference and positions to the manager
  2335. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  2336. $.ui.ddmanager.droppables[ scope ].push( this );
  2337. },
  2338. _splice: function( drop ) {
  2339. var i = 0;
  2340. for ( ; i < drop.length; i++ ) {
  2341. if ( drop[ i ] === this ) {
  2342. drop.splice( i, 1 );
  2343. }
  2344. }
  2345. },
  2346. _destroy: function() {
  2347. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2348. this._splice( drop );
  2349. this.element.removeClass( "ui-droppable ui-droppable-disabled" );
  2350. },
  2351. _setOption: function( key, value ) {
  2352. if ( key === "accept" ) {
  2353. this.accept = $.isFunction( value ) ? value : function( d ) {
  2354. return d.is( value );
  2355. };
  2356. } else if ( key === "scope" ) {
  2357. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2358. this._splice( drop );
  2359. this._addToManager( value );
  2360. }
  2361. this._super( key, value );
  2362. },
  2363. _activate: function( event ) {
  2364. var draggable = $.ui.ddmanager.current;
  2365. if ( this.options.activeClass ) {
  2366. this.element.addClass( this.options.activeClass );
  2367. }
  2368. if ( draggable ){
  2369. this._trigger( "activate", event, this.ui( draggable ) );
  2370. }
  2371. },
  2372. _deactivate: function( event ) {
  2373. var draggable = $.ui.ddmanager.current;
  2374. if ( this.options.activeClass ) {
  2375. this.element.removeClass( this.options.activeClass );
  2376. }
  2377. if ( draggable ){
  2378. this._trigger( "deactivate", event, this.ui( draggable ) );
  2379. }
  2380. },
  2381. _over: function( event ) {
  2382. var draggable = $.ui.ddmanager.current;
  2383. // Bail if draggable and droppable are same element
  2384. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2385. return;
  2386. }
  2387. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2388. if ( this.options.hoverClass ) {
  2389. this.element.addClass( this.options.hoverClass );
  2390. }
  2391. this._trigger( "over", event, this.ui( draggable ) );
  2392. }
  2393. },
  2394. _out: function( event ) {
  2395. var draggable = $.ui.ddmanager.current;
  2396. // Bail if draggable and droppable are same element
  2397. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2398. return;
  2399. }
  2400. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2401. if ( this.options.hoverClass ) {
  2402. this.element.removeClass( this.options.hoverClass );
  2403. }
  2404. this._trigger( "out", event, this.ui( draggable ) );
  2405. }
  2406. },
  2407. _drop: function( event, custom ) {
  2408. var draggable = custom || $.ui.ddmanager.current,
  2409. childrenIntersection = false;
  2410. // Bail if draggable and droppable are same element
  2411. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2412. return false;
  2413. }
  2414. this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
  2415. var inst = $( this ).droppable( "instance" );
  2416. if (
  2417. inst.options.greedy &&
  2418. !inst.options.disabled &&
  2419. inst.options.scope === draggable.options.scope &&
  2420. inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
  2421. $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
  2422. ) { childrenIntersection = true; return false; }
  2423. });
  2424. if ( childrenIntersection ) {
  2425. return false;
  2426. }
  2427. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2428. if ( this.options.activeClass ) {
  2429. this.element.removeClass( this.options.activeClass );
  2430. }
  2431. if ( this.options.hoverClass ) {
  2432. this.element.removeClass( this.options.hoverClass );
  2433. }
  2434. this._trigger( "drop", event, this.ui( draggable ) );
  2435. return this.element;
  2436. }
  2437. return false;
  2438. },
  2439. ui: function( c ) {
  2440. return {
  2441. draggable: ( c.currentItem || c.element ),
  2442. helper: c.helper,
  2443. position: c.position,
  2444. offset: c.positionAbs
  2445. };
  2446. }
  2447. });
  2448. $.ui.intersect = (function() {
  2449. function isOverAxis( x, reference, size ) {
  2450. return ( x >= reference ) && ( x < ( reference + size ) );
  2451. }
  2452. return function( draggable, droppable, toleranceMode, event ) {
  2453. if ( !droppable.offset ) {
  2454. return false;
  2455. }
  2456. var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left,
  2457. y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top,
  2458. x2 = x1 + draggable.helperProportions.width,
  2459. y2 = y1 + draggable.helperProportions.height,
  2460. l = droppable.offset.left,
  2461. t = droppable.offset.top,
  2462. r = l + droppable.proportions().width,
  2463. b = t + droppable.proportions().height;
  2464. switch ( toleranceMode ) {
  2465. case "fit":
  2466. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  2467. case "intersect":
  2468. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  2469. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  2470. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  2471. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  2472. case "pointer":
  2473. return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
  2474. case "touch":
  2475. return (
  2476. ( y1 >= t && y1 <= b ) || // Top edge touching
  2477. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  2478. ( y1 < t && y2 > b ) // Surrounded vertically
  2479. ) && (
  2480. ( x1 >= l && x1 <= r ) || // Left edge touching
  2481. ( x2 >= l && x2 <= r ) || // Right edge touching
  2482. ( x1 < l && x2 > r ) // Surrounded horizontally
  2483. );
  2484. default:
  2485. return false;
  2486. }
  2487. };
  2488. })();
  2489. /*
  2490. This manager tracks offsets of draggables and droppables
  2491. */
  2492. $.ui.ddmanager = {
  2493. current: null,
  2494. droppables: { "default": [] },
  2495. prepareOffsets: function( t, event ) {
  2496. var i, j,
  2497. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  2498. type = event ? event.type : null, // workaround for #2317
  2499. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  2500. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  2501. // No disabled and non-accepted
  2502. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
  2503. continue;
  2504. }
  2505. // Filter out elements in the current dragged item
  2506. for ( j = 0; j < list.length; j++ ) {
  2507. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  2508. m[ i ].proportions().height = 0;
  2509. continue droppablesLoop;
  2510. }
  2511. }
  2512. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  2513. if ( !m[ i ].visible ) {
  2514. continue;
  2515. }
  2516. // Activate the droppable if used directly from draggables
  2517. if ( type === "mousedown" ) {
  2518. m[ i ]._activate.call( m[ i ], event );
  2519. }
  2520. m[ i ].offset = m[ i ].element.offset();
  2521. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  2522. }
  2523. },
  2524. drop: function( draggable, event ) {
  2525. var dropped = false;
  2526. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2527. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  2528. if ( !this.options ) {
  2529. return;
  2530. }
  2531. if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
  2532. dropped = this._drop.call( this, event ) || dropped;
  2533. }
  2534. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2535. this.isout = true;
  2536. this.isover = false;
  2537. this._deactivate.call( this, event );
  2538. }
  2539. });
  2540. return dropped;
  2541. },
  2542. dragStart: function( draggable, event ) {
  2543. // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  2544. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  2545. if ( !draggable.options.refreshPositions ) {
  2546. $.ui.ddmanager.prepareOffsets( draggable, event );
  2547. }
  2548. });
  2549. },
  2550. drag: function( draggable, event ) {
  2551. // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  2552. if ( draggable.options.refreshPositions ) {
  2553. $.ui.ddmanager.prepareOffsets( draggable, event );
  2554. }
  2555. // Run through all droppables and check their positions based on specific tolerance options
  2556. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  2557. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  2558. return;
  2559. }
  2560. var parentInstance, scope, parent,
  2561. intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
  2562. c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
  2563. if ( !c ) {
  2564. return;
  2565. }
  2566. if ( this.options.greedy ) {
  2567. // find droppable parents with same scope
  2568. scope = this.options.scope;
  2569. parent = this.element.parents( ":data(ui-droppable)" ).filter(function() {
  2570. return $( this ).droppable( "instance" ).options.scope === scope;
  2571. });
  2572. if ( parent.length ) {
  2573. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  2574. parentInstance.greedyChild = ( c === "isover" );
  2575. }
  2576. }
  2577. // we just moved into a greedy child
  2578. if ( parentInstance && c === "isover" ) {
  2579. parentInstance.isover = false;
  2580. parentInstance.isout = true;
  2581. parentInstance._out.call( parentInstance, event );
  2582. }
  2583. this[ c ] = true;
  2584. this[c === "isout" ? "isover" : "isout"] = false;
  2585. this[c === "isover" ? "_over" : "_out"].call( this, event );
  2586. // we just moved out of a greedy child
  2587. if ( parentInstance && c === "isout" ) {
  2588. parentInstance.isout = false;
  2589. parentInstance.isover = true;
  2590. parentInstance._over.call( parentInstance, event );
  2591. }
  2592. });
  2593. },
  2594. dragStop: function( draggable, event ) {
  2595. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  2596. // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  2597. if ( !draggable.options.refreshPositions ) {
  2598. $.ui.ddmanager.prepareOffsets( draggable, event );
  2599. }
  2600. }
  2601. };
  2602. var droppable = $.ui.droppable;
  2603. /*!
  2604. * jQuery UI Resizable 1.11.2
  2605. * http://jqueryui.com
  2606. *
  2607. * Copyright 2014 jQuery Foundation and other contributors
  2608. * Released under the MIT license.
  2609. * http://jquery.org/license
  2610. *
  2611. * http://api.jqueryui.com/resizable/
  2612. */
  2613. $.widget("ui.resizable", $.ui.mouse, {
  2614. version: "1.11.2",
  2615. widgetEventPrefix: "resize",
  2616. options: {
  2617. alsoResize: false,
  2618. animate: false,
  2619. animateDuration: "slow",
  2620. animateEasing: "swing",
  2621. aspectRatio: false,
  2622. autoHide: false,
  2623. containment: false,
  2624. ghost: false,
  2625. grid: false,
  2626. handles: "e,s,se",
  2627. helper: false,
  2628. maxHeight: null,
  2629. maxWidth: null,
  2630. minHeight: 10,
  2631. minWidth: 10,
  2632. // See #7960
  2633. zIndex: 90,
  2634. // callbacks
  2635. resize: null,
  2636. start: null,
  2637. stop: null
  2638. },
  2639. _num: function( value ) {
  2640. return parseInt( value, 10 ) || 0;
  2641. },
  2642. _isNumber: function( value ) {
  2643. return !isNaN( parseInt( value, 10 ) );
  2644. },
  2645. _hasScroll: function( el, a ) {
  2646. if ( $( el ).css( "overflow" ) === "hidden") {
  2647. return false;
  2648. }
  2649. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  2650. has = false;
  2651. if ( el[ scroll ] > 0 ) {
  2652. return true;
  2653. }
  2654. // TODO: determine which cases actually cause this to happen
  2655. // if the element doesn't have the scroll set, see if it's possible to
  2656. // set the scroll
  2657. el[ scroll ] = 1;
  2658. has = ( el[ scroll ] > 0 );
  2659. el[ scroll ] = 0;
  2660. return has;
  2661. },
  2662. _create: function() {
  2663. var n, i, handle, axis, hname,
  2664. that = this,
  2665. o = this.options;
  2666. this.element.addClass("ui-resizable");
  2667. $.extend(this, {
  2668. _aspectRatio: !!(o.aspectRatio),
  2669. aspectRatio: o.aspectRatio,
  2670. originalElement: this.element,
  2671. _proportionallyResizeElements: [],
  2672. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  2673. });
  2674. // Wrap the element if it cannot hold child nodes
  2675. if (this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  2676. this.element.wrap(
  2677. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  2678. position: this.element.css("position"),
  2679. width: this.element.outerWidth(),
  2680. height: this.element.outerHeight(),
  2681. top: this.element.css("top"),
  2682. left: this.element.css("left")
  2683. })
  2684. );
  2685. this.element = this.element.parent().data(
  2686. "ui-resizable", this.element.resizable( "instance" )
  2687. );
  2688. this.elementIsWrapper = true;
  2689. this.element.css({
  2690. marginLeft: this.originalElement.css("marginLeft"),
  2691. marginTop: this.originalElement.css("marginTop"),
  2692. marginRight: this.originalElement.css("marginRight"),
  2693. marginBottom: this.originalElement.css("marginBottom")
  2694. });
  2695. this.originalElement.css({
  2696. marginLeft: 0,
  2697. marginTop: 0,
  2698. marginRight: 0,
  2699. marginBottom: 0
  2700. });
  2701. // support: Safari
  2702. // Prevent Safari textarea resize
  2703. this.originalResizeStyle = this.originalElement.css("resize");
  2704. this.originalElement.css("resize", "none");
  2705. this._proportionallyResizeElements.push( this.originalElement.css({
  2706. position: "static",
  2707. zoom: 1,
  2708. display: "block"
  2709. }) );
  2710. // support: IE9
  2711. // avoid IE jump (hard set the margin)
  2712. this.originalElement.css({ margin: this.originalElement.css("margin") });
  2713. this._proportionallyResize();
  2714. }
  2715. this.handles = o.handles ||
  2716. ( !$(".ui-resizable-handle", this.element).length ?
  2717. "e,s,se" : {
  2718. n: ".ui-resizable-n",
  2719. e: ".ui-resizable-e",
  2720. s: ".ui-resizable-s",
  2721. w: ".ui-resizable-w",
  2722. se: ".ui-resizable-se",
  2723. sw: ".ui-resizable-sw",
  2724. ne: ".ui-resizable-ne",
  2725. nw: ".ui-resizable-nw"
  2726. } );
  2727. if (this.handles.constructor === String) {
  2728. if ( this.handles === "all") {
  2729. this.handles = "n,e,s,w,se,sw,ne,nw";
  2730. }
  2731. n = this.handles.split(",");
  2732. this.handles = {};
  2733. for (i = 0; i < n.length; i++) {
  2734. handle = $.trim(n[i]);
  2735. hname = "ui-resizable-" + handle;
  2736. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  2737. axis.css({ zIndex: o.zIndex });
  2738. // TODO : What's going on here?
  2739. if ("se" === handle) {
  2740. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  2741. }
  2742. this.handles[handle] = ".ui-resizable-" + handle;
  2743. this.element.append(axis);
  2744. }
  2745. }
  2746. this._renderAxis = function(target) {
  2747. var i, axis, padPos, padWrapper;
  2748. target = target || this.element;
  2749. for (i in this.handles) {
  2750. if (this.handles[i].constructor === String) {
  2751. this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
  2752. }
  2753. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  2754. axis = $(this.handles[i], this.element);
  2755. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2756. padPos = [ "padding",
  2757. /ne|nw|n/.test(i) ? "Top" :
  2758. /se|sw|s/.test(i) ? "Bottom" :
  2759. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2760. target.css(padPos, padWrapper);
  2761. this._proportionallyResize();
  2762. }
  2763. // TODO: What's that good for? There's not anything to be executed left
  2764. if (!$(this.handles[i]).length) {
  2765. continue;
  2766. }
  2767. }
  2768. };
  2769. // TODO: make renderAxis a prototype function
  2770. this._renderAxis(this.element);
  2771. this._handles = $(".ui-resizable-handle", this.element)
  2772. .disableSelection();
  2773. this._handles.mouseover(function() {
  2774. if (!that.resizing) {
  2775. if (this.className) {
  2776. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2777. }
  2778. that.axis = axis && axis[1] ? axis[1] : "se";
  2779. }
  2780. });
  2781. if (o.autoHide) {
  2782. this._handles.hide();
  2783. $(this.element)
  2784. .addClass("ui-resizable-autohide")
  2785. .mouseenter(function() {
  2786. if (o.disabled) {
  2787. return;
  2788. }
  2789. $(this).removeClass("ui-resizable-autohide");
  2790. that._handles.show();
  2791. })
  2792. .mouseleave(function() {
  2793. if (o.disabled) {
  2794. return;
  2795. }
  2796. if (!that.resizing) {
  2797. $(this).addClass("ui-resizable-autohide");
  2798. that._handles.hide();
  2799. }
  2800. });
  2801. }
  2802. this._mouseInit();
  2803. },
  2804. _destroy: function() {
  2805. this._mouseDestroy();
  2806. var wrapper,
  2807. _destroy = function(exp) {
  2808. $(exp)
  2809. .removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2810. .removeData("resizable")
  2811. .removeData("ui-resizable")
  2812. .unbind(".resizable")
  2813. .find(".ui-resizable-handle")
  2814. .remove();
  2815. };
  2816. // TODO: Unwrap at same DOM position
  2817. if (this.elementIsWrapper) {
  2818. _destroy(this.element);
  2819. wrapper = this.element;
  2820. this.originalElement.css({
  2821. position: wrapper.css("position"),
  2822. width: wrapper.outerWidth(),
  2823. height: wrapper.outerHeight(),
  2824. top: wrapper.css("top"),
  2825. left: wrapper.css("left")
  2826. }).insertAfter( wrapper );
  2827. wrapper.remove();
  2828. }
  2829. this.originalElement.css("resize", this.originalResizeStyle);
  2830. _destroy(this.originalElement);
  2831. return this;
  2832. },
  2833. _mouseCapture: function(event) {
  2834. var i, handle,
  2835. capture = false;
  2836. for (i in this.handles) {
  2837. handle = $(this.handles[i])[0];
  2838. if (handle === event.target || $.contains(handle, event.target)) {
  2839. capture = true;
  2840. }
  2841. }
  2842. return !this.options.disabled && capture;
  2843. },
  2844. _mouseStart: function(event) {
  2845. var curleft, curtop, cursor,
  2846. o = this.options,
  2847. el = this.element;
  2848. this.resizing = true;
  2849. this._renderProxy();
  2850. curleft = this._num(this.helper.css("left"));
  2851. curtop = this._num(this.helper.css("top"));
  2852. if (o.containment) {
  2853. curleft += $(o.containment).scrollLeft() || 0;
  2854. curtop += $(o.containment).scrollTop() || 0;
  2855. }
  2856. this.offset = this.helper.offset();
  2857. this.position = { left: curleft, top: curtop };
  2858. this.size = this._helper ? {
  2859. width: this.helper.width(),
  2860. height: this.helper.height()
  2861. } : {
  2862. width: el.width(),
  2863. height: el.height()
  2864. };
  2865. this.originalSize = this._helper ? {
  2866. width: el.outerWidth(),
  2867. height: el.outerHeight()
  2868. } : {
  2869. width: el.width(),
  2870. height: el.height()
  2871. };
  2872. this.sizeDiff = {
  2873. width: el.outerWidth() - el.width(),
  2874. height: el.outerHeight() - el.height()
  2875. };
  2876. this.originalPosition = { left: curleft, top: curtop };
  2877. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2878. this.aspectRatio = (typeof o.aspectRatio === "number") ?
  2879. o.aspectRatio :
  2880. ((this.originalSize.width / this.originalSize.height) || 1);
  2881. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2882. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2883. el.addClass("ui-resizable-resizing");
  2884. this._propagate("start", event);
  2885. return true;
  2886. },
  2887. _mouseDrag: function(event) {
  2888. var data, props,
  2889. smp = this.originalMousePosition,
  2890. a = this.axis,
  2891. dx = (event.pageX - smp.left) || 0,
  2892. dy = (event.pageY - smp.top) || 0,
  2893. trigger = this._change[a];
  2894. this._updatePrevProperties();
  2895. if (!trigger) {
  2896. return false;
  2897. }
  2898. data = trigger.apply(this, [ event, dx, dy ]);
  2899. this._updateVirtualBoundaries(event.shiftKey);
  2900. if (this._aspectRatio || event.shiftKey) {
  2901. data = this._updateRatio(data, event);
  2902. }
  2903. data = this._respectSize(data, event);
  2904. this._updateCache(data);
  2905. this._propagate("resize", event);
  2906. props = this._applyChanges();
  2907. if ( !this._helper && this._proportionallyResizeElements.length ) {
  2908. this._proportionallyResize();
  2909. }
  2910. if ( !$.isEmptyObject( props ) ) {
  2911. this._updatePrevProperties();
  2912. this._trigger( "resize", event, this.ui() );
  2913. this._applyChanges();
  2914. }
  2915. return false;
  2916. },
  2917. _mouseStop: function(event) {
  2918. this.resizing = false;
  2919. var pr, ista, soffseth, soffsetw, s, left, top,
  2920. o = this.options, that = this;
  2921. if (this._helper) {
  2922. pr = this._proportionallyResizeElements;
  2923. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2924. soffseth = ista && this._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height;
  2925. soffsetw = ista ? 0 : that.sizeDiff.width;
  2926. s = {
  2927. width: (that.helper.width() - soffsetw),
  2928. height: (that.helper.height() - soffseth)
  2929. };
  2930. left = (parseInt(that.element.css("left"), 10) +
  2931. (that.position.left - that.originalPosition.left)) || null;
  2932. top = (parseInt(that.element.css("top"), 10) +
  2933. (that.position.top - that.originalPosition.top)) || null;
  2934. if (!o.animate) {
  2935. this.element.css($.extend(s, { top: top, left: left }));
  2936. }
  2937. that.helper.height(that.size.height);
  2938. that.helper.width(that.size.width);
  2939. if (this._helper && !o.animate) {
  2940. this._proportionallyResize();
  2941. }
  2942. }
  2943. $("body").css("cursor", "auto");
  2944. this.element.removeClass("ui-resizable-resizing");
  2945. this._propagate("stop", event);
  2946. if (this._helper) {
  2947. this.helper.remove();
  2948. }
  2949. return false;
  2950. },
  2951. _updatePrevProperties: function() {
  2952. this.prevPosition = {
  2953. top: this.position.top,
  2954. left: this.position.left
  2955. };
  2956. this.prevSize = {
  2957. width: this.size.width,
  2958. height: this.size.height
  2959. };
  2960. },
  2961. _applyChanges: function() {
  2962. var props = {};
  2963. if ( this.position.top !== this.prevPosition.top ) {
  2964. props.top = this.position.top + "px";
  2965. }
  2966. if ( this.position.left !== this.prevPosition.left ) {
  2967. props.left = this.position.left + "px";
  2968. }
  2969. if ( this.size.width !== this.prevSize.width ) {
  2970. props.width = this.size.width + "px";
  2971. }
  2972. if ( this.size.height !== this.prevSize.height ) {
  2973. props.height = this.size.height + "px";
  2974. }
  2975. this.helper.css( props );
  2976. return props;
  2977. },
  2978. _updateVirtualBoundaries: function(forceAspectRatio) {
  2979. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2980. o = this.options;
  2981. b = {
  2982. minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
  2983. maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2984. minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
  2985. maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2986. };
  2987. if (this._aspectRatio || forceAspectRatio) {
  2988. pMinWidth = b.minHeight * this.aspectRatio;
  2989. pMinHeight = b.minWidth / this.aspectRatio;
  2990. pMaxWidth = b.maxHeight * this.aspectRatio;
  2991. pMaxHeight = b.maxWidth / this.aspectRatio;
  2992. if (pMinWidth > b.minWidth) {
  2993. b.minWidth = pMinWidth;
  2994. }
  2995. if (pMinHeight > b.minHeight) {
  2996. b.minHeight = pMinHeight;
  2997. }
  2998. if (pMaxWidth < b.maxWidth) {
  2999. b.maxWidth = pMaxWidth;
  3000. }
  3001. if (pMaxHeight < b.maxHeight) {
  3002. b.maxHeight = pMaxHeight;
  3003. }
  3004. }
  3005. this._vBoundaries = b;
  3006. },
  3007. _updateCache: function(data) {
  3008. this.offset = this.helper.offset();
  3009. if (this._isNumber(data.left)) {
  3010. this.position.left = data.left;
  3011. }
  3012. if (this._isNumber(data.top)) {
  3013. this.position.top = data.top;
  3014. }
  3015. if (this._isNumber(data.height)) {
  3016. this.size.height = data.height;
  3017. }
  3018. if (this._isNumber(data.width)) {
  3019. this.size.width = data.width;
  3020. }
  3021. },
  3022. _updateRatio: function( data ) {
  3023. var cpos = this.position,
  3024. csize = this.size,
  3025. a = this.axis;
  3026. if (this._isNumber(data.height)) {
  3027. data.width = (data.height * this.aspectRatio);
  3028. } else if (this._isNumber(data.width)) {
  3029. data.height = (data.width / this.aspectRatio);
  3030. }
  3031. if (a === "sw") {
  3032. data.left = cpos.left + (csize.width - data.width);
  3033. data.top = null;
  3034. }
  3035. if (a === "nw") {
  3036. data.top = cpos.top + (csize.height - data.height);
  3037. data.left = cpos.left + (csize.width - data.width);
  3038. }
  3039. return data;
  3040. },
  3041. _respectSize: function( data ) {
  3042. var o = this._vBoundaries,
  3043. a = this.axis,
  3044. ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width),
  3045. ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  3046. isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width),
  3047. isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  3048. dw = this.originalPosition.left + this.originalSize.width,
  3049. dh = this.position.top + this.size.height,
  3050. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  3051. if (isminw) {
  3052. data.width = o.minWidth;
  3053. }
  3054. if (isminh) {
  3055. data.height = o.minHeight;
  3056. }
  3057. if (ismaxw) {
  3058. data.width = o.maxWidth;
  3059. }
  3060. if (ismaxh) {
  3061. data.height = o.maxHeight;
  3062. }
  3063. if (isminw && cw) {
  3064. data.left = dw - o.minWidth;
  3065. }
  3066. if (ismaxw && cw) {
  3067. data.left = dw - o.maxWidth;
  3068. }
  3069. if (isminh && ch) {
  3070. data.top = dh - o.minHeight;
  3071. }
  3072. if (ismaxh && ch) {
  3073. data.top = dh - o.maxHeight;
  3074. }
  3075. // Fixing jump error on top/left - bug #2330
  3076. if (!data.width && !data.height && !data.left && data.top) {
  3077. data.top = null;
  3078. } else if (!data.width && !data.height && !data.top && data.left) {
  3079. data.left = null;
  3080. }
  3081. return data;
  3082. },
  3083. _getPaddingPlusBorderDimensions: function( element ) {
  3084. var i = 0,
  3085. widths = [],
  3086. borders = [
  3087. element.css( "borderTopWidth" ),
  3088. element.css( "borderRightWidth" ),
  3089. element.css( "borderBottomWidth" ),
  3090. element.css( "borderLeftWidth" )
  3091. ],
  3092. paddings = [
  3093. element.css( "paddingTop" ),
  3094. element.css( "paddingRight" ),
  3095. element.css( "paddingBottom" ),
  3096. element.css( "paddingLeft" )
  3097. ];
  3098. for ( ; i < 4; i++ ) {
  3099. widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 );
  3100. widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 );
  3101. }
  3102. return {
  3103. height: widths[ 0 ] + widths[ 2 ],
  3104. width: widths[ 1 ] + widths[ 3 ]
  3105. };
  3106. },
  3107. _proportionallyResize: function() {
  3108. if (!this._proportionallyResizeElements.length) {
  3109. return;
  3110. }
  3111. var prel,
  3112. i = 0,
  3113. element = this.helper || this.element;
  3114. for ( ; i < this._proportionallyResizeElements.length; i++) {
  3115. prel = this._proportionallyResizeElements[i];
  3116. // TODO: Seems like a bug to cache this.outerDimensions
  3117. // considering that we are in a loop.
  3118. if (!this.outerDimensions) {
  3119. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  3120. }
  3121. prel.css({
  3122. height: (element.height() - this.outerDimensions.height) || 0,
  3123. width: (element.width() - this.outerDimensions.width) || 0
  3124. });
  3125. }
  3126. },
  3127. _renderProxy: function() {
  3128. var el = this.element, o = this.options;
  3129. this.elementOffset = el.offset();
  3130. if (this._helper) {
  3131. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  3132. this.helper.addClass(this._helper).css({
  3133. width: this.element.outerWidth() - 1,
  3134. height: this.element.outerHeight() - 1,
  3135. position: "absolute",
  3136. left: this.elementOffset.left + "px",
  3137. top: this.elementOffset.top + "px",
  3138. zIndex: ++o.zIndex //TODO: Don't modify option
  3139. });
  3140. this.helper
  3141. .appendTo("body")
  3142. .disableSelection();
  3143. } else {
  3144. this.helper = this.element;
  3145. }
  3146. },
  3147. _change: {
  3148. e: function(event, dx) {
  3149. return { width: this.originalSize.width + dx };
  3150. },
  3151. w: function(event, dx) {
  3152. var cs = this.originalSize, sp = this.originalPosition;
  3153. return { left: sp.left + dx, width: cs.width - dx };
  3154. },
  3155. n: function(event, dx, dy) {
  3156. var cs = this.originalSize, sp = this.originalPosition;
  3157. return { top: sp.top + dy, height: cs.height - dy };
  3158. },
  3159. s: function(event, dx, dy) {
  3160. return { height: this.originalSize.height + dy };
  3161. },
  3162. se: function(event, dx, dy) {
  3163. return $.extend(this._change.s.apply(this, arguments),
  3164. this._change.e.apply(this, [ event, dx, dy ]));
  3165. },
  3166. sw: function(event, dx, dy) {
  3167. return $.extend(this._change.s.apply(this, arguments),
  3168. this._change.w.apply(this, [ event, dx, dy ]));
  3169. },
  3170. ne: function(event, dx, dy) {
  3171. return $.extend(this._change.n.apply(this, arguments),
  3172. this._change.e.apply(this, [ event, dx, dy ]));
  3173. },
  3174. nw: function(event, dx, dy) {
  3175. return $.extend(this._change.n.apply(this, arguments),
  3176. this._change.w.apply(this, [ event, dx, dy ]));
  3177. }
  3178. },
  3179. _propagate: function(n, event) {
  3180. $.ui.plugin.call(this, n, [ event, this.ui() ]);
  3181. (n !== "resize" && this._trigger(n, event, this.ui()));
  3182. },
  3183. plugins: {},
  3184. ui: function() {
  3185. return {
  3186. originalElement: this.originalElement,
  3187. element: this.element,
  3188. helper: this.helper,
  3189. position: this.position,
  3190. size: this.size,
  3191. originalSize: this.originalSize,
  3192. originalPosition: this.originalPosition
  3193. };
  3194. }
  3195. });
  3196. /*
  3197. * Resizable Extensions
  3198. */
  3199. $.ui.plugin.add("resizable", "animate", {
  3200. stop: function( event ) {
  3201. var that = $(this).resizable( "instance" ),
  3202. o = that.options,
  3203. pr = that._proportionallyResizeElements,
  3204. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  3205. soffseth = ista && that._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height,
  3206. soffsetw = ista ? 0 : that.sizeDiff.width,
  3207. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  3208. left = (parseInt(that.element.css("left"), 10) +
  3209. (that.position.left - that.originalPosition.left)) || null,
  3210. top = (parseInt(that.element.css("top"), 10) +
  3211. (that.position.top - that.originalPosition.top)) || null;
  3212. that.element.animate(
  3213. $.extend(style, top && left ? { top: top, left: left } : {}), {
  3214. duration: o.animateDuration,
  3215. easing: o.animateEasing,
  3216. step: function() {
  3217. var data = {
  3218. width: parseInt(that.element.css("width"), 10),
  3219. height: parseInt(that.element.css("height"), 10),
  3220. top: parseInt(that.element.css("top"), 10),
  3221. left: parseInt(that.element.css("left"), 10)
  3222. };
  3223. if (pr && pr.length) {
  3224. $(pr[0]).css({ width: data.width, height: data.height });
  3225. }
  3226. // propagating resize, and updating values for each animation step
  3227. that._updateCache(data);
  3228. that._propagate("resize", event);
  3229. }
  3230. }
  3231. );
  3232. }
  3233. });
  3234. $.ui.plugin.add( "resizable", "containment", {
  3235. start: function() {
  3236. var element, p, co, ch, cw, width, height,
  3237. that = $( this ).resizable( "instance" ),
  3238. o = that.options,
  3239. el = that.element,
  3240. oc = o.containment,
  3241. ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  3242. if ( !ce ) {
  3243. return;
  3244. }
  3245. that.containerElement = $( ce );
  3246. if ( /document/.test( oc ) || oc === document ) {
  3247. that.containerOffset = {
  3248. left: 0,
  3249. top: 0
  3250. };
  3251. that.containerPosition = {
  3252. left: 0,
  3253. top: 0
  3254. };
  3255. that.parentData = {
  3256. element: $( document ),
  3257. left: 0,
  3258. top: 0,
  3259. width: $( document ).width(),
  3260. height: $( document ).height() || document.body.parentNode.scrollHeight
  3261. };
  3262. } else {
  3263. element = $( ce );
  3264. p = [];
  3265. $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {
  3266. p[ i ] = that._num( element.css( "padding" + name ) );
  3267. });
  3268. that.containerOffset = element.offset();
  3269. that.containerPosition = element.position();
  3270. that.containerSize = {
  3271. height: ( element.innerHeight() - p[ 3 ] ),
  3272. width: ( element.innerWidth() - p[ 1 ] )
  3273. };
  3274. co = that.containerOffset;
  3275. ch = that.containerSize.height;
  3276. cw = that.containerSize.width;
  3277. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  3278. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  3279. that.parentData = {
  3280. element: ce,
  3281. left: co.left,
  3282. top: co.top,
  3283. width: width,
  3284. height: height
  3285. };
  3286. }
  3287. },
  3288. resize: function( event ) {
  3289. var woset, hoset, isParent, isOffsetRelative,
  3290. that = $( this ).resizable( "instance" ),
  3291. o = that.options,
  3292. co = that.containerOffset,
  3293. cp = that.position,
  3294. pRatio = that._aspectRatio || event.shiftKey,
  3295. cop = {
  3296. top: 0,
  3297. left: 0
  3298. },
  3299. ce = that.containerElement,
  3300. continueResize = true;
  3301. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  3302. cop = co;
  3303. }
  3304. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  3305. that.size.width = that.size.width +
  3306. ( that._helper ?
  3307. ( that.position.left - co.left ) :
  3308. ( that.position.left - cop.left ) );
  3309. if ( pRatio ) {
  3310. that.size.height = that.size.width / that.aspectRatio;
  3311. continueResize = false;
  3312. }
  3313. that.position.left = o.helper ? co.left : 0;
  3314. }
  3315. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  3316. that.size.height = that.size.height +
  3317. ( that._helper ?
  3318. ( that.position.top - co.top ) :
  3319. that.position.top );
  3320. if ( pRatio ) {
  3321. that.size.width = that.size.height * that.aspectRatio;
  3322. continueResize = false;
  3323. }
  3324. that.position.top = that._helper ? co.top : 0;
  3325. }
  3326. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  3327. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  3328. if ( isParent && isOffsetRelative ) {
  3329. that.offset.left = that.parentData.left + that.position.left;
  3330. that.offset.top = that.parentData.top + that.position.top;
  3331. } else {
  3332. that.offset.left = that.element.offset().left;
  3333. that.offset.top = that.element.offset().top;
  3334. }
  3335. woset = Math.abs( that.sizeDiff.width +
  3336. (that._helper ?
  3337. that.offset.left - cop.left :
  3338. (that.offset.left - co.left)) );
  3339. hoset = Math.abs( that.sizeDiff.height +
  3340. (that._helper ?
  3341. that.offset.top - cop.top :
  3342. (that.offset.top - co.top)) );
  3343. if ( woset + that.size.width >= that.parentData.width ) {
  3344. that.size.width = that.parentData.width - woset;
  3345. if ( pRatio ) {
  3346. that.size.height = that.size.width / that.aspectRatio;
  3347. continueResize = false;
  3348. }
  3349. }
  3350. if ( hoset + that.size.height >= that.parentData.height ) {
  3351. that.size.height = that.parentData.height - hoset;
  3352. if ( pRatio ) {
  3353. that.size.width = that.size.height * that.aspectRatio;
  3354. continueResize = false;
  3355. }
  3356. }
  3357. if ( !continueResize ){
  3358. that.position.left = that.prevPosition.left;
  3359. that.position.top = that.prevPosition.top;
  3360. that.size.width = that.prevSize.width;
  3361. that.size.height = that.prevSize.height;
  3362. }
  3363. },
  3364. stop: function() {
  3365. var that = $( this ).resizable( "instance" ),
  3366. o = that.options,
  3367. co = that.containerOffset,
  3368. cop = that.containerPosition,
  3369. ce = that.containerElement,
  3370. helper = $( that.helper ),
  3371. ho = helper.offset(),
  3372. w = helper.outerWidth() - that.sizeDiff.width,
  3373. h = helper.outerHeight() - that.sizeDiff.height;
  3374. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  3375. $( this ).css({
  3376. left: ho.left - cop.left - co.left,
  3377. width: w,
  3378. height: h
  3379. });
  3380. }
  3381. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  3382. $( this ).css({
  3383. left: ho.left - cop.left - co.left,
  3384. width: w,
  3385. height: h
  3386. });
  3387. }
  3388. }
  3389. });
  3390. $.ui.plugin.add("resizable", "alsoResize", {
  3391. start: function() {
  3392. var that = $(this).resizable( "instance" ),
  3393. o = that.options,
  3394. _store = function(exp) {
  3395. $(exp).each(function() {
  3396. var el = $(this);
  3397. el.data("ui-resizable-alsoresize", {
  3398. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  3399. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  3400. });
  3401. });
  3402. };
  3403. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  3404. if (o.alsoResize.length) {
  3405. o.alsoResize = o.alsoResize[0];
  3406. _store(o.alsoResize);
  3407. } else {
  3408. $.each(o.alsoResize, function(exp) {
  3409. _store(exp);
  3410. });
  3411. }
  3412. } else {
  3413. _store(o.alsoResize);
  3414. }
  3415. },
  3416. resize: function(event, ui) {
  3417. var that = $(this).resizable( "instance" ),
  3418. o = that.options,
  3419. os = that.originalSize,
  3420. op = that.originalPosition,
  3421. delta = {
  3422. height: (that.size.height - os.height) || 0,
  3423. width: (that.size.width - os.width) || 0,
  3424. top: (that.position.top - op.top) || 0,
  3425. left: (that.position.left - op.left) || 0
  3426. },
  3427. _alsoResize = function(exp, c) {
  3428. $(exp).each(function() {
  3429. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  3430. css = c && c.length ?
  3431. c :
  3432. el.parents(ui.originalElement[0]).length ?
  3433. [ "width", "height" ] :
  3434. [ "width", "height", "top", "left" ];
  3435. $.each(css, function(i, prop) {
  3436. var sum = (start[prop] || 0) + (delta[prop] || 0);
  3437. if (sum && sum >= 0) {
  3438. style[prop] = sum || null;
  3439. }
  3440. });
  3441. el.css(style);
  3442. });
  3443. };
  3444. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  3445. $.each(o.alsoResize, function(exp, c) {
  3446. _alsoResize(exp, c);
  3447. });
  3448. } else {
  3449. _alsoResize(o.alsoResize);
  3450. }
  3451. },
  3452. stop: function() {
  3453. $(this).removeData("resizable-alsoresize");
  3454. }
  3455. });
  3456. $.ui.plugin.add("resizable", "ghost", {
  3457. start: function() {
  3458. var that = $(this).resizable( "instance" ), o = that.options, cs = that.size;
  3459. that.ghost = that.originalElement.clone();
  3460. that.ghost
  3461. .css({
  3462. opacity: 0.25,
  3463. display: "block",
  3464. position: "relative",
  3465. height: cs.height,
  3466. width: cs.width,
  3467. margin: 0,
  3468. left: 0,
  3469. top: 0
  3470. })
  3471. .addClass("ui-resizable-ghost")
  3472. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  3473. that.ghost.appendTo(that.helper);
  3474. },
  3475. resize: function() {
  3476. var that = $(this).resizable( "instance" );
  3477. if (that.ghost) {
  3478. that.ghost.css({
  3479. position: "relative",
  3480. height: that.size.height,
  3481. width: that.size.width
  3482. });
  3483. }
  3484. },
  3485. stop: function() {
  3486. var that = $(this).resizable( "instance" );
  3487. if (that.ghost && that.helper) {
  3488. that.helper.get(0).removeChild(that.ghost.get(0));
  3489. }
  3490. }
  3491. });
  3492. $.ui.plugin.add("resizable", "grid", {
  3493. resize: function() {
  3494. var outerDimensions,
  3495. that = $(this).resizable( "instance" ),
  3496. o = that.options,
  3497. cs = that.size,
  3498. os = that.originalSize,
  3499. op = that.originalPosition,
  3500. a = that.axis,
  3501. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  3502. gridX = (grid[0] || 1),
  3503. gridY = (grid[1] || 1),
  3504. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  3505. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  3506. newWidth = os.width + ox,
  3507. newHeight = os.height + oy,
  3508. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  3509. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  3510. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  3511. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  3512. o.grid = grid;
  3513. if (isMinWidth) {
  3514. newWidth += gridX;
  3515. }
  3516. if (isMinHeight) {
  3517. newHeight += gridY;
  3518. }
  3519. if (isMaxWidth) {
  3520. newWidth -= gridX;
  3521. }
  3522. if (isMaxHeight) {
  3523. newHeight -= gridY;
  3524. }
  3525. if (/^(se|s|e)$/.test(a)) {
  3526. that.size.width = newWidth;
  3527. that.size.height = newHeight;
  3528. } else if (/^(ne)$/.test(a)) {
  3529. that.size.width = newWidth;
  3530. that.size.height = newHeight;
  3531. that.position.top = op.top - oy;
  3532. } else if (/^(sw)$/.test(a)) {
  3533. that.size.width = newWidth;
  3534. that.size.height = newHeight;
  3535. that.position.left = op.left - ox;
  3536. } else {
  3537. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) {
  3538. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  3539. }
  3540. if ( newHeight - gridY > 0 ) {
  3541. that.size.height = newHeight;
  3542. that.position.top = op.top - oy;
  3543. } else {
  3544. newHeight = gridY - outerDimensions.height;
  3545. that.size.height = newHeight;
  3546. that.position.top = op.top + os.height - newHeight;
  3547. }
  3548. if ( newWidth - gridX > 0 ) {
  3549. that.size.width = newWidth;
  3550. that.position.left = op.left - ox;
  3551. } else {
  3552. newWidth = gridY - outerDimensions.height;
  3553. that.size.width = newWidth;
  3554. that.position.left = op.left + os.width - newWidth;
  3555. }
  3556. }
  3557. }
  3558. });
  3559. var resizable = $.ui.resizable;
  3560. /*!
  3561. * jQuery UI Selectable 1.11.2
  3562. * http://jqueryui.com
  3563. *
  3564. * Copyright 2014 jQuery Foundation and other contributors
  3565. * Released under the MIT license.
  3566. * http://jquery.org/license
  3567. *
  3568. * http://api.jqueryui.com/selectable/
  3569. */
  3570. var selectable = $.widget("ui.selectable", $.ui.mouse, {
  3571. version: "1.11.2",
  3572. options: {
  3573. appendTo: "body",
  3574. autoRefresh: true,
  3575. distance: 0,
  3576. filter: "*",
  3577. tolerance: "touch",
  3578. // callbacks
  3579. selected: null,
  3580. selecting: null,
  3581. start: null,
  3582. stop: null,
  3583. unselected: null,
  3584. unselecting: null
  3585. },
  3586. _create: function() {
  3587. var selectees,
  3588. that = this;
  3589. this.element.addClass("ui-selectable");
  3590. this.dragged = false;
  3591. // cache selectee children based on filter
  3592. this.refresh = function() {
  3593. selectees = $(that.options.filter, that.element[0]);
  3594. selectees.addClass("ui-selectee");
  3595. selectees.each(function() {
  3596. var $this = $(this),
  3597. pos = $this.offset();
  3598. $.data(this, "selectable-item", {
  3599. element: this,
  3600. $element: $this,
  3601. left: pos.left,
  3602. top: pos.top,
  3603. right: pos.left + $this.outerWidth(),
  3604. bottom: pos.top + $this.outerHeight(),
  3605. startselected: false,
  3606. selected: $this.hasClass("ui-selected"),
  3607. selecting: $this.hasClass("ui-selecting"),
  3608. unselecting: $this.hasClass("ui-unselecting")
  3609. });
  3610. });
  3611. };
  3612. this.refresh();
  3613. this.selectees = selectees.addClass("ui-selectee");
  3614. this._mouseInit();
  3615. this.helper = $("<div class='ui-selectable-helper'></div>");
  3616. },
  3617. _destroy: function() {
  3618. this.selectees
  3619. .removeClass("ui-selectee")
  3620. .removeData("selectable-item");
  3621. this.element
  3622. .removeClass("ui-selectable ui-selectable-disabled");
  3623. this._mouseDestroy();
  3624. },
  3625. _mouseStart: function(event) {
  3626. var that = this,
  3627. options = this.options;
  3628. this.opos = [ event.pageX, event.pageY ];
  3629. if (this.options.disabled) {
  3630. return;
  3631. }
  3632. this.selectees = $(options.filter, this.element[0]);
  3633. this._trigger("start", event);
  3634. $(options.appendTo).append(this.helper);
  3635. // position helper (lasso)
  3636. this.helper.css({
  3637. "left": event.pageX,
  3638. "top": event.pageY,
  3639. "width": 0,
  3640. "height": 0
  3641. });
  3642. if (options.autoRefresh) {
  3643. this.refresh();
  3644. }
  3645. this.selectees.filter(".ui-selected").each(function() {
  3646. var selectee = $.data(this, "selectable-item");
  3647. selectee.startselected = true;
  3648. if (!event.metaKey && !event.ctrlKey) {
  3649. selectee.$element.removeClass("ui-selected");
  3650. selectee.selected = false;
  3651. selectee.$element.addClass("ui-unselecting");
  3652. selectee.unselecting = true;
  3653. // selectable UNSELECTING callback
  3654. that._trigger("unselecting", event, {
  3655. unselecting: selectee.element
  3656. });
  3657. }
  3658. });
  3659. $(event.target).parents().addBack().each(function() {
  3660. var doSelect,
  3661. selectee = $.data(this, "selectable-item");
  3662. if (selectee) {
  3663. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  3664. selectee.$element
  3665. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  3666. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  3667. selectee.unselecting = !doSelect;
  3668. selectee.selecting = doSelect;
  3669. selectee.selected = doSelect;
  3670. // selectable (UN)SELECTING callback
  3671. if (doSelect) {
  3672. that._trigger("selecting", event, {
  3673. selecting: selectee.element
  3674. });
  3675. } else {
  3676. that._trigger("unselecting", event, {
  3677. unselecting: selectee.element
  3678. });
  3679. }
  3680. return false;
  3681. }
  3682. });
  3683. },
  3684. _mouseDrag: function(event) {
  3685. this.dragged = true;
  3686. if (this.options.disabled) {
  3687. return;
  3688. }
  3689. var tmp,
  3690. that = this,
  3691. options = this.options,
  3692. x1 = this.opos[0],
  3693. y1 = this.opos[1],
  3694. x2 = event.pageX,
  3695. y2 = event.pageY;
  3696. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  3697. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  3698. this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });
  3699. this.selectees.each(function() {
  3700. var selectee = $.data(this, "selectable-item"),
  3701. hit = false;
  3702. //prevent helper from being selected if appendTo: selectable
  3703. if (!selectee || selectee.element === that.element[0]) {
  3704. return;
  3705. }
  3706. if (options.tolerance === "touch") {
  3707. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  3708. } else if (options.tolerance === "fit") {
  3709. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  3710. }
  3711. if (hit) {
  3712. // SELECT
  3713. if (selectee.selected) {
  3714. selectee.$element.removeClass("ui-selected");
  3715. selectee.selected = false;
  3716. }
  3717. if (selectee.unselecting) {
  3718. selectee.$element.removeClass("ui-unselecting");
  3719. selectee.unselecting = false;
  3720. }
  3721. if (!selectee.selecting) {
  3722. selectee.$element.addClass("ui-selecting");
  3723. selectee.selecting = true;
  3724. // selectable SELECTING callback
  3725. that._trigger("selecting", event, {
  3726. selecting: selectee.element
  3727. });
  3728. }
  3729. } else {
  3730. // UNSELECT
  3731. if (selectee.selecting) {
  3732. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  3733. selectee.$element.removeClass("ui-selecting");
  3734. selectee.selecting = false;
  3735. selectee.$element.addClass("ui-selected");
  3736. selectee.selected = true;
  3737. } else {
  3738. selectee.$element.removeClass("ui-selecting");
  3739. selectee.selecting = false;
  3740. if (selectee.startselected) {
  3741. selectee.$element.addClass("ui-unselecting");
  3742. selectee.unselecting = true;
  3743. }
  3744. // selectable UNSELECTING callback
  3745. that._trigger("unselecting", event, {
  3746. unselecting: selectee.element
  3747. });
  3748. }
  3749. }
  3750. if (selectee.selected) {
  3751. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  3752. selectee.$element.removeClass("ui-selected");
  3753. selectee.selected = false;
  3754. selectee.$element.addClass("ui-unselecting");
  3755. selectee.unselecting = true;
  3756. // selectable UNSELECTING callback
  3757. that._trigger("unselecting", event, {
  3758. unselecting: selectee.element
  3759. });
  3760. }
  3761. }
  3762. }
  3763. });
  3764. return false;
  3765. },
  3766. _mouseStop: function(event) {
  3767. var that = this;
  3768. this.dragged = false;
  3769. $(".ui-unselecting", this.element[0]).each(function() {
  3770. var selectee = $.data(this, "selectable-item");
  3771. selectee.$element.removeClass("ui-unselecting");
  3772. selectee.unselecting = false;
  3773. selectee.startselected = false;
  3774. that._trigger("unselected", event, {
  3775. unselected: selectee.element
  3776. });
  3777. });
  3778. $(".ui-selecting", this.element[0]).each(function() {
  3779. var selectee = $.data(this, "selectable-item");
  3780. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  3781. selectee.selecting = false;
  3782. selectee.selected = true;
  3783. selectee.startselected = true;
  3784. that._trigger("selected", event, {
  3785. selected: selectee.element
  3786. });
  3787. });
  3788. this._trigger("stop", event);
  3789. this.helper.remove();
  3790. return false;
  3791. }
  3792. });
  3793. /*!
  3794. * jQuery UI Sortable 1.11.2
  3795. * http://jqueryui.com
  3796. *
  3797. * Copyright 2014 jQuery Foundation and other contributors
  3798. * Released under the MIT license.
  3799. * http://jquery.org/license
  3800. *
  3801. * http://api.jqueryui.com/sortable/
  3802. */
  3803. var sortable = $.widget("ui.sortable", $.ui.mouse, {
  3804. version: "1.11.2",
  3805. widgetEventPrefix: "sort",
  3806. ready: false,
  3807. options: {
  3808. appendTo: "parent",
  3809. axis: false,
  3810. connectWith: false,
  3811. containment: false,
  3812. cursor: "auto",
  3813. cursorAt: false,
  3814. dropOnEmpty: true,
  3815. forcePlaceholderSize: false,
  3816. forceHelperSize: false,
  3817. grid: false,
  3818. handle: false,
  3819. helper: "original",
  3820. items: "> *",
  3821. opacity: false,
  3822. placeholder: false,
  3823. revert: false,
  3824. scroll: true,
  3825. scrollSensitivity: 20,
  3826. scrollSpeed: 20,
  3827. scope: "default",
  3828. tolerance: "intersect",
  3829. zIndex: 1000,
  3830. // callbacks
  3831. activate: null,
  3832. beforeStop: null,
  3833. change: null,
  3834. deactivate: null,
  3835. out: null,
  3836. over: null,
  3837. receive: null,
  3838. remove: null,
  3839. sort: null,
  3840. start: null,
  3841. stop: null,
  3842. update: null
  3843. },
  3844. _isOverAxis: function( x, reference, size ) {
  3845. return ( x >= reference ) && ( x < ( reference + size ) );
  3846. },
  3847. _isFloating: function( item ) {
  3848. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  3849. },
  3850. _create: function() {
  3851. var o = this.options;
  3852. this.containerCache = {};
  3853. this.element.addClass("ui-sortable");
  3854. //Get the items
  3855. this.refresh();
  3856. //Let's determine if the items are being displayed horizontally
  3857. this.floating = this.items.length ? o.axis === "x" || this._isFloating(this.items[0].item) : false;
  3858. //Let's determine the parent's offset
  3859. this.offset = this.element.offset();
  3860. //Initialize mouse events for interaction
  3861. this._mouseInit();
  3862. this._setHandleClassName();
  3863. //We're ready to go
  3864. this.ready = true;
  3865. },
  3866. _setOption: function( key, value ) {
  3867. this._super( key, value );
  3868. if ( key === "handle" ) {
  3869. this._setHandleClassName();
  3870. }
  3871. },
  3872. _setHandleClassName: function() {
  3873. this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" );
  3874. $.each( this.items, function() {
  3875. ( this.instance.options.handle ?
  3876. this.item.find( this.instance.options.handle ) : this.item )
  3877. .addClass( "ui-sortable-handle" );
  3878. });
  3879. },
  3880. _destroy: function() {
  3881. this.element
  3882. .removeClass( "ui-sortable ui-sortable-disabled" )
  3883. .find( ".ui-sortable-handle" )
  3884. .removeClass( "ui-sortable-handle" );
  3885. this._mouseDestroy();
  3886. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  3887. this.items[i].item.removeData(this.widgetName + "-item");
  3888. }
  3889. return this;
  3890. },
  3891. _mouseCapture: function(event, overrideHandle) {
  3892. var currentItem = null,
  3893. validHandle = false,
  3894. that = this;
  3895. if (this.reverting) {
  3896. return false;
  3897. }
  3898. if(this.options.disabled || this.options.type === "static") {
  3899. return false;
  3900. }
  3901. //We have to refresh the items data once first
  3902. this._refreshItems(event);
  3903. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  3904. $(event.target).parents().each(function() {
  3905. if($.data(this, that.widgetName + "-item") === that) {
  3906. currentItem = $(this);
  3907. return false;
  3908. }
  3909. });
  3910. if($.data(event.target, that.widgetName + "-item") === that) {
  3911. currentItem = $(event.target);
  3912. }
  3913. if(!currentItem) {
  3914. return false;
  3915. }
  3916. if(this.options.handle && !overrideHandle) {
  3917. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  3918. if(this === event.target) {
  3919. validHandle = true;
  3920. }
  3921. });
  3922. if(!validHandle) {
  3923. return false;
  3924. }
  3925. }
  3926. this.currentItem = currentItem;
  3927. this._removeCurrentsFromItems();
  3928. return true;
  3929. },
  3930. _mouseStart: function(event, overrideHandle, noActivation) {
  3931. var i, body,
  3932. o = this.options;
  3933. this.currentContainer = this;
  3934. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3935. this.refreshPositions();
  3936. //Create and append the visible helper
  3937. this.helper = this._createHelper(event);
  3938. //Cache the helper size
  3939. this._cacheHelperProportions();
  3940. /*
  3941. * - Position generation -
  3942. * This block generates everything position related - it's the core of draggables.
  3943. */
  3944. //Cache the margins of the original element
  3945. this._cacheMargins();
  3946. //Get the next scrolling parent
  3947. this.scrollParent = this.helper.scrollParent();
  3948. //The element's absolute position on the page minus margins
  3949. this.offset = this.currentItem.offset();
  3950. this.offset = {
  3951. top: this.offset.top - this.margins.top,
  3952. left: this.offset.left - this.margins.left
  3953. };
  3954. $.extend(this.offset, {
  3955. click: { //Where the click happened, relative to the element
  3956. left: event.pageX - this.offset.left,
  3957. top: event.pageY - this.offset.top
  3958. },
  3959. parent: this._getParentOffset(),
  3960. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3961. });
  3962. // Only after we got the offset, we can change the helper's position to absolute
  3963. // TODO: Still need to figure out a way to make relative sorting possible
  3964. this.helper.css("position", "absolute");
  3965. this.cssPosition = this.helper.css("position");
  3966. //Generate the original position
  3967. this.originalPosition = this._generatePosition(event);
  3968. this.originalPageX = event.pageX;
  3969. this.originalPageY = event.pageY;
  3970. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3971. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3972. //Cache the former DOM position
  3973. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3974. //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
  3975. if(this.helper[0] !== this.currentItem[0]) {
  3976. this.currentItem.hide();
  3977. }
  3978. //Create the placeholder
  3979. this._createPlaceholder();
  3980. //Set a containment if given in the options
  3981. if(o.containment) {
  3982. this._setContainment();
  3983. }
  3984. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  3985. body = this.document.find( "body" );
  3986. // support: IE
  3987. this.storedCursor = body.css( "cursor" );
  3988. body.css( "cursor", o.cursor );
  3989. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  3990. }
  3991. if(o.opacity) { // opacity option
  3992. if (this.helper.css("opacity")) {
  3993. this._storedOpacity = this.helper.css("opacity");
  3994. }
  3995. this.helper.css("opacity", o.opacity);
  3996. }
  3997. if(o.zIndex) { // zIndex option
  3998. if (this.helper.css("zIndex")) {
  3999. this._storedZIndex = this.helper.css("zIndex");
  4000. }
  4001. this.helper.css("zIndex", o.zIndex);
  4002. }
  4003. //Prepare scrolling
  4004. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  4005. this.overflowOffset = this.scrollParent.offset();
  4006. }
  4007. //Call callbacks
  4008. this._trigger("start", event, this._uiHash());
  4009. //Recache the helper size
  4010. if(!this._preserveHelperProportions) {
  4011. this._cacheHelperProportions();
  4012. }
  4013. //Post "activate" events to possible containers
  4014. if( !noActivation ) {
  4015. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  4016. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  4017. }
  4018. }
  4019. //Prepare possible droppables
  4020. if($.ui.ddmanager) {
  4021. $.ui.ddmanager.current = this;
  4022. }
  4023. if ($.ui.ddmanager && !o.dropBehaviour) {
  4024. $.ui.ddmanager.prepareOffsets(this, event);
  4025. }
  4026. this.dragging = true;
  4027. this.helper.addClass("ui-sortable-helper");
  4028. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  4029. return true;
  4030. },
  4031. _mouseDrag: function(event) {
  4032. var i, item, itemElement, intersection,
  4033. o = this.options,
  4034. scrolled = false;
  4035. //Compute the helpers position
  4036. this.position = this._generatePosition(event);
  4037. this.positionAbs = this._convertPositionTo("absolute");
  4038. if (!this.lastPositionAbs) {
  4039. this.lastPositionAbs = this.positionAbs;
  4040. }
  4041. //Do scrolling
  4042. if(this.options.scroll) {
  4043. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  4044. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  4045. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  4046. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  4047. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  4048. }
  4049. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  4050. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  4051. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  4052. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  4053. }
  4054. } else {
  4055. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  4056. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  4057. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  4058. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  4059. }
  4060. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  4061. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  4062. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  4063. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  4064. }
  4065. }
  4066. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  4067. $.ui.ddmanager.prepareOffsets(this, event);
  4068. }
  4069. }
  4070. //Regenerate the absolute position used for position checks
  4071. this.positionAbs = this._convertPositionTo("absolute");
  4072. //Set the helper position
  4073. if(!this.options.axis || this.options.axis !== "y") {
  4074. this.helper[0].style.left = this.position.left+"px";
  4075. }
  4076. if(!this.options.axis || this.options.axis !== "x") {
  4077. this.helper[0].style.top = this.position.top+"px";
  4078. }
  4079. //Rearrange
  4080. for (i = this.items.length - 1; i >= 0; i--) {
  4081. //Cache variables and intersection, continue if no intersection
  4082. item = this.items[i];
  4083. itemElement = item.item[0];
  4084. intersection = this._intersectsWithPointer(item);
  4085. if (!intersection) {
  4086. continue;
  4087. }
  4088. // Only put the placeholder inside the current Container, skip all
  4089. // items from other containers. This works because when moving
  4090. // an item from one container to another the
  4091. // currentContainer is switched before the placeholder is moved.
  4092. //
  4093. // Without this, moving items in "sub-sortables" can cause
  4094. // the placeholder to jitter between the outer and inner container.
  4095. if (item.instance !== this.currentContainer) {
  4096. continue;
  4097. }
  4098. // cannot intersect with itself
  4099. // no useless actions that have been done before
  4100. // no action if the item moved is the parent of the item checked
  4101. if (itemElement !== this.currentItem[0] &&
  4102. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  4103. !$.contains(this.placeholder[0], itemElement) &&
  4104. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  4105. ) {
  4106. this.direction = intersection === 1 ? "down" : "up";
  4107. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  4108. this._rearrange(event, item);
  4109. } else {
  4110. break;
  4111. }
  4112. this._trigger("change", event, this._uiHash());
  4113. break;
  4114. }
  4115. }
  4116. //Post events to containers
  4117. this._contactContainers(event);
  4118. //Interconnect with droppables
  4119. if($.ui.ddmanager) {
  4120. $.ui.ddmanager.drag(this, event);
  4121. }
  4122. //Call callbacks
  4123. this._trigger("sort", event, this._uiHash());
  4124. this.lastPositionAbs = this.positionAbs;
  4125. return false;
  4126. },
  4127. _mouseStop: function(event, noPropagation) {
  4128. if(!event) {
  4129. return;
  4130. }
  4131. //If we are using droppables, inform the manager about the drop
  4132. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  4133. $.ui.ddmanager.drop(this, event);
  4134. }
  4135. if(this.options.revert) {
  4136. var that = this,
  4137. cur = this.placeholder.offset(),
  4138. axis = this.options.axis,
  4139. animation = {};
  4140. if ( !axis || axis === "x" ) {
  4141. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  4142. }
  4143. if ( !axis || axis === "y" ) {
  4144. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  4145. }
  4146. this.reverting = true;
  4147. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  4148. that._clear(event);
  4149. });
  4150. } else {
  4151. this._clear(event, noPropagation);
  4152. }
  4153. return false;
  4154. },
  4155. cancel: function() {
  4156. if(this.dragging) {
  4157. this._mouseUp({ target: null });
  4158. if(this.options.helper === "original") {
  4159. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  4160. } else {
  4161. this.currentItem.show();
  4162. }
  4163. //Post deactivating events to containers
  4164. for (var i = this.containers.length - 1; i >= 0; i--){
  4165. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  4166. if(this.containers[i].containerCache.over) {
  4167. this.containers[i]._trigger("out", null, this._uiHash(this));
  4168. this.containers[i].containerCache.over = 0;
  4169. }
  4170. }
  4171. }
  4172. if (this.placeholder) {
  4173. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  4174. if(this.placeholder[0].parentNode) {
  4175. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  4176. }
  4177. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  4178. this.helper.remove();
  4179. }
  4180. $.extend(this, {
  4181. helper: null,
  4182. dragging: false,
  4183. reverting: false,
  4184. _noFinalSort: null
  4185. });
  4186. if(this.domPosition.prev) {
  4187. $(this.domPosition.prev).after(this.currentItem);
  4188. } else {
  4189. $(this.domPosition.parent).prepend(this.currentItem);
  4190. }
  4191. }
  4192. return this;
  4193. },
  4194. serialize: function(o) {
  4195. var items = this._getItemsAsjQuery(o && o.connected),
  4196. str = [];
  4197. o = o || {};
  4198. $(items).each(function() {
  4199. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  4200. if (res) {
  4201. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  4202. }
  4203. });
  4204. if(!str.length && o.key) {
  4205. str.push(o.key + "=");
  4206. }
  4207. return str.join("&");
  4208. },
  4209. toArray: function(o) {
  4210. var items = this._getItemsAsjQuery(o && o.connected),
  4211. ret = [];
  4212. o = o || {};
  4213. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  4214. return ret;
  4215. },
  4216. /* Be careful with the following core functions */
  4217. _intersectsWith: function(item) {
  4218. var x1 = this.positionAbs.left,
  4219. x2 = x1 + this.helperProportions.width,
  4220. y1 = this.positionAbs.top,
  4221. y2 = y1 + this.helperProportions.height,
  4222. l = item.left,
  4223. r = l + item.width,
  4224. t = item.top,
  4225. b = t + item.height,
  4226. dyClick = this.offset.click.top,
  4227. dxClick = this.offset.click.left,
  4228. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  4229. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  4230. isOverElement = isOverElementHeight && isOverElementWidth;
  4231. if ( this.options.tolerance === "pointer" ||
  4232. this.options.forcePointerForContainers ||
  4233. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  4234. ) {
  4235. return isOverElement;
  4236. } else {
  4237. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  4238. x2 - (this.helperProportions.width / 2) < r && // Left Half
  4239. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  4240. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  4241. }
  4242. },
  4243. _intersectsWithPointer: function(item) {
  4244. var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  4245. isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  4246. isOverElement = isOverElementHeight && isOverElementWidth,
  4247. verticalDirection = this._getDragVerticalDirection(),
  4248. horizontalDirection = this._getDragHorizontalDirection();
  4249. if (!isOverElement) {
  4250. return false;
  4251. }
  4252. return this.floating ?
  4253. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  4254. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  4255. },
  4256. _intersectsWithSides: function(item) {
  4257. var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  4258. isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  4259. verticalDirection = this._getDragVerticalDirection(),
  4260. horizontalDirection = this._getDragHorizontalDirection();
  4261. if (this.floating && horizontalDirection) {
  4262. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  4263. } else {
  4264. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  4265. }
  4266. },
  4267. _getDragVerticalDirection: function() {
  4268. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  4269. return delta !== 0 && (delta > 0 ? "down" : "up");
  4270. },
  4271. _getDragHorizontalDirection: function() {
  4272. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  4273. return delta !== 0 && (delta > 0 ? "right" : "left");
  4274. },
  4275. refresh: function(event) {
  4276. this._refreshItems(event);
  4277. this._setHandleClassName();
  4278. this.refreshPositions();
  4279. return this;
  4280. },
  4281. _connectWith: function() {
  4282. var options = this.options;
  4283. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  4284. },
  4285. _getItemsAsjQuery: function(connected) {
  4286. var i, j, cur, inst,
  4287. items = [],
  4288. queries = [],
  4289. connectWith = this._connectWith();
  4290. if(connectWith && connected) {
  4291. for (i = connectWith.length - 1; i >= 0; i--){
  4292. cur = $(connectWith[i]);
  4293. for ( j = cur.length - 1; j >= 0; j--){
  4294. inst = $.data(cur[j], this.widgetFullName);
  4295. if(inst && inst !== this && !inst.options.disabled) {
  4296. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]);
  4297. }
  4298. }
  4299. }
  4300. }
  4301. queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
  4302. function addItems() {
  4303. items.push( this );
  4304. }
  4305. for (i = queries.length - 1; i >= 0; i--){
  4306. queries[i][0].each( addItems );
  4307. }
  4308. return $(items);
  4309. },
  4310. _removeCurrentsFromItems: function() {
  4311. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  4312. this.items = $.grep(this.items, function (item) {
  4313. for (var j=0; j < list.length; j++) {
  4314. if(list[j] === item.item[0]) {
  4315. return false;
  4316. }
  4317. }
  4318. return true;
  4319. });
  4320. },
  4321. _refreshItems: function(event) {
  4322. this.items = [];
  4323. this.containers = [this];
  4324. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  4325. items = this.items,
  4326. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  4327. connectWith = this._connectWith();
  4328. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  4329. for (i = connectWith.length - 1; i >= 0; i--){
  4330. cur = $(connectWith[i]);
  4331. for (j = cur.length - 1; j >= 0; j--){
  4332. inst = $.data(cur[j], this.widgetFullName);
  4333. if(inst && inst !== this && !inst.options.disabled) {
  4334. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  4335. this.containers.push(inst);
  4336. }
  4337. }
  4338. }
  4339. }
  4340. for (i = queries.length - 1; i >= 0; i--) {
  4341. targetData = queries[i][1];
  4342. _queries = queries[i][0];
  4343. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  4344. item = $(_queries[j]);
  4345. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  4346. items.push({
  4347. item: item,
  4348. instance: targetData,
  4349. width: 0, height: 0,
  4350. left: 0, top: 0
  4351. });
  4352. }
  4353. }
  4354. },
  4355. refreshPositions: function(fast) {
  4356. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  4357. if(this.offsetParent && this.helper) {
  4358. this.offset.parent = this._getParentOffset();
  4359. }
  4360. var i, item, t, p;
  4361. for (i = this.items.length - 1; i >= 0; i--){
  4362. item = this.items[i];
  4363. //We ignore calculating positions of all connected containers when we're not over them
  4364. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  4365. continue;
  4366. }
  4367. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  4368. if (!fast) {
  4369. item.width = t.outerWidth();
  4370. item.height = t.outerHeight();
  4371. }
  4372. p = t.offset();
  4373. item.left = p.left;
  4374. item.top = p.top;
  4375. }
  4376. if(this.options.custom && this.options.custom.refreshContainers) {
  4377. this.options.custom.refreshContainers.call(this);
  4378. } else {
  4379. for (i = this.containers.length - 1; i >= 0; i--){
  4380. p = this.containers[i].element.offset();
  4381. this.containers[i].containerCache.left = p.left;
  4382. this.containers[i].containerCache.top = p.top;
  4383. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  4384. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  4385. }
  4386. }
  4387. return this;
  4388. },
  4389. _createPlaceholder: function(that) {
  4390. that = that || this;
  4391. var className,
  4392. o = that.options;
  4393. if(!o.placeholder || o.placeholder.constructor === String) {
  4394. className = o.placeholder;
  4395. o.placeholder = {
  4396. element: function() {
  4397. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  4398. element = $( "<" + nodeName + ">", that.document[0] )
  4399. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  4400. .removeClass("ui-sortable-helper");
  4401. if ( nodeName === "tr" ) {
  4402. that.currentItem.children().each(function() {
  4403. $( "<td>&#160;</td>", that.document[0] )
  4404. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  4405. .appendTo( element );
  4406. });
  4407. } else if ( nodeName === "img" ) {
  4408. element.attr( "src", that.currentItem.attr( "src" ) );
  4409. }
  4410. if ( !className ) {
  4411. element.css( "visibility", "hidden" );
  4412. }
  4413. return element;
  4414. },
  4415. update: function(container, p) {
  4416. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  4417. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  4418. if(className && !o.forcePlaceholderSize) {
  4419. return;
  4420. }
  4421. //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
  4422. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  4423. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  4424. }
  4425. };
  4426. }
  4427. //Create the placeholder
  4428. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  4429. //Append it after the actual current item
  4430. that.currentItem.after(that.placeholder);
  4431. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  4432. o.placeholder.update(that, that.placeholder);
  4433. },
  4434. _contactContainers: function(event) {
  4435. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
  4436. innermostContainer = null,
  4437. innermostIndex = null;
  4438. // get innermost container that intersects with item
  4439. for (i = this.containers.length - 1; i >= 0; i--) {
  4440. // never consider a container that's located within the item itself
  4441. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  4442. continue;
  4443. }
  4444. if(this._intersectsWith(this.containers[i].containerCache)) {
  4445. // if we've already found a container and it's more "inner" than this, then continue
  4446. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  4447. continue;
  4448. }
  4449. innermostContainer = this.containers[i];
  4450. innermostIndex = i;
  4451. } else {
  4452. // container doesn't intersect. trigger "out" event if necessary
  4453. if(this.containers[i].containerCache.over) {
  4454. this.containers[i]._trigger("out", event, this._uiHash(this));
  4455. this.containers[i].containerCache.over = 0;
  4456. }
  4457. }
  4458. }
  4459. // if no intersecting containers found, return
  4460. if(!innermostContainer) {
  4461. return;
  4462. }
  4463. // move the item into the container if it's not there already
  4464. if(this.containers.length === 1) {
  4465. if (!this.containers[innermostIndex].containerCache.over) {
  4466. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4467. this.containers[innermostIndex].containerCache.over = 1;
  4468. }
  4469. } else {
  4470. //When entering a new container, we will find the item with the least distance and append our item near it
  4471. dist = 10000;
  4472. itemWithLeastDistance = null;
  4473. floating = innermostContainer.floating || this._isFloating(this.currentItem);
  4474. posProperty = floating ? "left" : "top";
  4475. sizeProperty = floating ? "width" : "height";
  4476. axis = floating ? "clientX" : "clientY";
  4477. for (j = this.items.length - 1; j >= 0; j--) {
  4478. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  4479. continue;
  4480. }
  4481. if(this.items[j].item[0] === this.currentItem[0]) {
  4482. continue;
  4483. }
  4484. cur = this.items[j].item.offset()[posProperty];
  4485. nearBottom = false;
  4486. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  4487. nearBottom = true;
  4488. }
  4489. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  4490. dist = Math.abs( event[ axis ] - cur );
  4491. itemWithLeastDistance = this.items[ j ];
  4492. this.direction = nearBottom ? "up": "down";
  4493. }
  4494. }
  4495. //Check if dropOnEmpty is enabled
  4496. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  4497. return;
  4498. }
  4499. if(this.currentContainer === this.containers[innermostIndex]) {
  4500. if ( !this.currentContainer.containerCache.over ) {
  4501. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  4502. this.currentContainer.containerCache.over = 1;
  4503. }
  4504. return;
  4505. }
  4506. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  4507. this._trigger("change", event, this._uiHash());
  4508. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  4509. this.currentContainer = this.containers[innermostIndex];
  4510. //Update the placeholder
  4511. this.options.placeholder.update(this.currentContainer, this.placeholder);
  4512. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4513. this.containers[innermostIndex].containerCache.over = 1;
  4514. }
  4515. },
  4516. _createHelper: function(event) {
  4517. var o = this.options,
  4518. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  4519. //Add the helper to the DOM if that didn't happen already
  4520. if(!helper.parents("body").length) {
  4521. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  4522. }
  4523. if(helper[0] === this.currentItem[0]) {
  4524. this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
  4525. }
  4526. if(!helper[0].style.width || o.forceHelperSize) {
  4527. helper.width(this.currentItem.width());
  4528. }
  4529. if(!helper[0].style.height || o.forceHelperSize) {
  4530. helper.height(this.currentItem.height());
  4531. }
  4532. return helper;
  4533. },
  4534. _adjustOffsetFromHelper: function(obj) {
  4535. if (typeof obj === "string") {
  4536. obj = obj.split(" ");
  4537. }
  4538. if ($.isArray(obj)) {
  4539. obj = {left: +obj[0], top: +obj[1] || 0};
  4540. }
  4541. if ("left" in obj) {
  4542. this.offset.click.left = obj.left + this.margins.left;
  4543. }
  4544. if ("right" in obj) {
  4545. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  4546. }
  4547. if ("top" in obj) {
  4548. this.offset.click.top = obj.top + this.margins.top;
  4549. }
  4550. if ("bottom" in obj) {
  4551. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  4552. }
  4553. },
  4554. _getParentOffset: function() {
  4555. //Get the offsetParent and cache its position
  4556. this.offsetParent = this.helper.offsetParent();
  4557. var po = this.offsetParent.offset();
  4558. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  4559. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  4560. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  4561. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  4562. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  4563. po.left += this.scrollParent.scrollLeft();
  4564. po.top += this.scrollParent.scrollTop();
  4565. }
  4566. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  4567. // with an ugly IE fix
  4568. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  4569. po = { top: 0, left: 0 };
  4570. }
  4571. return {
  4572. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  4573. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  4574. };
  4575. },
  4576. _getRelativeOffset: function() {
  4577. if(this.cssPosition === "relative") {
  4578. var p = this.currentItem.position();
  4579. return {
  4580. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  4581. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  4582. };
  4583. } else {
  4584. return { top: 0, left: 0 };
  4585. }
  4586. },
  4587. _cacheMargins: function() {
  4588. this.margins = {
  4589. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  4590. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  4591. };
  4592. },
  4593. _cacheHelperProportions: function() {
  4594. this.helperProportions = {
  4595. width: this.helper.outerWidth(),
  4596. height: this.helper.outerHeight()
  4597. };
  4598. },
  4599. _setContainment: function() {
  4600. var ce, co, over,
  4601. o = this.options;
  4602. if(o.containment === "parent") {
  4603. o.containment = this.helper[0].parentNode;
  4604. }
  4605. if(o.containment === "document" || o.containment === "window") {
  4606. this.containment = [
  4607. 0 - this.offset.relative.left - this.offset.parent.left,
  4608. 0 - this.offset.relative.top - this.offset.parent.top,
  4609. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  4610. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  4611. ];
  4612. }
  4613. if(!(/^(document|window|parent)$/).test(o.containment)) {
  4614. ce = $(o.containment)[0];
  4615. co = $(o.containment).offset();
  4616. over = ($(ce).css("overflow") !== "hidden");
  4617. this.containment = [
  4618. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  4619. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  4620. co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
  4621. co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
  4622. ];
  4623. }
  4624. },
  4625. _convertPositionTo: function(d, pos) {
  4626. if(!pos) {
  4627. pos = this.position;
  4628. }
  4629. var mod = d === "absolute" ? 1 : -1,
  4630. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  4631. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  4632. return {
  4633. top: (
  4634. pos.top + // The absolute mouse position
  4635. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4636. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  4637. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  4638. ),
  4639. left: (
  4640. pos.left + // The absolute mouse position
  4641. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4642. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  4643. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  4644. )
  4645. };
  4646. },
  4647. _generatePosition: function(event) {
  4648. var top, left,
  4649. o = this.options,
  4650. pageX = event.pageX,
  4651. pageY = event.pageY,
  4652. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  4653. // This is another very weird special case that only happens for relative elements:
  4654. // 1. If the css position is relative
  4655. // 2. and the scroll parent is the document or similar to the offset parent
  4656. // we have to refresh the relative offset during the scroll so there are no jumps
  4657. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  4658. this.offset.relative = this._getRelativeOffset();
  4659. }
  4660. /*
  4661. * - Position constraining -
  4662. * Constrain the position to a mix of grid, containment.
  4663. */
  4664. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  4665. if(this.containment) {
  4666. if(event.pageX - this.offset.click.left < this.containment[0]) {
  4667. pageX = this.containment[0] + this.offset.click.left;
  4668. }
  4669. if(event.pageY - this.offset.click.top < this.containment[1]) {
  4670. pageY = this.containment[1] + this.offset.click.top;
  4671. }
  4672. if(event.pageX - this.offset.click.left > this.containment[2]) {
  4673. pageX = this.containment[2] + this.offset.click.left;
  4674. }
  4675. if(event.pageY - this.offset.click.top > this.containment[3]) {
  4676. pageY = this.containment[3] + this.offset.click.top;
  4677. }
  4678. }
  4679. if(o.grid) {
  4680. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  4681. pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
  4682. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  4683. pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
  4684. }
  4685. }
  4686. return {
  4687. top: (
  4688. pageY - // The absolute mouse position
  4689. this.offset.click.top - // Click offset (relative to the element)
  4690. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  4691. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  4692. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  4693. ),
  4694. left: (
  4695. pageX - // The absolute mouse position
  4696. this.offset.click.left - // Click offset (relative to the element)
  4697. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  4698. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  4699. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  4700. )
  4701. };
  4702. },
  4703. _rearrange: function(event, i, a, hardRefresh) {
  4704. a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling));
  4705. //Various things done here to improve the performance:
  4706. // 1. we create a setTimeout, that calls refreshPositions
  4707. // 2. on the instance, we have a counter variable, that get's higher after every append
  4708. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  4709. // 4. this lets only the last addition to the timeout stack through
  4710. this.counter = this.counter ? ++this.counter : 1;
  4711. var counter = this.counter;
  4712. this._delay(function() {
  4713. if(counter === this.counter) {
  4714. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  4715. }
  4716. });
  4717. },
  4718. _clear: function(event, noPropagation) {
  4719. this.reverting = false;
  4720. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  4721. // everything else normalized again
  4722. var i,
  4723. delayedTriggers = [];
  4724. // We first have to update the dom position of the actual currentItem
  4725. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  4726. if(!this._noFinalSort && this.currentItem.parent().length) {
  4727. this.placeholder.before(this.currentItem);
  4728. }
  4729. this._noFinalSort = null;
  4730. if(this.helper[0] === this.currentItem[0]) {
  4731. for(i in this._storedCSS) {
  4732. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  4733. this._storedCSS[i] = "";
  4734. }
  4735. }
  4736. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  4737. } else {
  4738. this.currentItem.show();
  4739. }
  4740. if(this.fromOutside && !noPropagation) {
  4741. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  4742. }
  4743. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  4744. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  4745. }
  4746. // Check if the items Container has Changed and trigger appropriate
  4747. // events.
  4748. if (this !== this.currentContainer) {
  4749. if(!noPropagation) {
  4750. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  4751. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4752. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4753. }
  4754. }
  4755. //Post events to containers
  4756. function delayEvent( type, instance, container ) {
  4757. return function( event ) {
  4758. container._trigger( type, event, instance._uiHash( instance ) );
  4759. };
  4760. }
  4761. for (i = this.containers.length - 1; i >= 0; i--){
  4762. if (!noPropagation) {
  4763. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  4764. }
  4765. if(this.containers[i].containerCache.over) {
  4766. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  4767. this.containers[i].containerCache.over = 0;
  4768. }
  4769. }
  4770. //Do what was originally in plugins
  4771. if ( this.storedCursor ) {
  4772. this.document.find( "body" ).css( "cursor", this.storedCursor );
  4773. this.storedStylesheet.remove();
  4774. }
  4775. if(this._storedOpacity) {
  4776. this.helper.css("opacity", this._storedOpacity);
  4777. }
  4778. if(this._storedZIndex) {
  4779. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  4780. }
  4781. this.dragging = false;
  4782. if(!noPropagation) {
  4783. this._trigger("beforeStop", event, this._uiHash());
  4784. }
  4785. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  4786. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  4787. if ( !this.cancelHelperRemoval ) {
  4788. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  4789. this.helper.remove();
  4790. }
  4791. this.helper = null;
  4792. }
  4793. if(!noPropagation) {
  4794. for (i=0; i < delayedTriggers.length; i++) {
  4795. delayedTriggers[i].call(this, event);
  4796. } //Trigger all delayed events
  4797. this._trigger("stop", event, this._uiHash());
  4798. }
  4799. this.fromOutside = false;
  4800. return !this.cancelHelperRemoval;
  4801. },
  4802. _trigger: function() {
  4803. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  4804. this.cancel();
  4805. }
  4806. },
  4807. _uiHash: function(_inst) {
  4808. var inst = _inst || this;
  4809. return {
  4810. helper: inst.helper,
  4811. placeholder: inst.placeholder || $([]),
  4812. position: inst.position,
  4813. originalPosition: inst.originalPosition,
  4814. offset: inst.positionAbs,
  4815. item: inst.currentItem,
  4816. sender: _inst ? _inst.element : null
  4817. };
  4818. }
  4819. });
  4820. /*!
  4821. * jQuery UI Accordion 1.11.2
  4822. * http://jqueryui.com
  4823. *
  4824. * Copyright 2014 jQuery Foundation and other contributors
  4825. * Released under the MIT license.
  4826. * http://jquery.org/license
  4827. *
  4828. * http://api.jqueryui.com/accordion/
  4829. */
  4830. var accordion = $.widget( "ui.accordion", {
  4831. version: "1.11.2",
  4832. options: {
  4833. active: 0,
  4834. animate: {},
  4835. collapsible: false,
  4836. event: "click",
  4837. header: "> li > :first-child,> :not(li):even",
  4838. heightStyle: "auto",
  4839. icons: {
  4840. activeHeader: "ui-icon-triangle-1-s",
  4841. header: "ui-icon-triangle-1-e"
  4842. },
  4843. // callbacks
  4844. activate: null,
  4845. beforeActivate: null
  4846. },
  4847. hideProps: {
  4848. borderTopWidth: "hide",
  4849. borderBottomWidth: "hide",
  4850. paddingTop: "hide",
  4851. paddingBottom: "hide",
  4852. height: "hide"
  4853. },
  4854. showProps: {
  4855. borderTopWidth: "show",
  4856. borderBottomWidth: "show",
  4857. paddingTop: "show",
  4858. paddingBottom: "show",
  4859. height: "show"
  4860. },
  4861. _create: function() {
  4862. var options = this.options;
  4863. this.prevShow = this.prevHide = $();
  4864. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  4865. // ARIA
  4866. .attr( "role", "tablist" );
  4867. // don't allow collapsible: false and active: false / null
  4868. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  4869. options.active = 0;
  4870. }
  4871. this._processPanels();
  4872. // handle negative values
  4873. if ( options.active < 0 ) {
  4874. options.active += this.headers.length;
  4875. }
  4876. this._refresh();
  4877. },
  4878. _getCreateEventData: function() {
  4879. return {
  4880. header: this.active,
  4881. panel: !this.active.length ? $() : this.active.next()
  4882. };
  4883. },
  4884. _createIcons: function() {
  4885. var icons = this.options.icons;
  4886. if ( icons ) {
  4887. $( "<span>" )
  4888. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  4889. .prependTo( this.headers );
  4890. this.active.children( ".ui-accordion-header-icon" )
  4891. .removeClass( icons.header )
  4892. .addClass( icons.activeHeader );
  4893. this.headers.addClass( "ui-accordion-icons" );
  4894. }
  4895. },
  4896. _destroyIcons: function() {
  4897. this.headers
  4898. .removeClass( "ui-accordion-icons" )
  4899. .children( ".ui-accordion-header-icon" )
  4900. .remove();
  4901. },
  4902. _destroy: function() {
  4903. var contents;
  4904. // clean up main element
  4905. this.element
  4906. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  4907. .removeAttr( "role" );
  4908. // clean up headers
  4909. this.headers
  4910. .removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " +
  4911. "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
  4912. .removeAttr( "role" )
  4913. .removeAttr( "aria-expanded" )
  4914. .removeAttr( "aria-selected" )
  4915. .removeAttr( "aria-controls" )
  4916. .removeAttr( "tabIndex" )
  4917. .removeUniqueId();
  4918. this._destroyIcons();
  4919. // clean up content panels
  4920. contents = this.headers.next()
  4921. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " +
  4922. "ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  4923. .css( "display", "" )
  4924. .removeAttr( "role" )
  4925. .removeAttr( "aria-hidden" )
  4926. .removeAttr( "aria-labelledby" )
  4927. .removeUniqueId();
  4928. if ( this.options.heightStyle !== "content" ) {
  4929. contents.css( "height", "" );
  4930. }
  4931. },
  4932. _setOption: function( key, value ) {
  4933. if ( key === "active" ) {
  4934. // _activate() will handle invalid values and update this.options
  4935. this._activate( value );
  4936. return;
  4937. }
  4938. if ( key === "event" ) {
  4939. if ( this.options.event ) {
  4940. this._off( this.headers, this.options.event );
  4941. }
  4942. this._setupEvents( value );
  4943. }
  4944. this._super( key, value );
  4945. // setting collapsible: false while collapsed; open first panel
  4946. if ( key === "collapsible" && !value && this.options.active === false ) {
  4947. this._activate( 0 );
  4948. }
  4949. if ( key === "icons" ) {
  4950. this._destroyIcons();
  4951. if ( value ) {
  4952. this._createIcons();
  4953. }
  4954. }
  4955. // #5332 - opacity doesn't cascade to positioned elements in IE
  4956. // so we need to add the disabled class to the headers and panels
  4957. if ( key === "disabled" ) {
  4958. this.element
  4959. .toggleClass( "ui-state-disabled", !!value )
  4960. .attr( "aria-disabled", value );
  4961. this.headers.add( this.headers.next() )
  4962. .toggleClass( "ui-state-disabled", !!value );
  4963. }
  4964. },
  4965. _keydown: function( event ) {
  4966. if ( event.altKey || event.ctrlKey ) {
  4967. return;
  4968. }
  4969. var keyCode = $.ui.keyCode,
  4970. length = this.headers.length,
  4971. currentIndex = this.headers.index( event.target ),
  4972. toFocus = false;
  4973. switch ( event.keyCode ) {
  4974. case keyCode.RIGHT:
  4975. case keyCode.DOWN:
  4976. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  4977. break;
  4978. case keyCode.LEFT:
  4979. case keyCode.UP:
  4980. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  4981. break;
  4982. case keyCode.SPACE:
  4983. case keyCode.ENTER:
  4984. this._eventHandler( event );
  4985. break;
  4986. case keyCode.HOME:
  4987. toFocus = this.headers[ 0 ];
  4988. break;
  4989. case keyCode.END:
  4990. toFocus = this.headers[ length - 1 ];
  4991. break;
  4992. }
  4993. if ( toFocus ) {
  4994. $( event.target ).attr( "tabIndex", -1 );
  4995. $( toFocus ).attr( "tabIndex", 0 );
  4996. toFocus.focus();
  4997. event.preventDefault();
  4998. }
  4999. },
  5000. _panelKeyDown: function( event ) {
  5001. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  5002. $( event.currentTarget ).prev().focus();
  5003. }
  5004. },
  5005. refresh: function() {
  5006. var options = this.options;
  5007. this._processPanels();
  5008. // was collapsed or no panel
  5009. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  5010. options.active = false;
  5011. this.active = $();
  5012. // active false only when collapsible is true
  5013. } else if ( options.active === false ) {
  5014. this._activate( 0 );
  5015. // was active, but active panel is gone
  5016. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5017. // all remaining panel are disabled
  5018. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  5019. options.active = false;
  5020. this.active = $();
  5021. // activate previous panel
  5022. } else {
  5023. this._activate( Math.max( 0, options.active - 1 ) );
  5024. }
  5025. // was active, active panel still exists
  5026. } else {
  5027. // make sure active index is correct
  5028. options.active = this.headers.index( this.active );
  5029. }
  5030. this._destroyIcons();
  5031. this._refresh();
  5032. },
  5033. _processPanels: function() {
  5034. var prevHeaders = this.headers,
  5035. prevPanels = this.panels;
  5036. this.headers = this.element.find( this.options.header )
  5037. .addClass( "ui-accordion-header ui-state-default ui-corner-all" );
  5038. this.panels = this.headers.next()
  5039. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  5040. .filter( ":not(.ui-accordion-content-active)" )
  5041. .hide();
  5042. // Avoid memory leaks (#10056)
  5043. if ( prevPanels ) {
  5044. this._off( prevHeaders.not( this.headers ) );
  5045. this._off( prevPanels.not( this.panels ) );
  5046. }
  5047. },
  5048. _refresh: function() {
  5049. var maxHeight,
  5050. options = this.options,
  5051. heightStyle = options.heightStyle,
  5052. parent = this.element.parent();
  5053. this.active = this._findActive( options.active )
  5054. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  5055. .removeClass( "ui-corner-all" );
  5056. this.active.next()
  5057. .addClass( "ui-accordion-content-active" )
  5058. .show();
  5059. this.headers
  5060. .attr( "role", "tab" )
  5061. .each(function() {
  5062. var header = $( this ),
  5063. headerId = header.uniqueId().attr( "id" ),
  5064. panel = header.next(),
  5065. panelId = panel.uniqueId().attr( "id" );
  5066. header.attr( "aria-controls", panelId );
  5067. panel.attr( "aria-labelledby", headerId );
  5068. })
  5069. .next()
  5070. .attr( "role", "tabpanel" );
  5071. this.headers
  5072. .not( this.active )
  5073. .attr({
  5074. "aria-selected": "false",
  5075. "aria-expanded": "false",
  5076. tabIndex: -1
  5077. })
  5078. .next()
  5079. .attr({
  5080. "aria-hidden": "true"
  5081. })
  5082. .hide();
  5083. // make sure at least one header is in the tab order
  5084. if ( !this.active.length ) {
  5085. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  5086. } else {
  5087. this.active.attr({
  5088. "aria-selected": "true",
  5089. "aria-expanded": "true",
  5090. tabIndex: 0
  5091. })
  5092. .next()
  5093. .attr({
  5094. "aria-hidden": "false"
  5095. });
  5096. }
  5097. this._createIcons();
  5098. this._setupEvents( options.event );
  5099. if ( heightStyle === "fill" ) {
  5100. maxHeight = parent.height();
  5101. this.element.siblings( ":visible" ).each(function() {
  5102. var elem = $( this ),
  5103. position = elem.css( "position" );
  5104. if ( position === "absolute" || position === "fixed" ) {
  5105. return;
  5106. }
  5107. maxHeight -= elem.outerHeight( true );
  5108. });
  5109. this.headers.each(function() {
  5110. maxHeight -= $( this ).outerHeight( true );
  5111. });
  5112. this.headers.next()
  5113. .each(function() {
  5114. $( this ).height( Math.max( 0, maxHeight -
  5115. $( this ).innerHeight() + $( this ).height() ) );
  5116. })
  5117. .css( "overflow", "auto" );
  5118. } else if ( heightStyle === "auto" ) {
  5119. maxHeight = 0;
  5120. this.headers.next()
  5121. .each(function() {
  5122. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  5123. })
  5124. .height( maxHeight );
  5125. }
  5126. },
  5127. _activate: function( index ) {
  5128. var active = this._findActive( index )[ 0 ];
  5129. // trying to activate the already active panel
  5130. if ( active === this.active[ 0 ] ) {
  5131. return;
  5132. }
  5133. // trying to collapse, simulate a click on the currently active header
  5134. active = active || this.active[ 0 ];
  5135. this._eventHandler({
  5136. target: active,
  5137. currentTarget: active,
  5138. preventDefault: $.noop
  5139. });
  5140. },
  5141. _findActive: function( selector ) {
  5142. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  5143. },
  5144. _setupEvents: function( event ) {
  5145. var events = {
  5146. keydown: "_keydown"
  5147. };
  5148. if ( event ) {
  5149. $.each( event.split( " " ), function( index, eventName ) {
  5150. events[ eventName ] = "_eventHandler";
  5151. });
  5152. }
  5153. this._off( this.headers.add( this.headers.next() ) );
  5154. this._on( this.headers, events );
  5155. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  5156. this._hoverable( this.headers );
  5157. this._focusable( this.headers );
  5158. },
  5159. _eventHandler: function( event ) {
  5160. var options = this.options,
  5161. active = this.active,
  5162. clicked = $( event.currentTarget ),
  5163. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  5164. collapsing = clickedIsActive && options.collapsible,
  5165. toShow = collapsing ? $() : clicked.next(),
  5166. toHide = active.next(),
  5167. eventData = {
  5168. oldHeader: active,
  5169. oldPanel: toHide,
  5170. newHeader: collapsing ? $() : clicked,
  5171. newPanel: toShow
  5172. };
  5173. event.preventDefault();
  5174. if (
  5175. // click on active header, but not collapsible
  5176. ( clickedIsActive && !options.collapsible ) ||
  5177. // allow canceling activation
  5178. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  5179. return;
  5180. }
  5181. options.active = collapsing ? false : this.headers.index( clicked );
  5182. // when the call to ._toggle() comes after the class changes
  5183. // it causes a very odd bug in IE 8 (see #6720)
  5184. this.active = clickedIsActive ? $() : clicked;
  5185. this._toggle( eventData );
  5186. // switch classes
  5187. // corner classes on the previously active header stay after the animation
  5188. active.removeClass( "ui-accordion-header-active ui-state-active" );
  5189. if ( options.icons ) {
  5190. active.children( ".ui-accordion-header-icon" )
  5191. .removeClass( options.icons.activeHeader )
  5192. .addClass( options.icons.header );
  5193. }
  5194. if ( !clickedIsActive ) {
  5195. clicked
  5196. .removeClass( "ui-corner-all" )
  5197. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  5198. if ( options.icons ) {
  5199. clicked.children( ".ui-accordion-header-icon" )
  5200. .removeClass( options.icons.header )
  5201. .addClass( options.icons.activeHeader );
  5202. }
  5203. clicked
  5204. .next()
  5205. .addClass( "ui-accordion-content-active" );
  5206. }
  5207. },
  5208. _toggle: function( data ) {
  5209. var toShow = data.newPanel,
  5210. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  5211. // handle activating a panel during the animation for another activation
  5212. this.prevShow.add( this.prevHide ).stop( true, true );
  5213. this.prevShow = toShow;
  5214. this.prevHide = toHide;
  5215. if ( this.options.animate ) {
  5216. this._animate( toShow, toHide, data );
  5217. } else {
  5218. toHide.hide();
  5219. toShow.show();
  5220. this._toggleComplete( data );
  5221. }
  5222. toHide.attr({
  5223. "aria-hidden": "true"
  5224. });
  5225. toHide.prev().attr( "aria-selected", "false" );
  5226. // if we're switching panels, remove the old header from the tab order
  5227. // if we're opening from collapsed state, remove the previous header from the tab order
  5228. // if we're collapsing, then keep the collapsing header in the tab order
  5229. if ( toShow.length && toHide.length ) {
  5230. toHide.prev().attr({
  5231. "tabIndex": -1,
  5232. "aria-expanded": "false"
  5233. });
  5234. } else if ( toShow.length ) {
  5235. this.headers.filter(function() {
  5236. return $( this ).attr( "tabIndex" ) === 0;
  5237. })
  5238. .attr( "tabIndex", -1 );
  5239. }
  5240. toShow
  5241. .attr( "aria-hidden", "false" )
  5242. .prev()
  5243. .attr({
  5244. "aria-selected": "true",
  5245. tabIndex: 0,
  5246. "aria-expanded": "true"
  5247. });
  5248. },
  5249. _animate: function( toShow, toHide, data ) {
  5250. var total, easing, duration,
  5251. that = this,
  5252. adjust = 0,
  5253. down = toShow.length &&
  5254. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  5255. animate = this.options.animate || {},
  5256. options = down && animate.down || animate,
  5257. complete = function() {
  5258. that._toggleComplete( data );
  5259. };
  5260. if ( typeof options === "number" ) {
  5261. duration = options;
  5262. }
  5263. if ( typeof options === "string" ) {
  5264. easing = options;
  5265. }
  5266. // fall back from options to animation in case of partial down settings
  5267. easing = easing || options.easing || animate.easing;
  5268. duration = duration || options.duration || animate.duration;
  5269. if ( !toHide.length ) {
  5270. return toShow.animate( this.showProps, duration, easing, complete );
  5271. }
  5272. if ( !toShow.length ) {
  5273. return toHide.animate( this.hideProps, duration, easing, complete );
  5274. }
  5275. total = toShow.show().outerHeight();
  5276. toHide.animate( this.hideProps, {
  5277. duration: duration,
  5278. easing: easing,
  5279. step: function( now, fx ) {
  5280. fx.now = Math.round( now );
  5281. }
  5282. });
  5283. toShow
  5284. .hide()
  5285. .animate( this.showProps, {
  5286. duration: duration,
  5287. easing: easing,
  5288. complete: complete,
  5289. step: function( now, fx ) {
  5290. fx.now = Math.round( now );
  5291. if ( fx.prop !== "height" ) {
  5292. adjust += fx.now;
  5293. } else if ( that.options.heightStyle !== "content" ) {
  5294. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  5295. adjust = 0;
  5296. }
  5297. }
  5298. });
  5299. },
  5300. _toggleComplete: function( data ) {
  5301. var toHide = data.oldPanel;
  5302. toHide
  5303. .removeClass( "ui-accordion-content-active" )
  5304. .prev()
  5305. .removeClass( "ui-corner-top" )
  5306. .addClass( "ui-corner-all" );
  5307. // Work around for rendering bug in IE (#5421)
  5308. if ( toHide.length ) {
  5309. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  5310. }
  5311. this._trigger( "activate", null, data );
  5312. }
  5313. });
  5314. /*!
  5315. * jQuery UI Menu 1.11.2
  5316. * http://jqueryui.com
  5317. *
  5318. * Copyright 2014 jQuery Foundation and other contributors
  5319. * Released under the MIT license.
  5320. * http://jquery.org/license
  5321. *
  5322. * http://api.jqueryui.com/menu/
  5323. */
  5324. var menu = $.widget( "ui.menu", {
  5325. version: "1.11.2",
  5326. defaultElement: "<ul>",
  5327. delay: 300,
  5328. options: {
  5329. icons: {
  5330. submenu: "ui-icon-carat-1-e"
  5331. },
  5332. items: "> *",
  5333. menus: "ul",
  5334. position: {
  5335. my: "left-1 top",
  5336. at: "right top"
  5337. },
  5338. role: "menu",
  5339. // callbacks
  5340. blur: null,
  5341. focus: null,
  5342. select: null
  5343. },
  5344. _create: function() {
  5345. this.activeMenu = this.element;
  5346. // Flag used to prevent firing of the click handler
  5347. // as the event bubbles up through nested menus
  5348. this.mouseHandled = false;
  5349. this.element
  5350. .uniqueId()
  5351. .addClass( "ui-menu ui-widget ui-widget-content" )
  5352. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  5353. .attr({
  5354. role: this.options.role,
  5355. tabIndex: 0
  5356. });
  5357. if ( this.options.disabled ) {
  5358. this.element
  5359. .addClass( "ui-state-disabled" )
  5360. .attr( "aria-disabled", "true" );
  5361. }
  5362. this._on({
  5363. // Prevent focus from sticking to links inside menu after clicking
  5364. // them (focus should always stay on UL during navigation).
  5365. "mousedown .ui-menu-item": function( event ) {
  5366. event.preventDefault();
  5367. },
  5368. "click .ui-menu-item": function( event ) {
  5369. var target = $( event.target );
  5370. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  5371. this.select( event );
  5372. // Only set the mouseHandled flag if the event will bubble, see #9469.
  5373. if ( !event.isPropagationStopped() ) {
  5374. this.mouseHandled = true;
  5375. }
  5376. // Open submenu on click
  5377. if ( target.has( ".ui-menu" ).length ) {
  5378. this.expand( event );
  5379. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  5380. // Redirect focus to the menu
  5381. this.element.trigger( "focus", [ true ] );
  5382. // If the active item is on the top level, let it stay active.
  5383. // Otherwise, blur the active item since it is no longer visible.
  5384. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  5385. clearTimeout( this.timer );
  5386. }
  5387. }
  5388. }
  5389. },
  5390. "mouseenter .ui-menu-item": function( event ) {
  5391. // Ignore mouse events while typeahead is active, see #10458.
  5392. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  5393. // is over an item in the menu
  5394. if ( this.previousFilter ) {
  5395. return;
  5396. }
  5397. var target = $( event.currentTarget );
  5398. // Remove ui-state-active class from siblings of the newly focused menu item
  5399. // to avoid a jump caused by adjacent elements both having a class with a border
  5400. target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
  5401. this.focus( event, target );
  5402. },
  5403. mouseleave: "collapseAll",
  5404. "mouseleave .ui-menu": "collapseAll",
  5405. focus: function( event, keepActiveItem ) {
  5406. // If there's already an active item, keep it active
  5407. // If not, activate the first item
  5408. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  5409. if ( !keepActiveItem ) {
  5410. this.focus( event, item );
  5411. }
  5412. },
  5413. blur: function( event ) {
  5414. this._delay(function() {
  5415. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  5416. this.collapseAll( event );
  5417. }
  5418. });
  5419. },
  5420. keydown: "_keydown"
  5421. });
  5422. this.refresh();
  5423. // Clicks outside of a menu collapse any open menus
  5424. this._on( this.document, {
  5425. click: function( event ) {
  5426. if ( this._closeOnDocumentClick( event ) ) {
  5427. this.collapseAll( event );
  5428. }
  5429. // Reset the mouseHandled flag
  5430. this.mouseHandled = false;
  5431. }
  5432. });
  5433. },
  5434. _destroy: function() {
  5435. // Destroy (sub)menus
  5436. this.element
  5437. .removeAttr( "aria-activedescendant" )
  5438. .find( ".ui-menu" ).addBack()
  5439. .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
  5440. .removeAttr( "role" )
  5441. .removeAttr( "tabIndex" )
  5442. .removeAttr( "aria-labelledby" )
  5443. .removeAttr( "aria-expanded" )
  5444. .removeAttr( "aria-hidden" )
  5445. .removeAttr( "aria-disabled" )
  5446. .removeUniqueId()
  5447. .show();
  5448. // Destroy menu items
  5449. this.element.find( ".ui-menu-item" )
  5450. .removeClass( "ui-menu-item" )
  5451. .removeAttr( "role" )
  5452. .removeAttr( "aria-disabled" )
  5453. .removeUniqueId()
  5454. .removeClass( "ui-state-hover" )
  5455. .removeAttr( "tabIndex" )
  5456. .removeAttr( "role" )
  5457. .removeAttr( "aria-haspopup" )
  5458. .children().each( function() {
  5459. var elem = $( this );
  5460. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  5461. elem.remove();
  5462. }
  5463. });
  5464. // Destroy menu dividers
  5465. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  5466. },
  5467. _keydown: function( event ) {
  5468. var match, prev, character, skip,
  5469. preventDefault = true;
  5470. switch ( event.keyCode ) {
  5471. case $.ui.keyCode.PAGE_UP:
  5472. this.previousPage( event );
  5473. break;
  5474. case $.ui.keyCode.PAGE_DOWN:
  5475. this.nextPage( event );
  5476. break;
  5477. case $.ui.keyCode.HOME:
  5478. this._move( "first", "first", event );
  5479. break;
  5480. case $.ui.keyCode.END:
  5481. this._move( "last", "last", event );
  5482. break;
  5483. case $.ui.keyCode.UP:
  5484. this.previous( event );
  5485. break;
  5486. case $.ui.keyCode.DOWN:
  5487. this.next( event );
  5488. break;
  5489. case $.ui.keyCode.LEFT:
  5490. this.collapse( event );
  5491. break;
  5492. case $.ui.keyCode.RIGHT:
  5493. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  5494. this.expand( event );
  5495. }
  5496. break;
  5497. case $.ui.keyCode.ENTER:
  5498. case $.ui.keyCode.SPACE:
  5499. this._activate( event );
  5500. break;
  5501. case $.ui.keyCode.ESCAPE:
  5502. this.collapse( event );
  5503. break;
  5504. default:
  5505. preventDefault = false;
  5506. prev = this.previousFilter || "";
  5507. character = String.fromCharCode( event.keyCode );
  5508. skip = false;
  5509. clearTimeout( this.filterTimer );
  5510. if ( character === prev ) {
  5511. skip = true;
  5512. } else {
  5513. character = prev + character;
  5514. }
  5515. match = this._filterMenuItems( character );
  5516. match = skip && match.index( this.active.next() ) !== -1 ?
  5517. this.active.nextAll( ".ui-menu-item" ) :
  5518. match;
  5519. // If no matches on the current filter, reset to the last character pressed
  5520. // to move down the menu to the first item that starts with that character
  5521. if ( !match.length ) {
  5522. character = String.fromCharCode( event.keyCode );
  5523. match = this._filterMenuItems( character );
  5524. }
  5525. if ( match.length ) {
  5526. this.focus( event, match );
  5527. this.previousFilter = character;
  5528. this.filterTimer = this._delay(function() {
  5529. delete this.previousFilter;
  5530. }, 1000 );
  5531. } else {
  5532. delete this.previousFilter;
  5533. }
  5534. }
  5535. if ( preventDefault ) {
  5536. event.preventDefault();
  5537. }
  5538. },
  5539. _activate: function( event ) {
  5540. if ( !this.active.is( ".ui-state-disabled" ) ) {
  5541. if ( this.active.is( "[aria-haspopup='true']" ) ) {
  5542. this.expand( event );
  5543. } else {
  5544. this.select( event );
  5545. }
  5546. }
  5547. },
  5548. refresh: function() {
  5549. var menus, items,
  5550. that = this,
  5551. icon = this.options.icons.submenu,
  5552. submenus = this.element.find( this.options.menus );
  5553. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  5554. // Initialize nested menus
  5555. submenus.filter( ":not(.ui-menu)" )
  5556. .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
  5557. .hide()
  5558. .attr({
  5559. role: this.options.role,
  5560. "aria-hidden": "true",
  5561. "aria-expanded": "false"
  5562. })
  5563. .each(function() {
  5564. var menu = $( this ),
  5565. item = menu.parent(),
  5566. submenuCarat = $( "<span>" )
  5567. .addClass( "ui-menu-icon ui-icon " + icon )
  5568. .data( "ui-menu-submenu-carat", true );
  5569. item
  5570. .attr( "aria-haspopup", "true" )
  5571. .prepend( submenuCarat );
  5572. menu.attr( "aria-labelledby", item.attr( "id" ) );
  5573. });
  5574. menus = submenus.add( this.element );
  5575. items = menus.find( this.options.items );
  5576. // Initialize menu-items containing spaces and/or dashes only as dividers
  5577. items.not( ".ui-menu-item" ).each(function() {
  5578. var item = $( this );
  5579. if ( that._isDivider( item ) ) {
  5580. item.addClass( "ui-widget-content ui-menu-divider" );
  5581. }
  5582. });
  5583. // Don't refresh list items that are already adapted
  5584. items.not( ".ui-menu-item, .ui-menu-divider" )
  5585. .addClass( "ui-menu-item" )
  5586. .uniqueId()
  5587. .attr({
  5588. tabIndex: -1,
  5589. role: this._itemRole()
  5590. });
  5591. // Add aria-disabled attribute to any disabled menu item
  5592. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  5593. // If the active item has been removed, blur the menu
  5594. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5595. this.blur();
  5596. }
  5597. },
  5598. _itemRole: function() {
  5599. return {
  5600. menu: "menuitem",
  5601. listbox: "option"
  5602. }[ this.options.role ];
  5603. },
  5604. _setOption: function( key, value ) {
  5605. if ( key === "icons" ) {
  5606. this.element.find( ".ui-menu-icon" )
  5607. .removeClass( this.options.icons.submenu )
  5608. .addClass( value.submenu );
  5609. }
  5610. if ( key === "disabled" ) {
  5611. this.element
  5612. .toggleClass( "ui-state-disabled", !!value )
  5613. .attr( "aria-disabled", value );
  5614. }
  5615. this._super( key, value );
  5616. },
  5617. focus: function( event, item ) {
  5618. var nested, focused;
  5619. this.blur( event, event && event.type === "focus" );
  5620. this._scrollIntoView( item );
  5621. this.active = item.first();
  5622. focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
  5623. // Only update aria-activedescendant if there's a role
  5624. // otherwise we assume focus is managed elsewhere
  5625. if ( this.options.role ) {
  5626. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  5627. }
  5628. // Highlight active parent menu item, if any
  5629. this.active
  5630. .parent()
  5631. .closest( ".ui-menu-item" )
  5632. .addClass( "ui-state-active" );
  5633. if ( event && event.type === "keydown" ) {
  5634. this._close();
  5635. } else {
  5636. this.timer = this._delay(function() {
  5637. this._close();
  5638. }, this.delay );
  5639. }
  5640. nested = item.children( ".ui-menu" );
  5641. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  5642. this._startOpening(nested);
  5643. }
  5644. this.activeMenu = item.parent();
  5645. this._trigger( "focus", event, { item: item } );
  5646. },
  5647. _scrollIntoView: function( item ) {
  5648. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  5649. if ( this._hasScroll() ) {
  5650. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  5651. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  5652. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  5653. scroll = this.activeMenu.scrollTop();
  5654. elementHeight = this.activeMenu.height();
  5655. itemHeight = item.outerHeight();
  5656. if ( offset < 0 ) {
  5657. this.activeMenu.scrollTop( scroll + offset );
  5658. } else if ( offset + itemHeight > elementHeight ) {
  5659. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  5660. }
  5661. }
  5662. },
  5663. blur: function( event, fromFocus ) {
  5664. if ( !fromFocus ) {
  5665. clearTimeout( this.timer );
  5666. }
  5667. if ( !this.active ) {
  5668. return;
  5669. }
  5670. this.active.removeClass( "ui-state-focus" );
  5671. this.active = null;
  5672. this._trigger( "blur", event, { item: this.active } );
  5673. },
  5674. _startOpening: function( submenu ) {
  5675. clearTimeout( this.timer );
  5676. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  5677. // shift in the submenu position when mousing over the carat icon
  5678. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  5679. return;
  5680. }
  5681. this.timer = this._delay(function() {
  5682. this._close();
  5683. this._open( submenu );
  5684. }, this.delay );
  5685. },
  5686. _open: function( submenu ) {
  5687. var position = $.extend({
  5688. of: this.active
  5689. }, this.options.position );
  5690. clearTimeout( this.timer );
  5691. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  5692. .hide()
  5693. .attr( "aria-hidden", "true" );
  5694. submenu
  5695. .show()
  5696. .removeAttr( "aria-hidden" )
  5697. .attr( "aria-expanded", "true" )
  5698. .position( position );
  5699. },
  5700. collapseAll: function( event, all ) {
  5701. clearTimeout( this.timer );
  5702. this.timer = this._delay(function() {
  5703. // If we were passed an event, look for the submenu that contains the event
  5704. var currentMenu = all ? this.element :
  5705. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  5706. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  5707. if ( !currentMenu.length ) {
  5708. currentMenu = this.element;
  5709. }
  5710. this._close( currentMenu );
  5711. this.blur( event );
  5712. this.activeMenu = currentMenu;
  5713. }, this.delay );
  5714. },
  5715. // With no arguments, closes the currently active menu - if nothing is active
  5716. // it closes all menus. If passed an argument, it will search for menus BELOW
  5717. _close: function( startMenu ) {
  5718. if ( !startMenu ) {
  5719. startMenu = this.active ? this.active.parent() : this.element;
  5720. }
  5721. startMenu
  5722. .find( ".ui-menu" )
  5723. .hide()
  5724. .attr( "aria-hidden", "true" )
  5725. .attr( "aria-expanded", "false" )
  5726. .end()
  5727. .find( ".ui-state-active" ).not( ".ui-state-focus" )
  5728. .removeClass( "ui-state-active" );
  5729. },
  5730. _closeOnDocumentClick: function( event ) {
  5731. return !$( event.target ).closest( ".ui-menu" ).length;
  5732. },
  5733. _isDivider: function( item ) {
  5734. // Match hyphen, em dash, en dash
  5735. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  5736. },
  5737. collapse: function( event ) {
  5738. var newItem = this.active &&
  5739. this.active.parent().closest( ".ui-menu-item", this.element );
  5740. if ( newItem && newItem.length ) {
  5741. this._close();
  5742. this.focus( event, newItem );
  5743. }
  5744. },
  5745. expand: function( event ) {
  5746. var newItem = this.active &&
  5747. this.active
  5748. .children( ".ui-menu " )
  5749. .find( this.options.items )
  5750. .first();
  5751. if ( newItem && newItem.length ) {
  5752. this._open( newItem.parent() );
  5753. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  5754. this._delay(function() {
  5755. this.focus( event, newItem );
  5756. });
  5757. }
  5758. },
  5759. next: function( event ) {
  5760. this._move( "next", "first", event );
  5761. },
  5762. previous: function( event ) {
  5763. this._move( "prev", "last", event );
  5764. },
  5765. isFirstItem: function() {
  5766. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  5767. },
  5768. isLastItem: function() {
  5769. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  5770. },
  5771. _move: function( direction, filter, event ) {
  5772. var next;
  5773. if ( this.active ) {
  5774. if ( direction === "first" || direction === "last" ) {
  5775. next = this.active
  5776. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  5777. .eq( -1 );
  5778. } else {
  5779. next = this.active
  5780. [ direction + "All" ]( ".ui-menu-item" )
  5781. .eq( 0 );
  5782. }
  5783. }
  5784. if ( !next || !next.length || !this.active ) {
  5785. next = this.activeMenu.find( this.options.items )[ filter ]();
  5786. }
  5787. this.focus( event, next );
  5788. },
  5789. nextPage: function( event ) {
  5790. var item, base, height;
  5791. if ( !this.active ) {
  5792. this.next( event );
  5793. return;
  5794. }
  5795. if ( this.isLastItem() ) {
  5796. return;
  5797. }
  5798. if ( this._hasScroll() ) {
  5799. base = this.active.offset().top;
  5800. height = this.element.height();
  5801. this.active.nextAll( ".ui-menu-item" ).each(function() {
  5802. item = $( this );
  5803. return item.offset().top - base - height < 0;
  5804. });
  5805. this.focus( event, item );
  5806. } else {
  5807. this.focus( event, this.activeMenu.find( this.options.items )
  5808. [ !this.active ? "first" : "last" ]() );
  5809. }
  5810. },
  5811. previousPage: function( event ) {
  5812. var item, base, height;
  5813. if ( !this.active ) {
  5814. this.next( event );
  5815. return;
  5816. }
  5817. if ( this.isFirstItem() ) {
  5818. return;
  5819. }
  5820. if ( this._hasScroll() ) {
  5821. base = this.active.offset().top;
  5822. height = this.element.height();
  5823. this.active.prevAll( ".ui-menu-item" ).each(function() {
  5824. item = $( this );
  5825. return item.offset().top - base + height > 0;
  5826. });
  5827. this.focus( event, item );
  5828. } else {
  5829. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  5830. }
  5831. },
  5832. _hasScroll: function() {
  5833. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  5834. },
  5835. select: function( event ) {
  5836. // TODO: It should never be possible to not have an active item at this
  5837. // point, but the tests don't trigger mouseenter before click.
  5838. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  5839. var ui = { item: this.active };
  5840. if ( !this.active.has( ".ui-menu" ).length ) {
  5841. this.collapseAll( event, true );
  5842. }
  5843. this._trigger( "select", event, ui );
  5844. },
  5845. _filterMenuItems: function(character) {
  5846. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  5847. regex = new RegExp( "^" + escapedCharacter, "i" );
  5848. return this.activeMenu
  5849. .find( this.options.items )
  5850. // Only match on items, not dividers or other content (#10571)
  5851. .filter( ".ui-menu-item" )
  5852. .filter(function() {
  5853. return regex.test( $.trim( $( this ).text() ) );
  5854. });
  5855. }
  5856. });
  5857. /*!
  5858. * jQuery UI Autocomplete 1.11.2
  5859. * http://jqueryui.com
  5860. *
  5861. * Copyright 2014 jQuery Foundation and other contributors
  5862. * Released under the MIT license.
  5863. * http://jquery.org/license
  5864. *
  5865. * http://api.jqueryui.com/autocomplete/
  5866. */
  5867. $.widget( "ui.autocomplete", {
  5868. version: "1.11.2",
  5869. defaultElement: "<input>",
  5870. options: {
  5871. appendTo: null,
  5872. autoFocus: false,
  5873. delay: 300,
  5874. minLength: 1,
  5875. position: {
  5876. my: "left top",
  5877. at: "left bottom",
  5878. collision: "none"
  5879. },
  5880. source: null,
  5881. // callbacks
  5882. change: null,
  5883. close: null,
  5884. focus: null,
  5885. open: null,
  5886. response: null,
  5887. search: null,
  5888. select: null
  5889. },
  5890. requestIndex: 0,
  5891. pending: 0,
  5892. _create: function() {
  5893. // Some browsers only repeat keydown events, not keypress events,
  5894. // so we use the suppressKeyPress flag to determine if we've already
  5895. // handled the keydown event. #7269
  5896. // Unfortunately the code for & in keypress is the same as the up arrow,
  5897. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  5898. // events when we know the keydown event was used to modify the
  5899. // search term. #7799
  5900. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  5901. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  5902. isTextarea = nodeName === "textarea",
  5903. isInput = nodeName === "input";
  5904. this.isMultiLine =
  5905. // Textareas are always multi-line
  5906. isTextarea ? true :
  5907. // Inputs are always single-line, even if inside a contentEditable element
  5908. // IE also treats inputs as contentEditable
  5909. isInput ? false :
  5910. // All other element types are determined by whether or not they're contentEditable
  5911. this.element.prop( "isContentEditable" );
  5912. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  5913. this.isNewMenu = true;
  5914. this.element
  5915. .addClass( "ui-autocomplete-input" )
  5916. .attr( "autocomplete", "off" );
  5917. this._on( this.element, {
  5918. keydown: function( event ) {
  5919. if ( this.element.prop( "readOnly" ) ) {
  5920. suppressKeyPress = true;
  5921. suppressInput = true;
  5922. suppressKeyPressRepeat = true;
  5923. return;
  5924. }
  5925. suppressKeyPress = false;
  5926. suppressInput = false;
  5927. suppressKeyPressRepeat = false;
  5928. var keyCode = $.ui.keyCode;
  5929. switch ( event.keyCode ) {
  5930. case keyCode.PAGE_UP:
  5931. suppressKeyPress = true;
  5932. this._move( "previousPage", event );
  5933. break;
  5934. case keyCode.PAGE_DOWN:
  5935. suppressKeyPress = true;
  5936. this._move( "nextPage", event );
  5937. break;
  5938. case keyCode.UP:
  5939. suppressKeyPress = true;
  5940. this._keyEvent( "previous", event );
  5941. break;
  5942. case keyCode.DOWN:
  5943. suppressKeyPress = true;
  5944. this._keyEvent( "next", event );
  5945. break;
  5946. case keyCode.ENTER:
  5947. // when menu is open and has focus
  5948. if ( this.menu.active ) {
  5949. // #6055 - Opera still allows the keypress to occur
  5950. // which causes forms to submit
  5951. suppressKeyPress = true;
  5952. event.preventDefault();
  5953. this.menu.select( event );
  5954. }
  5955. break;
  5956. case keyCode.TAB:
  5957. if ( this.menu.active ) {
  5958. this.menu.select( event );
  5959. }
  5960. break;
  5961. case keyCode.ESCAPE:
  5962. if ( this.menu.element.is( ":visible" ) ) {
  5963. if ( !this.isMultiLine ) {
  5964. this._value( this.term );
  5965. }
  5966. this.close( event );
  5967. // Different browsers have different default behavior for escape
  5968. // Single press can mean undo or clear
  5969. // Double press in IE means clear the whole form
  5970. event.preventDefault();
  5971. }
  5972. break;
  5973. default:
  5974. suppressKeyPressRepeat = true;
  5975. // search timeout should be triggered before the input value is changed
  5976. this._searchTimeout( event );
  5977. break;
  5978. }
  5979. },
  5980. keypress: function( event ) {
  5981. if ( suppressKeyPress ) {
  5982. suppressKeyPress = false;
  5983. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5984. event.preventDefault();
  5985. }
  5986. return;
  5987. }
  5988. if ( suppressKeyPressRepeat ) {
  5989. return;
  5990. }
  5991. // replicate some key handlers to allow them to repeat in Firefox and Opera
  5992. var keyCode = $.ui.keyCode;
  5993. switch ( event.keyCode ) {
  5994. case keyCode.PAGE_UP:
  5995. this._move( "previousPage", event );
  5996. break;
  5997. case keyCode.PAGE_DOWN:
  5998. this._move( "nextPage", event );
  5999. break;
  6000. case keyCode.UP:
  6001. this._keyEvent( "previous", event );
  6002. break;
  6003. case keyCode.DOWN:
  6004. this._keyEvent( "next", event );
  6005. break;
  6006. }
  6007. },
  6008. input: function( event ) {
  6009. if ( suppressInput ) {
  6010. suppressInput = false;
  6011. event.preventDefault();
  6012. return;
  6013. }
  6014. this._searchTimeout( event );
  6015. },
  6016. focus: function() {
  6017. this.selectedItem = null;
  6018. this.previous = this._value();
  6019. },
  6020. blur: function( event ) {
  6021. if ( this.cancelBlur ) {
  6022. delete this.cancelBlur;
  6023. return;
  6024. }
  6025. clearTimeout( this.searching );
  6026. this.close( event );
  6027. this._change( event );
  6028. }
  6029. });
  6030. this._initSource();
  6031. this.menu = $( "<ul>" )
  6032. .addClass( "ui-autocomplete ui-front" )
  6033. .appendTo( this._appendTo() )
  6034. .menu({
  6035. // disable ARIA support, the live region takes care of that
  6036. role: null
  6037. })
  6038. .hide()
  6039. .menu( "instance" );
  6040. this._on( this.menu.element, {
  6041. mousedown: function( event ) {
  6042. // prevent moving focus out of the text field
  6043. event.preventDefault();
  6044. // IE doesn't prevent moving focus even with event.preventDefault()
  6045. // so we set a flag to know when we should ignore the blur event
  6046. this.cancelBlur = true;
  6047. this._delay(function() {
  6048. delete this.cancelBlur;
  6049. });
  6050. // clicking on the scrollbar causes focus to shift to the body
  6051. // but we can't detect a mouseup or a click immediately afterward
  6052. // so we have to track the next mousedown and close the menu if
  6053. // the user clicks somewhere outside of the autocomplete
  6054. var menuElement = this.menu.element[ 0 ];
  6055. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  6056. this._delay(function() {
  6057. var that = this;
  6058. this.document.one( "mousedown", function( event ) {
  6059. if ( event.target !== that.element[ 0 ] &&
  6060. event.target !== menuElement &&
  6061. !$.contains( menuElement, event.target ) ) {
  6062. that.close();
  6063. }
  6064. });
  6065. });
  6066. }
  6067. },
  6068. menufocus: function( event, ui ) {
  6069. var label, item;
  6070. // support: Firefox
  6071. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  6072. if ( this.isNewMenu ) {
  6073. this.isNewMenu = false;
  6074. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  6075. this.menu.blur();
  6076. this.document.one( "mousemove", function() {
  6077. $( event.target ).trigger( event.originalEvent );
  6078. });
  6079. return;
  6080. }
  6081. }
  6082. item = ui.item.data( "ui-autocomplete-item" );
  6083. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  6084. // use value to match what will end up in the input, if it was a key event
  6085. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  6086. this._value( item.value );
  6087. }
  6088. }
  6089. // Announce the value in the liveRegion
  6090. label = ui.item.attr( "aria-label" ) || item.value;
  6091. if ( label && $.trim( label ).length ) {
  6092. this.liveRegion.children().hide();
  6093. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  6094. }
  6095. },
  6096. menuselect: function( event, ui ) {
  6097. var item = ui.item.data( "ui-autocomplete-item" ),
  6098. previous = this.previous;
  6099. // only trigger when focus was lost (click on menu)
  6100. if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
  6101. this.element.focus();
  6102. this.previous = previous;
  6103. // #6109 - IE triggers two focus events and the second
  6104. // is asynchronous, so we need to reset the previous
  6105. // term synchronously and asynchronously :-(
  6106. this._delay(function() {
  6107. this.previous = previous;
  6108. this.selectedItem = item;
  6109. });
  6110. }
  6111. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  6112. this._value( item.value );
  6113. }
  6114. // reset the term after the select event
  6115. // this allows custom select handling to work properly
  6116. this.term = this._value();
  6117. this.close( event );
  6118. this.selectedItem = item;
  6119. }
  6120. });
  6121. this.liveRegion = $( "<span>", {
  6122. role: "status",
  6123. "aria-live": "assertive",
  6124. "aria-relevant": "additions"
  6125. })
  6126. .addClass( "ui-helper-hidden-accessible" )
  6127. .appendTo( this.document[ 0 ].body );
  6128. // turning off autocomplete prevents the browser from remembering the
  6129. // value when navigating through history, so we re-enable autocomplete
  6130. // if the page is unloaded before the widget is destroyed. #7790
  6131. this._on( this.window, {
  6132. beforeunload: function() {
  6133. this.element.removeAttr( "autocomplete" );
  6134. }
  6135. });
  6136. },
  6137. _destroy: function() {
  6138. clearTimeout( this.searching );
  6139. this.element
  6140. .removeClass( "ui-autocomplete-input" )
  6141. .removeAttr( "autocomplete" );
  6142. this.menu.element.remove();
  6143. this.liveRegion.remove();
  6144. },
  6145. _setOption: function( key, value ) {
  6146. this._super( key, value );
  6147. if ( key === "source" ) {
  6148. this._initSource();
  6149. }
  6150. if ( key === "appendTo" ) {
  6151. this.menu.element.appendTo( this._appendTo() );
  6152. }
  6153. if ( key === "disabled" && value && this.xhr ) {
  6154. this.xhr.abort();
  6155. }
  6156. },
  6157. _appendTo: function() {
  6158. var element = this.options.appendTo;
  6159. if ( element ) {
  6160. element = element.jquery || element.nodeType ?
  6161. $( element ) :
  6162. this.document.find( element ).eq( 0 );
  6163. }
  6164. if ( !element || !element[ 0 ] ) {
  6165. element = this.element.closest( ".ui-front" );
  6166. }
  6167. if ( !element.length ) {
  6168. element = this.document[ 0 ].body;
  6169. }
  6170. return element;
  6171. },
  6172. _initSource: function() {
  6173. var array, url,
  6174. that = this;
  6175. if ( $.isArray( this.options.source ) ) {
  6176. array = this.options.source;
  6177. this.source = function( request, response ) {
  6178. response( $.ui.autocomplete.filter( array, request.term ) );
  6179. };
  6180. } else if ( typeof this.options.source === "string" ) {
  6181. url = this.options.source;
  6182. this.source = function( request, response ) {
  6183. if ( that.xhr ) {
  6184. that.xhr.abort();
  6185. }
  6186. that.xhr = $.ajax({
  6187. url: url,
  6188. data: request,
  6189. dataType: "json",
  6190. success: function( data ) {
  6191. response( data );
  6192. },
  6193. error: function() {
  6194. response([]);
  6195. }
  6196. });
  6197. };
  6198. } else {
  6199. this.source = this.options.source;
  6200. }
  6201. },
  6202. _searchTimeout: function( event ) {
  6203. clearTimeout( this.searching );
  6204. this.searching = this._delay(function() {
  6205. // Search if the value has changed, or if the user retypes the same value (see #7434)
  6206. var equalValues = this.term === this._value(),
  6207. menuVisible = this.menu.element.is( ":visible" ),
  6208. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  6209. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  6210. this.selectedItem = null;
  6211. this.search( null, event );
  6212. }
  6213. }, this.options.delay );
  6214. },
  6215. search: function( value, event ) {
  6216. value = value != null ? value : this._value();
  6217. // always save the actual value, not the one passed as an argument
  6218. this.term = this._value();
  6219. if ( value.length < this.options.minLength ) {
  6220. return this.close( event );
  6221. }
  6222. if ( this._trigger( "search", event ) === false ) {
  6223. return;
  6224. }
  6225. return this._search( value );
  6226. },
  6227. _search: function( value ) {
  6228. this.pending++;
  6229. this.element.addClass( "ui-autocomplete-loading" );
  6230. this.cancelSearch = false;
  6231. this.source( { term: value }, this._response() );
  6232. },
  6233. _response: function() {
  6234. var index = ++this.requestIndex;
  6235. return $.proxy(function( content ) {
  6236. if ( index === this.requestIndex ) {
  6237. this.__response( content );
  6238. }
  6239. this.pending--;
  6240. if ( !this.pending ) {
  6241. this.element.removeClass( "ui-autocomplete-loading" );
  6242. }
  6243. }, this );
  6244. },
  6245. __response: function( content ) {
  6246. if ( content ) {
  6247. content = this._normalize( content );
  6248. }
  6249. this._trigger( "response", null, { content: content } );
  6250. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  6251. this._suggest( content );
  6252. this._trigger( "open" );
  6253. } else {
  6254. // use ._close() instead of .close() so we don't cancel future searches
  6255. this._close();
  6256. }
  6257. },
  6258. close: function( event ) {
  6259. this.cancelSearch = true;
  6260. this._close( event );
  6261. },
  6262. _close: function( event ) {
  6263. if ( this.menu.element.is( ":visible" ) ) {
  6264. this.menu.element.hide();
  6265. this.menu.blur();
  6266. this.isNewMenu = true;
  6267. this._trigger( "close", event );
  6268. }
  6269. },
  6270. _change: function( event ) {
  6271. if ( this.previous !== this._value() ) {
  6272. this._trigger( "change", event, { item: this.selectedItem } );
  6273. }
  6274. },
  6275. _normalize: function( items ) {
  6276. // assume all items have the right format when the first item is complete
  6277. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  6278. return items;
  6279. }
  6280. return $.map( items, function( item ) {
  6281. if ( typeof item === "string" ) {
  6282. return {
  6283. label: item,
  6284. value: item
  6285. };
  6286. }
  6287. return $.extend( {}, item, {
  6288. label: item.label || item.value,
  6289. value: item.value || item.label
  6290. });
  6291. });
  6292. },
  6293. _suggest: function( items ) {
  6294. var ul = this.menu.element.empty();
  6295. this._renderMenu( ul, items );
  6296. this.isNewMenu = true;
  6297. this.menu.refresh();
  6298. // size and position menu
  6299. ul.show();
  6300. this._resizeMenu();
  6301. ul.position( $.extend({
  6302. of: this.element
  6303. }, this.options.position ) );
  6304. if ( this.options.autoFocus ) {
  6305. this.menu.next();
  6306. }
  6307. },
  6308. _resizeMenu: function() {
  6309. var ul = this.menu.element;
  6310. ul.outerWidth( Math.max(
  6311. // Firefox wraps long text (possibly a rounding bug)
  6312. // so we add 1px to avoid the wrapping (#7513)
  6313. ul.width( "" ).outerWidth() + 1,
  6314. this.element.outerWidth()
  6315. ) );
  6316. },
  6317. _renderMenu: function( ul, items ) {
  6318. var that = this;
  6319. $.each( items, function( index, item ) {
  6320. that._renderItemData( ul, item );
  6321. });
  6322. },
  6323. _renderItemData: function( ul, item ) {
  6324. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  6325. },
  6326. _renderItem: function( ul, item ) {
  6327. return $( "<li>" ).text( item.label ).appendTo( ul );
  6328. },
  6329. _move: function( direction, event ) {
  6330. if ( !this.menu.element.is( ":visible" ) ) {
  6331. this.search( null, event );
  6332. return;
  6333. }
  6334. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  6335. this.menu.isLastItem() && /^next/.test( direction ) ) {
  6336. if ( !this.isMultiLine ) {
  6337. this._value( this.term );
  6338. }
  6339. this.menu.blur();
  6340. return;
  6341. }
  6342. this.menu[ direction ]( event );
  6343. },
  6344. widget: function() {
  6345. return this.menu.element;
  6346. },
  6347. _value: function() {
  6348. return this.valueMethod.apply( this.element, arguments );
  6349. },
  6350. _keyEvent: function( keyEvent, event ) {
  6351. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  6352. this._move( keyEvent, event );
  6353. // prevents moving cursor to beginning/end of the text field in some browsers
  6354. event.preventDefault();
  6355. }
  6356. }
  6357. });
  6358. $.extend( $.ui.autocomplete, {
  6359. escapeRegex: function( value ) {
  6360. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  6361. },
  6362. filter: function( array, term ) {
  6363. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  6364. return $.grep( array, function( value ) {
  6365. return matcher.test( value.label || value.value || value );
  6366. });
  6367. }
  6368. });
  6369. // live region extension, adding a `messages` option
  6370. // NOTE: This is an experimental API. We are still investigating
  6371. // a full solution for string manipulation and internationalization.
  6372. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  6373. options: {
  6374. messages: {
  6375. noResults: "No search results.",
  6376. results: function( amount ) {
  6377. return amount + ( amount > 1 ? " results are" : " result is" ) +
  6378. " available, use up and down arrow keys to navigate.";
  6379. }
  6380. }
  6381. },
  6382. __response: function( content ) {
  6383. var message;
  6384. this._superApply( arguments );
  6385. if ( this.options.disabled || this.cancelSearch ) {
  6386. return;
  6387. }
  6388. if ( content && content.length ) {
  6389. message = this.options.messages.results( content.length );
  6390. } else {
  6391. message = this.options.messages.noResults;
  6392. }
  6393. this.liveRegion.children().hide();
  6394. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  6395. }
  6396. });
  6397. var autocomplete = $.ui.autocomplete;
  6398. /*!
  6399. * jQuery UI Button 1.11.2
  6400. * http://jqueryui.com
  6401. *
  6402. * Copyright 2014 jQuery Foundation and other contributors
  6403. * Released under the MIT license.
  6404. * http://jquery.org/license
  6405. *
  6406. * http://api.jqueryui.com/button/
  6407. */
  6408. var lastActive,
  6409. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  6410. 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",
  6411. formResetHandler = function() {
  6412. var form = $( this );
  6413. setTimeout(function() {
  6414. form.find( ":ui-button" ).button( "refresh" );
  6415. }, 1 );
  6416. },
  6417. radioGroup = function( radio ) {
  6418. var name = radio.name,
  6419. form = radio.form,
  6420. radios = $( [] );
  6421. if ( name ) {
  6422. name = name.replace( /'/g, "\\'" );
  6423. if ( form ) {
  6424. radios = $( form ).find( "[name='" + name + "'][type=radio]" );
  6425. } else {
  6426. radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
  6427. .filter(function() {
  6428. return !this.form;
  6429. });
  6430. }
  6431. }
  6432. return radios;
  6433. };
  6434. $.widget( "ui.button", {
  6435. version: "1.11.2",
  6436. defaultElement: "<button>",
  6437. options: {
  6438. disabled: null,
  6439. text: true,
  6440. label: null,
  6441. icons: {
  6442. primary: null,
  6443. secondary: null
  6444. }
  6445. },
  6446. _create: function() {
  6447. this.element.closest( "form" )
  6448. .unbind( "reset" + this.eventNamespace )
  6449. .bind( "reset" + this.eventNamespace, formResetHandler );
  6450. if ( typeof this.options.disabled !== "boolean" ) {
  6451. this.options.disabled = !!this.element.prop( "disabled" );
  6452. } else {
  6453. this.element.prop( "disabled", this.options.disabled );
  6454. }
  6455. this._determineButtonType();
  6456. this.hasTitle = !!this.buttonElement.attr( "title" );
  6457. var that = this,
  6458. options = this.options,
  6459. toggleButton = this.type === "checkbox" || this.type === "radio",
  6460. activeClass = !toggleButton ? "ui-state-active" : "";
  6461. if ( options.label === null ) {
  6462. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  6463. }
  6464. this._hoverable( this.buttonElement );
  6465. this.buttonElement
  6466. .addClass( baseClasses )
  6467. .attr( "role", "button" )
  6468. .bind( "mouseenter" + this.eventNamespace, function() {
  6469. if ( options.disabled ) {
  6470. return;
  6471. }
  6472. if ( this === lastActive ) {
  6473. $( this ).addClass( "ui-state-active" );
  6474. }
  6475. })
  6476. .bind( "mouseleave" + this.eventNamespace, function() {
  6477. if ( options.disabled ) {
  6478. return;
  6479. }
  6480. $( this ).removeClass( activeClass );
  6481. })
  6482. .bind( "click" + this.eventNamespace, function( event ) {
  6483. if ( options.disabled ) {
  6484. event.preventDefault();
  6485. event.stopImmediatePropagation();
  6486. }
  6487. });
  6488. // Can't use _focusable() because the element that receives focus
  6489. // and the element that gets the ui-state-focus class are different
  6490. this._on({
  6491. focus: function() {
  6492. this.buttonElement.addClass( "ui-state-focus" );
  6493. },
  6494. blur: function() {
  6495. this.buttonElement.removeClass( "ui-state-focus" );
  6496. }
  6497. });
  6498. if ( toggleButton ) {
  6499. this.element.bind( "change" + this.eventNamespace, function() {
  6500. that.refresh();
  6501. });
  6502. }
  6503. if ( this.type === "checkbox" ) {
  6504. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6505. if ( options.disabled ) {
  6506. return false;
  6507. }
  6508. });
  6509. } else if ( this.type === "radio" ) {
  6510. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6511. if ( options.disabled ) {
  6512. return false;
  6513. }
  6514. $( this ).addClass( "ui-state-active" );
  6515. that.buttonElement.attr( "aria-pressed", "true" );
  6516. var radio = that.element[ 0 ];
  6517. radioGroup( radio )
  6518. .not( radio )
  6519. .map(function() {
  6520. return $( this ).button( "widget" )[ 0 ];
  6521. })
  6522. .removeClass( "ui-state-active" )
  6523. .attr( "aria-pressed", "false" );
  6524. });
  6525. } else {
  6526. this.buttonElement
  6527. .bind( "mousedown" + this.eventNamespace, function() {
  6528. if ( options.disabled ) {
  6529. return false;
  6530. }
  6531. $( this ).addClass( "ui-state-active" );
  6532. lastActive = this;
  6533. that.document.one( "mouseup", function() {
  6534. lastActive = null;
  6535. });
  6536. })
  6537. .bind( "mouseup" + this.eventNamespace, function() {
  6538. if ( options.disabled ) {
  6539. return false;
  6540. }
  6541. $( this ).removeClass( "ui-state-active" );
  6542. })
  6543. .bind( "keydown" + this.eventNamespace, function(event) {
  6544. if ( options.disabled ) {
  6545. return false;
  6546. }
  6547. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  6548. $( this ).addClass( "ui-state-active" );
  6549. }
  6550. })
  6551. // see #8559, we bind to blur here in case the button element loses
  6552. // focus between keydown and keyup, it would be left in an "active" state
  6553. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  6554. $( this ).removeClass( "ui-state-active" );
  6555. });
  6556. if ( this.buttonElement.is("a") ) {
  6557. this.buttonElement.keyup(function(event) {
  6558. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  6559. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  6560. $( this ).click();
  6561. }
  6562. });
  6563. }
  6564. }
  6565. this._setOption( "disabled", options.disabled );
  6566. this._resetButton();
  6567. },
  6568. _determineButtonType: function() {
  6569. var ancestor, labelSelector, checked;
  6570. if ( this.element.is("[type=checkbox]") ) {
  6571. this.type = "checkbox";
  6572. } else if ( this.element.is("[type=radio]") ) {
  6573. this.type = "radio";
  6574. } else if ( this.element.is("input") ) {
  6575. this.type = "input";
  6576. } else {
  6577. this.type = "button";
  6578. }
  6579. if ( this.type === "checkbox" || this.type === "radio" ) {
  6580. // we don't search against the document in case the element
  6581. // is disconnected from the DOM
  6582. ancestor = this.element.parents().last();
  6583. labelSelector = "label[for='" + this.element.attr("id") + "']";
  6584. this.buttonElement = ancestor.find( labelSelector );
  6585. if ( !this.buttonElement.length ) {
  6586. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  6587. this.buttonElement = ancestor.filter( labelSelector );
  6588. if ( !this.buttonElement.length ) {
  6589. this.buttonElement = ancestor.find( labelSelector );
  6590. }
  6591. }
  6592. this.element.addClass( "ui-helper-hidden-accessible" );
  6593. checked = this.element.is( ":checked" );
  6594. if ( checked ) {
  6595. this.buttonElement.addClass( "ui-state-active" );
  6596. }
  6597. this.buttonElement.prop( "aria-pressed", checked );
  6598. } else {
  6599. this.buttonElement = this.element;
  6600. }
  6601. },
  6602. widget: function() {
  6603. return this.buttonElement;
  6604. },
  6605. _destroy: function() {
  6606. this.element
  6607. .removeClass( "ui-helper-hidden-accessible" );
  6608. this.buttonElement
  6609. .removeClass( baseClasses + " ui-state-active " + typeClasses )
  6610. .removeAttr( "role" )
  6611. .removeAttr( "aria-pressed" )
  6612. .html( this.buttonElement.find(".ui-button-text").html() );
  6613. if ( !this.hasTitle ) {
  6614. this.buttonElement.removeAttr( "title" );
  6615. }
  6616. },
  6617. _setOption: function( key, value ) {
  6618. this._super( key, value );
  6619. if ( key === "disabled" ) {
  6620. this.widget().toggleClass( "ui-state-disabled", !!value );
  6621. this.element.prop( "disabled", !!value );
  6622. if ( value ) {
  6623. if ( this.type === "checkbox" || this.type === "radio" ) {
  6624. this.buttonElement.removeClass( "ui-state-focus" );
  6625. } else {
  6626. this.buttonElement.removeClass( "ui-state-focus ui-state-active" );
  6627. }
  6628. }
  6629. return;
  6630. }
  6631. this._resetButton();
  6632. },
  6633. refresh: function() {
  6634. //See #8237 & #8828
  6635. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  6636. if ( isDisabled !== this.options.disabled ) {
  6637. this._setOption( "disabled", isDisabled );
  6638. }
  6639. if ( this.type === "radio" ) {
  6640. radioGroup( this.element[0] ).each(function() {
  6641. if ( $( this ).is( ":checked" ) ) {
  6642. $( this ).button( "widget" )
  6643. .addClass( "ui-state-active" )
  6644. .attr( "aria-pressed", "true" );
  6645. } else {
  6646. $( this ).button( "widget" )
  6647. .removeClass( "ui-state-active" )
  6648. .attr( "aria-pressed", "false" );
  6649. }
  6650. });
  6651. } else if ( this.type === "checkbox" ) {
  6652. if ( this.element.is( ":checked" ) ) {
  6653. this.buttonElement
  6654. .addClass( "ui-state-active" )
  6655. .attr( "aria-pressed", "true" );
  6656. } else {
  6657. this.buttonElement
  6658. .removeClass( "ui-state-active" )
  6659. .attr( "aria-pressed", "false" );
  6660. }
  6661. }
  6662. },
  6663. _resetButton: function() {
  6664. if ( this.type === "input" ) {
  6665. if ( this.options.label ) {
  6666. this.element.val( this.options.label );
  6667. }
  6668. return;
  6669. }
  6670. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  6671. buttonText = $( "<span></span>", this.document[0] )
  6672. .addClass( "ui-button-text" )
  6673. .html( this.options.label )
  6674. .appendTo( buttonElement.empty() )
  6675. .text(),
  6676. icons = this.options.icons,
  6677. multipleIcons = icons.primary && icons.secondary,
  6678. buttonClasses = [];
  6679. if ( icons.primary || icons.secondary ) {
  6680. if ( this.options.text ) {
  6681. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  6682. }
  6683. if ( icons.primary ) {
  6684. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  6685. }
  6686. if ( icons.secondary ) {
  6687. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  6688. }
  6689. if ( !this.options.text ) {
  6690. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  6691. if ( !this.hasTitle ) {
  6692. buttonElement.attr( "title", $.trim( buttonText ) );
  6693. }
  6694. }
  6695. } else {
  6696. buttonClasses.push( "ui-button-text-only" );
  6697. }
  6698. buttonElement.addClass( buttonClasses.join( " " ) );
  6699. }
  6700. });
  6701. $.widget( "ui.buttonset", {
  6702. version: "1.11.2",
  6703. options: {
  6704. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  6705. },
  6706. _create: function() {
  6707. this.element.addClass( "ui-buttonset" );
  6708. },
  6709. _init: function() {
  6710. this.refresh();
  6711. },
  6712. _setOption: function( key, value ) {
  6713. if ( key === "disabled" ) {
  6714. this.buttons.button( "option", key, value );
  6715. }
  6716. this._super( key, value );
  6717. },
  6718. refresh: function() {
  6719. var rtl = this.element.css( "direction" ) === "rtl",
  6720. allButtons = this.element.find( this.options.items ),
  6721. existingButtons = allButtons.filter( ":ui-button" );
  6722. // Initialize new buttons
  6723. allButtons.not( ":ui-button" ).button();
  6724. // Refresh existing buttons
  6725. existingButtons.button( "refresh" );
  6726. this.buttons = allButtons
  6727. .map(function() {
  6728. return $( this ).button( "widget" )[ 0 ];
  6729. })
  6730. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  6731. .filter( ":first" )
  6732. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  6733. .end()
  6734. .filter( ":last" )
  6735. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  6736. .end()
  6737. .end();
  6738. },
  6739. _destroy: function() {
  6740. this.element.removeClass( "ui-buttonset" );
  6741. this.buttons
  6742. .map(function() {
  6743. return $( this ).button( "widget" )[ 0 ];
  6744. })
  6745. .removeClass( "ui-corner-left ui-corner-right" )
  6746. .end()
  6747. .button( "destroy" );
  6748. }
  6749. });
  6750. var button = $.ui.button;
  6751. /*!
  6752. * jQuery UI Datepicker 1.11.2
  6753. * http://jqueryui.com
  6754. *
  6755. * Copyright 2014 jQuery Foundation and other contributors
  6756. * Released under the MIT license.
  6757. * http://jquery.org/license
  6758. *
  6759. * http://api.jqueryui.com/datepicker/
  6760. */
  6761. $.extend($.ui, { datepicker: { version: "1.11.2" } });
  6762. var datepicker_instActive;
  6763. function datepicker_getZindex( elem ) {
  6764. var position, value;
  6765. while ( elem.length && elem[ 0 ] !== document ) {
  6766. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  6767. // This makes behavior of this function consistent across browsers
  6768. // WebKit always returns auto if the element is positioned
  6769. position = elem.css( "position" );
  6770. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  6771. // IE returns 0 when zIndex is not specified
  6772. // other browsers return a string
  6773. // we ignore the case of nested elements with an explicit value of 0
  6774. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  6775. value = parseInt( elem.css( "zIndex" ), 10 );
  6776. if ( !isNaN( value ) && value !== 0 ) {
  6777. return value;
  6778. }
  6779. }
  6780. elem = elem.parent();
  6781. }
  6782. return 0;
  6783. }
  6784. /* Date picker manager.
  6785. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6786. Settings for (groups of) date pickers are maintained in an instance object,
  6787. allowing multiple different settings on the same page. */
  6788. function Datepicker() {
  6789. this._curInst = null; // The current instance in use
  6790. this._keyEvent = false; // If the last event was a key event
  6791. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6792. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6793. this._inDialog = false; // True if showing within a "dialog", false if not
  6794. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  6795. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  6796. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  6797. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  6798. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  6799. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  6800. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  6801. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  6802. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  6803. this.regional = []; // Available regional settings, indexed by language code
  6804. this.regional[""] = { // Default regional settings
  6805. closeText: "Done", // Display text for close link
  6806. prevText: "Prev", // Display text for previous month link
  6807. nextText: "Next", // Display text for next month link
  6808. currentText: "Today", // Display text for current month link
  6809. monthNames: ["January","February","March","April","May","June",
  6810. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  6811. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  6812. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  6813. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  6814. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  6815. weekHeader: "Wk", // Column header for week of the year
  6816. dateFormat: "mm/dd/yy", // See format options on parseDate
  6817. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6818. isRTL: false, // True if right-to-left language, false if left-to-right
  6819. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6820. yearSuffix: "" // Additional text to append to the year in the month headers
  6821. };
  6822. this._defaults = { // Global defaults for all the date picker instances
  6823. showOn: "focus", // "focus" for popup on focus,
  6824. // "button" for trigger button, or "both" for either
  6825. showAnim: "fadeIn", // Name of jQuery animation for popup
  6826. showOptions: {}, // Options for enhanced animations
  6827. defaultDate: null, // Used when field is blank: actual date,
  6828. // +/-number for offset from today, null for today
  6829. appendText: "", // Display text following the input box, e.g. showing the format
  6830. buttonText: "...", // Text for trigger button
  6831. buttonImage: "", // URL for trigger button image
  6832. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6833. hideIfNoPrevNext: false, // True to hide next/previous month links
  6834. // if not applicable, false to just disable them
  6835. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6836. gotoCurrent: false, // True if today link goes back to current selection instead
  6837. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6838. changeYear: false, // True if year can be selected directly, false if only prev/next
  6839. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  6840. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6841. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6842. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6843. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6844. showWeek: false, // True to show week of the year, false to not show it
  6845. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6846. // takes a Date and returns the number of the week for it
  6847. shortYearCutoff: "+10", // Short year values < this are in the current century,
  6848. // > this are in the previous century,
  6849. // string value starting with "+" for current year + value
  6850. minDate: null, // The earliest selectable date, or null for no limit
  6851. maxDate: null, // The latest selectable date, or null for no limit
  6852. duration: "fast", // Duration of display/closure
  6853. beforeShowDay: null, // Function that takes a date and returns an array with
  6854. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  6855. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6856. beforeShow: null, // Function that takes an input field and
  6857. // returns a set of custom settings for the date picker
  6858. onSelect: null, // Define a callback function when a date is selected
  6859. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6860. onClose: null, // Define a callback function when the datepicker is closed
  6861. numberOfMonths: 1, // Number of months to show at a time
  6862. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6863. stepMonths: 1, // Number of months to step back/forward
  6864. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6865. altField: "", // Selector for an alternate field to store selected dates into
  6866. altFormat: "", // The date format to use for the alternate field
  6867. constrainInput: true, // The input is constrained by the current date format
  6868. showButtonPanel: false, // True to show button panel, false to not show it
  6869. autoSize: false, // True to size the input for the date format, false to leave as is
  6870. disabled: false // The initial disabled state
  6871. };
  6872. $.extend(this._defaults, this.regional[""]);
  6873. this.regional.en = $.extend( true, {}, this.regional[ "" ]);
  6874. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  6875. this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  6876. }
  6877. $.extend(Datepicker.prototype, {
  6878. /* Class name added to elements to indicate already configured with a date picker. */
  6879. markerClassName: "hasDatepicker",
  6880. //Keep track of the maximum number of rows displayed (see #7043)
  6881. maxRows: 4,
  6882. // TODO rename to "widget" when switching to widget factory
  6883. _widgetDatepicker: function() {
  6884. return this.dpDiv;
  6885. },
  6886. /* Override the default settings for all instances of the date picker.
  6887. * @param settings object - the new settings to use as defaults (anonymous object)
  6888. * @return the manager object
  6889. */
  6890. setDefaults: function(settings) {
  6891. datepicker_extendRemove(this._defaults, settings || {});
  6892. return this;
  6893. },
  6894. /* Attach the date picker to a jQuery selection.
  6895. * @param target element - the target input field or division or span
  6896. * @param settings object - the new settings to use for this date picker instance (anonymous)
  6897. */
  6898. _attachDatepicker: function(target, settings) {
  6899. var nodeName, inline, inst;
  6900. nodeName = target.nodeName.toLowerCase();
  6901. inline = (nodeName === "div" || nodeName === "span");
  6902. if (!target.id) {
  6903. this.uuid += 1;
  6904. target.id = "dp" + this.uuid;
  6905. }
  6906. inst = this._newInst($(target), inline);
  6907. inst.settings = $.extend({}, settings || {});
  6908. if (nodeName === "input") {
  6909. this._connectDatepicker(target, inst);
  6910. } else if (inline) {
  6911. this._inlineDatepicker(target, inst);
  6912. }
  6913. },
  6914. /* Create a new instance object. */
  6915. _newInst: function(target, inline) {
  6916. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  6917. return {id: id, input: target, // associated target
  6918. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6919. drawMonth: 0, drawYear: 0, // month being drawn
  6920. inline: inline, // is datepicker inline or not
  6921. dpDiv: (!inline ? this.dpDiv : // presentation div
  6922. datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  6923. },
  6924. /* Attach the date picker to an input field. */
  6925. _connectDatepicker: function(target, inst) {
  6926. var input = $(target);
  6927. inst.append = $([]);
  6928. inst.trigger = $([]);
  6929. if (input.hasClass(this.markerClassName)) {
  6930. return;
  6931. }
  6932. this._attachments(input, inst);
  6933. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  6934. keypress(this._doKeyPress).keyup(this._doKeyUp);
  6935. this._autoSize(inst);
  6936. $.data(target, "datepicker", inst);
  6937. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  6938. if( inst.settings.disabled ) {
  6939. this._disableDatepicker( target );
  6940. }
  6941. },
  6942. /* Make attachments based on settings. */
  6943. _attachments: function(input, inst) {
  6944. var showOn, buttonText, buttonImage,
  6945. appendText = this._get(inst, "appendText"),
  6946. isRTL = this._get(inst, "isRTL");
  6947. if (inst.append) {
  6948. inst.append.remove();
  6949. }
  6950. if (appendText) {
  6951. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  6952. input[isRTL ? "before" : "after"](inst.append);
  6953. }
  6954. input.unbind("focus", this._showDatepicker);
  6955. if (inst.trigger) {
  6956. inst.trigger.remove();
  6957. }
  6958. showOn = this._get(inst, "showOn");
  6959. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  6960. input.focus(this._showDatepicker);
  6961. }
  6962. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  6963. buttonText = this._get(inst, "buttonText");
  6964. buttonImage = this._get(inst, "buttonImage");
  6965. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  6966. $("<img/>").addClass(this._triggerClass).
  6967. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  6968. $("<button type='button'></button>").addClass(this._triggerClass).
  6969. html(!buttonImage ? buttonText : $("<img/>").attr(
  6970. { src:buttonImage, alt:buttonText, title:buttonText })));
  6971. input[isRTL ? "before" : "after"](inst.trigger);
  6972. inst.trigger.click(function() {
  6973. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  6974. $.datepicker._hideDatepicker();
  6975. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  6976. $.datepicker._hideDatepicker();
  6977. $.datepicker._showDatepicker(input[0]);
  6978. } else {
  6979. $.datepicker._showDatepicker(input[0]);
  6980. }
  6981. return false;
  6982. });
  6983. }
  6984. },
  6985. /* Apply the maximum length for the date format. */
  6986. _autoSize: function(inst) {
  6987. if (this._get(inst, "autoSize") && !inst.inline) {
  6988. var findMax, max, maxI, i,
  6989. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  6990. dateFormat = this._get(inst, "dateFormat");
  6991. if (dateFormat.match(/[DM]/)) {
  6992. findMax = function(names) {
  6993. max = 0;
  6994. maxI = 0;
  6995. for (i = 0; i < names.length; i++) {
  6996. if (names[i].length > max) {
  6997. max = names[i].length;
  6998. maxI = i;
  6999. }
  7000. }
  7001. return maxI;
  7002. };
  7003. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  7004. "monthNames" : "monthNamesShort"))));
  7005. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  7006. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  7007. }
  7008. inst.input.attr("size", this._formatDate(inst, date).length);
  7009. }
  7010. },
  7011. /* Attach an inline date picker to a div. */
  7012. _inlineDatepicker: function(target, inst) {
  7013. var divSpan = $(target);
  7014. if (divSpan.hasClass(this.markerClassName)) {
  7015. return;
  7016. }
  7017. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  7018. $.data(target, "datepicker", inst);
  7019. this._setDate(inst, this._getDefaultDate(inst), true);
  7020. this._updateDatepicker(inst);
  7021. this._updateAlternate(inst);
  7022. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  7023. if( inst.settings.disabled ) {
  7024. this._disableDatepicker( target );
  7025. }
  7026. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  7027. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  7028. inst.dpDiv.css( "display", "block" );
  7029. },
  7030. /* Pop-up the date picker in a "dialog" box.
  7031. * @param input element - ignored
  7032. * @param date string or Date - the initial date to display
  7033. * @param onSelect function - the function to call when a date is selected
  7034. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  7035. * @param pos int[2] - coordinates for the dialog's position within the screen or
  7036. * event - with x/y coordinates or
  7037. * leave empty for default (screen centre)
  7038. * @return the manager object
  7039. */
  7040. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  7041. var id, browserWidth, browserHeight, scrollX, scrollY,
  7042. inst = this._dialogInst; // internal instance
  7043. if (!inst) {
  7044. this.uuid += 1;
  7045. id = "dp" + this.uuid;
  7046. this._dialogInput = $("<input type='text' id='" + id +
  7047. "' style='position: absolute; top: -100px; width: 0px;'/>");
  7048. this._dialogInput.keydown(this._doKeyDown);
  7049. $("body").append(this._dialogInput);
  7050. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  7051. inst.settings = {};
  7052. $.data(this._dialogInput[0], "datepicker", inst);
  7053. }
  7054. datepicker_extendRemove(inst.settings, settings || {});
  7055. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  7056. this._dialogInput.val(date);
  7057. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  7058. if (!this._pos) {
  7059. browserWidth = document.documentElement.clientWidth;
  7060. browserHeight = document.documentElement.clientHeight;
  7061. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  7062. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  7063. this._pos = // should use actual width/height below
  7064. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  7065. }
  7066. // move input on screen for focus, but hidden behind dialog
  7067. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  7068. inst.settings.onSelect = onSelect;
  7069. this._inDialog = true;
  7070. this.dpDiv.addClass(this._dialogClass);
  7071. this._showDatepicker(this._dialogInput[0]);
  7072. if ($.blockUI) {
  7073. $.blockUI(this.dpDiv);
  7074. }
  7075. $.data(this._dialogInput[0], "datepicker", inst);
  7076. return this;
  7077. },
  7078. /* Detach a datepicker from its control.
  7079. * @param target element - the target input field or division or span
  7080. */
  7081. _destroyDatepicker: function(target) {
  7082. var nodeName,
  7083. $target = $(target),
  7084. inst = $.data(target, "datepicker");
  7085. if (!$target.hasClass(this.markerClassName)) {
  7086. return;
  7087. }
  7088. nodeName = target.nodeName.toLowerCase();
  7089. $.removeData(target, "datepicker");
  7090. if (nodeName === "input") {
  7091. inst.append.remove();
  7092. inst.trigger.remove();
  7093. $target.removeClass(this.markerClassName).
  7094. unbind("focus", this._showDatepicker).
  7095. unbind("keydown", this._doKeyDown).
  7096. unbind("keypress", this._doKeyPress).
  7097. unbind("keyup", this._doKeyUp);
  7098. } else if (nodeName === "div" || nodeName === "span") {
  7099. $target.removeClass(this.markerClassName).empty();
  7100. }
  7101. },
  7102. /* Enable the date picker to a jQuery selection.
  7103. * @param target element - the target input field or division or span
  7104. */
  7105. _enableDatepicker: function(target) {
  7106. var nodeName, inline,
  7107. $target = $(target),
  7108. inst = $.data(target, "datepicker");
  7109. if (!$target.hasClass(this.markerClassName)) {
  7110. return;
  7111. }
  7112. nodeName = target.nodeName.toLowerCase();
  7113. if (nodeName === "input") {
  7114. target.disabled = false;
  7115. inst.trigger.filter("button").
  7116. each(function() { this.disabled = false; }).end().
  7117. filter("img").css({opacity: "1.0", cursor: ""});
  7118. } else if (nodeName === "div" || nodeName === "span") {
  7119. inline = $target.children("." + this._inlineClass);
  7120. inline.children().removeClass("ui-state-disabled");
  7121. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  7122. prop("disabled", false);
  7123. }
  7124. this._disabledInputs = $.map(this._disabledInputs,
  7125. function(value) { return (value === target ? null : value); }); // delete entry
  7126. },
  7127. /* Disable the date picker to a jQuery selection.
  7128. * @param target element - the target input field or division or span
  7129. */
  7130. _disableDatepicker: function(target) {
  7131. var nodeName, inline,
  7132. $target = $(target),
  7133. inst = $.data(target, "datepicker");
  7134. if (!$target.hasClass(this.markerClassName)) {
  7135. return;
  7136. }
  7137. nodeName = target.nodeName.toLowerCase();
  7138. if (nodeName === "input") {
  7139. target.disabled = true;
  7140. inst.trigger.filter("button").
  7141. each(function() { this.disabled = true; }).end().
  7142. filter("img").css({opacity: "0.5", cursor: "default"});
  7143. } else if (nodeName === "div" || nodeName === "span") {
  7144. inline = $target.children("." + this._inlineClass);
  7145. inline.children().addClass("ui-state-disabled");
  7146. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  7147. prop("disabled", true);
  7148. }
  7149. this._disabledInputs = $.map(this._disabledInputs,
  7150. function(value) { return (value === target ? null : value); }); // delete entry
  7151. this._disabledInputs[this._disabledInputs.length] = target;
  7152. },
  7153. /* Is the first field in a jQuery collection disabled as a datepicker?
  7154. * @param target element - the target input field or division or span
  7155. * @return boolean - true if disabled, false if enabled
  7156. */
  7157. _isDisabledDatepicker: function(target) {
  7158. if (!target) {
  7159. return false;
  7160. }
  7161. for (var i = 0; i < this._disabledInputs.length; i++) {
  7162. if (this._disabledInputs[i] === target) {
  7163. return true;
  7164. }
  7165. }
  7166. return false;
  7167. },
  7168. /* Retrieve the instance data for the target control.
  7169. * @param target element - the target input field or division or span
  7170. * @return object - the associated instance data
  7171. * @throws error if a jQuery problem getting data
  7172. */
  7173. _getInst: function(target) {
  7174. try {
  7175. return $.data(target, "datepicker");
  7176. }
  7177. catch (err) {
  7178. throw "Missing instance data for this datepicker";
  7179. }
  7180. },
  7181. /* Update or retrieve the settings for a date picker attached to an input field or division.
  7182. * @param target element - the target input field or division or span
  7183. * @param name object - the new settings to update or
  7184. * string - the name of the setting to change or retrieve,
  7185. * when retrieving also "all" for all instance settings or
  7186. * "defaults" for all global defaults
  7187. * @param value any - the new value for the setting
  7188. * (omit if above is an object or to retrieve a value)
  7189. */
  7190. _optionDatepicker: function(target, name, value) {
  7191. var settings, date, minDate, maxDate,
  7192. inst = this._getInst(target);
  7193. if (arguments.length === 2 && typeof name === "string") {
  7194. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  7195. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  7196. this._get(inst, name)) : null));
  7197. }
  7198. settings = name || {};
  7199. if (typeof name === "string") {
  7200. settings = {};
  7201. settings[name] = value;
  7202. }
  7203. if (inst) {
  7204. if (this._curInst === inst) {
  7205. this._hideDatepicker();
  7206. }
  7207. date = this._getDateDatepicker(target, true);
  7208. minDate = this._getMinMaxDate(inst, "min");
  7209. maxDate = this._getMinMaxDate(inst, "max");
  7210. datepicker_extendRemove(inst.settings, settings);
  7211. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  7212. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  7213. inst.settings.minDate = this._formatDate(inst, minDate);
  7214. }
  7215. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  7216. inst.settings.maxDate = this._formatDate(inst, maxDate);
  7217. }
  7218. if ( "disabled" in settings ) {
  7219. if ( settings.disabled ) {
  7220. this._disableDatepicker(target);
  7221. } else {
  7222. this._enableDatepicker(target);
  7223. }
  7224. }
  7225. this._attachments($(target), inst);
  7226. this._autoSize(inst);
  7227. this._setDate(inst, date);
  7228. this._updateAlternate(inst);
  7229. this._updateDatepicker(inst);
  7230. }
  7231. },
  7232. // change method deprecated
  7233. _changeDatepicker: function(target, name, value) {
  7234. this._optionDatepicker(target, name, value);
  7235. },
  7236. /* Redraw the date picker attached to an input field or division.
  7237. * @param target element - the target input field or division or span
  7238. */
  7239. _refreshDatepicker: function(target) {
  7240. var inst = this._getInst(target);
  7241. if (inst) {
  7242. this._updateDatepicker(inst);
  7243. }
  7244. },
  7245. /* Set the dates for a jQuery selection.
  7246. * @param target element - the target input field or division or span
  7247. * @param date Date - the new date
  7248. */
  7249. _setDateDatepicker: function(target, date) {
  7250. var inst = this._getInst(target);
  7251. if (inst) {
  7252. this._setDate(inst, date);
  7253. this._updateDatepicker(inst);
  7254. this._updateAlternate(inst);
  7255. }
  7256. },
  7257. /* Get the date(s) for the first entry in a jQuery selection.
  7258. * @param target element - the target input field or division or span
  7259. * @param noDefault boolean - true if no default date is to be used
  7260. * @return Date - the current date
  7261. */
  7262. _getDateDatepicker: function(target, noDefault) {
  7263. var inst = this._getInst(target);
  7264. if (inst && !inst.inline) {
  7265. this._setDateFromField(inst, noDefault);
  7266. }
  7267. return (inst ? this._getDate(inst) : null);
  7268. },
  7269. /* Handle keystrokes. */
  7270. _doKeyDown: function(event) {
  7271. var onSelect, dateStr, sel,
  7272. inst = $.datepicker._getInst(event.target),
  7273. handled = true,
  7274. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  7275. inst._keyEvent = true;
  7276. if ($.datepicker._datepickerShowing) {
  7277. switch (event.keyCode) {
  7278. case 9: $.datepicker._hideDatepicker();
  7279. handled = false;
  7280. break; // hide on tab out
  7281. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  7282. $.datepicker._currentClass + ")", inst.dpDiv);
  7283. if (sel[0]) {
  7284. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  7285. }
  7286. onSelect = $.datepicker._get(inst, "onSelect");
  7287. if (onSelect) {
  7288. dateStr = $.datepicker._formatDate(inst);
  7289. // trigger custom callback
  7290. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  7291. } else {
  7292. $.datepicker._hideDatepicker();
  7293. }
  7294. return false; // don't submit the form
  7295. case 27: $.datepicker._hideDatepicker();
  7296. break; // hide on escape
  7297. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7298. -$.datepicker._get(inst, "stepBigMonths") :
  7299. -$.datepicker._get(inst, "stepMonths")), "M");
  7300. break; // previous month/year on page up/+ ctrl
  7301. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7302. +$.datepicker._get(inst, "stepBigMonths") :
  7303. +$.datepicker._get(inst, "stepMonths")), "M");
  7304. break; // next month/year on page down/+ ctrl
  7305. case 35: if (event.ctrlKey || event.metaKey) {
  7306. $.datepicker._clearDate(event.target);
  7307. }
  7308. handled = event.ctrlKey || event.metaKey;
  7309. break; // clear on ctrl or command +end
  7310. case 36: if (event.ctrlKey || event.metaKey) {
  7311. $.datepicker._gotoToday(event.target);
  7312. }
  7313. handled = event.ctrlKey || event.metaKey;
  7314. break; // current on ctrl or command +home
  7315. case 37: if (event.ctrlKey || event.metaKey) {
  7316. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  7317. }
  7318. handled = event.ctrlKey || event.metaKey;
  7319. // -1 day on ctrl or command +left
  7320. if (event.originalEvent.altKey) {
  7321. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7322. -$.datepicker._get(inst, "stepBigMonths") :
  7323. -$.datepicker._get(inst, "stepMonths")), "M");
  7324. }
  7325. // next month/year on alt +left on Mac
  7326. break;
  7327. case 38: if (event.ctrlKey || event.metaKey) {
  7328. $.datepicker._adjustDate(event.target, -7, "D");
  7329. }
  7330. handled = event.ctrlKey || event.metaKey;
  7331. break; // -1 week on ctrl or command +up
  7332. case 39: if (event.ctrlKey || event.metaKey) {
  7333. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  7334. }
  7335. handled = event.ctrlKey || event.metaKey;
  7336. // +1 day on ctrl or command +right
  7337. if (event.originalEvent.altKey) {
  7338. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  7339. +$.datepicker._get(inst, "stepBigMonths") :
  7340. +$.datepicker._get(inst, "stepMonths")), "M");
  7341. }
  7342. // next month/year on alt +right
  7343. break;
  7344. case 40: if (event.ctrlKey || event.metaKey) {
  7345. $.datepicker._adjustDate(event.target, +7, "D");
  7346. }
  7347. handled = event.ctrlKey || event.metaKey;
  7348. break; // +1 week on ctrl or command +down
  7349. default: handled = false;
  7350. }
  7351. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  7352. $.datepicker._showDatepicker(this);
  7353. } else {
  7354. handled = false;
  7355. }
  7356. if (handled) {
  7357. event.preventDefault();
  7358. event.stopPropagation();
  7359. }
  7360. },
  7361. /* Filter entered characters - based on date format. */
  7362. _doKeyPress: function(event) {
  7363. var chars, chr,
  7364. inst = $.datepicker._getInst(event.target);
  7365. if ($.datepicker._get(inst, "constrainInput")) {
  7366. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  7367. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  7368. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  7369. }
  7370. },
  7371. /* Synchronise manual entry and field/alternate field. */
  7372. _doKeyUp: function(event) {
  7373. var date,
  7374. inst = $.datepicker._getInst(event.target);
  7375. if (inst.input.val() !== inst.lastVal) {
  7376. try {
  7377. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7378. (inst.input ? inst.input.val() : null),
  7379. $.datepicker._getFormatConfig(inst));
  7380. if (date) { // only if valid
  7381. $.datepicker._setDateFromField(inst);
  7382. $.datepicker._updateAlternate(inst);
  7383. $.datepicker._updateDatepicker(inst);
  7384. }
  7385. }
  7386. catch (err) {
  7387. }
  7388. }
  7389. return true;
  7390. },
  7391. /* Pop-up the date picker for a given input field.
  7392. * If false returned from beforeShow event handler do not show.
  7393. * @param input element - the input field attached to the date picker or
  7394. * event - if triggered by focus
  7395. */
  7396. _showDatepicker: function(input) {
  7397. input = input.target || input;
  7398. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  7399. input = $("input", input.parentNode)[0];
  7400. }
  7401. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  7402. return;
  7403. }
  7404. var inst, beforeShow, beforeShowSettings, isFixed,
  7405. offset, showAnim, duration;
  7406. inst = $.datepicker._getInst(input);
  7407. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  7408. $.datepicker._curInst.dpDiv.stop(true, true);
  7409. if ( inst && $.datepicker._datepickerShowing ) {
  7410. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  7411. }
  7412. }
  7413. beforeShow = $.datepicker._get(inst, "beforeShow");
  7414. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  7415. if(beforeShowSettings === false){
  7416. return;
  7417. }
  7418. datepicker_extendRemove(inst.settings, beforeShowSettings);
  7419. inst.lastVal = null;
  7420. $.datepicker._lastInput = input;
  7421. $.datepicker._setDateFromField(inst);
  7422. if ($.datepicker._inDialog) { // hide cursor
  7423. input.value = "";
  7424. }
  7425. if (!$.datepicker._pos) { // position below input
  7426. $.datepicker._pos = $.datepicker._findPos(input);
  7427. $.datepicker._pos[1] += input.offsetHeight; // add the height
  7428. }
  7429. isFixed = false;
  7430. $(input).parents().each(function() {
  7431. isFixed |= $(this).css("position") === "fixed";
  7432. return !isFixed;
  7433. });
  7434. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  7435. $.datepicker._pos = null;
  7436. //to avoid flashes on Firefox
  7437. inst.dpDiv.empty();
  7438. // determine sizing offscreen
  7439. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  7440. $.datepicker._updateDatepicker(inst);
  7441. // fix width for dynamic number of date pickers
  7442. // and adjust position before showing
  7443. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  7444. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  7445. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  7446. left: offset.left + "px", top: offset.top + "px"});
  7447. if (!inst.inline) {
  7448. showAnim = $.datepicker._get(inst, "showAnim");
  7449. duration = $.datepicker._get(inst, "duration");
  7450. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  7451. $.datepicker._datepickerShowing = true;
  7452. if ( $.effects && $.effects.effect[ showAnim ] ) {
  7453. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  7454. } else {
  7455. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  7456. }
  7457. if ( $.datepicker._shouldFocusInput( inst ) ) {
  7458. inst.input.focus();
  7459. }
  7460. $.datepicker._curInst = inst;
  7461. }
  7462. },
  7463. /* Generate the date picker content. */
  7464. _updateDatepicker: function(inst) {
  7465. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  7466. datepicker_instActive = inst; // for delegate hover events
  7467. inst.dpDiv.empty().append(this._generateHTML(inst));
  7468. this._attachHandlers(inst);
  7469. var origyearshtml,
  7470. numMonths = this._getNumberOfMonths(inst),
  7471. cols = numMonths[1],
  7472. width = 17,
  7473. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
  7474. if ( activeCell.length > 0 ) {
  7475. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  7476. }
  7477. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  7478. if (cols > 1) {
  7479. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  7480. }
  7481. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  7482. "Class"]("ui-datepicker-multi");
  7483. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  7484. "Class"]("ui-datepicker-rtl");
  7485. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  7486. inst.input.focus();
  7487. }
  7488. // deffered render of the years select (to avoid flashes on Firefox)
  7489. if( inst.yearshtml ){
  7490. origyearshtml = inst.yearshtml;
  7491. setTimeout(function(){
  7492. //assure that inst.yearshtml didn't change.
  7493. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  7494. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  7495. }
  7496. origyearshtml = inst.yearshtml = null;
  7497. }, 0);
  7498. }
  7499. },
  7500. // #6694 - don't focus the input if it's already focused
  7501. // this breaks the change event in IE
  7502. // Support: IE and jQuery <1.9
  7503. _shouldFocusInput: function( inst ) {
  7504. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  7505. },
  7506. /* Check positioning to remain on screen. */
  7507. _checkOffset: function(inst, offset, isFixed) {
  7508. var dpWidth = inst.dpDiv.outerWidth(),
  7509. dpHeight = inst.dpDiv.outerHeight(),
  7510. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  7511. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  7512. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  7513. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  7514. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  7515. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  7516. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  7517. // now check if datepicker is showing outside window viewport - move to a better place if so.
  7518. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  7519. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  7520. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  7521. Math.abs(dpHeight + inputHeight) : 0);
  7522. return offset;
  7523. },
  7524. /* Find an object's position on the screen. */
  7525. _findPos: function(obj) {
  7526. var position,
  7527. inst = this._getInst(obj),
  7528. isRTL = this._get(inst, "isRTL");
  7529. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  7530. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  7531. }
  7532. position = $(obj).offset();
  7533. return [position.left, position.top];
  7534. },
  7535. /* Hide the date picker from view.
  7536. * @param input element - the input field attached to the date picker
  7537. */
  7538. _hideDatepicker: function(input) {
  7539. var showAnim, duration, postProcess, onClose,
  7540. inst = this._curInst;
  7541. if (!inst || (input && inst !== $.data(input, "datepicker"))) {
  7542. return;
  7543. }
  7544. if (this._datepickerShowing) {
  7545. showAnim = this._get(inst, "showAnim");
  7546. duration = this._get(inst, "duration");
  7547. postProcess = function() {
  7548. $.datepicker._tidyDialog(inst);
  7549. };
  7550. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  7551. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  7552. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  7553. } else {
  7554. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  7555. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  7556. }
  7557. if (!showAnim) {
  7558. postProcess();
  7559. }
  7560. this._datepickerShowing = false;
  7561. onClose = this._get(inst, "onClose");
  7562. if (onClose) {
  7563. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  7564. }
  7565. this._lastInput = null;
  7566. if (this._inDialog) {
  7567. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  7568. if ($.blockUI) {
  7569. $.unblockUI();
  7570. $("body").append(this.dpDiv);
  7571. }
  7572. }
  7573. this._inDialog = false;
  7574. }
  7575. },
  7576. /* Tidy up after a dialog display. */
  7577. _tidyDialog: function(inst) {
  7578. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  7579. },
  7580. /* Close date picker if clicked elsewhere. */
  7581. _checkExternalClick: function(event) {
  7582. if (!$.datepicker._curInst) {
  7583. return;
  7584. }
  7585. var $target = $(event.target),
  7586. inst = $.datepicker._getInst($target[0]);
  7587. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  7588. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  7589. !$target.hasClass($.datepicker.markerClassName) &&
  7590. !$target.closest("." + $.datepicker._triggerClass).length &&
  7591. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  7592. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  7593. $.datepicker._hideDatepicker();
  7594. }
  7595. },
  7596. /* Adjust one of the date sub-fields. */
  7597. _adjustDate: function(id, offset, period) {
  7598. var target = $(id),
  7599. inst = this._getInst(target[0]);
  7600. if (this._isDisabledDatepicker(target[0])) {
  7601. return;
  7602. }
  7603. this._adjustInstDate(inst, offset +
  7604. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  7605. period);
  7606. this._updateDatepicker(inst);
  7607. },
  7608. /* Action for current link. */
  7609. _gotoToday: function(id) {
  7610. var date,
  7611. target = $(id),
  7612. inst = this._getInst(target[0]);
  7613. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  7614. inst.selectedDay = inst.currentDay;
  7615. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  7616. inst.drawYear = inst.selectedYear = inst.currentYear;
  7617. } else {
  7618. date = new Date();
  7619. inst.selectedDay = date.getDate();
  7620. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7621. inst.drawYear = inst.selectedYear = date.getFullYear();
  7622. }
  7623. this._notifyChange(inst);
  7624. this._adjustDate(target);
  7625. },
  7626. /* Action for selecting a new month/year. */
  7627. _selectMonthYear: function(id, select, period) {
  7628. var target = $(id),
  7629. inst = this._getInst(target[0]);
  7630. inst["selected" + (period === "M" ? "Month" : "Year")] =
  7631. inst["draw" + (period === "M" ? "Month" : "Year")] =
  7632. parseInt(select.options[select.selectedIndex].value,10);
  7633. this._notifyChange(inst);
  7634. this._adjustDate(target);
  7635. },
  7636. /* Action for selecting a day. */
  7637. _selectDay: function(id, month, year, td) {
  7638. var inst,
  7639. target = $(id);
  7640. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  7641. return;
  7642. }
  7643. inst = this._getInst(target[0]);
  7644. inst.selectedDay = inst.currentDay = $("a", td).html();
  7645. inst.selectedMonth = inst.currentMonth = month;
  7646. inst.selectedYear = inst.currentYear = year;
  7647. this._selectDate(id, this._formatDate(inst,
  7648. inst.currentDay, inst.currentMonth, inst.currentYear));
  7649. },
  7650. /* Erase the input field and hide the date picker. */
  7651. _clearDate: function(id) {
  7652. var target = $(id);
  7653. this._selectDate(target, "");
  7654. },
  7655. /* Update the input field with the selected date. */
  7656. _selectDate: function(id, dateStr) {
  7657. var onSelect,
  7658. target = $(id),
  7659. inst = this._getInst(target[0]);
  7660. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  7661. if (inst.input) {
  7662. inst.input.val(dateStr);
  7663. }
  7664. this._updateAlternate(inst);
  7665. onSelect = this._get(inst, "onSelect");
  7666. if (onSelect) {
  7667. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  7668. } else if (inst.input) {
  7669. inst.input.trigger("change"); // fire the change event
  7670. }
  7671. if (inst.inline){
  7672. this._updateDatepicker(inst);
  7673. } else {
  7674. this._hideDatepicker();
  7675. this._lastInput = inst.input[0];
  7676. if (typeof(inst.input[0]) !== "object") {
  7677. inst.input.focus(); // restore focus
  7678. }
  7679. this._lastInput = null;
  7680. }
  7681. },
  7682. /* Update any alternate field to synchronise with the main field. */
  7683. _updateAlternate: function(inst) {
  7684. var altFormat, date, dateStr,
  7685. altField = this._get(inst, "altField");
  7686. if (altField) { // update alternate field too
  7687. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  7688. date = this._getDate(inst);
  7689. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  7690. $(altField).each(function() { $(this).val(dateStr); });
  7691. }
  7692. },
  7693. /* Set as beforeShowDay function to prevent selection of weekends.
  7694. * @param date Date - the date to customise
  7695. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  7696. */
  7697. noWeekends: function(date) {
  7698. var day = date.getDay();
  7699. return [(day > 0 && day < 6), ""];
  7700. },
  7701. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  7702. * @param date Date - the date to get the week for
  7703. * @return number - the number of the week within the year that contains this date
  7704. */
  7705. iso8601Week: function(date) {
  7706. var time,
  7707. checkDate = new Date(date.getTime());
  7708. // Find Thursday of this week starting on Monday
  7709. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  7710. time = checkDate.getTime();
  7711. checkDate.setMonth(0); // Compare with Jan 1
  7712. checkDate.setDate(1);
  7713. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  7714. },
  7715. /* Parse a string value into a date object.
  7716. * See formatDate below for the possible formats.
  7717. *
  7718. * @param format string - the expected format of the date
  7719. * @param value string - the date in the above format
  7720. * @param settings Object - attributes include:
  7721. * shortYearCutoff number - the cutoff year for determining the century (optional)
  7722. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7723. * dayNames string[7] - names of the days from Sunday (optional)
  7724. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7725. * monthNames string[12] - names of the months (optional)
  7726. * @return Date - the extracted date value or null if value is blank
  7727. */
  7728. parseDate: function (format, value, settings) {
  7729. if (format == null || value == null) {
  7730. throw "Invalid arguments";
  7731. }
  7732. value = (typeof value === "object" ? value.toString() : value + "");
  7733. if (value === "") {
  7734. return null;
  7735. }
  7736. var iFormat, dim, extra,
  7737. iValue = 0,
  7738. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  7739. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  7740. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  7741. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7742. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7743. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7744. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7745. year = -1,
  7746. month = -1,
  7747. day = -1,
  7748. doy = -1,
  7749. literal = false,
  7750. date,
  7751. // Check whether a format character is doubled
  7752. lookAhead = function(match) {
  7753. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7754. if (matches) {
  7755. iFormat++;
  7756. }
  7757. return matches;
  7758. },
  7759. // Extract a number from the string value
  7760. getNumber = function(match) {
  7761. var isDoubled = lookAhead(match),
  7762. size = (match === "@" ? 14 : (match === "!" ? 20 :
  7763. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  7764. minSize = (match === "y" ? size : 1),
  7765. digits = new RegExp("^\\d{" + minSize + "," + size + "}"),
  7766. num = value.substring(iValue).match(digits);
  7767. if (!num) {
  7768. throw "Missing number at position " + iValue;
  7769. }
  7770. iValue += num[0].length;
  7771. return parseInt(num[0], 10);
  7772. },
  7773. // Extract a name from the string value and convert to an index
  7774. getName = function(match, shortNames, longNames) {
  7775. var index = -1,
  7776. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  7777. return [ [k, v] ];
  7778. }).sort(function (a, b) {
  7779. return -(a[1].length - b[1].length);
  7780. });
  7781. $.each(names, function (i, pair) {
  7782. var name = pair[1];
  7783. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  7784. index = pair[0];
  7785. iValue += name.length;
  7786. return false;
  7787. }
  7788. });
  7789. if (index !== -1) {
  7790. return index + 1;
  7791. } else {
  7792. throw "Unknown name at position " + iValue;
  7793. }
  7794. },
  7795. // Confirm that a literal character matches the string value
  7796. checkLiteral = function() {
  7797. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  7798. throw "Unexpected literal at position " + iValue;
  7799. }
  7800. iValue++;
  7801. };
  7802. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7803. if (literal) {
  7804. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7805. literal = false;
  7806. } else {
  7807. checkLiteral();
  7808. }
  7809. } else {
  7810. switch (format.charAt(iFormat)) {
  7811. case "d":
  7812. day = getNumber("d");
  7813. break;
  7814. case "D":
  7815. getName("D", dayNamesShort, dayNames);
  7816. break;
  7817. case "o":
  7818. doy = getNumber("o");
  7819. break;
  7820. case "m":
  7821. month = getNumber("m");
  7822. break;
  7823. case "M":
  7824. month = getName("M", monthNamesShort, monthNames);
  7825. break;
  7826. case "y":
  7827. year = getNumber("y");
  7828. break;
  7829. case "@":
  7830. date = new Date(getNumber("@"));
  7831. year = date.getFullYear();
  7832. month = date.getMonth() + 1;
  7833. day = date.getDate();
  7834. break;
  7835. case "!":
  7836. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  7837. year = date.getFullYear();
  7838. month = date.getMonth() + 1;
  7839. day = date.getDate();
  7840. break;
  7841. case "'":
  7842. if (lookAhead("'")){
  7843. checkLiteral();
  7844. } else {
  7845. literal = true;
  7846. }
  7847. break;
  7848. default:
  7849. checkLiteral();
  7850. }
  7851. }
  7852. }
  7853. if (iValue < value.length){
  7854. extra = value.substr(iValue);
  7855. if (!/^\s+/.test(extra)) {
  7856. throw "Extra/unparsed characters found in date: " + extra;
  7857. }
  7858. }
  7859. if (year === -1) {
  7860. year = new Date().getFullYear();
  7861. } else if (year < 100) {
  7862. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7863. (year <= shortYearCutoff ? 0 : -100);
  7864. }
  7865. if (doy > -1) {
  7866. month = 1;
  7867. day = doy;
  7868. do {
  7869. dim = this._getDaysInMonth(year, month - 1);
  7870. if (day <= dim) {
  7871. break;
  7872. }
  7873. month++;
  7874. day -= dim;
  7875. } while (true);
  7876. }
  7877. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  7878. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  7879. throw "Invalid date"; // E.g. 31/02/00
  7880. }
  7881. return date;
  7882. },
  7883. /* Standard date formats. */
  7884. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  7885. COOKIE: "D, dd M yy",
  7886. ISO_8601: "yy-mm-dd",
  7887. RFC_822: "D, d M y",
  7888. RFC_850: "DD, dd-M-y",
  7889. RFC_1036: "D, d M y",
  7890. RFC_1123: "D, d M yy",
  7891. RFC_2822: "D, d M yy",
  7892. RSS: "D, d M y", // RFC 822
  7893. TICKS: "!",
  7894. TIMESTAMP: "@",
  7895. W3C: "yy-mm-dd", // ISO 8601
  7896. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  7897. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  7898. /* Format a date object into a string value.
  7899. * The format can be combinations of the following:
  7900. * d - day of month (no leading zero)
  7901. * dd - day of month (two digit)
  7902. * o - day of year (no leading zeros)
  7903. * oo - day of year (three digit)
  7904. * D - day name short
  7905. * DD - day name long
  7906. * m - month of year (no leading zero)
  7907. * mm - month of year (two digit)
  7908. * M - month name short
  7909. * MM - month name long
  7910. * y - year (two digit)
  7911. * yy - year (four digit)
  7912. * @ - Unix timestamp (ms since 01/01/1970)
  7913. * ! - Windows ticks (100ns since 01/01/0001)
  7914. * "..." - literal text
  7915. * '' - single quote
  7916. *
  7917. * @param format string - the desired format of the date
  7918. * @param date Date - the date value to format
  7919. * @param settings Object - attributes include:
  7920. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7921. * dayNames string[7] - names of the days from Sunday (optional)
  7922. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7923. * monthNames string[12] - names of the months (optional)
  7924. * @return string - the date in the above format
  7925. */
  7926. formatDate: function (format, date, settings) {
  7927. if (!date) {
  7928. return "";
  7929. }
  7930. var iFormat,
  7931. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7932. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7933. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7934. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7935. // Check whether a format character is doubled
  7936. lookAhead = function(match) {
  7937. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7938. if (matches) {
  7939. iFormat++;
  7940. }
  7941. return matches;
  7942. },
  7943. // Format a number, with leading zero if necessary
  7944. formatNumber = function(match, value, len) {
  7945. var num = "" + value;
  7946. if (lookAhead(match)) {
  7947. while (num.length < len) {
  7948. num = "0" + num;
  7949. }
  7950. }
  7951. return num;
  7952. },
  7953. // Format a name, short or long as requested
  7954. formatName = function(match, value, shortNames, longNames) {
  7955. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  7956. },
  7957. output = "",
  7958. literal = false;
  7959. if (date) {
  7960. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7961. if (literal) {
  7962. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7963. literal = false;
  7964. } else {
  7965. output += format.charAt(iFormat);
  7966. }
  7967. } else {
  7968. switch (format.charAt(iFormat)) {
  7969. case "d":
  7970. output += formatNumber("d", date.getDate(), 2);
  7971. break;
  7972. case "D":
  7973. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  7974. break;
  7975. case "o":
  7976. output += formatNumber("o",
  7977. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  7978. break;
  7979. case "m":
  7980. output += formatNumber("m", date.getMonth() + 1, 2);
  7981. break;
  7982. case "M":
  7983. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  7984. break;
  7985. case "y":
  7986. output += (lookAhead("y") ? date.getFullYear() :
  7987. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  7988. break;
  7989. case "@":
  7990. output += date.getTime();
  7991. break;
  7992. case "!":
  7993. output += date.getTime() * 10000 + this._ticksTo1970;
  7994. break;
  7995. case "'":
  7996. if (lookAhead("'")) {
  7997. output += "'";
  7998. } else {
  7999. literal = true;
  8000. }
  8001. break;
  8002. default:
  8003. output += format.charAt(iFormat);
  8004. }
  8005. }
  8006. }
  8007. }
  8008. return output;
  8009. },
  8010. /* Extract all possible characters from the date format. */
  8011. _possibleChars: function (format) {
  8012. var iFormat,
  8013. chars = "",
  8014. literal = false,
  8015. // Check whether a format character is doubled
  8016. lookAhead = function(match) {
  8017. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  8018. if (matches) {
  8019. iFormat++;
  8020. }
  8021. return matches;
  8022. };
  8023. for (iFormat = 0; iFormat < format.length; iFormat++) {
  8024. if (literal) {
  8025. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  8026. literal = false;
  8027. } else {
  8028. chars += format.charAt(iFormat);
  8029. }
  8030. } else {
  8031. switch (format.charAt(iFormat)) {
  8032. case "d": case "m": case "y": case "@":
  8033. chars += "0123456789";
  8034. break;
  8035. case "D": case "M":
  8036. return null; // Accept anything
  8037. case "'":
  8038. if (lookAhead("'")) {
  8039. chars += "'";
  8040. } else {
  8041. literal = true;
  8042. }
  8043. break;
  8044. default:
  8045. chars += format.charAt(iFormat);
  8046. }
  8047. }
  8048. }
  8049. return chars;
  8050. },
  8051. /* Get a setting value, defaulting if necessary. */
  8052. _get: function(inst, name) {
  8053. return inst.settings[name] !== undefined ?
  8054. inst.settings[name] : this._defaults[name];
  8055. },
  8056. /* Parse existing date and initialise date picker. */
  8057. _setDateFromField: function(inst, noDefault) {
  8058. if (inst.input.val() === inst.lastVal) {
  8059. return;
  8060. }
  8061. var dateFormat = this._get(inst, "dateFormat"),
  8062. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  8063. defaultDate = this._getDefaultDate(inst),
  8064. date = defaultDate,
  8065. settings = this._getFormatConfig(inst);
  8066. try {
  8067. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  8068. } catch (event) {
  8069. dates = (noDefault ? "" : dates);
  8070. }
  8071. inst.selectedDay = date.getDate();
  8072. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8073. inst.drawYear = inst.selectedYear = date.getFullYear();
  8074. inst.currentDay = (dates ? date.getDate() : 0);
  8075. inst.currentMonth = (dates ? date.getMonth() : 0);
  8076. inst.currentYear = (dates ? date.getFullYear() : 0);
  8077. this._adjustInstDate(inst);
  8078. },
  8079. /* Retrieve the default date shown on opening. */
  8080. _getDefaultDate: function(inst) {
  8081. return this._restrictMinMax(inst,
  8082. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  8083. },
  8084. /* A date may be specified as an exact value or a relative one. */
  8085. _determineDate: function(inst, date, defaultDate) {
  8086. var offsetNumeric = function(offset) {
  8087. var date = new Date();
  8088. date.setDate(date.getDate() + offset);
  8089. return date;
  8090. },
  8091. offsetString = function(offset) {
  8092. try {
  8093. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  8094. offset, $.datepicker._getFormatConfig(inst));
  8095. }
  8096. catch (e) {
  8097. // Ignore
  8098. }
  8099. var date = (offset.toLowerCase().match(/^c/) ?
  8100. $.datepicker._getDate(inst) : null) || new Date(),
  8101. year = date.getFullYear(),
  8102. month = date.getMonth(),
  8103. day = date.getDate(),
  8104. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  8105. matches = pattern.exec(offset);
  8106. while (matches) {
  8107. switch (matches[2] || "d") {
  8108. case "d" : case "D" :
  8109. day += parseInt(matches[1],10); break;
  8110. case "w" : case "W" :
  8111. day += parseInt(matches[1],10) * 7; break;
  8112. case "m" : case "M" :
  8113. month += parseInt(matches[1],10);
  8114. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  8115. break;
  8116. case "y": case "Y" :
  8117. year += parseInt(matches[1],10);
  8118. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  8119. break;
  8120. }
  8121. matches = pattern.exec(offset);
  8122. }
  8123. return new Date(year, month, day);
  8124. },
  8125. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  8126. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  8127. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  8128. if (newDate) {
  8129. newDate.setHours(0);
  8130. newDate.setMinutes(0);
  8131. newDate.setSeconds(0);
  8132. newDate.setMilliseconds(0);
  8133. }
  8134. return this._daylightSavingAdjust(newDate);
  8135. },
  8136. /* Handle switch to/from daylight saving.
  8137. * Hours may be non-zero on daylight saving cut-over:
  8138. * > 12 when midnight changeover, but then cannot generate
  8139. * midnight datetime, so jump to 1AM, otherwise reset.
  8140. * @param date (Date) the date to check
  8141. * @return (Date) the corrected date
  8142. */
  8143. _daylightSavingAdjust: function(date) {
  8144. if (!date) {
  8145. return null;
  8146. }
  8147. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  8148. return date;
  8149. },
  8150. /* Set the date(s) directly. */
  8151. _setDate: function(inst, date, noChange) {
  8152. var clear = !date,
  8153. origMonth = inst.selectedMonth,
  8154. origYear = inst.selectedYear,
  8155. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  8156. inst.selectedDay = inst.currentDay = newDate.getDate();
  8157. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  8158. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  8159. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  8160. this._notifyChange(inst);
  8161. }
  8162. this._adjustInstDate(inst);
  8163. if (inst.input) {
  8164. inst.input.val(clear ? "" : this._formatDate(inst));
  8165. }
  8166. },
  8167. /* Retrieve the date(s) directly. */
  8168. _getDate: function(inst) {
  8169. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  8170. this._daylightSavingAdjust(new Date(
  8171. inst.currentYear, inst.currentMonth, inst.currentDay)));
  8172. return startDate;
  8173. },
  8174. /* Attach the onxxx handlers. These are declared statically so
  8175. * they work with static code transformers like Caja.
  8176. */
  8177. _attachHandlers: function(inst) {
  8178. var stepMonths = this._get(inst, "stepMonths"),
  8179. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  8180. inst.dpDiv.find("[data-handler]").map(function () {
  8181. var handler = {
  8182. prev: function () {
  8183. $.datepicker._adjustDate(id, -stepMonths, "M");
  8184. },
  8185. next: function () {
  8186. $.datepicker._adjustDate(id, +stepMonths, "M");
  8187. },
  8188. hide: function () {
  8189. $.datepicker._hideDatepicker();
  8190. },
  8191. today: function () {
  8192. $.datepicker._gotoToday(id);
  8193. },
  8194. selectDay: function () {
  8195. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  8196. return false;
  8197. },
  8198. selectMonth: function () {
  8199. $.datepicker._selectMonthYear(id, this, "M");
  8200. return false;
  8201. },
  8202. selectYear: function () {
  8203. $.datepicker._selectMonthYear(id, this, "Y");
  8204. return false;
  8205. }
  8206. };
  8207. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  8208. });
  8209. },
  8210. /* Generate the HTML for the current state of the date picker. */
  8211. _generateHTML: function(inst) {
  8212. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  8213. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  8214. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  8215. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  8216. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  8217. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  8218. tempDate = new Date(),
  8219. today = this._daylightSavingAdjust(
  8220. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  8221. isRTL = this._get(inst, "isRTL"),
  8222. showButtonPanel = this._get(inst, "showButtonPanel"),
  8223. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  8224. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  8225. numMonths = this._getNumberOfMonths(inst),
  8226. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  8227. stepMonths = this._get(inst, "stepMonths"),
  8228. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  8229. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  8230. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  8231. minDate = this._getMinMaxDate(inst, "min"),
  8232. maxDate = this._getMinMaxDate(inst, "max"),
  8233. drawMonth = inst.drawMonth - showCurrentAtPos,
  8234. drawYear = inst.drawYear;
  8235. if (drawMonth < 0) {
  8236. drawMonth += 12;
  8237. drawYear--;
  8238. }
  8239. if (maxDate) {
  8240. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  8241. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  8242. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  8243. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  8244. drawMonth--;
  8245. if (drawMonth < 0) {
  8246. drawMonth = 11;
  8247. drawYear--;
  8248. }
  8249. }
  8250. }
  8251. inst.drawMonth = drawMonth;
  8252. inst.drawYear = drawYear;
  8253. prevText = this._get(inst, "prevText");
  8254. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  8255. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  8256. this._getFormatConfig(inst)));
  8257. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  8258. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  8259. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  8260. (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>"));
  8261. nextText = this._get(inst, "nextText");
  8262. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  8263. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  8264. this._getFormatConfig(inst)));
  8265. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  8266. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  8267. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  8268. (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>"));
  8269. currentText = this._get(inst, "currentText");
  8270. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  8271. currentText = (!navigationAsDateFormat ? currentText :
  8272. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  8273. 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'>" +
  8274. this._get(inst, "closeText") + "</button>" : "");
  8275. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  8276. (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'" +
  8277. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  8278. firstDay = parseInt(this._get(inst, "firstDay"),10);
  8279. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  8280. showWeek = this._get(inst, "showWeek");
  8281. dayNames = this._get(inst, "dayNames");
  8282. dayNamesMin = this._get(inst, "dayNamesMin");
  8283. monthNames = this._get(inst, "monthNames");
  8284. monthNamesShort = this._get(inst, "monthNamesShort");
  8285. beforeShowDay = this._get(inst, "beforeShowDay");
  8286. showOtherMonths = this._get(inst, "showOtherMonths");
  8287. selectOtherMonths = this._get(inst, "selectOtherMonths");
  8288. defaultDate = this._getDefaultDate(inst);
  8289. html = "";
  8290. dow;
  8291. for (row = 0; row < numMonths[0]; row++) {
  8292. group = "";
  8293. this.maxRows = 4;
  8294. for (col = 0; col < numMonths[1]; col++) {
  8295. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  8296. cornerClass = " ui-corner-all";
  8297. calender = "";
  8298. if (isMultiMonth) {
  8299. calender += "<div class='ui-datepicker-group";
  8300. if (numMonths[1] > 1) {
  8301. switch (col) {
  8302. case 0: calender += " ui-datepicker-group-first";
  8303. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  8304. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  8305. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  8306. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  8307. }
  8308. }
  8309. calender += "'>";
  8310. }
  8311. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  8312. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  8313. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  8314. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  8315. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  8316. "</div><table class='ui-datepicker-calendar'><thead>" +
  8317. "<tr>";
  8318. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  8319. for (dow = 0; dow < 7; dow++) { // days of the week
  8320. day = (dow + firstDay) % 7;
  8321. thead += "<th scope='col'" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  8322. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  8323. }
  8324. calender += thead + "</tr></thead><tbody>";
  8325. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  8326. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  8327. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  8328. }
  8329. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  8330. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  8331. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  8332. this.maxRows = numRows;
  8333. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  8334. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  8335. calender += "<tr>";
  8336. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  8337. this._get(inst, "calculateWeek")(printDate) + "</td>");
  8338. for (dow = 0; dow < 7; dow++) { // create date picker days
  8339. daySettings = (beforeShowDay ?
  8340. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  8341. otherMonth = (printDate.getMonth() !== drawMonth);
  8342. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  8343. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  8344. tbody += "<td class='" +
  8345. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  8346. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  8347. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  8348. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  8349. // or defaultDate is current printedDate and defaultDate is selectedDate
  8350. " " + this._dayOverClass : "") + // highlight selected day
  8351. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  8352. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  8353. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  8354. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  8355. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  8356. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  8357. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  8358. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  8359. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  8360. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  8361. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  8362. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  8363. printDate.setDate(printDate.getDate() + 1);
  8364. printDate = this._daylightSavingAdjust(printDate);
  8365. }
  8366. calender += tbody + "</tr>";
  8367. }
  8368. drawMonth++;
  8369. if (drawMonth > 11) {
  8370. drawMonth = 0;
  8371. drawYear++;
  8372. }
  8373. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  8374. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  8375. group += calender;
  8376. }
  8377. html += group;
  8378. }
  8379. html += buttonPanel;
  8380. inst._keyEvent = false;
  8381. return html;
  8382. },
  8383. /* Generate the month and year header. */
  8384. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  8385. secondary, monthNames, monthNamesShort) {
  8386. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  8387. changeMonth = this._get(inst, "changeMonth"),
  8388. changeYear = this._get(inst, "changeYear"),
  8389. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  8390. html = "<div class='ui-datepicker-title'>",
  8391. monthHtml = "";
  8392. // month selection
  8393. if (secondary || !changeMonth) {
  8394. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  8395. } else {
  8396. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  8397. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  8398. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  8399. for ( month = 0; month < 12; month++) {
  8400. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  8401. monthHtml += "<option value='" + month + "'" +
  8402. (month === drawMonth ? " selected='selected'" : "") +
  8403. ">" + monthNamesShort[month] + "</option>";
  8404. }
  8405. }
  8406. monthHtml += "</select>";
  8407. }
  8408. if (!showMonthAfterYear) {
  8409. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  8410. }
  8411. // year selection
  8412. if ( !inst.yearshtml ) {
  8413. inst.yearshtml = "";
  8414. if (secondary || !changeYear) {
  8415. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  8416. } else {
  8417. // determine range of years to display
  8418. years = this._get(inst, "yearRange").split(":");
  8419. thisYear = new Date().getFullYear();
  8420. determineYear = function(value) {
  8421. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  8422. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  8423. parseInt(value, 10)));
  8424. return (isNaN(year) ? thisYear : year);
  8425. };
  8426. year = determineYear(years[0]);
  8427. endYear = Math.max(year, determineYear(years[1] || ""));
  8428. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  8429. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  8430. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  8431. for (; year <= endYear; year++) {
  8432. inst.yearshtml += "<option value='" + year + "'" +
  8433. (year === drawYear ? " selected='selected'" : "") +
  8434. ">" + year + "</option>";
  8435. }
  8436. inst.yearshtml += "</select>";
  8437. html += inst.yearshtml;
  8438. inst.yearshtml = null;
  8439. }
  8440. }
  8441. html += this._get(inst, "yearSuffix");
  8442. if (showMonthAfterYear) {
  8443. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  8444. }
  8445. html += "</div>"; // Close datepicker_header
  8446. return html;
  8447. },
  8448. /* Adjust one of the date sub-fields. */
  8449. _adjustInstDate: function(inst, offset, period) {
  8450. var year = inst.drawYear + (period === "Y" ? offset : 0),
  8451. month = inst.drawMonth + (period === "M" ? offset : 0),
  8452. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  8453. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  8454. inst.selectedDay = date.getDate();
  8455. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8456. inst.drawYear = inst.selectedYear = date.getFullYear();
  8457. if (period === "M" || period === "Y") {
  8458. this._notifyChange(inst);
  8459. }
  8460. },
  8461. /* Ensure a date is within any min/max bounds. */
  8462. _restrictMinMax: function(inst, date) {
  8463. var minDate = this._getMinMaxDate(inst, "min"),
  8464. maxDate = this._getMinMaxDate(inst, "max"),
  8465. newDate = (minDate && date < minDate ? minDate : date);
  8466. return (maxDate && newDate > maxDate ? maxDate : newDate);
  8467. },
  8468. /* Notify change of month/year. */
  8469. _notifyChange: function(inst) {
  8470. var onChange = this._get(inst, "onChangeMonthYear");
  8471. if (onChange) {
  8472. onChange.apply((inst.input ? inst.input[0] : null),
  8473. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  8474. }
  8475. },
  8476. /* Determine the number of months to show. */
  8477. _getNumberOfMonths: function(inst) {
  8478. var numMonths = this._get(inst, "numberOfMonths");
  8479. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  8480. },
  8481. /* Determine the current maximum date - ensure no time components are set. */
  8482. _getMinMaxDate: function(inst, minMax) {
  8483. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  8484. },
  8485. /* Find the number of days in a given month. */
  8486. _getDaysInMonth: function(year, month) {
  8487. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  8488. },
  8489. /* Find the day of the week of the first of a month. */
  8490. _getFirstDayOfMonth: function(year, month) {
  8491. return new Date(year, month, 1).getDay();
  8492. },
  8493. /* Determines if we should allow a "next/prev" month display change. */
  8494. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  8495. var numMonths = this._getNumberOfMonths(inst),
  8496. date = this._daylightSavingAdjust(new Date(curYear,
  8497. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  8498. if (offset < 0) {
  8499. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  8500. }
  8501. return this._isInRange(inst, date);
  8502. },
  8503. /* Is the given date in the accepted range? */
  8504. _isInRange: function(inst, date) {
  8505. var yearSplit, currentYear,
  8506. minDate = this._getMinMaxDate(inst, "min"),
  8507. maxDate = this._getMinMaxDate(inst, "max"),
  8508. minYear = null,
  8509. maxYear = null,
  8510. years = this._get(inst, "yearRange");
  8511. if (years){
  8512. yearSplit = years.split(":");
  8513. currentYear = new Date().getFullYear();
  8514. minYear = parseInt(yearSplit[0], 10);
  8515. maxYear = parseInt(yearSplit[1], 10);
  8516. if ( yearSplit[0].match(/[+\-].*/) ) {
  8517. minYear += currentYear;
  8518. }
  8519. if ( yearSplit[1].match(/[+\-].*/) ) {
  8520. maxYear += currentYear;
  8521. }
  8522. }
  8523. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  8524. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  8525. (!minYear || date.getFullYear() >= minYear) &&
  8526. (!maxYear || date.getFullYear() <= maxYear));
  8527. },
  8528. /* Provide the configuration settings for formatting/parsing. */
  8529. _getFormatConfig: function(inst) {
  8530. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  8531. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  8532. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  8533. return {shortYearCutoff: shortYearCutoff,
  8534. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  8535. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  8536. },
  8537. /* Format the given date for display. */
  8538. _formatDate: function(inst, day, month, year) {
  8539. if (!day) {
  8540. inst.currentDay = inst.selectedDay;
  8541. inst.currentMonth = inst.selectedMonth;
  8542. inst.currentYear = inst.selectedYear;
  8543. }
  8544. var date = (day ? (typeof day === "object" ? day :
  8545. this._daylightSavingAdjust(new Date(year, month, day))) :
  8546. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  8547. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  8548. }
  8549. });
  8550. /*
  8551. * Bind hover events for datepicker elements.
  8552. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  8553. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  8554. */
  8555. function datepicker_bindHover(dpDiv) {
  8556. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  8557. return dpDiv.delegate(selector, "mouseout", function() {
  8558. $(this).removeClass("ui-state-hover");
  8559. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8560. $(this).removeClass("ui-datepicker-prev-hover");
  8561. }
  8562. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8563. $(this).removeClass("ui-datepicker-next-hover");
  8564. }
  8565. })
  8566. .delegate( selector, "mouseover", datepicker_handleMouseover );
  8567. }
  8568. function datepicker_handleMouseover() {
  8569. if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) {
  8570. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  8571. $(this).addClass("ui-state-hover");
  8572. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8573. $(this).addClass("ui-datepicker-prev-hover");
  8574. }
  8575. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8576. $(this).addClass("ui-datepicker-next-hover");
  8577. }
  8578. }
  8579. }
  8580. /* jQuery extend now ignores nulls! */
  8581. function datepicker_extendRemove(target, props) {
  8582. $.extend(target, props);
  8583. for (var name in props) {
  8584. if (props[name] == null) {
  8585. target[name] = props[name];
  8586. }
  8587. }
  8588. return target;
  8589. }
  8590. /* Invoke the datepicker functionality.
  8591. @param options string - a command, optionally followed by additional parameters or
  8592. Object - settings for attaching new datepicker functionality
  8593. @return jQuery object */
  8594. $.fn.datepicker = function(options){
  8595. /* Verify an empty collection wasn't passed - Fixes #6976 */
  8596. if ( !this.length ) {
  8597. return this;
  8598. }
  8599. /* Initialise the date picker. */
  8600. if (!$.datepicker.initialized) {
  8601. $(document).mousedown($.datepicker._checkExternalClick);
  8602. $.datepicker.initialized = true;
  8603. }
  8604. /* Append datepicker main container to body if not exist. */
  8605. if ($("#"+$.datepicker._mainDivId).length === 0) {
  8606. $("body").append($.datepicker.dpDiv);
  8607. }
  8608. var otherArgs = Array.prototype.slice.call(arguments, 1);
  8609. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  8610. return $.datepicker["_" + options + "Datepicker"].
  8611. apply($.datepicker, [this[0]].concat(otherArgs));
  8612. }
  8613. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  8614. return $.datepicker["_" + options + "Datepicker"].
  8615. apply($.datepicker, [this[0]].concat(otherArgs));
  8616. }
  8617. return this.each(function() {
  8618. typeof options === "string" ?
  8619. $.datepicker["_" + options + "Datepicker"].
  8620. apply($.datepicker, [this].concat(otherArgs)) :
  8621. $.datepicker._attachDatepicker(this, options);
  8622. });
  8623. };
  8624. $.datepicker = new Datepicker(); // singleton instance
  8625. $.datepicker.initialized = false;
  8626. $.datepicker.uuid = new Date().getTime();
  8627. $.datepicker.version = "1.11.2";
  8628. var datepicker = $.datepicker;
  8629. /*!
  8630. * jQuery UI Dialog 1.11.2
  8631. * http://jqueryui.com
  8632. *
  8633. * Copyright 2014 jQuery Foundation and other contributors
  8634. * Released under the MIT license.
  8635. * http://jquery.org/license
  8636. *
  8637. * http://api.jqueryui.com/dialog/
  8638. */
  8639. var dialog = $.widget( "ui.dialog", {
  8640. version: "1.11.2",
  8641. options: {
  8642. appendTo: "body",
  8643. autoOpen: true,
  8644. buttons: [],
  8645. closeOnEscape: true,
  8646. closeText: "Close",
  8647. dialogClass: "",
  8648. draggable: true,
  8649. hide: null,
  8650. height: "auto",
  8651. maxHeight: null,
  8652. maxWidth: null,
  8653. minHeight: 150,
  8654. minWidth: 150,
  8655. modal: false,
  8656. position: {
  8657. my: "center",
  8658. at: "center",
  8659. of: window,
  8660. collision: "fit",
  8661. // Ensure the titlebar is always visible
  8662. using: function( pos ) {
  8663. var topOffset = $( this ).css( pos ).offset().top;
  8664. if ( topOffset < 0 ) {
  8665. $( this ).css( "top", pos.top - topOffset );
  8666. }
  8667. }
  8668. },
  8669. resizable: true,
  8670. show: null,
  8671. title: null,
  8672. width: 300,
  8673. // callbacks
  8674. beforeClose: null,
  8675. close: null,
  8676. drag: null,
  8677. dragStart: null,
  8678. dragStop: null,
  8679. focus: null,
  8680. open: null,
  8681. resize: null,
  8682. resizeStart: null,
  8683. resizeStop: null
  8684. },
  8685. sizeRelatedOptions: {
  8686. buttons: true,
  8687. height: true,
  8688. maxHeight: true,
  8689. maxWidth: true,
  8690. minHeight: true,
  8691. minWidth: true,
  8692. width: true
  8693. },
  8694. resizableRelatedOptions: {
  8695. maxHeight: true,
  8696. maxWidth: true,
  8697. minHeight: true,
  8698. minWidth: true
  8699. },
  8700. _create: function() {
  8701. this.originalCss = {
  8702. display: this.element[ 0 ].style.display,
  8703. width: this.element[ 0 ].style.width,
  8704. minHeight: this.element[ 0 ].style.minHeight,
  8705. maxHeight: this.element[ 0 ].style.maxHeight,
  8706. height: this.element[ 0 ].style.height
  8707. };
  8708. this.originalPosition = {
  8709. parent: this.element.parent(),
  8710. index: this.element.parent().children().index( this.element )
  8711. };
  8712. this.originalTitle = this.element.attr( "title" );
  8713. this.options.title = this.options.title || this.originalTitle;
  8714. this._createWrapper();
  8715. this.element
  8716. .show()
  8717. .removeAttr( "title" )
  8718. .addClass( "ui-dialog-content ui-widget-content" )
  8719. .appendTo( this.uiDialog );
  8720. this._createTitlebar();
  8721. this._createButtonPane();
  8722. if ( this.options.draggable && $.fn.draggable ) {
  8723. this._makeDraggable();
  8724. }
  8725. if ( this.options.resizable && $.fn.resizable ) {
  8726. this._makeResizable();
  8727. }
  8728. this._isOpen = false;
  8729. this._trackFocus();
  8730. },
  8731. _init: function() {
  8732. if ( this.options.autoOpen ) {
  8733. this.open();
  8734. }
  8735. },
  8736. _appendTo: function() {
  8737. var element = this.options.appendTo;
  8738. if ( element && (element.jquery || element.nodeType) ) {
  8739. return $( element );
  8740. }
  8741. return this.document.find( element || "body" ).eq( 0 );
  8742. },
  8743. _destroy: function() {
  8744. var next,
  8745. originalPosition = this.originalPosition;
  8746. this._destroyOverlay();
  8747. this.element
  8748. .removeUniqueId()
  8749. .removeClass( "ui-dialog-content ui-widget-content" )
  8750. .css( this.originalCss )
  8751. // Without detaching first, the following becomes really slow
  8752. .detach();
  8753. this.uiDialog.stop( true, true ).remove();
  8754. if ( this.originalTitle ) {
  8755. this.element.attr( "title", this.originalTitle );
  8756. }
  8757. next = originalPosition.parent.children().eq( originalPosition.index );
  8758. // Don't try to place the dialog next to itself (#8613)
  8759. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  8760. next.before( this.element );
  8761. } else {
  8762. originalPosition.parent.append( this.element );
  8763. }
  8764. },
  8765. widget: function() {
  8766. return this.uiDialog;
  8767. },
  8768. disable: $.noop,
  8769. enable: $.noop,
  8770. close: function( event ) {
  8771. var activeElement,
  8772. that = this;
  8773. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  8774. return;
  8775. }
  8776. this._isOpen = false;
  8777. this._focusedElement = null;
  8778. this._destroyOverlay();
  8779. this._untrackInstance();
  8780. if ( !this.opener.filter( ":focusable" ).focus().length ) {
  8781. // support: IE9
  8782. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  8783. try {
  8784. activeElement = this.document[ 0 ].activeElement;
  8785. // Support: IE9, IE10
  8786. // If the <body> is blurred, IE will switch windows, see #4520
  8787. if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {
  8788. // Hiding a focused element doesn't trigger blur in WebKit
  8789. // so in case we have nothing to focus on, explicitly blur the active element
  8790. // https://bugs.webkit.org/show_bug.cgi?id=47182
  8791. $( activeElement ).blur();
  8792. }
  8793. } catch ( error ) {}
  8794. }
  8795. this._hide( this.uiDialog, this.options.hide, function() {
  8796. that._trigger( "close", event );
  8797. });
  8798. },
  8799. isOpen: function() {
  8800. return this._isOpen;
  8801. },
  8802. moveToTop: function() {
  8803. this._moveToTop();
  8804. },
  8805. _moveToTop: function( event, silent ) {
  8806. var moved = false,
  8807. zIndicies = this.uiDialog.siblings( ".ui-front:visible" ).map(function() {
  8808. return +$( this ).css( "z-index" );
  8809. }).get(),
  8810. zIndexMax = Math.max.apply( null, zIndicies );
  8811. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  8812. this.uiDialog.css( "z-index", zIndexMax + 1 );
  8813. moved = true;
  8814. }
  8815. if ( moved && !silent ) {
  8816. this._trigger( "focus", event );
  8817. }
  8818. return moved;
  8819. },
  8820. open: function() {
  8821. var that = this;
  8822. if ( this._isOpen ) {
  8823. if ( this._moveToTop() ) {
  8824. this._focusTabbable();
  8825. }
  8826. return;
  8827. }
  8828. this._isOpen = true;
  8829. this.opener = $( this.document[ 0 ].activeElement );
  8830. this._size();
  8831. this._position();
  8832. this._createOverlay();
  8833. this._moveToTop( null, true );
  8834. // Ensure the overlay is moved to the top with the dialog, but only when
  8835. // opening. The overlay shouldn't move after the dialog is open so that
  8836. // modeless dialogs opened after the modal dialog stack properly.
  8837. if ( this.overlay ) {
  8838. this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
  8839. }
  8840. this._show( this.uiDialog, this.options.show, function() {
  8841. that._focusTabbable();
  8842. that._trigger( "focus" );
  8843. });
  8844. // Track the dialog immediately upon openening in case a focus event
  8845. // somehow occurs outside of the dialog before an element inside the
  8846. // dialog is focused (#10152)
  8847. this._makeFocusTarget();
  8848. this._trigger( "open" );
  8849. },
  8850. _focusTabbable: function() {
  8851. // Set focus to the first match:
  8852. // 1. An element that was focused previously
  8853. // 2. First element inside the dialog matching [autofocus]
  8854. // 3. Tabbable element inside the content element
  8855. // 4. Tabbable element inside the buttonpane
  8856. // 5. The close button
  8857. // 6. The dialog itself
  8858. var hasFocus = this._focusedElement;
  8859. if ( !hasFocus ) {
  8860. hasFocus = this.element.find( "[autofocus]" );
  8861. }
  8862. if ( !hasFocus.length ) {
  8863. hasFocus = this.element.find( ":tabbable" );
  8864. }
  8865. if ( !hasFocus.length ) {
  8866. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  8867. }
  8868. if ( !hasFocus.length ) {
  8869. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  8870. }
  8871. if ( !hasFocus.length ) {
  8872. hasFocus = this.uiDialog;
  8873. }
  8874. hasFocus.eq( 0 ).focus();
  8875. },
  8876. _keepFocus: function( event ) {
  8877. function checkFocus() {
  8878. var activeElement = this.document[0].activeElement,
  8879. isActive = this.uiDialog[0] === activeElement ||
  8880. $.contains( this.uiDialog[0], activeElement );
  8881. if ( !isActive ) {
  8882. this._focusTabbable();
  8883. }
  8884. }
  8885. event.preventDefault();
  8886. checkFocus.call( this );
  8887. // support: IE
  8888. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  8889. // so we check again later
  8890. this._delay( checkFocus );
  8891. },
  8892. _createWrapper: function() {
  8893. this.uiDialog = $("<div>")
  8894. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  8895. this.options.dialogClass )
  8896. .hide()
  8897. .attr({
  8898. // Setting tabIndex makes the div focusable
  8899. tabIndex: -1,
  8900. role: "dialog"
  8901. })
  8902. .appendTo( this._appendTo() );
  8903. this._on( this.uiDialog, {
  8904. keydown: function( event ) {
  8905. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  8906. event.keyCode === $.ui.keyCode.ESCAPE ) {
  8907. event.preventDefault();
  8908. this.close( event );
  8909. return;
  8910. }
  8911. // prevent tabbing out of dialogs
  8912. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  8913. return;
  8914. }
  8915. var tabbables = this.uiDialog.find( ":tabbable" ),
  8916. first = tabbables.filter( ":first" ),
  8917. last = tabbables.filter( ":last" );
  8918. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  8919. this._delay(function() {
  8920. first.focus();
  8921. });
  8922. event.preventDefault();
  8923. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  8924. this._delay(function() {
  8925. last.focus();
  8926. });
  8927. event.preventDefault();
  8928. }
  8929. },
  8930. mousedown: function( event ) {
  8931. if ( this._moveToTop( event ) ) {
  8932. this._focusTabbable();
  8933. }
  8934. }
  8935. });
  8936. // We assume that any existing aria-describedby attribute means
  8937. // that the dialog content is marked up properly
  8938. // otherwise we brute force the content as the description
  8939. if ( !this.element.find( "[aria-describedby]" ).length ) {
  8940. this.uiDialog.attr({
  8941. "aria-describedby": this.element.uniqueId().attr( "id" )
  8942. });
  8943. }
  8944. },
  8945. _createTitlebar: function() {
  8946. var uiDialogTitle;
  8947. this.uiDialogTitlebar = $( "<div>" )
  8948. .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" )
  8949. .prependTo( this.uiDialog );
  8950. this._on( this.uiDialogTitlebar, {
  8951. mousedown: function( event ) {
  8952. // Don't prevent click on close button (#8838)
  8953. // Focusing a dialog that is partially scrolled out of view
  8954. // causes the browser to scroll it into view, preventing the click event
  8955. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  8956. // Dialog isn't getting focus when dragging (#8063)
  8957. this.uiDialog.focus();
  8958. }
  8959. }
  8960. });
  8961. // support: IE
  8962. // Use type="button" to prevent enter keypresses in textboxes from closing the
  8963. // dialog in IE (#9312)
  8964. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  8965. .button({
  8966. label: this.options.closeText,
  8967. icons: {
  8968. primary: "ui-icon-closethick"
  8969. },
  8970. text: false
  8971. })
  8972. .addClass( "ui-dialog-titlebar-close" )
  8973. .appendTo( this.uiDialogTitlebar );
  8974. this._on( this.uiDialogTitlebarClose, {
  8975. click: function( event ) {
  8976. event.preventDefault();
  8977. this.close( event );
  8978. }
  8979. });
  8980. uiDialogTitle = $( "<span>" )
  8981. .uniqueId()
  8982. .addClass( "ui-dialog-title" )
  8983. .prependTo( this.uiDialogTitlebar );
  8984. this._title( uiDialogTitle );
  8985. this.uiDialog.attr({
  8986. "aria-labelledby": uiDialogTitle.attr( "id" )
  8987. });
  8988. },
  8989. _title: function( title ) {
  8990. if ( !this.options.title ) {
  8991. title.html( "&#160;" );
  8992. }
  8993. title.text( this.options.title );
  8994. },
  8995. _createButtonPane: function() {
  8996. this.uiDialogButtonPane = $( "<div>" )
  8997. .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
  8998. this.uiButtonSet = $( "<div>" )
  8999. .addClass( "ui-dialog-buttonset" )
  9000. .appendTo( this.uiDialogButtonPane );
  9001. this._createButtons();
  9002. },
  9003. _createButtons: function() {
  9004. var that = this,
  9005. buttons = this.options.buttons;
  9006. // if we already have a button pane, remove it
  9007. this.uiDialogButtonPane.remove();
  9008. this.uiButtonSet.empty();
  9009. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  9010. this.uiDialog.removeClass( "ui-dialog-buttons" );
  9011. return;
  9012. }
  9013. $.each( buttons, function( name, props ) {
  9014. var click, buttonOptions;
  9015. props = $.isFunction( props ) ?
  9016. { click: props, text: name } :
  9017. props;
  9018. // Default to a non-submitting button
  9019. props = $.extend( { type: "button" }, props );
  9020. // Change the context for the click callback to be the main element
  9021. click = props.click;
  9022. props.click = function() {
  9023. click.apply( that.element[ 0 ], arguments );
  9024. };
  9025. buttonOptions = {
  9026. icons: props.icons,
  9027. text: props.showText
  9028. };
  9029. delete props.icons;
  9030. delete props.showText;
  9031. $( "<button></button>", props )
  9032. .button( buttonOptions )
  9033. .appendTo( that.uiButtonSet );
  9034. });
  9035. this.uiDialog.addClass( "ui-dialog-buttons" );
  9036. this.uiDialogButtonPane.appendTo( this.uiDialog );
  9037. },
  9038. _makeDraggable: function() {
  9039. var that = this,
  9040. options = this.options;
  9041. function filteredUi( ui ) {
  9042. return {
  9043. position: ui.position,
  9044. offset: ui.offset
  9045. };
  9046. }
  9047. this.uiDialog.draggable({
  9048. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  9049. handle: ".ui-dialog-titlebar",
  9050. containment: "document",
  9051. start: function( event, ui ) {
  9052. $( this ).addClass( "ui-dialog-dragging" );
  9053. that._blockFrames();
  9054. that._trigger( "dragStart", event, filteredUi( ui ) );
  9055. },
  9056. drag: function( event, ui ) {
  9057. that._trigger( "drag", event, filteredUi( ui ) );
  9058. },
  9059. stop: function( event, ui ) {
  9060. var left = ui.offset.left - that.document.scrollLeft(),
  9061. top = ui.offset.top - that.document.scrollTop();
  9062. options.position = {
  9063. my: "left top",
  9064. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  9065. "top" + (top >= 0 ? "+" : "") + top,
  9066. of: that.window
  9067. };
  9068. $( this ).removeClass( "ui-dialog-dragging" );
  9069. that._unblockFrames();
  9070. that._trigger( "dragStop", event, filteredUi( ui ) );
  9071. }
  9072. });
  9073. },
  9074. _makeResizable: function() {
  9075. var that = this,
  9076. options = this.options,
  9077. handles = options.resizable,
  9078. // .ui-resizable has position: relative defined in the stylesheet
  9079. // but dialogs have to use absolute or fixed positioning
  9080. position = this.uiDialog.css("position"),
  9081. resizeHandles = typeof handles === "string" ?
  9082. handles :
  9083. "n,e,s,w,se,sw,ne,nw";
  9084. function filteredUi( ui ) {
  9085. return {
  9086. originalPosition: ui.originalPosition,
  9087. originalSize: ui.originalSize,
  9088. position: ui.position,
  9089. size: ui.size
  9090. };
  9091. }
  9092. this.uiDialog.resizable({
  9093. cancel: ".ui-dialog-content",
  9094. containment: "document",
  9095. alsoResize: this.element,
  9096. maxWidth: options.maxWidth,
  9097. maxHeight: options.maxHeight,
  9098. minWidth: options.minWidth,
  9099. minHeight: this._minHeight(),
  9100. handles: resizeHandles,
  9101. start: function( event, ui ) {
  9102. $( this ).addClass( "ui-dialog-resizing" );
  9103. that._blockFrames();
  9104. that._trigger( "resizeStart", event, filteredUi( ui ) );
  9105. },
  9106. resize: function( event, ui ) {
  9107. that._trigger( "resize", event, filteredUi( ui ) );
  9108. },
  9109. stop: function( event, ui ) {
  9110. var offset = that.uiDialog.offset(),
  9111. left = offset.left - that.document.scrollLeft(),
  9112. top = offset.top - that.document.scrollTop();
  9113. options.height = that.uiDialog.height();
  9114. options.width = that.uiDialog.width();
  9115. options.position = {
  9116. my: "left top",
  9117. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  9118. "top" + (top >= 0 ? "+" : "") + top,
  9119. of: that.window
  9120. };
  9121. $( this ).removeClass( "ui-dialog-resizing" );
  9122. that._unblockFrames();
  9123. that._trigger( "resizeStop", event, filteredUi( ui ) );
  9124. }
  9125. })
  9126. .css( "position", position );
  9127. },
  9128. _trackFocus: function() {
  9129. this._on( this.widget(), {
  9130. focusin: function( event ) {
  9131. this._makeFocusTarget();
  9132. this._focusedElement = $( event.target );
  9133. }
  9134. });
  9135. },
  9136. _makeFocusTarget: function() {
  9137. this._untrackInstance();
  9138. this._trackingInstances().unshift( this );
  9139. },
  9140. _untrackInstance: function() {
  9141. var instances = this._trackingInstances(),
  9142. exists = $.inArray( this, instances );
  9143. if ( exists !== -1 ) {
  9144. instances.splice( exists, 1 );
  9145. }
  9146. },
  9147. _trackingInstances: function() {
  9148. var instances = this.document.data( "ui-dialog-instances" );
  9149. if ( !instances ) {
  9150. instances = [];
  9151. this.document.data( "ui-dialog-instances", instances );
  9152. }
  9153. return instances;
  9154. },
  9155. _minHeight: function() {
  9156. var options = this.options;
  9157. return options.height === "auto" ?
  9158. options.minHeight :
  9159. Math.min( options.minHeight, options.height );
  9160. },
  9161. _position: function() {
  9162. // Need to show the dialog to get the actual offset in the position plugin
  9163. var isVisible = this.uiDialog.is( ":visible" );
  9164. if ( !isVisible ) {
  9165. this.uiDialog.show();
  9166. }
  9167. this.uiDialog.position( this.options.position );
  9168. if ( !isVisible ) {
  9169. this.uiDialog.hide();
  9170. }
  9171. },
  9172. _setOptions: function( options ) {
  9173. var that = this,
  9174. resize = false,
  9175. resizableOptions = {};
  9176. $.each( options, function( key, value ) {
  9177. that._setOption( key, value );
  9178. if ( key in that.sizeRelatedOptions ) {
  9179. resize = true;
  9180. }
  9181. if ( key in that.resizableRelatedOptions ) {
  9182. resizableOptions[ key ] = value;
  9183. }
  9184. });
  9185. if ( resize ) {
  9186. this._size();
  9187. this._position();
  9188. }
  9189. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  9190. this.uiDialog.resizable( "option", resizableOptions );
  9191. }
  9192. },
  9193. _setOption: function( key, value ) {
  9194. var isDraggable, isResizable,
  9195. uiDialog = this.uiDialog;
  9196. if ( key === "dialogClass" ) {
  9197. uiDialog
  9198. .removeClass( this.options.dialogClass )
  9199. .addClass( value );
  9200. }
  9201. if ( key === "disabled" ) {
  9202. return;
  9203. }
  9204. this._super( key, value );
  9205. if ( key === "appendTo" ) {
  9206. this.uiDialog.appendTo( this._appendTo() );
  9207. }
  9208. if ( key === "buttons" ) {
  9209. this._createButtons();
  9210. }
  9211. if ( key === "closeText" ) {
  9212. this.uiDialogTitlebarClose.button({
  9213. // Ensure that we always pass a string
  9214. label: "" + value
  9215. });
  9216. }
  9217. if ( key === "draggable" ) {
  9218. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  9219. if ( isDraggable && !value ) {
  9220. uiDialog.draggable( "destroy" );
  9221. }
  9222. if ( !isDraggable && value ) {
  9223. this._makeDraggable();
  9224. }
  9225. }
  9226. if ( key === "position" ) {
  9227. this._position();
  9228. }
  9229. if ( key === "resizable" ) {
  9230. // currently resizable, becoming non-resizable
  9231. isResizable = uiDialog.is( ":data(ui-resizable)" );
  9232. if ( isResizable && !value ) {
  9233. uiDialog.resizable( "destroy" );
  9234. }
  9235. // currently resizable, changing handles
  9236. if ( isResizable && typeof value === "string" ) {
  9237. uiDialog.resizable( "option", "handles", value );
  9238. }
  9239. // currently non-resizable, becoming resizable
  9240. if ( !isResizable && value !== false ) {
  9241. this._makeResizable();
  9242. }
  9243. }
  9244. if ( key === "title" ) {
  9245. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  9246. }
  9247. },
  9248. _size: function() {
  9249. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  9250. // divs will both have width and height set, so we need to reset them
  9251. var nonContentHeight, minContentHeight, maxContentHeight,
  9252. options = this.options;
  9253. // Reset content sizing
  9254. this.element.show().css({
  9255. width: "auto",
  9256. minHeight: 0,
  9257. maxHeight: "none",
  9258. height: 0
  9259. });
  9260. if ( options.minWidth > options.width ) {
  9261. options.width = options.minWidth;
  9262. }
  9263. // reset wrapper sizing
  9264. // determine the height of all the non-content elements
  9265. nonContentHeight = this.uiDialog.css({
  9266. height: "auto",
  9267. width: options.width
  9268. })
  9269. .outerHeight();
  9270. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  9271. maxContentHeight = typeof options.maxHeight === "number" ?
  9272. Math.max( 0, options.maxHeight - nonContentHeight ) :
  9273. "none";
  9274. if ( options.height === "auto" ) {
  9275. this.element.css({
  9276. minHeight: minContentHeight,
  9277. maxHeight: maxContentHeight,
  9278. height: "auto"
  9279. });
  9280. } else {
  9281. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  9282. }
  9283. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  9284. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  9285. }
  9286. },
  9287. _blockFrames: function() {
  9288. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  9289. var iframe = $( this );
  9290. return $( "<div>" )
  9291. .css({
  9292. position: "absolute",
  9293. width: iframe.outerWidth(),
  9294. height: iframe.outerHeight()
  9295. })
  9296. .appendTo( iframe.parent() )
  9297. .offset( iframe.offset() )[0];
  9298. });
  9299. },
  9300. _unblockFrames: function() {
  9301. if ( this.iframeBlocks ) {
  9302. this.iframeBlocks.remove();
  9303. delete this.iframeBlocks;
  9304. }
  9305. },
  9306. _allowInteraction: function( event ) {
  9307. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  9308. return true;
  9309. }
  9310. // TODO: Remove hack when datepicker implements
  9311. // the .ui-front logic (#8989)
  9312. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  9313. },
  9314. _createOverlay: function() {
  9315. if ( !this.options.modal ) {
  9316. return;
  9317. }
  9318. // We use a delay in case the overlay is created from an
  9319. // event that we're going to be cancelling (#2804)
  9320. var isOpening = true;
  9321. this._delay(function() {
  9322. isOpening = false;
  9323. });
  9324. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  9325. // Prevent use of anchors and inputs
  9326. // Using _on() for an event handler shared across many instances is
  9327. // safe because the dialogs stack and must be closed in reverse order
  9328. this._on( this.document, {
  9329. focusin: function( event ) {
  9330. if ( isOpening ) {
  9331. return;
  9332. }
  9333. if ( !this._allowInteraction( event ) ) {
  9334. event.preventDefault();
  9335. this._trackingInstances()[ 0 ]._focusTabbable();
  9336. }
  9337. }
  9338. });
  9339. }
  9340. this.overlay = $( "<div>" )
  9341. .addClass( "ui-widget-overlay ui-front" )
  9342. .appendTo( this._appendTo() );
  9343. this._on( this.overlay, {
  9344. mousedown: "_keepFocus"
  9345. });
  9346. this.document.data( "ui-dialog-overlays",
  9347. (this.document.data( "ui-dialog-overlays" ) || 0) + 1 );
  9348. },
  9349. _destroyOverlay: function() {
  9350. if ( !this.options.modal ) {
  9351. return;
  9352. }
  9353. if ( this.overlay ) {
  9354. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  9355. if ( !overlays ) {
  9356. this.document
  9357. .unbind( "focusin" )
  9358. .removeData( "ui-dialog-overlays" );
  9359. } else {
  9360. this.document.data( "ui-dialog-overlays", overlays );
  9361. }
  9362. this.overlay.remove();
  9363. this.overlay = null;
  9364. }
  9365. }
  9366. });
  9367. /*!
  9368. * jQuery UI Progressbar 1.11.2
  9369. * http://jqueryui.com
  9370. *
  9371. * Copyright 2014 jQuery Foundation and other contributors
  9372. * Released under the MIT license.
  9373. * http://jquery.org/license
  9374. *
  9375. * http://api.jqueryui.com/progressbar/
  9376. */
  9377. var progressbar = $.widget( "ui.progressbar", {
  9378. version: "1.11.2",
  9379. options: {
  9380. max: 100,
  9381. value: 0,
  9382. change: null,
  9383. complete: null
  9384. },
  9385. min: 0,
  9386. _create: function() {
  9387. // Constrain initial value
  9388. this.oldValue = this.options.value = this._constrainedValue();
  9389. this.element
  9390. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  9391. .attr({
  9392. // Only set static values, aria-valuenow and aria-valuemax are
  9393. // set inside _refreshValue()
  9394. role: "progressbar",
  9395. "aria-valuemin": this.min
  9396. });
  9397. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  9398. .appendTo( this.element );
  9399. this._refreshValue();
  9400. },
  9401. _destroy: function() {
  9402. this.element
  9403. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  9404. .removeAttr( "role" )
  9405. .removeAttr( "aria-valuemin" )
  9406. .removeAttr( "aria-valuemax" )
  9407. .removeAttr( "aria-valuenow" );
  9408. this.valueDiv.remove();
  9409. },
  9410. value: function( newValue ) {
  9411. if ( newValue === undefined ) {
  9412. return this.options.value;
  9413. }
  9414. this.options.value = this._constrainedValue( newValue );
  9415. this._refreshValue();
  9416. },
  9417. _constrainedValue: function( newValue ) {
  9418. if ( newValue === undefined ) {
  9419. newValue = this.options.value;
  9420. }
  9421. this.indeterminate = newValue === false;
  9422. // sanitize value
  9423. if ( typeof newValue !== "number" ) {
  9424. newValue = 0;
  9425. }
  9426. return this.indeterminate ? false :
  9427. Math.min( this.options.max, Math.max( this.min, newValue ) );
  9428. },
  9429. _setOptions: function( options ) {
  9430. // Ensure "value" option is set after other values (like max)
  9431. var value = options.value;
  9432. delete options.value;
  9433. this._super( options );
  9434. this.options.value = this._constrainedValue( value );
  9435. this._refreshValue();
  9436. },
  9437. _setOption: function( key, value ) {
  9438. if ( key === "max" ) {
  9439. // Don't allow a max less than min
  9440. value = Math.max( this.min, value );
  9441. }
  9442. if ( key === "disabled" ) {
  9443. this.element
  9444. .toggleClass( "ui-state-disabled", !!value )
  9445. .attr( "aria-disabled", value );
  9446. }
  9447. this._super( key, value );
  9448. },
  9449. _percentage: function() {
  9450. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  9451. },
  9452. _refreshValue: function() {
  9453. var value = this.options.value,
  9454. percentage = this._percentage();
  9455. this.valueDiv
  9456. .toggle( this.indeterminate || value > this.min )
  9457. .toggleClass( "ui-corner-right", value === this.options.max )
  9458. .width( percentage.toFixed(0) + "%" );
  9459. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  9460. if ( this.indeterminate ) {
  9461. this.element.removeAttr( "aria-valuenow" );
  9462. if ( !this.overlayDiv ) {
  9463. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  9464. }
  9465. } else {
  9466. this.element.attr({
  9467. "aria-valuemax": this.options.max,
  9468. "aria-valuenow": value
  9469. });
  9470. if ( this.overlayDiv ) {
  9471. this.overlayDiv.remove();
  9472. this.overlayDiv = null;
  9473. }
  9474. }
  9475. if ( this.oldValue !== value ) {
  9476. this.oldValue = value;
  9477. this._trigger( "change" );
  9478. }
  9479. if ( value === this.options.max ) {
  9480. this._trigger( "complete" );
  9481. }
  9482. }
  9483. });
  9484. /*!
  9485. * jQuery UI Selectmenu 1.11.2
  9486. * http://jqueryui.com
  9487. *
  9488. * Copyright 2014 jQuery Foundation and other contributors
  9489. * Released under the MIT license.
  9490. * http://jquery.org/license
  9491. *
  9492. * http://api.jqueryui.com/selectmenu
  9493. */
  9494. var selectmenu = $.widget( "ui.selectmenu", {
  9495. version: "1.11.2",
  9496. defaultElement: "<select>",
  9497. options: {
  9498. appendTo: null,
  9499. disabled: null,
  9500. icons: {
  9501. button: "ui-icon-triangle-1-s"
  9502. },
  9503. position: {
  9504. my: "left top",
  9505. at: "left bottom",
  9506. collision: "none"
  9507. },
  9508. width: null,
  9509. // callbacks
  9510. change: null,
  9511. close: null,
  9512. focus: null,
  9513. open: null,
  9514. select: null
  9515. },
  9516. _create: function() {
  9517. var selectmenuId = this.element.uniqueId().attr( "id" );
  9518. this.ids = {
  9519. element: selectmenuId,
  9520. button: selectmenuId + "-button",
  9521. menu: selectmenuId + "-menu"
  9522. };
  9523. this._drawButton();
  9524. this._drawMenu();
  9525. if ( this.options.disabled ) {
  9526. this.disable();
  9527. }
  9528. },
  9529. _drawButton: function() {
  9530. var that = this,
  9531. tabindex = this.element.attr( "tabindex" );
  9532. // Associate existing label with the new button
  9533. this.label = $( "label[for='" + this.ids.element + "']" ).attr( "for", this.ids.button );
  9534. this._on( this.label, {
  9535. click: function( event ) {
  9536. this.button.focus();
  9537. event.preventDefault();
  9538. }
  9539. });
  9540. // Hide original select element
  9541. this.element.hide();
  9542. // Create button
  9543. this.button = $( "<span>", {
  9544. "class": "ui-selectmenu-button ui-widget ui-state-default ui-corner-all",
  9545. tabindex: tabindex || this.options.disabled ? -1 : 0,
  9546. id: this.ids.button,
  9547. role: "combobox",
  9548. "aria-expanded": "false",
  9549. "aria-autocomplete": "list",
  9550. "aria-owns": this.ids.menu,
  9551. "aria-haspopup": "true"
  9552. })
  9553. .insertAfter( this.element );
  9554. $( "<span>", {
  9555. "class": "ui-icon " + this.options.icons.button
  9556. })
  9557. .prependTo( this.button );
  9558. this.buttonText = $( "<span>", {
  9559. "class": "ui-selectmenu-text"
  9560. })
  9561. .appendTo( this.button );
  9562. this._setText( this.buttonText, this.element.find( "option:selected" ).text() );
  9563. this._resizeButton();
  9564. this._on( this.button, this._buttonEvents );
  9565. this.button.one( "focusin", function() {
  9566. // Delay rendering the menu items until the button receives focus.
  9567. // The menu may have already been rendered via a programmatic open.
  9568. if ( !that.menuItems ) {
  9569. that._refreshMenu();
  9570. }
  9571. });
  9572. this._hoverable( this.button );
  9573. this._focusable( this.button );
  9574. },
  9575. _drawMenu: function() {
  9576. var that = this;
  9577. // Create menu
  9578. this.menu = $( "<ul>", {
  9579. "aria-hidden": "true",
  9580. "aria-labelledby": this.ids.button,
  9581. id: this.ids.menu
  9582. });
  9583. // Wrap menu
  9584. this.menuWrap = $( "<div>", {
  9585. "class": "ui-selectmenu-menu ui-front"
  9586. })
  9587. .append( this.menu )
  9588. .appendTo( this._appendTo() );
  9589. // Initialize menu widget
  9590. this.menuInstance = this.menu
  9591. .menu({
  9592. role: "listbox",
  9593. select: function( event, ui ) {
  9594. event.preventDefault();
  9595. // support: IE8
  9596. // If the item was selected via a click, the text selection
  9597. // will be destroyed in IE
  9598. that._setSelection();
  9599. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  9600. },
  9601. focus: function( event, ui ) {
  9602. var item = ui.item.data( "ui-selectmenu-item" );
  9603. // Prevent inital focus from firing and check if its a newly focused item
  9604. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  9605. that._trigger( "focus", event, { item: item } );
  9606. if ( !that.isOpen ) {
  9607. that._select( item, event );
  9608. }
  9609. }
  9610. that.focusIndex = item.index;
  9611. that.button.attr( "aria-activedescendant",
  9612. that.menuItems.eq( item.index ).attr( "id" ) );
  9613. }
  9614. })
  9615. .menu( "instance" );
  9616. // Adjust menu styles to dropdown
  9617. this.menu
  9618. .addClass( "ui-corner-bottom" )
  9619. .removeClass( "ui-corner-all" );
  9620. // Don't close the menu on mouseleave
  9621. this.menuInstance._off( this.menu, "mouseleave" );
  9622. // Cancel the menu's collapseAll on document click
  9623. this.menuInstance._closeOnDocumentClick = function() {
  9624. return false;
  9625. };
  9626. // Selects often contain empty items, but never contain dividers
  9627. this.menuInstance._isDivider = function() {
  9628. return false;
  9629. };
  9630. },
  9631. refresh: function() {
  9632. this._refreshMenu();
  9633. this._setText( this.buttonText, this._getSelectedItem().text() );
  9634. if ( !this.options.width ) {
  9635. this._resizeButton();
  9636. }
  9637. },
  9638. _refreshMenu: function() {
  9639. this.menu.empty();
  9640. var item,
  9641. options = this.element.find( "option" );
  9642. if ( !options.length ) {
  9643. return;
  9644. }
  9645. this._parseOptions( options );
  9646. this._renderMenu( this.menu, this.items );
  9647. this.menuInstance.refresh();
  9648. this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" );
  9649. item = this._getSelectedItem();
  9650. // Update the menu to have the correct item focused
  9651. this.menuInstance.focus( null, item );
  9652. this._setAria( item.data( "ui-selectmenu-item" ) );
  9653. // Set disabled state
  9654. this._setOption( "disabled", this.element.prop( "disabled" ) );
  9655. },
  9656. open: function( event ) {
  9657. if ( this.options.disabled ) {
  9658. return;
  9659. }
  9660. // If this is the first time the menu is being opened, render the items
  9661. if ( !this.menuItems ) {
  9662. this._refreshMenu();
  9663. } else {
  9664. // Menu clears focus on close, reset focus to selected item
  9665. this.menu.find( ".ui-state-focus" ).removeClass( "ui-state-focus" );
  9666. this.menuInstance.focus( null, this._getSelectedItem() );
  9667. }
  9668. this.isOpen = true;
  9669. this._toggleAttr();
  9670. this._resizeMenu();
  9671. this._position();
  9672. this._on( this.document, this._documentClick );
  9673. this._trigger( "open", event );
  9674. },
  9675. _position: function() {
  9676. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  9677. },
  9678. close: function( event ) {
  9679. if ( !this.isOpen ) {
  9680. return;
  9681. }
  9682. this.isOpen = false;
  9683. this._toggleAttr();
  9684. this.range = null;
  9685. this._off( this.document );
  9686. this._trigger( "close", event );
  9687. },
  9688. widget: function() {
  9689. return this.button;
  9690. },
  9691. menuWidget: function() {
  9692. return this.menu;
  9693. },
  9694. _renderMenu: function( ul, items ) {
  9695. var that = this,
  9696. currentOptgroup = "";
  9697. $.each( items, function( index, item ) {
  9698. if ( item.optgroup !== currentOptgroup ) {
  9699. $( "<li>", {
  9700. "class": "ui-selectmenu-optgroup ui-menu-divider" +
  9701. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  9702. " ui-state-disabled" :
  9703. "" ),
  9704. text: item.optgroup
  9705. })
  9706. .appendTo( ul );
  9707. currentOptgroup = item.optgroup;
  9708. }
  9709. that._renderItemData( ul, item );
  9710. });
  9711. },
  9712. _renderItemData: function( ul, item ) {
  9713. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  9714. },
  9715. _renderItem: function( ul, item ) {
  9716. var li = $( "<li>" );
  9717. if ( item.disabled ) {
  9718. li.addClass( "ui-state-disabled" );
  9719. }
  9720. this._setText( li, item.label );
  9721. return li.appendTo( ul );
  9722. },
  9723. _setText: function( element, value ) {
  9724. if ( value ) {
  9725. element.text( value );
  9726. } else {
  9727. element.html( "&#160;" );
  9728. }
  9729. },
  9730. _move: function( direction, event ) {
  9731. var item, next,
  9732. filter = ".ui-menu-item";
  9733. if ( this.isOpen ) {
  9734. item = this.menuItems.eq( this.focusIndex );
  9735. } else {
  9736. item = this.menuItems.eq( this.element[ 0 ].selectedIndex );
  9737. filter += ":not(.ui-state-disabled)";
  9738. }
  9739. if ( direction === "first" || direction === "last" ) {
  9740. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  9741. } else {
  9742. next = item[ direction + "All" ]( filter ).eq( 0 );
  9743. }
  9744. if ( next.length ) {
  9745. this.menuInstance.focus( event, next );
  9746. }
  9747. },
  9748. _getSelectedItem: function() {
  9749. return this.menuItems.eq( this.element[ 0 ].selectedIndex );
  9750. },
  9751. _toggle: function( event ) {
  9752. this[ this.isOpen ? "close" : "open" ]( event );
  9753. },
  9754. _setSelection: function() {
  9755. var selection;
  9756. if ( !this.range ) {
  9757. return;
  9758. }
  9759. if ( window.getSelection ) {
  9760. selection = window.getSelection();
  9761. selection.removeAllRanges();
  9762. selection.addRange( this.range );
  9763. // support: IE8
  9764. } else {
  9765. this.range.select();
  9766. }
  9767. // support: IE
  9768. // Setting the text selection kills the button focus in IE, but
  9769. // restoring the focus doesn't kill the selection.
  9770. this.button.focus();
  9771. },
  9772. _documentClick: {
  9773. mousedown: function( event ) {
  9774. if ( !this.isOpen ) {
  9775. return;
  9776. }
  9777. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + this.ids.button ).length ) {
  9778. this.close( event );
  9779. }
  9780. }
  9781. },
  9782. _buttonEvents: {
  9783. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  9784. mousedown: function() {
  9785. var selection;
  9786. if ( window.getSelection ) {
  9787. selection = window.getSelection();
  9788. if ( selection.rangeCount ) {
  9789. this.range = selection.getRangeAt( 0 );
  9790. }
  9791. // support: IE8
  9792. } else {
  9793. this.range = document.selection.createRange();
  9794. }
  9795. },
  9796. click: function( event ) {
  9797. this._setSelection();
  9798. this._toggle( event );
  9799. },
  9800. keydown: function( event ) {
  9801. var preventDefault = true;
  9802. switch ( event.keyCode ) {
  9803. case $.ui.keyCode.TAB:
  9804. case $.ui.keyCode.ESCAPE:
  9805. this.close( event );
  9806. preventDefault = false;
  9807. break;
  9808. case $.ui.keyCode.ENTER:
  9809. if ( this.isOpen ) {
  9810. this._selectFocusedItem( event );
  9811. }
  9812. break;
  9813. case $.ui.keyCode.UP:
  9814. if ( event.altKey ) {
  9815. this._toggle( event );
  9816. } else {
  9817. this._move( "prev", event );
  9818. }
  9819. break;
  9820. case $.ui.keyCode.DOWN:
  9821. if ( event.altKey ) {
  9822. this._toggle( event );
  9823. } else {
  9824. this._move( "next", event );
  9825. }
  9826. break;
  9827. case $.ui.keyCode.SPACE:
  9828. if ( this.isOpen ) {
  9829. this._selectFocusedItem( event );
  9830. } else {
  9831. this._toggle( event );
  9832. }
  9833. break;
  9834. case $.ui.keyCode.LEFT:
  9835. this._move( "prev", event );
  9836. break;
  9837. case $.ui.keyCode.RIGHT:
  9838. this._move( "next", event );
  9839. break;
  9840. case $.ui.keyCode.HOME:
  9841. case $.ui.keyCode.PAGE_UP:
  9842. this._move( "first", event );
  9843. break;
  9844. case $.ui.keyCode.END:
  9845. case $.ui.keyCode.PAGE_DOWN:
  9846. this._move( "last", event );
  9847. break;
  9848. default:
  9849. this.menu.trigger( event );
  9850. preventDefault = false;
  9851. }
  9852. if ( preventDefault ) {
  9853. event.preventDefault();
  9854. }
  9855. }
  9856. },
  9857. _selectFocusedItem: function( event ) {
  9858. var item = this.menuItems.eq( this.focusIndex );
  9859. if ( !item.hasClass( "ui-state-disabled" ) ) {
  9860. this._select( item.data( "ui-selectmenu-item" ), event );
  9861. }
  9862. },
  9863. _select: function( item, event ) {
  9864. var oldIndex = this.element[ 0 ].selectedIndex;
  9865. // Change native select element
  9866. this.element[ 0 ].selectedIndex = item.index;
  9867. this._setText( this.buttonText, item.label );
  9868. this._setAria( item );
  9869. this._trigger( "select", event, { item: item } );
  9870. if ( item.index !== oldIndex ) {
  9871. this._trigger( "change", event, { item: item } );
  9872. }
  9873. this.close( event );
  9874. },
  9875. _setAria: function( item ) {
  9876. var id = this.menuItems.eq( item.index ).attr( "id" );
  9877. this.button.attr({
  9878. "aria-labelledby": id,
  9879. "aria-activedescendant": id
  9880. });
  9881. this.menu.attr( "aria-activedescendant", id );
  9882. },
  9883. _setOption: function( key, value ) {
  9884. if ( key === "icons" ) {
  9885. this.button.find( "span.ui-icon" )
  9886. .removeClass( this.options.icons.button )
  9887. .addClass( value.button );
  9888. }
  9889. this._super( key, value );
  9890. if ( key === "appendTo" ) {
  9891. this.menuWrap.appendTo( this._appendTo() );
  9892. }
  9893. if ( key === "disabled" ) {
  9894. this.menuInstance.option( "disabled", value );
  9895. this.button
  9896. .toggleClass( "ui-state-disabled", value )
  9897. .attr( "aria-disabled", value );
  9898. this.element.prop( "disabled", value );
  9899. if ( value ) {
  9900. this.button.attr( "tabindex", -1 );
  9901. this.close();
  9902. } else {
  9903. this.button.attr( "tabindex", 0 );
  9904. }
  9905. }
  9906. if ( key === "width" ) {
  9907. this._resizeButton();
  9908. }
  9909. },
  9910. _appendTo: function() {
  9911. var element = this.options.appendTo;
  9912. if ( element ) {
  9913. element = element.jquery || element.nodeType ?
  9914. $( element ) :
  9915. this.document.find( element ).eq( 0 );
  9916. }
  9917. if ( !element || !element[ 0 ] ) {
  9918. element = this.element.closest( ".ui-front" );
  9919. }
  9920. if ( !element.length ) {
  9921. element = this.document[ 0 ].body;
  9922. }
  9923. return element;
  9924. },
  9925. _toggleAttr: function() {
  9926. this.button
  9927. .toggleClass( "ui-corner-top", this.isOpen )
  9928. .toggleClass( "ui-corner-all", !this.isOpen )
  9929. .attr( "aria-expanded", this.isOpen );
  9930. this.menuWrap.toggleClass( "ui-selectmenu-open", this.isOpen );
  9931. this.menu.attr( "aria-hidden", !this.isOpen );
  9932. },
  9933. _resizeButton: function() {
  9934. var width = this.options.width;
  9935. if ( !width ) {
  9936. width = this.element.show().outerWidth();
  9937. this.element.hide();
  9938. }
  9939. this.button.outerWidth( width );
  9940. },
  9941. _resizeMenu: function() {
  9942. this.menu.outerWidth( Math.max(
  9943. this.button.outerWidth(),
  9944. // support: IE10
  9945. // IE10 wraps long text (possibly a rounding bug)
  9946. // so we add 1px to avoid the wrapping
  9947. this.menu.width( "" ).outerWidth() + 1
  9948. ) );
  9949. },
  9950. _getCreateOptions: function() {
  9951. return { disabled: this.element.prop( "disabled" ) };
  9952. },
  9953. _parseOptions: function( options ) {
  9954. var data = [];
  9955. options.each(function( index, item ) {
  9956. var option = $( item ),
  9957. optgroup = option.parent( "optgroup" );
  9958. data.push({
  9959. element: option,
  9960. index: index,
  9961. value: option.attr( "value" ),
  9962. label: option.text(),
  9963. optgroup: optgroup.attr( "label" ) || "",
  9964. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  9965. });
  9966. });
  9967. this.items = data;
  9968. },
  9969. _destroy: function() {
  9970. this.menuWrap.remove();
  9971. this.button.remove();
  9972. this.element.show();
  9973. this.element.removeUniqueId();
  9974. this.label.attr( "for", this.ids.element );
  9975. }
  9976. });
  9977. /*!
  9978. * jQuery UI Slider 1.11.2
  9979. * http://jqueryui.com
  9980. *
  9981. * Copyright 2014 jQuery Foundation and other contributors
  9982. * Released under the MIT license.
  9983. * http://jquery.org/license
  9984. *
  9985. * http://api.jqueryui.com/slider/
  9986. */
  9987. var slider = $.widget( "ui.slider", $.ui.mouse, {
  9988. version: "1.11.2",
  9989. widgetEventPrefix: "slide",
  9990. options: {
  9991. animate: false,
  9992. distance: 0,
  9993. max: 100,
  9994. min: 0,
  9995. orientation: "horizontal",
  9996. range: false,
  9997. step: 1,
  9998. value: 0,
  9999. values: null,
  10000. // callbacks
  10001. change: null,
  10002. slide: null,
  10003. start: null,
  10004. stop: null
  10005. },
  10006. // number of pages in a slider
  10007. // (how many times can you page up/down to go through the whole range)
  10008. numPages: 5,
  10009. _create: function() {
  10010. this._keySliding = false;
  10011. this._mouseSliding = false;
  10012. this._animateOff = true;
  10013. this._handleIndex = null;
  10014. this._detectOrientation();
  10015. this._mouseInit();
  10016. this._calculateNewMax();
  10017. this.element
  10018. .addClass( "ui-slider" +
  10019. " ui-slider-" + this.orientation +
  10020. " ui-widget" +
  10021. " ui-widget-content" +
  10022. " ui-corner-all");
  10023. this._refresh();
  10024. this._setOption( "disabled", this.options.disabled );
  10025. this._animateOff = false;
  10026. },
  10027. _refresh: function() {
  10028. this._createRange();
  10029. this._createHandles();
  10030. this._setupEvents();
  10031. this._refreshValue();
  10032. },
  10033. _createHandles: function() {
  10034. var i, handleCount,
  10035. options = this.options,
  10036. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  10037. handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",
  10038. handles = [];
  10039. handleCount = ( options.values && options.values.length ) || 1;
  10040. if ( existingHandles.length > handleCount ) {
  10041. existingHandles.slice( handleCount ).remove();
  10042. existingHandles = existingHandles.slice( 0, handleCount );
  10043. }
  10044. for ( i = existingHandles.length; i < handleCount; i++ ) {
  10045. handles.push( handle );
  10046. }
  10047. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  10048. this.handle = this.handles.eq( 0 );
  10049. this.handles.each(function( i ) {
  10050. $( this ).data( "ui-slider-handle-index", i );
  10051. });
  10052. },
  10053. _createRange: function() {
  10054. var options = this.options,
  10055. classes = "";
  10056. if ( options.range ) {
  10057. if ( options.range === true ) {
  10058. if ( !options.values ) {
  10059. options.values = [ this._valueMin(), this._valueMin() ];
  10060. } else if ( options.values.length && options.values.length !== 2 ) {
  10061. options.values = [ options.values[0], options.values[0] ];
  10062. } else if ( $.isArray( options.values ) ) {
  10063. options.values = options.values.slice(0);
  10064. }
  10065. }
  10066. if ( !this.range || !this.range.length ) {
  10067. this.range = $( "<div></div>" )
  10068. .appendTo( this.element );
  10069. classes = "ui-slider-range" +
  10070. // note: this isn't the most fittingly semantic framework class for this element,
  10071. // but worked best visually with a variety of themes
  10072. " ui-widget-header ui-corner-all";
  10073. } else {
  10074. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  10075. // Handle range switching from true to min/max
  10076. .css({
  10077. "left": "",
  10078. "bottom": ""
  10079. });
  10080. }
  10081. this.range.addClass( classes +
  10082. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  10083. } else {
  10084. if ( this.range ) {
  10085. this.range.remove();
  10086. }
  10087. this.range = null;
  10088. }
  10089. },
  10090. _setupEvents: function() {
  10091. this._off( this.handles );
  10092. this._on( this.handles, this._handleEvents );
  10093. this._hoverable( this.handles );
  10094. this._focusable( this.handles );
  10095. },
  10096. _destroy: function() {
  10097. this.handles.remove();
  10098. if ( this.range ) {
  10099. this.range.remove();
  10100. }
  10101. this.element
  10102. .removeClass( "ui-slider" +
  10103. " ui-slider-horizontal" +
  10104. " ui-slider-vertical" +
  10105. " ui-widget" +
  10106. " ui-widget-content" +
  10107. " ui-corner-all" );
  10108. this._mouseDestroy();
  10109. },
  10110. _mouseCapture: function( event ) {
  10111. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  10112. that = this,
  10113. o = this.options;
  10114. if ( o.disabled ) {
  10115. return false;
  10116. }
  10117. this.elementSize = {
  10118. width: this.element.outerWidth(),
  10119. height: this.element.outerHeight()
  10120. };
  10121. this.elementOffset = this.element.offset();
  10122. position = { x: event.pageX, y: event.pageY };
  10123. normValue = this._normValueFromMouse( position );
  10124. distance = this._valueMax() - this._valueMin() + 1;
  10125. this.handles.each(function( i ) {
  10126. var thisDistance = Math.abs( normValue - that.values(i) );
  10127. if (( distance > thisDistance ) ||
  10128. ( distance === thisDistance &&
  10129. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  10130. distance = thisDistance;
  10131. closestHandle = $( this );
  10132. index = i;
  10133. }
  10134. });
  10135. allowed = this._start( event, index );
  10136. if ( allowed === false ) {
  10137. return false;
  10138. }
  10139. this._mouseSliding = true;
  10140. this._handleIndex = index;
  10141. closestHandle
  10142. .addClass( "ui-state-active" )
  10143. .focus();
  10144. offset = closestHandle.offset();
  10145. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  10146. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  10147. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  10148. top: event.pageY - offset.top -
  10149. ( closestHandle.height() / 2 ) -
  10150. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  10151. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  10152. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  10153. };
  10154. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  10155. this._slide( event, index, normValue );
  10156. }
  10157. this._animateOff = true;
  10158. return true;
  10159. },
  10160. _mouseStart: function() {
  10161. return true;
  10162. },
  10163. _mouseDrag: function( event ) {
  10164. var position = { x: event.pageX, y: event.pageY },
  10165. normValue = this._normValueFromMouse( position );
  10166. this._slide( event, this._handleIndex, normValue );
  10167. return false;
  10168. },
  10169. _mouseStop: function( event ) {
  10170. this.handles.removeClass( "ui-state-active" );
  10171. this._mouseSliding = false;
  10172. this._stop( event, this._handleIndex );
  10173. this._change( event, this._handleIndex );
  10174. this._handleIndex = null;
  10175. this._clickOffset = null;
  10176. this._animateOff = false;
  10177. return false;
  10178. },
  10179. _detectOrientation: function() {
  10180. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  10181. },
  10182. _normValueFromMouse: function( position ) {
  10183. var pixelTotal,
  10184. pixelMouse,
  10185. percentMouse,
  10186. valueTotal,
  10187. valueMouse;
  10188. if ( this.orientation === "horizontal" ) {
  10189. pixelTotal = this.elementSize.width;
  10190. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  10191. } else {
  10192. pixelTotal = this.elementSize.height;
  10193. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  10194. }
  10195. percentMouse = ( pixelMouse / pixelTotal );
  10196. if ( percentMouse > 1 ) {
  10197. percentMouse = 1;
  10198. }
  10199. if ( percentMouse < 0 ) {
  10200. percentMouse = 0;
  10201. }
  10202. if ( this.orientation === "vertical" ) {
  10203. percentMouse = 1 - percentMouse;
  10204. }
  10205. valueTotal = this._valueMax() - this._valueMin();
  10206. valueMouse = this._valueMin() + percentMouse * valueTotal;
  10207. return this._trimAlignValue( valueMouse );
  10208. },
  10209. _start: function( event, index ) {
  10210. var uiHash = {
  10211. handle: this.handles[ index ],
  10212. value: this.value()
  10213. };
  10214. if ( this.options.values && this.options.values.length ) {
  10215. uiHash.value = this.values( index );
  10216. uiHash.values = this.values();
  10217. }
  10218. return this._trigger( "start", event, uiHash );
  10219. },
  10220. _slide: function( event, index, newVal ) {
  10221. var otherVal,
  10222. newValues,
  10223. allowed;
  10224. if ( this.options.values && this.options.values.length ) {
  10225. otherVal = this.values( index ? 0 : 1 );
  10226. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  10227. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  10228. ) {
  10229. newVal = otherVal;
  10230. }
  10231. if ( newVal !== this.values( index ) ) {
  10232. newValues = this.values();
  10233. newValues[ index ] = newVal;
  10234. // A slide can be canceled by returning false from the slide callback
  10235. allowed = this._trigger( "slide", event, {
  10236. handle: this.handles[ index ],
  10237. value: newVal,
  10238. values: newValues
  10239. } );
  10240. otherVal = this.values( index ? 0 : 1 );
  10241. if ( allowed !== false ) {
  10242. this.values( index, newVal );
  10243. }
  10244. }
  10245. } else {
  10246. if ( newVal !== this.value() ) {
  10247. // A slide can be canceled by returning false from the slide callback
  10248. allowed = this._trigger( "slide", event, {
  10249. handle: this.handles[ index ],
  10250. value: newVal
  10251. } );
  10252. if ( allowed !== false ) {
  10253. this.value( newVal );
  10254. }
  10255. }
  10256. }
  10257. },
  10258. _stop: function( event, index ) {
  10259. var uiHash = {
  10260. handle: this.handles[ index ],
  10261. value: this.value()
  10262. };
  10263. if ( this.options.values && this.options.values.length ) {
  10264. uiHash.value = this.values( index );
  10265. uiHash.values = this.values();
  10266. }
  10267. this._trigger( "stop", event, uiHash );
  10268. },
  10269. _change: function( event, index ) {
  10270. if ( !this._keySliding && !this._mouseSliding ) {
  10271. var uiHash = {
  10272. handle: this.handles[ index ],
  10273. value: this.value()
  10274. };
  10275. if ( this.options.values && this.options.values.length ) {
  10276. uiHash.value = this.values( index );
  10277. uiHash.values = this.values();
  10278. }
  10279. //store the last changed value index for reference when handles overlap
  10280. this._lastChangedValue = index;
  10281. this._trigger( "change", event, uiHash );
  10282. }
  10283. },
  10284. value: function( newValue ) {
  10285. if ( arguments.length ) {
  10286. this.options.value = this._trimAlignValue( newValue );
  10287. this._refreshValue();
  10288. this._change( null, 0 );
  10289. return;
  10290. }
  10291. return this._value();
  10292. },
  10293. values: function( index, newValue ) {
  10294. var vals,
  10295. newValues,
  10296. i;
  10297. if ( arguments.length > 1 ) {
  10298. this.options.values[ index ] = this._trimAlignValue( newValue );
  10299. this._refreshValue();
  10300. this._change( null, index );
  10301. return;
  10302. }
  10303. if ( arguments.length ) {
  10304. if ( $.isArray( arguments[ 0 ] ) ) {
  10305. vals = this.options.values;
  10306. newValues = arguments[ 0 ];
  10307. for ( i = 0; i < vals.length; i += 1 ) {
  10308. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  10309. this._change( null, i );
  10310. }
  10311. this._refreshValue();
  10312. } else {
  10313. if ( this.options.values && this.options.values.length ) {
  10314. return this._values( index );
  10315. } else {
  10316. return this.value();
  10317. }
  10318. }
  10319. } else {
  10320. return this._values();
  10321. }
  10322. },
  10323. _setOption: function( key, value ) {
  10324. var i,
  10325. valsLength = 0;
  10326. if ( key === "range" && this.options.range === true ) {
  10327. if ( value === "min" ) {
  10328. this.options.value = this._values( 0 );
  10329. this.options.values = null;
  10330. } else if ( value === "max" ) {
  10331. this.options.value = this._values( this.options.values.length - 1 );
  10332. this.options.values = null;
  10333. }
  10334. }
  10335. if ( $.isArray( this.options.values ) ) {
  10336. valsLength = this.options.values.length;
  10337. }
  10338. if ( key === "disabled" ) {
  10339. this.element.toggleClass( "ui-state-disabled", !!value );
  10340. }
  10341. this._super( key, value );
  10342. switch ( key ) {
  10343. case "orientation":
  10344. this._detectOrientation();
  10345. this.element
  10346. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  10347. .addClass( "ui-slider-" + this.orientation );
  10348. this._refreshValue();
  10349. // Reset positioning from previous orientation
  10350. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  10351. break;
  10352. case "value":
  10353. this._animateOff = true;
  10354. this._refreshValue();
  10355. this._change( null, 0 );
  10356. this._animateOff = false;
  10357. break;
  10358. case "values":
  10359. this._animateOff = true;
  10360. this._refreshValue();
  10361. for ( i = 0; i < valsLength; i += 1 ) {
  10362. this._change( null, i );
  10363. }
  10364. this._animateOff = false;
  10365. break;
  10366. case "step":
  10367. case "min":
  10368. case "max":
  10369. this._animateOff = true;
  10370. this._calculateNewMax();
  10371. this._refreshValue();
  10372. this._animateOff = false;
  10373. break;
  10374. case "range":
  10375. this._animateOff = true;
  10376. this._refresh();
  10377. this._animateOff = false;
  10378. break;
  10379. }
  10380. },
  10381. //internal value getter
  10382. // _value() returns value trimmed by min and max, aligned by step
  10383. _value: function() {
  10384. var val = this.options.value;
  10385. val = this._trimAlignValue( val );
  10386. return val;
  10387. },
  10388. //internal values getter
  10389. // _values() returns array of values trimmed by min and max, aligned by step
  10390. // _values( index ) returns single value trimmed by min and max, aligned by step
  10391. _values: function( index ) {
  10392. var val,
  10393. vals,
  10394. i;
  10395. if ( arguments.length ) {
  10396. val = this.options.values[ index ];
  10397. val = this._trimAlignValue( val );
  10398. return val;
  10399. } else if ( this.options.values && this.options.values.length ) {
  10400. // .slice() creates a copy of the array
  10401. // this copy gets trimmed by min and max and then returned
  10402. vals = this.options.values.slice();
  10403. for ( i = 0; i < vals.length; i += 1) {
  10404. vals[ i ] = this._trimAlignValue( vals[ i ] );
  10405. }
  10406. return vals;
  10407. } else {
  10408. return [];
  10409. }
  10410. },
  10411. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  10412. _trimAlignValue: function( val ) {
  10413. if ( val <= this._valueMin() ) {
  10414. return this._valueMin();
  10415. }
  10416. if ( val >= this._valueMax() ) {
  10417. return this._valueMax();
  10418. }
  10419. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  10420. valModStep = (val - this._valueMin()) % step,
  10421. alignValue = val - valModStep;
  10422. if ( Math.abs(valModStep) * 2 >= step ) {
  10423. alignValue += ( valModStep > 0 ) ? step : ( -step );
  10424. }
  10425. // Since JavaScript has problems with large floats, round
  10426. // the final value to 5 digits after the decimal point (see #4124)
  10427. return parseFloat( alignValue.toFixed(5) );
  10428. },
  10429. _calculateNewMax: function() {
  10430. var remainder = ( this.options.max - this._valueMin() ) % this.options.step;
  10431. this.max = this.options.max - remainder;
  10432. },
  10433. _valueMin: function() {
  10434. return this.options.min;
  10435. },
  10436. _valueMax: function() {
  10437. return this.max;
  10438. },
  10439. _refreshValue: function() {
  10440. var lastValPercent, valPercent, value, valueMin, valueMax,
  10441. oRange = this.options.range,
  10442. o = this.options,
  10443. that = this,
  10444. animate = ( !this._animateOff ) ? o.animate : false,
  10445. _set = {};
  10446. if ( this.options.values && this.options.values.length ) {
  10447. this.handles.each(function( i ) {
  10448. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  10449. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  10450. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  10451. if ( that.options.range === true ) {
  10452. if ( that.orientation === "horizontal" ) {
  10453. if ( i === 0 ) {
  10454. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  10455. }
  10456. if ( i === 1 ) {
  10457. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  10458. }
  10459. } else {
  10460. if ( i === 0 ) {
  10461. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  10462. }
  10463. if ( i === 1 ) {
  10464. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  10465. }
  10466. }
  10467. }
  10468. lastValPercent = valPercent;
  10469. });
  10470. } else {
  10471. value = this.value();
  10472. valueMin = this._valueMin();
  10473. valueMax = this._valueMax();
  10474. valPercent = ( valueMax !== valueMin ) ?
  10475. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  10476. 0;
  10477. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  10478. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  10479. if ( oRange === "min" && this.orientation === "horizontal" ) {
  10480. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  10481. }
  10482. if ( oRange === "max" && this.orientation === "horizontal" ) {
  10483. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  10484. }
  10485. if ( oRange === "min" && this.orientation === "vertical" ) {
  10486. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  10487. }
  10488. if ( oRange === "max" && this.orientation === "vertical" ) {
  10489. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  10490. }
  10491. }
  10492. },
  10493. _handleEvents: {
  10494. keydown: function( event ) {
  10495. var allowed, curVal, newVal, step,
  10496. index = $( event.target ).data( "ui-slider-handle-index" );
  10497. switch ( event.keyCode ) {
  10498. case $.ui.keyCode.HOME:
  10499. case $.ui.keyCode.END:
  10500. case $.ui.keyCode.PAGE_UP:
  10501. case $.ui.keyCode.PAGE_DOWN:
  10502. case $.ui.keyCode.UP:
  10503. case $.ui.keyCode.RIGHT:
  10504. case $.ui.keyCode.DOWN:
  10505. case $.ui.keyCode.LEFT:
  10506. event.preventDefault();
  10507. if ( !this._keySliding ) {
  10508. this._keySliding = true;
  10509. $( event.target ).addClass( "ui-state-active" );
  10510. allowed = this._start( event, index );
  10511. if ( allowed === false ) {
  10512. return;
  10513. }
  10514. }
  10515. break;
  10516. }
  10517. step = this.options.step;
  10518. if ( this.options.values && this.options.values.length ) {
  10519. curVal = newVal = this.values( index );
  10520. } else {
  10521. curVal = newVal = this.value();
  10522. }
  10523. switch ( event.keyCode ) {
  10524. case $.ui.keyCode.HOME:
  10525. newVal = this._valueMin();
  10526. break;
  10527. case $.ui.keyCode.END:
  10528. newVal = this._valueMax();
  10529. break;
  10530. case $.ui.keyCode.PAGE_UP:
  10531. newVal = this._trimAlignValue(
  10532. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  10533. );
  10534. break;
  10535. case $.ui.keyCode.PAGE_DOWN:
  10536. newVal = this._trimAlignValue(
  10537. curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
  10538. break;
  10539. case $.ui.keyCode.UP:
  10540. case $.ui.keyCode.RIGHT:
  10541. if ( curVal === this._valueMax() ) {
  10542. return;
  10543. }
  10544. newVal = this._trimAlignValue( curVal + step );
  10545. break;
  10546. case $.ui.keyCode.DOWN:
  10547. case $.ui.keyCode.LEFT:
  10548. if ( curVal === this._valueMin() ) {
  10549. return;
  10550. }
  10551. newVal = this._trimAlignValue( curVal - step );
  10552. break;
  10553. }
  10554. this._slide( event, index, newVal );
  10555. },
  10556. keyup: function( event ) {
  10557. var index = $( event.target ).data( "ui-slider-handle-index" );
  10558. if ( this._keySliding ) {
  10559. this._keySliding = false;
  10560. this._stop( event, index );
  10561. this._change( event, index );
  10562. $( event.target ).removeClass( "ui-state-active" );
  10563. }
  10564. }
  10565. }
  10566. });
  10567. /*!
  10568. * jQuery UI Spinner 1.11.2
  10569. * http://jqueryui.com
  10570. *
  10571. * Copyright 2014 jQuery Foundation and other contributors
  10572. * Released under the MIT license.
  10573. * http://jquery.org/license
  10574. *
  10575. * http://api.jqueryui.com/spinner/
  10576. */
  10577. function spinner_modifier( fn ) {
  10578. return function() {
  10579. var previous = this.element.val();
  10580. fn.apply( this, arguments );
  10581. this._refresh();
  10582. if ( previous !== this.element.val() ) {
  10583. this._trigger( "change" );
  10584. }
  10585. };
  10586. }
  10587. var spinner = $.widget( "ui.spinner", {
  10588. version: "1.11.2",
  10589. defaultElement: "<input>",
  10590. widgetEventPrefix: "spin",
  10591. options: {
  10592. culture: null,
  10593. icons: {
  10594. down: "ui-icon-triangle-1-s",
  10595. up: "ui-icon-triangle-1-n"
  10596. },
  10597. incremental: true,
  10598. max: null,
  10599. min: null,
  10600. numberFormat: null,
  10601. page: 10,
  10602. step: 1,
  10603. change: null,
  10604. spin: null,
  10605. start: null,
  10606. stop: null
  10607. },
  10608. _create: function() {
  10609. // handle string values that need to be parsed
  10610. this._setOption( "max", this.options.max );
  10611. this._setOption( "min", this.options.min );
  10612. this._setOption( "step", this.options.step );
  10613. // Only format if there is a value, prevents the field from being marked
  10614. // as invalid in Firefox, see #9573.
  10615. if ( this.value() !== "" ) {
  10616. // Format the value, but don't constrain.
  10617. this._value( this.element.val(), true );
  10618. }
  10619. this._draw();
  10620. this._on( this._events );
  10621. this._refresh();
  10622. // turning off autocomplete prevents the browser from remembering the
  10623. // value when navigating through history, so we re-enable autocomplete
  10624. // if the page is unloaded before the widget is destroyed. #7790
  10625. this._on( this.window, {
  10626. beforeunload: function() {
  10627. this.element.removeAttr( "autocomplete" );
  10628. }
  10629. });
  10630. },
  10631. _getCreateOptions: function() {
  10632. var options = {},
  10633. element = this.element;
  10634. $.each( [ "min", "max", "step" ], function( i, option ) {
  10635. var value = element.attr( option );
  10636. if ( value !== undefined && value.length ) {
  10637. options[ option ] = value;
  10638. }
  10639. });
  10640. return options;
  10641. },
  10642. _events: {
  10643. keydown: function( event ) {
  10644. if ( this._start( event ) && this._keydown( event ) ) {
  10645. event.preventDefault();
  10646. }
  10647. },
  10648. keyup: "_stop",
  10649. focus: function() {
  10650. this.previous = this.element.val();
  10651. },
  10652. blur: function( event ) {
  10653. if ( this.cancelBlur ) {
  10654. delete this.cancelBlur;
  10655. return;
  10656. }
  10657. this._stop();
  10658. this._refresh();
  10659. if ( this.previous !== this.element.val() ) {
  10660. this._trigger( "change", event );
  10661. }
  10662. },
  10663. mousewheel: function( event, delta ) {
  10664. if ( !delta ) {
  10665. return;
  10666. }
  10667. if ( !this.spinning && !this._start( event ) ) {
  10668. return false;
  10669. }
  10670. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  10671. clearTimeout( this.mousewheelTimer );
  10672. this.mousewheelTimer = this._delay(function() {
  10673. if ( this.spinning ) {
  10674. this._stop( event );
  10675. }
  10676. }, 100 );
  10677. event.preventDefault();
  10678. },
  10679. "mousedown .ui-spinner-button": function( event ) {
  10680. var previous;
  10681. // We never want the buttons to have focus; whenever the user is
  10682. // interacting with the spinner, the focus should be on the input.
  10683. // If the input is focused then this.previous is properly set from
  10684. // when the input first received focus. If the input is not focused
  10685. // then we need to set this.previous based on the value before spinning.
  10686. previous = this.element[0] === this.document[0].activeElement ?
  10687. this.previous : this.element.val();
  10688. function checkFocus() {
  10689. var isActive = this.element[0] === this.document[0].activeElement;
  10690. if ( !isActive ) {
  10691. this.element.focus();
  10692. this.previous = previous;
  10693. // support: IE
  10694. // IE sets focus asynchronously, so we need to check if focus
  10695. // moved off of the input because the user clicked on the button.
  10696. this._delay(function() {
  10697. this.previous = previous;
  10698. });
  10699. }
  10700. }
  10701. // ensure focus is on (or stays on) the text field
  10702. event.preventDefault();
  10703. checkFocus.call( this );
  10704. // support: IE
  10705. // IE doesn't prevent moving focus even with event.preventDefault()
  10706. // so we set a flag to know when we should ignore the blur event
  10707. // and check (again) if focus moved off of the input.
  10708. this.cancelBlur = true;
  10709. this._delay(function() {
  10710. delete this.cancelBlur;
  10711. checkFocus.call( this );
  10712. });
  10713. if ( this._start( event ) === false ) {
  10714. return;
  10715. }
  10716. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  10717. },
  10718. "mouseup .ui-spinner-button": "_stop",
  10719. "mouseenter .ui-spinner-button": function( event ) {
  10720. // button will add ui-state-active if mouse was down while mouseleave and kept down
  10721. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  10722. return;
  10723. }
  10724. if ( this._start( event ) === false ) {
  10725. return false;
  10726. }
  10727. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  10728. },
  10729. // TODO: do we really want to consider this a stop?
  10730. // shouldn't we just stop the repeater and wait until mouseup before
  10731. // we trigger the stop event?
  10732. "mouseleave .ui-spinner-button": "_stop"
  10733. },
  10734. _draw: function() {
  10735. var uiSpinner = this.uiSpinner = this.element
  10736. .addClass( "ui-spinner-input" )
  10737. .attr( "autocomplete", "off" )
  10738. .wrap( this._uiSpinnerHtml() )
  10739. .parent()
  10740. // add buttons
  10741. .append( this._buttonHtml() );
  10742. this.element.attr( "role", "spinbutton" );
  10743. // button bindings
  10744. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  10745. .attr( "tabIndex", -1 )
  10746. .button()
  10747. .removeClass( "ui-corner-all" );
  10748. // IE 6 doesn't understand height: 50% for the buttons
  10749. // unless the wrapper has an explicit height
  10750. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  10751. uiSpinner.height() > 0 ) {
  10752. uiSpinner.height( uiSpinner.height() );
  10753. }
  10754. // disable spinner if element was already disabled
  10755. if ( this.options.disabled ) {
  10756. this.disable();
  10757. }
  10758. },
  10759. _keydown: function( event ) {
  10760. var options = this.options,
  10761. keyCode = $.ui.keyCode;
  10762. switch ( event.keyCode ) {
  10763. case keyCode.UP:
  10764. this._repeat( null, 1, event );
  10765. return true;
  10766. case keyCode.DOWN:
  10767. this._repeat( null, -1, event );
  10768. return true;
  10769. case keyCode.PAGE_UP:
  10770. this._repeat( null, options.page, event );
  10771. return true;
  10772. case keyCode.PAGE_DOWN:
  10773. this._repeat( null, -options.page, event );
  10774. return true;
  10775. }
  10776. return false;
  10777. },
  10778. _uiSpinnerHtml: function() {
  10779. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  10780. },
  10781. _buttonHtml: function() {
  10782. return "" +
  10783. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  10784. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  10785. "</a>" +
  10786. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  10787. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  10788. "</a>";
  10789. },
  10790. _start: function( event ) {
  10791. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  10792. return false;
  10793. }
  10794. if ( !this.counter ) {
  10795. this.counter = 1;
  10796. }
  10797. this.spinning = true;
  10798. return true;
  10799. },
  10800. _repeat: function( i, steps, event ) {
  10801. i = i || 500;
  10802. clearTimeout( this.timer );
  10803. this.timer = this._delay(function() {
  10804. this._repeat( 40, steps, event );
  10805. }, i );
  10806. this._spin( steps * this.options.step, event );
  10807. },
  10808. _spin: function( step, event ) {
  10809. var value = this.value() || 0;
  10810. if ( !this.counter ) {
  10811. this.counter = 1;
  10812. }
  10813. value = this._adjustValue( value + step * this._increment( this.counter ) );
  10814. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  10815. this._value( value );
  10816. this.counter++;
  10817. }
  10818. },
  10819. _increment: function( i ) {
  10820. var incremental = this.options.incremental;
  10821. if ( incremental ) {
  10822. return $.isFunction( incremental ) ?
  10823. incremental( i ) :
  10824. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  10825. }
  10826. return 1;
  10827. },
  10828. _precision: function() {
  10829. var precision = this._precisionOf( this.options.step );
  10830. if ( this.options.min !== null ) {
  10831. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  10832. }
  10833. return precision;
  10834. },
  10835. _precisionOf: function( num ) {
  10836. var str = num.toString(),
  10837. decimal = str.indexOf( "." );
  10838. return decimal === -1 ? 0 : str.length - decimal - 1;
  10839. },
  10840. _adjustValue: function( value ) {
  10841. var base, aboveMin,
  10842. options = this.options;
  10843. // make sure we're at a valid step
  10844. // - find out where we are relative to the base (min or 0)
  10845. base = options.min !== null ? options.min : 0;
  10846. aboveMin = value - base;
  10847. // - round to the nearest step
  10848. aboveMin = Math.round(aboveMin / options.step) * options.step;
  10849. // - rounding is based on 0, so adjust back to our base
  10850. value = base + aboveMin;
  10851. // fix precision from bad JS floating point math
  10852. value = parseFloat( value.toFixed( this._precision() ) );
  10853. // clamp the value
  10854. if ( options.max !== null && value > options.max) {
  10855. return options.max;
  10856. }
  10857. if ( options.min !== null && value < options.min ) {
  10858. return options.min;
  10859. }
  10860. return value;
  10861. },
  10862. _stop: function( event ) {
  10863. if ( !this.spinning ) {
  10864. return;
  10865. }
  10866. clearTimeout( this.timer );
  10867. clearTimeout( this.mousewheelTimer );
  10868. this.counter = 0;
  10869. this.spinning = false;
  10870. this._trigger( "stop", event );
  10871. },
  10872. _setOption: function( key, value ) {
  10873. if ( key === "culture" || key === "numberFormat" ) {
  10874. var prevValue = this._parse( this.element.val() );
  10875. this.options[ key ] = value;
  10876. this.element.val( this._format( prevValue ) );
  10877. return;
  10878. }
  10879. if ( key === "max" || key === "min" || key === "step" ) {
  10880. if ( typeof value === "string" ) {
  10881. value = this._parse( value );
  10882. }
  10883. }
  10884. if ( key === "icons" ) {
  10885. this.buttons.first().find( ".ui-icon" )
  10886. .removeClass( this.options.icons.up )
  10887. .addClass( value.up );
  10888. this.buttons.last().find( ".ui-icon" )
  10889. .removeClass( this.options.icons.down )
  10890. .addClass( value.down );
  10891. }
  10892. this._super( key, value );
  10893. if ( key === "disabled" ) {
  10894. this.widget().toggleClass( "ui-state-disabled", !!value );
  10895. this.element.prop( "disabled", !!value );
  10896. this.buttons.button( value ? "disable" : "enable" );
  10897. }
  10898. },
  10899. _setOptions: spinner_modifier(function( options ) {
  10900. this._super( options );
  10901. }),
  10902. _parse: function( val ) {
  10903. if ( typeof val === "string" && val !== "" ) {
  10904. val = window.Globalize && this.options.numberFormat ?
  10905. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  10906. }
  10907. return val === "" || isNaN( val ) ? null : val;
  10908. },
  10909. _format: function( value ) {
  10910. if ( value === "" ) {
  10911. return "";
  10912. }
  10913. return window.Globalize && this.options.numberFormat ?
  10914. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  10915. value;
  10916. },
  10917. _refresh: function() {
  10918. this.element.attr({
  10919. "aria-valuemin": this.options.min,
  10920. "aria-valuemax": this.options.max,
  10921. // TODO: what should we do with values that can't be parsed?
  10922. "aria-valuenow": this._parse( this.element.val() )
  10923. });
  10924. },
  10925. isValid: function() {
  10926. var value = this.value();
  10927. // null is invalid
  10928. if ( value === null ) {
  10929. return false;
  10930. }
  10931. // if value gets adjusted, it's invalid
  10932. return value === this._adjustValue( value );
  10933. },
  10934. // update the value without triggering change
  10935. _value: function( value, allowAny ) {
  10936. var parsed;
  10937. if ( value !== "" ) {
  10938. parsed = this._parse( value );
  10939. if ( parsed !== null ) {
  10940. if ( !allowAny ) {
  10941. parsed = this._adjustValue( parsed );
  10942. }
  10943. value = this._format( parsed );
  10944. }
  10945. }
  10946. this.element.val( value );
  10947. this._refresh();
  10948. },
  10949. _destroy: function() {
  10950. this.element
  10951. .removeClass( "ui-spinner-input" )
  10952. .prop( "disabled", false )
  10953. .removeAttr( "autocomplete" )
  10954. .removeAttr( "role" )
  10955. .removeAttr( "aria-valuemin" )
  10956. .removeAttr( "aria-valuemax" )
  10957. .removeAttr( "aria-valuenow" );
  10958. this.uiSpinner.replaceWith( this.element );
  10959. },
  10960. stepUp: spinner_modifier(function( steps ) {
  10961. this._stepUp( steps );
  10962. }),
  10963. _stepUp: function( steps ) {
  10964. if ( this._start() ) {
  10965. this._spin( (steps || 1) * this.options.step );
  10966. this._stop();
  10967. }
  10968. },
  10969. stepDown: spinner_modifier(function( steps ) {
  10970. this._stepDown( steps );
  10971. }),
  10972. _stepDown: function( steps ) {
  10973. if ( this._start() ) {
  10974. this._spin( (steps || 1) * -this.options.step );
  10975. this._stop();
  10976. }
  10977. },
  10978. pageUp: spinner_modifier(function( pages ) {
  10979. this._stepUp( (pages || 1) * this.options.page );
  10980. }),
  10981. pageDown: spinner_modifier(function( pages ) {
  10982. this._stepDown( (pages || 1) * this.options.page );
  10983. }),
  10984. value: function( newVal ) {
  10985. if ( !arguments.length ) {
  10986. return this._parse( this.element.val() );
  10987. }
  10988. spinner_modifier( this._value ).call( this, newVal );
  10989. },
  10990. widget: function() {
  10991. return this.uiSpinner;
  10992. }
  10993. });
  10994. /*!
  10995. * jQuery UI Tabs 1.11.2
  10996. * http://jqueryui.com
  10997. *
  10998. * Copyright 2014 jQuery Foundation and other contributors
  10999. * Released under the MIT license.
  11000. * http://jquery.org/license
  11001. *
  11002. * http://api.jqueryui.com/tabs/
  11003. */
  11004. var tabs = $.widget( "ui.tabs", {
  11005. version: "1.11.2",
  11006. delay: 300,
  11007. options: {
  11008. active: null,
  11009. collapsible: false,
  11010. event: "click",
  11011. heightStyle: "content",
  11012. hide: null,
  11013. show: null,
  11014. // callbacks
  11015. activate: null,
  11016. beforeActivate: null,
  11017. beforeLoad: null,
  11018. load: null
  11019. },
  11020. _isLocal: (function() {
  11021. var rhash = /#.*$/;
  11022. return function( anchor ) {
  11023. var anchorUrl, locationUrl;
  11024. // support: IE7
  11025. // IE7 doesn't normalize the href property when set via script (#9317)
  11026. anchor = anchor.cloneNode( false );
  11027. anchorUrl = anchor.href.replace( rhash, "" );
  11028. locationUrl = location.href.replace( rhash, "" );
  11029. // decoding may throw an error if the URL isn't UTF-8 (#9518)
  11030. try {
  11031. anchorUrl = decodeURIComponent( anchorUrl );
  11032. } catch ( error ) {}
  11033. try {
  11034. locationUrl = decodeURIComponent( locationUrl );
  11035. } catch ( error ) {}
  11036. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  11037. };
  11038. })(),
  11039. _create: function() {
  11040. var that = this,
  11041. options = this.options;
  11042. this.running = false;
  11043. this.element
  11044. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  11045. .toggleClass( "ui-tabs-collapsible", options.collapsible );
  11046. this._processTabs();
  11047. options.active = this._initialActive();
  11048. // Take disabling tabs via class attribute from HTML
  11049. // into account and update option properly.
  11050. if ( $.isArray( options.disabled ) ) {
  11051. options.disabled = $.unique( options.disabled.concat(
  11052. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  11053. return that.tabs.index( li );
  11054. })
  11055. ) ).sort();
  11056. }
  11057. // check for length avoids error when initializing empty list
  11058. if ( this.options.active !== false && this.anchors.length ) {
  11059. this.active = this._findActive( options.active );
  11060. } else {
  11061. this.active = $();
  11062. }
  11063. this._refresh();
  11064. if ( this.active.length ) {
  11065. this.load( options.active );
  11066. }
  11067. },
  11068. _initialActive: function() {
  11069. var active = this.options.active,
  11070. collapsible = this.options.collapsible,
  11071. locationHash = location.hash.substring( 1 );
  11072. if ( active === null ) {
  11073. // check the fragment identifier in the URL
  11074. if ( locationHash ) {
  11075. this.tabs.each(function( i, tab ) {
  11076. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  11077. active = i;
  11078. return false;
  11079. }
  11080. });
  11081. }
  11082. // check for a tab marked active via a class
  11083. if ( active === null ) {
  11084. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  11085. }
  11086. // no active tab, set to false
  11087. if ( active === null || active === -1 ) {
  11088. active = this.tabs.length ? 0 : false;
  11089. }
  11090. }
  11091. // handle numbers: negative, out of range
  11092. if ( active !== false ) {
  11093. active = this.tabs.index( this.tabs.eq( active ) );
  11094. if ( active === -1 ) {
  11095. active = collapsible ? false : 0;
  11096. }
  11097. }
  11098. // don't allow collapsible: false and active: false
  11099. if ( !collapsible && active === false && this.anchors.length ) {
  11100. active = 0;
  11101. }
  11102. return active;
  11103. },
  11104. _getCreateEventData: function() {
  11105. return {
  11106. tab: this.active,
  11107. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  11108. };
  11109. },
  11110. _tabKeydown: function( event ) {
  11111. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  11112. selectedIndex = this.tabs.index( focusedTab ),
  11113. goingForward = true;
  11114. if ( this._handlePageNav( event ) ) {
  11115. return;
  11116. }
  11117. switch ( event.keyCode ) {
  11118. case $.ui.keyCode.RIGHT:
  11119. case $.ui.keyCode.DOWN:
  11120. selectedIndex++;
  11121. break;
  11122. case $.ui.keyCode.UP:
  11123. case $.ui.keyCode.LEFT:
  11124. goingForward = false;
  11125. selectedIndex--;
  11126. break;
  11127. case $.ui.keyCode.END:
  11128. selectedIndex = this.anchors.length - 1;
  11129. break;
  11130. case $.ui.keyCode.HOME:
  11131. selectedIndex = 0;
  11132. break;
  11133. case $.ui.keyCode.SPACE:
  11134. // Activate only, no collapsing
  11135. event.preventDefault();
  11136. clearTimeout( this.activating );
  11137. this._activate( selectedIndex );
  11138. return;
  11139. case $.ui.keyCode.ENTER:
  11140. // Toggle (cancel delayed activation, allow collapsing)
  11141. event.preventDefault();
  11142. clearTimeout( this.activating );
  11143. // Determine if we should collapse or activate
  11144. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  11145. return;
  11146. default:
  11147. return;
  11148. }
  11149. // Focus the appropriate tab, based on which key was pressed
  11150. event.preventDefault();
  11151. clearTimeout( this.activating );
  11152. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  11153. // Navigating with control key will prevent automatic activation
  11154. if ( !event.ctrlKey ) {
  11155. // Update aria-selected immediately so that AT think the tab is already selected.
  11156. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  11157. // but the tab will already be activated by the time the announcement finishes.
  11158. focusedTab.attr( "aria-selected", "false" );
  11159. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  11160. this.activating = this._delay(function() {
  11161. this.option( "active", selectedIndex );
  11162. }, this.delay );
  11163. }
  11164. },
  11165. _panelKeydown: function( event ) {
  11166. if ( this._handlePageNav( event ) ) {
  11167. return;
  11168. }
  11169. // Ctrl+up moves focus to the current tab
  11170. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  11171. event.preventDefault();
  11172. this.active.focus();
  11173. }
  11174. },
  11175. // Alt+page up/down moves focus to the previous/next tab (and activates)
  11176. _handlePageNav: function( event ) {
  11177. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  11178. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  11179. return true;
  11180. }
  11181. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  11182. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  11183. return true;
  11184. }
  11185. },
  11186. _findNextTab: function( index, goingForward ) {
  11187. var lastTabIndex = this.tabs.length - 1;
  11188. function constrain() {
  11189. if ( index > lastTabIndex ) {
  11190. index = 0;
  11191. }
  11192. if ( index < 0 ) {
  11193. index = lastTabIndex;
  11194. }
  11195. return index;
  11196. }
  11197. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  11198. index = goingForward ? index + 1 : index - 1;
  11199. }
  11200. return index;
  11201. },
  11202. _focusNextTab: function( index, goingForward ) {
  11203. index = this._findNextTab( index, goingForward );
  11204. this.tabs.eq( index ).focus();
  11205. return index;
  11206. },
  11207. _setOption: function( key, value ) {
  11208. if ( key === "active" ) {
  11209. // _activate() will handle invalid values and update this.options
  11210. this._activate( value );
  11211. return;
  11212. }
  11213. if ( key === "disabled" ) {
  11214. // don't use the widget factory's disabled handling
  11215. this._setupDisabled( value );
  11216. return;
  11217. }
  11218. this._super( key, value);
  11219. if ( key === "collapsible" ) {
  11220. this.element.toggleClass( "ui-tabs-collapsible", value );
  11221. // Setting collapsible: false while collapsed; open first panel
  11222. if ( !value && this.options.active === false ) {
  11223. this._activate( 0 );
  11224. }
  11225. }
  11226. if ( key === "event" ) {
  11227. this._setupEvents( value );
  11228. }
  11229. if ( key === "heightStyle" ) {
  11230. this._setupHeightStyle( value );
  11231. }
  11232. },
  11233. _sanitizeSelector: function( hash ) {
  11234. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  11235. },
  11236. refresh: function() {
  11237. var options = this.options,
  11238. lis = this.tablist.children( ":has(a[href])" );
  11239. // get disabled tabs from class attribute from HTML
  11240. // this will get converted to a boolean if needed in _refresh()
  11241. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  11242. return lis.index( tab );
  11243. });
  11244. this._processTabs();
  11245. // was collapsed or no tabs
  11246. if ( options.active === false || !this.anchors.length ) {
  11247. options.active = false;
  11248. this.active = $();
  11249. // was active, but active tab is gone
  11250. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  11251. // all remaining tabs are disabled
  11252. if ( this.tabs.length === options.disabled.length ) {
  11253. options.active = false;
  11254. this.active = $();
  11255. // activate previous tab
  11256. } else {
  11257. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  11258. }
  11259. // was active, active tab still exists
  11260. } else {
  11261. // make sure active index is correct
  11262. options.active = this.tabs.index( this.active );
  11263. }
  11264. this._refresh();
  11265. },
  11266. _refresh: function() {
  11267. this._setupDisabled( this.options.disabled );
  11268. this._setupEvents( this.options.event );
  11269. this._setupHeightStyle( this.options.heightStyle );
  11270. this.tabs.not( this.active ).attr({
  11271. "aria-selected": "false",
  11272. "aria-expanded": "false",
  11273. tabIndex: -1
  11274. });
  11275. this.panels.not( this._getPanelForTab( this.active ) )
  11276. .hide()
  11277. .attr({
  11278. "aria-hidden": "true"
  11279. });
  11280. // Make sure one tab is in the tab order
  11281. if ( !this.active.length ) {
  11282. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  11283. } else {
  11284. this.active
  11285. .addClass( "ui-tabs-active ui-state-active" )
  11286. .attr({
  11287. "aria-selected": "true",
  11288. "aria-expanded": "true",
  11289. tabIndex: 0
  11290. });
  11291. this._getPanelForTab( this.active )
  11292. .show()
  11293. .attr({
  11294. "aria-hidden": "false"
  11295. });
  11296. }
  11297. },
  11298. _processTabs: function() {
  11299. var that = this,
  11300. prevTabs = this.tabs,
  11301. prevAnchors = this.anchors,
  11302. prevPanels = this.panels;
  11303. this.tablist = this._getList()
  11304. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  11305. .attr( "role", "tablist" )
  11306. // Prevent users from focusing disabled tabs via click
  11307. .delegate( "> li", "mousedown" + this.eventNamespace, function( event ) {
  11308. if ( $( this ).is( ".ui-state-disabled" ) ) {
  11309. event.preventDefault();
  11310. }
  11311. })
  11312. // support: IE <9
  11313. // Preventing the default action in mousedown doesn't prevent IE
  11314. // from focusing the element, so if the anchor gets focused, blur.
  11315. // We don't have to worry about focusing the previously focused
  11316. // element since clicking on a non-focusable element should focus
  11317. // the body anyway.
  11318. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  11319. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  11320. this.blur();
  11321. }
  11322. });
  11323. this.tabs = this.tablist.find( "> li:has(a[href])" )
  11324. .addClass( "ui-state-default ui-corner-top" )
  11325. .attr({
  11326. role: "tab",
  11327. tabIndex: -1
  11328. });
  11329. this.anchors = this.tabs.map(function() {
  11330. return $( "a", this )[ 0 ];
  11331. })
  11332. .addClass( "ui-tabs-anchor" )
  11333. .attr({
  11334. role: "presentation",
  11335. tabIndex: -1
  11336. });
  11337. this.panels = $();
  11338. this.anchors.each(function( i, anchor ) {
  11339. var selector, panel, panelId,
  11340. anchorId = $( anchor ).uniqueId().attr( "id" ),
  11341. tab = $( anchor ).closest( "li" ),
  11342. originalAriaControls = tab.attr( "aria-controls" );
  11343. // inline tab
  11344. if ( that._isLocal( anchor ) ) {
  11345. selector = anchor.hash;
  11346. panelId = selector.substring( 1 );
  11347. panel = that.element.find( that._sanitizeSelector( selector ) );
  11348. // remote tab
  11349. } else {
  11350. // If the tab doesn't already have aria-controls,
  11351. // generate an id by using a throw-away element
  11352. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  11353. selector = "#" + panelId;
  11354. panel = that.element.find( selector );
  11355. if ( !panel.length ) {
  11356. panel = that._createPanel( panelId );
  11357. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  11358. }
  11359. panel.attr( "aria-live", "polite" );
  11360. }
  11361. if ( panel.length) {
  11362. that.panels = that.panels.add( panel );
  11363. }
  11364. if ( originalAriaControls ) {
  11365. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  11366. }
  11367. tab.attr({
  11368. "aria-controls": panelId,
  11369. "aria-labelledby": anchorId
  11370. });
  11371. panel.attr( "aria-labelledby", anchorId );
  11372. });
  11373. this.panels
  11374. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  11375. .attr( "role", "tabpanel" );
  11376. // Avoid memory leaks (#10056)
  11377. if ( prevTabs ) {
  11378. this._off( prevTabs.not( this.tabs ) );
  11379. this._off( prevAnchors.not( this.anchors ) );
  11380. this._off( prevPanels.not( this.panels ) );
  11381. }
  11382. },
  11383. // allow overriding how to find the list for rare usage scenarios (#7715)
  11384. _getList: function() {
  11385. return this.tablist || this.element.find( "ol,ul" ).eq( 0 );
  11386. },
  11387. _createPanel: function( id ) {
  11388. return $( "<div>" )
  11389. .attr( "id", id )
  11390. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  11391. .data( "ui-tabs-destroy", true );
  11392. },
  11393. _setupDisabled: function( disabled ) {
  11394. if ( $.isArray( disabled ) ) {
  11395. if ( !disabled.length ) {
  11396. disabled = false;
  11397. } else if ( disabled.length === this.anchors.length ) {
  11398. disabled = true;
  11399. }
  11400. }
  11401. // disable tabs
  11402. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  11403. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  11404. $( li )
  11405. .addClass( "ui-state-disabled" )
  11406. .attr( "aria-disabled", "true" );
  11407. } else {
  11408. $( li )
  11409. .removeClass( "ui-state-disabled" )
  11410. .removeAttr( "aria-disabled" );
  11411. }
  11412. }
  11413. this.options.disabled = disabled;
  11414. },
  11415. _setupEvents: function( event ) {
  11416. var events = {};
  11417. if ( event ) {
  11418. $.each( event.split(" "), function( index, eventName ) {
  11419. events[ eventName ] = "_eventHandler";
  11420. });
  11421. }
  11422. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  11423. // Always prevent the default action, even when disabled
  11424. this._on( true, this.anchors, {
  11425. click: function( event ) {
  11426. event.preventDefault();
  11427. }
  11428. });
  11429. this._on( this.anchors, events );
  11430. this._on( this.tabs, { keydown: "_tabKeydown" } );
  11431. this._on( this.panels, { keydown: "_panelKeydown" } );
  11432. this._focusable( this.tabs );
  11433. this._hoverable( this.tabs );
  11434. },
  11435. _setupHeightStyle: function( heightStyle ) {
  11436. var maxHeight,
  11437. parent = this.element.parent();
  11438. if ( heightStyle === "fill" ) {
  11439. maxHeight = parent.height();
  11440. maxHeight -= this.element.outerHeight() - this.element.height();
  11441. this.element.siblings( ":visible" ).each(function() {
  11442. var elem = $( this ),
  11443. position = elem.css( "position" );
  11444. if ( position === "absolute" || position === "fixed" ) {
  11445. return;
  11446. }
  11447. maxHeight -= elem.outerHeight( true );
  11448. });
  11449. this.element.children().not( this.panels ).each(function() {
  11450. maxHeight -= $( this ).outerHeight( true );
  11451. });
  11452. this.panels.each(function() {
  11453. $( this ).height( Math.max( 0, maxHeight -
  11454. $( this ).innerHeight() + $( this ).height() ) );
  11455. })
  11456. .css( "overflow", "auto" );
  11457. } else if ( heightStyle === "auto" ) {
  11458. maxHeight = 0;
  11459. this.panels.each(function() {
  11460. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  11461. }).height( maxHeight );
  11462. }
  11463. },
  11464. _eventHandler: function( event ) {
  11465. var options = this.options,
  11466. active = this.active,
  11467. anchor = $( event.currentTarget ),
  11468. tab = anchor.closest( "li" ),
  11469. clickedIsActive = tab[ 0 ] === active[ 0 ],
  11470. collapsing = clickedIsActive && options.collapsible,
  11471. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  11472. toHide = !active.length ? $() : this._getPanelForTab( active ),
  11473. eventData = {
  11474. oldTab: active,
  11475. oldPanel: toHide,
  11476. newTab: collapsing ? $() : tab,
  11477. newPanel: toShow
  11478. };
  11479. event.preventDefault();
  11480. if ( tab.hasClass( "ui-state-disabled" ) ||
  11481. // tab is already loading
  11482. tab.hasClass( "ui-tabs-loading" ) ||
  11483. // can't switch durning an animation
  11484. this.running ||
  11485. // click on active header, but not collapsible
  11486. ( clickedIsActive && !options.collapsible ) ||
  11487. // allow canceling activation
  11488. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  11489. return;
  11490. }
  11491. options.active = collapsing ? false : this.tabs.index( tab );
  11492. this.active = clickedIsActive ? $() : tab;
  11493. if ( this.xhr ) {
  11494. this.xhr.abort();
  11495. }
  11496. if ( !toHide.length && !toShow.length ) {
  11497. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  11498. }
  11499. if ( toShow.length ) {
  11500. this.load( this.tabs.index( tab ), event );
  11501. }
  11502. this._toggle( event, eventData );
  11503. },
  11504. // handles show/hide for selecting tabs
  11505. _toggle: function( event, eventData ) {
  11506. var that = this,
  11507. toShow = eventData.newPanel,
  11508. toHide = eventData.oldPanel;
  11509. this.running = true;
  11510. function complete() {
  11511. that.running = false;
  11512. that._trigger( "activate", event, eventData );
  11513. }
  11514. function show() {
  11515. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  11516. if ( toShow.length && that.options.show ) {
  11517. that._show( toShow, that.options.show, complete );
  11518. } else {
  11519. toShow.show();
  11520. complete();
  11521. }
  11522. }
  11523. // start out by hiding, then showing, then completing
  11524. if ( toHide.length && this.options.hide ) {
  11525. this._hide( toHide, this.options.hide, function() {
  11526. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  11527. show();
  11528. });
  11529. } else {
  11530. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  11531. toHide.hide();
  11532. show();
  11533. }
  11534. toHide.attr( "aria-hidden", "true" );
  11535. eventData.oldTab.attr({
  11536. "aria-selected": "false",
  11537. "aria-expanded": "false"
  11538. });
  11539. // If we're switching tabs, remove the old tab from the tab order.
  11540. // If we're opening from collapsed state, remove the previous tab from the tab order.
  11541. // If we're collapsing, then keep the collapsing tab in the tab order.
  11542. if ( toShow.length && toHide.length ) {
  11543. eventData.oldTab.attr( "tabIndex", -1 );
  11544. } else if ( toShow.length ) {
  11545. this.tabs.filter(function() {
  11546. return $( this ).attr( "tabIndex" ) === 0;
  11547. })
  11548. .attr( "tabIndex", -1 );
  11549. }
  11550. toShow.attr( "aria-hidden", "false" );
  11551. eventData.newTab.attr({
  11552. "aria-selected": "true",
  11553. "aria-expanded": "true",
  11554. tabIndex: 0
  11555. });
  11556. },
  11557. _activate: function( index ) {
  11558. var anchor,
  11559. active = this._findActive( index );
  11560. // trying to activate the already active panel
  11561. if ( active[ 0 ] === this.active[ 0 ] ) {
  11562. return;
  11563. }
  11564. // trying to collapse, simulate a click on the current active header
  11565. if ( !active.length ) {
  11566. active = this.active;
  11567. }
  11568. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  11569. this._eventHandler({
  11570. target: anchor,
  11571. currentTarget: anchor,
  11572. preventDefault: $.noop
  11573. });
  11574. },
  11575. _findActive: function( index ) {
  11576. return index === false ? $() : this.tabs.eq( index );
  11577. },
  11578. _getIndex: function( index ) {
  11579. // meta-function to give users option to provide a href string instead of a numerical index.
  11580. if ( typeof index === "string" ) {
  11581. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  11582. }
  11583. return index;
  11584. },
  11585. _destroy: function() {
  11586. if ( this.xhr ) {
  11587. this.xhr.abort();
  11588. }
  11589. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  11590. this.tablist
  11591. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  11592. .removeAttr( "role" );
  11593. this.anchors
  11594. .removeClass( "ui-tabs-anchor" )
  11595. .removeAttr( "role" )
  11596. .removeAttr( "tabIndex" )
  11597. .removeUniqueId();
  11598. this.tablist.unbind( this.eventNamespace );
  11599. this.tabs.add( this.panels ).each(function() {
  11600. if ( $.data( this, "ui-tabs-destroy" ) ) {
  11601. $( this ).remove();
  11602. } else {
  11603. $( this )
  11604. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  11605. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  11606. .removeAttr( "tabIndex" )
  11607. .removeAttr( "aria-live" )
  11608. .removeAttr( "aria-busy" )
  11609. .removeAttr( "aria-selected" )
  11610. .removeAttr( "aria-labelledby" )
  11611. .removeAttr( "aria-hidden" )
  11612. .removeAttr( "aria-expanded" )
  11613. .removeAttr( "role" );
  11614. }
  11615. });
  11616. this.tabs.each(function() {
  11617. var li = $( this ),
  11618. prev = li.data( "ui-tabs-aria-controls" );
  11619. if ( prev ) {
  11620. li
  11621. .attr( "aria-controls", prev )
  11622. .removeData( "ui-tabs-aria-controls" );
  11623. } else {
  11624. li.removeAttr( "aria-controls" );
  11625. }
  11626. });
  11627. this.panels.show();
  11628. if ( this.options.heightStyle !== "content" ) {
  11629. this.panels.css( "height", "" );
  11630. }
  11631. },
  11632. enable: function( index ) {
  11633. var disabled = this.options.disabled;
  11634. if ( disabled === false ) {
  11635. return;
  11636. }
  11637. if ( index === undefined ) {
  11638. disabled = false;
  11639. } else {
  11640. index = this._getIndex( index );
  11641. if ( $.isArray( disabled ) ) {
  11642. disabled = $.map( disabled, function( num ) {
  11643. return num !== index ? num : null;
  11644. });
  11645. } else {
  11646. disabled = $.map( this.tabs, function( li, num ) {
  11647. return num !== index ? num : null;
  11648. });
  11649. }
  11650. }
  11651. this._setupDisabled( disabled );
  11652. },
  11653. disable: function( index ) {
  11654. var disabled = this.options.disabled;
  11655. if ( disabled === true ) {
  11656. return;
  11657. }
  11658. if ( index === undefined ) {
  11659. disabled = true;
  11660. } else {
  11661. index = this._getIndex( index );
  11662. if ( $.inArray( index, disabled ) !== -1 ) {
  11663. return;
  11664. }
  11665. if ( $.isArray( disabled ) ) {
  11666. disabled = $.merge( [ index ], disabled ).sort();
  11667. } else {
  11668. disabled = [ index ];
  11669. }
  11670. }
  11671. this._setupDisabled( disabled );
  11672. },
  11673. load: function( index, event ) {
  11674. index = this._getIndex( index );
  11675. var that = this,
  11676. tab = this.tabs.eq( index ),
  11677. anchor = tab.find( ".ui-tabs-anchor" ),
  11678. panel = this._getPanelForTab( tab ),
  11679. eventData = {
  11680. tab: tab,
  11681. panel: panel
  11682. };
  11683. // not remote
  11684. if ( this._isLocal( anchor[ 0 ] ) ) {
  11685. return;
  11686. }
  11687. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  11688. // support: jQuery <1.8
  11689. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  11690. // but as of 1.8, $.ajax() always returns a jqXHR object.
  11691. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  11692. tab.addClass( "ui-tabs-loading" );
  11693. panel.attr( "aria-busy", "true" );
  11694. this.xhr
  11695. .success(function( response ) {
  11696. // support: jQuery <1.8
  11697. // http://bugs.jquery.com/ticket/11778
  11698. setTimeout(function() {
  11699. panel.html( response );
  11700. that._trigger( "load", event, eventData );
  11701. }, 1 );
  11702. })
  11703. .complete(function( jqXHR, status ) {
  11704. // support: jQuery <1.8
  11705. // http://bugs.jquery.com/ticket/11778
  11706. setTimeout(function() {
  11707. if ( status === "abort" ) {
  11708. that.panels.stop( false, true );
  11709. }
  11710. tab.removeClass( "ui-tabs-loading" );
  11711. panel.removeAttr( "aria-busy" );
  11712. if ( jqXHR === that.xhr ) {
  11713. delete that.xhr;
  11714. }
  11715. }, 1 );
  11716. });
  11717. }
  11718. },
  11719. _ajaxSettings: function( anchor, event, eventData ) {
  11720. var that = this;
  11721. return {
  11722. url: anchor.attr( "href" ),
  11723. beforeSend: function( jqXHR, settings ) {
  11724. return that._trigger( "beforeLoad", event,
  11725. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  11726. }
  11727. };
  11728. },
  11729. _getPanelForTab: function( tab ) {
  11730. var id = $( tab ).attr( "aria-controls" );
  11731. return this.element.find( this._sanitizeSelector( "#" + id ) );
  11732. }
  11733. });
  11734. /*!
  11735. * jQuery UI Tooltip 1.11.2
  11736. * http://jqueryui.com
  11737. *
  11738. * Copyright 2014 jQuery Foundation and other contributors
  11739. * Released under the MIT license.
  11740. * http://jquery.org/license
  11741. *
  11742. * http://api.jqueryui.com/tooltip/
  11743. */
  11744. var tooltip = $.widget( "ui.tooltip", {
  11745. version: "1.11.2",
  11746. options: {
  11747. content: function() {
  11748. // support: IE<9, Opera in jQuery <1.7
  11749. // .text() can't accept undefined, so coerce to a string
  11750. var title = $( this ).attr( "title" ) || "";
  11751. // Escape title, since we're going from an attribute to raw HTML
  11752. return $( "<a>" ).text( title ).html();
  11753. },
  11754. hide: true,
  11755. // Disabled elements have inconsistent behavior across browsers (#8661)
  11756. items: "[title]:not([disabled])",
  11757. position: {
  11758. my: "left top+15",
  11759. at: "left bottom",
  11760. collision: "flipfit flip"
  11761. },
  11762. show: true,
  11763. tooltipClass: null,
  11764. track: false,
  11765. // callbacks
  11766. close: null,
  11767. open: null
  11768. },
  11769. _addDescribedBy: function( elem, id ) {
  11770. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  11771. describedby.push( id );
  11772. elem
  11773. .data( "ui-tooltip-id", id )
  11774. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  11775. },
  11776. _removeDescribedBy: function( elem ) {
  11777. var id = elem.data( "ui-tooltip-id" ),
  11778. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  11779. index = $.inArray( id, describedby );
  11780. if ( index !== -1 ) {
  11781. describedby.splice( index, 1 );
  11782. }
  11783. elem.removeData( "ui-tooltip-id" );
  11784. describedby = $.trim( describedby.join( " " ) );
  11785. if ( describedby ) {
  11786. elem.attr( "aria-describedby", describedby );
  11787. } else {
  11788. elem.removeAttr( "aria-describedby" );
  11789. }
  11790. },
  11791. _create: function() {
  11792. this._on({
  11793. mouseover: "open",
  11794. focusin: "open"
  11795. });
  11796. // IDs of generated tooltips, needed for destroy
  11797. this.tooltips = {};
  11798. // IDs of parent tooltips where we removed the title attribute
  11799. this.parents = {};
  11800. if ( this.options.disabled ) {
  11801. this._disable();
  11802. }
  11803. // Append the aria-live region so tooltips announce correctly
  11804. this.liveRegion = $( "<div>" )
  11805. .attr({
  11806. role: "log",
  11807. "aria-live": "assertive",
  11808. "aria-relevant": "additions"
  11809. })
  11810. .addClass( "ui-helper-hidden-accessible" )
  11811. .appendTo( this.document[ 0 ].body );
  11812. },
  11813. _setOption: function( key, value ) {
  11814. var that = this;
  11815. if ( key === "disabled" ) {
  11816. this[ value ? "_disable" : "_enable" ]();
  11817. this.options[ key ] = value;
  11818. // disable element style changes
  11819. return;
  11820. }
  11821. this._super( key, value );
  11822. if ( key === "content" ) {
  11823. $.each( this.tooltips, function( id, tooltipData ) {
  11824. that._updateContent( tooltipData.element );
  11825. });
  11826. }
  11827. },
  11828. _disable: function() {
  11829. var that = this;
  11830. // close open tooltips
  11831. $.each( this.tooltips, function( id, tooltipData ) {
  11832. var event = $.Event( "blur" );
  11833. event.target = event.currentTarget = tooltipData.element[ 0 ];
  11834. that.close( event, true );
  11835. });
  11836. // remove title attributes to prevent native tooltips
  11837. this.element.find( this.options.items ).addBack().each(function() {
  11838. var element = $( this );
  11839. if ( element.is( "[title]" ) ) {
  11840. element
  11841. .data( "ui-tooltip-title", element.attr( "title" ) )
  11842. .removeAttr( "title" );
  11843. }
  11844. });
  11845. },
  11846. _enable: function() {
  11847. // restore title attributes
  11848. this.element.find( this.options.items ).addBack().each(function() {
  11849. var element = $( this );
  11850. if ( element.data( "ui-tooltip-title" ) ) {
  11851. element.attr( "title", element.data( "ui-tooltip-title" ) );
  11852. }
  11853. });
  11854. },
  11855. open: function( event ) {
  11856. var that = this,
  11857. target = $( event ? event.target : this.element )
  11858. // we need closest here due to mouseover bubbling,
  11859. // but always pointing at the same event target
  11860. .closest( this.options.items );
  11861. // No element to show a tooltip for or the tooltip is already open
  11862. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  11863. return;
  11864. }
  11865. if ( target.attr( "title" ) ) {
  11866. target.data( "ui-tooltip-title", target.attr( "title" ) );
  11867. }
  11868. target.data( "ui-tooltip-open", true );
  11869. // kill parent tooltips, custom or native, for hover
  11870. if ( event && event.type === "mouseover" ) {
  11871. target.parents().each(function() {
  11872. var parent = $( this ),
  11873. blurEvent;
  11874. if ( parent.data( "ui-tooltip-open" ) ) {
  11875. blurEvent = $.Event( "blur" );
  11876. blurEvent.target = blurEvent.currentTarget = this;
  11877. that.close( blurEvent, true );
  11878. }
  11879. if ( parent.attr( "title" ) ) {
  11880. parent.uniqueId();
  11881. that.parents[ this.id ] = {
  11882. element: this,
  11883. title: parent.attr( "title" )
  11884. };
  11885. parent.attr( "title", "" );
  11886. }
  11887. });
  11888. }
  11889. this._updateContent( target, event );
  11890. },
  11891. _updateContent: function( target, event ) {
  11892. var content,
  11893. contentOption = this.options.content,
  11894. that = this,
  11895. eventType = event ? event.type : null;
  11896. if ( typeof contentOption === "string" ) {
  11897. return this._open( event, target, contentOption );
  11898. }
  11899. content = contentOption.call( target[0], function( response ) {
  11900. // ignore async response if tooltip was closed already
  11901. if ( !target.data( "ui-tooltip-open" ) ) {
  11902. return;
  11903. }
  11904. // IE may instantly serve a cached response for ajax requests
  11905. // delay this call to _open so the other call to _open runs first
  11906. that._delay(function() {
  11907. // jQuery creates a special event for focusin when it doesn't
  11908. // exist natively. To improve performance, the native event
  11909. // object is reused and the type is changed. Therefore, we can't
  11910. // rely on the type being correct after the event finished
  11911. // bubbling, so we set it back to the previous value. (#8740)
  11912. if ( event ) {
  11913. event.type = eventType;
  11914. }
  11915. this._open( event, target, response );
  11916. });
  11917. });
  11918. if ( content ) {
  11919. this._open( event, target, content );
  11920. }
  11921. },
  11922. _open: function( event, target, content ) {
  11923. var tooltipData, tooltip, events, delayedShow, a11yContent,
  11924. positionOption = $.extend( {}, this.options.position );
  11925. if ( !content ) {
  11926. return;
  11927. }
  11928. // Content can be updated multiple times. If the tooltip already
  11929. // exists, then just update the content and bail.
  11930. tooltipData = this._find( target );
  11931. if ( tooltipData ) {
  11932. tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
  11933. return;
  11934. }
  11935. // if we have a title, clear it to prevent the native tooltip
  11936. // we have to check first to avoid defining a title if none exists
  11937. // (we don't want to cause an element to start matching [title])
  11938. //
  11939. // We use removeAttr only for key events, to allow IE to export the correct
  11940. // accessible attributes. For mouse events, set to empty string to avoid
  11941. // native tooltip showing up (happens only when removing inside mouseover).
  11942. if ( target.is( "[title]" ) ) {
  11943. if ( event && event.type === "mouseover" ) {
  11944. target.attr( "title", "" );
  11945. } else {
  11946. target.removeAttr( "title" );
  11947. }
  11948. }
  11949. tooltipData = this._tooltip( target );
  11950. tooltip = tooltipData.tooltip;
  11951. this._addDescribedBy( target, tooltip.attr( "id" ) );
  11952. tooltip.find( ".ui-tooltip-content" ).html( content );
  11953. // Support: Voiceover on OS X, JAWS on IE <= 9
  11954. // JAWS announces deletions even when aria-relevant="additions"
  11955. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  11956. this.liveRegion.children().hide();
  11957. if ( content.clone ) {
  11958. a11yContent = content.clone();
  11959. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  11960. } else {
  11961. a11yContent = content;
  11962. }
  11963. $( "<div>" ).html( a11yContent ).appendTo( this.liveRegion );
  11964. function position( event ) {
  11965. positionOption.of = event;
  11966. if ( tooltip.is( ":hidden" ) ) {
  11967. return;
  11968. }
  11969. tooltip.position( positionOption );
  11970. }
  11971. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  11972. this._on( this.document, {
  11973. mousemove: position
  11974. });
  11975. // trigger once to override element-relative positioning
  11976. position( event );
  11977. } else {
  11978. tooltip.position( $.extend({
  11979. of: target
  11980. }, this.options.position ) );
  11981. }
  11982. tooltip.hide();
  11983. this._show( tooltip, this.options.show );
  11984. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  11985. // as the tooltip is visible, position the tooltip using the most recent
  11986. // event.
  11987. if ( this.options.show && this.options.show.delay ) {
  11988. delayedShow = this.delayedShow = setInterval(function() {
  11989. if ( tooltip.is( ":visible" ) ) {
  11990. position( positionOption.of );
  11991. clearInterval( delayedShow );
  11992. }
  11993. }, $.fx.interval );
  11994. }
  11995. this._trigger( "open", event, { tooltip: tooltip } );
  11996. events = {
  11997. keyup: function( event ) {
  11998. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  11999. var fakeEvent = $.Event(event);
  12000. fakeEvent.currentTarget = target[0];
  12001. this.close( fakeEvent, true );
  12002. }
  12003. }
  12004. };
  12005. // Only bind remove handler for delegated targets. Non-delegated
  12006. // tooltips will handle this in destroy.
  12007. if ( target[ 0 ] !== this.element[ 0 ] ) {
  12008. events.remove = function() {
  12009. this._removeTooltip( tooltip );
  12010. };
  12011. }
  12012. if ( !event || event.type === "mouseover" ) {
  12013. events.mouseleave = "close";
  12014. }
  12015. if ( !event || event.type === "focusin" ) {
  12016. events.focusout = "close";
  12017. }
  12018. this._on( true, target, events );
  12019. },
  12020. close: function( event ) {
  12021. var tooltip,
  12022. that = this,
  12023. target = $( event ? event.currentTarget : this.element ),
  12024. tooltipData = this._find( target );
  12025. // The tooltip may already be closed
  12026. if ( !tooltipData ) {
  12027. return;
  12028. }
  12029. tooltip = tooltipData.tooltip;
  12030. // disabling closes the tooltip, so we need to track when we're closing
  12031. // to avoid an infinite loop in case the tooltip becomes disabled on close
  12032. if ( tooltipData.closing ) {
  12033. return;
  12034. }
  12035. // Clear the interval for delayed tracking tooltips
  12036. clearInterval( this.delayedShow );
  12037. // only set title if we had one before (see comment in _open())
  12038. // If the title attribute has changed since open(), don't restore
  12039. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  12040. target.attr( "title", target.data( "ui-tooltip-title" ) );
  12041. }
  12042. this._removeDescribedBy( target );
  12043. tooltipData.hiding = true;
  12044. tooltip.stop( true );
  12045. this._hide( tooltip, this.options.hide, function() {
  12046. that._removeTooltip( $( this ) );
  12047. });
  12048. target.removeData( "ui-tooltip-open" );
  12049. this._off( target, "mouseleave focusout keyup" );
  12050. // Remove 'remove' binding only on delegated targets
  12051. if ( target[ 0 ] !== this.element[ 0 ] ) {
  12052. this._off( target, "remove" );
  12053. }
  12054. this._off( this.document, "mousemove" );
  12055. if ( event && event.type === "mouseleave" ) {
  12056. $.each( this.parents, function( id, parent ) {
  12057. $( parent.element ).attr( "title", parent.title );
  12058. delete that.parents[ id ];
  12059. });
  12060. }
  12061. tooltipData.closing = true;
  12062. this._trigger( "close", event, { tooltip: tooltip } );
  12063. if ( !tooltipData.hiding ) {
  12064. tooltipData.closing = false;
  12065. }
  12066. },
  12067. _tooltip: function( element ) {
  12068. var tooltip = $( "<div>" )
  12069. .attr( "role", "tooltip" )
  12070. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  12071. ( this.options.tooltipClass || "" ) ),
  12072. id = tooltip.uniqueId().attr( "id" );
  12073. $( "<div>" )
  12074. .addClass( "ui-tooltip-content" )
  12075. .appendTo( tooltip );
  12076. tooltip.appendTo( this.document[0].body );
  12077. return this.tooltips[ id ] = {
  12078. element: element,
  12079. tooltip: tooltip
  12080. };
  12081. },
  12082. _find: function( target ) {
  12083. var id = target.data( "ui-tooltip-id" );
  12084. return id ? this.tooltips[ id ] : null;
  12085. },
  12086. _removeTooltip: function( tooltip ) {
  12087. tooltip.remove();
  12088. delete this.tooltips[ tooltip.attr( "id" ) ];
  12089. },
  12090. _destroy: function() {
  12091. var that = this;
  12092. // close open tooltips
  12093. $.each( this.tooltips, function( id, tooltipData ) {
  12094. // Delegate to close method to handle common cleanup
  12095. var event = $.Event( "blur" ),
  12096. element = tooltipData.element;
  12097. event.target = event.currentTarget = element[ 0 ];
  12098. that.close( event, true );
  12099. // Remove immediately; destroying an open tooltip doesn't use the
  12100. // hide animation
  12101. $( "#" + id ).remove();
  12102. // Restore the title
  12103. if ( element.data( "ui-tooltip-title" ) ) {
  12104. // If the title attribute has changed since open(), don't restore
  12105. if ( !element.attr( "title" ) ) {
  12106. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12107. }
  12108. element.removeData( "ui-tooltip-title" );
  12109. }
  12110. });
  12111. this.liveRegion.remove();
  12112. }
  12113. });
  12114. /*!
  12115. * jQuery UI Effects 1.11.2
  12116. * http://jqueryui.com
  12117. *
  12118. * Copyright 2014 jQuery Foundation and other contributors
  12119. * Released under the MIT license.
  12120. * http://jquery.org/license
  12121. *
  12122. * http://api.jqueryui.com/category/effects-core/
  12123. */
  12124. var dataSpace = "ui-effects-",
  12125. // Create a local jQuery because jQuery Color relies on it and the
  12126. // global may not exist with AMD and a custom build (#10199)
  12127. jQuery = $;
  12128. $.effects = {
  12129. effect: {}
  12130. };
  12131. /*!
  12132. * jQuery Color Animations v2.1.2
  12133. * https://github.com/jquery/jquery-color
  12134. *
  12135. * Copyright 2014 jQuery Foundation and other contributors
  12136. * Released under the MIT license.
  12137. * http://jquery.org/license
  12138. *
  12139. * Date: Wed Jan 16 08:47:09 2013 -0600
  12140. */
  12141. (function( jQuery, undefined ) {
  12142. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  12143. // plusequals test for += 100 -= 100
  12144. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  12145. // a set of RE's that can match strings and generate color tuples.
  12146. stringParsers = [ {
  12147. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  12148. parse: function( execResult ) {
  12149. return [
  12150. execResult[ 1 ],
  12151. execResult[ 2 ],
  12152. execResult[ 3 ],
  12153. execResult[ 4 ]
  12154. ];
  12155. }
  12156. }, {
  12157. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  12158. parse: function( execResult ) {
  12159. return [
  12160. execResult[ 1 ] * 2.55,
  12161. execResult[ 2 ] * 2.55,
  12162. execResult[ 3 ] * 2.55,
  12163. execResult[ 4 ]
  12164. ];
  12165. }
  12166. }, {
  12167. // this regex ignores A-F because it's compared against an already lowercased string
  12168. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  12169. parse: function( execResult ) {
  12170. return [
  12171. parseInt( execResult[ 1 ], 16 ),
  12172. parseInt( execResult[ 2 ], 16 ),
  12173. parseInt( execResult[ 3 ], 16 )
  12174. ];
  12175. }
  12176. }, {
  12177. // this regex ignores A-F because it's compared against an already lowercased string
  12178. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  12179. parse: function( execResult ) {
  12180. return [
  12181. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  12182. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  12183. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  12184. ];
  12185. }
  12186. }, {
  12187. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  12188. space: "hsla",
  12189. parse: function( execResult ) {
  12190. return [
  12191. execResult[ 1 ],
  12192. execResult[ 2 ] / 100,
  12193. execResult[ 3 ] / 100,
  12194. execResult[ 4 ]
  12195. ];
  12196. }
  12197. } ],
  12198. // jQuery.Color( )
  12199. color = jQuery.Color = function( color, green, blue, alpha ) {
  12200. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  12201. },
  12202. spaces = {
  12203. rgba: {
  12204. props: {
  12205. red: {
  12206. idx: 0,
  12207. type: "byte"
  12208. },
  12209. green: {
  12210. idx: 1,
  12211. type: "byte"
  12212. },
  12213. blue: {
  12214. idx: 2,
  12215. type: "byte"
  12216. }
  12217. }
  12218. },
  12219. hsla: {
  12220. props: {
  12221. hue: {
  12222. idx: 0,
  12223. type: "degrees"
  12224. },
  12225. saturation: {
  12226. idx: 1,
  12227. type: "percent"
  12228. },
  12229. lightness: {
  12230. idx: 2,
  12231. type: "percent"
  12232. }
  12233. }
  12234. }
  12235. },
  12236. propTypes = {
  12237. "byte": {
  12238. floor: true,
  12239. max: 255
  12240. },
  12241. "percent": {
  12242. max: 1
  12243. },
  12244. "degrees": {
  12245. mod: 360,
  12246. floor: true
  12247. }
  12248. },
  12249. support = color.support = {},
  12250. // element for support tests
  12251. supportElem = jQuery( "<p>" )[ 0 ],
  12252. // colors = jQuery.Color.names
  12253. colors,
  12254. // local aliases of functions called often
  12255. each = jQuery.each;
  12256. // determine rgba support immediately
  12257. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  12258. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  12259. // define cache name and alpha properties
  12260. // for rgba and hsla spaces
  12261. each( spaces, function( spaceName, space ) {
  12262. space.cache = "_" + spaceName;
  12263. space.props.alpha = {
  12264. idx: 3,
  12265. type: "percent",
  12266. def: 1
  12267. };
  12268. });
  12269. function clamp( value, prop, allowEmpty ) {
  12270. var type = propTypes[ prop.type ] || {};
  12271. if ( value == null ) {
  12272. return (allowEmpty || !prop.def) ? null : prop.def;
  12273. }
  12274. // ~~ is an short way of doing floor for positive numbers
  12275. value = type.floor ? ~~value : parseFloat( value );
  12276. // IE will pass in empty strings as value for alpha,
  12277. // which will hit this case
  12278. if ( isNaN( value ) ) {
  12279. return prop.def;
  12280. }
  12281. if ( type.mod ) {
  12282. // we add mod before modding to make sure that negatives values
  12283. // get converted properly: -10 -> 350
  12284. return (value + type.mod) % type.mod;
  12285. }
  12286. // for now all property types without mod have min and max
  12287. return 0 > value ? 0 : type.max < value ? type.max : value;
  12288. }
  12289. function stringParse( string ) {
  12290. var inst = color(),
  12291. rgba = inst._rgba = [];
  12292. string = string.toLowerCase();
  12293. each( stringParsers, function( i, parser ) {
  12294. var parsed,
  12295. match = parser.re.exec( string ),
  12296. values = match && parser.parse( match ),
  12297. spaceName = parser.space || "rgba";
  12298. if ( values ) {
  12299. parsed = inst[ spaceName ]( values );
  12300. // if this was an rgba parse the assignment might happen twice
  12301. // oh well....
  12302. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  12303. rgba = inst._rgba = parsed._rgba;
  12304. // exit each( stringParsers ) here because we matched
  12305. return false;
  12306. }
  12307. });
  12308. // Found a stringParser that handled it
  12309. if ( rgba.length ) {
  12310. // if this came from a parsed string, force "transparent" when alpha is 0
  12311. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  12312. if ( rgba.join() === "0,0,0,0" ) {
  12313. jQuery.extend( rgba, colors.transparent );
  12314. }
  12315. return inst;
  12316. }
  12317. // named colors
  12318. return colors[ string ];
  12319. }
  12320. color.fn = jQuery.extend( color.prototype, {
  12321. parse: function( red, green, blue, alpha ) {
  12322. if ( red === undefined ) {
  12323. this._rgba = [ null, null, null, null ];
  12324. return this;
  12325. }
  12326. if ( red.jquery || red.nodeType ) {
  12327. red = jQuery( red ).css( green );
  12328. green = undefined;
  12329. }
  12330. var inst = this,
  12331. type = jQuery.type( red ),
  12332. rgba = this._rgba = [];
  12333. // more than 1 argument specified - assume ( red, green, blue, alpha )
  12334. if ( green !== undefined ) {
  12335. red = [ red, green, blue, alpha ];
  12336. type = "array";
  12337. }
  12338. if ( type === "string" ) {
  12339. return this.parse( stringParse( red ) || colors._default );
  12340. }
  12341. if ( type === "array" ) {
  12342. each( spaces.rgba.props, function( key, prop ) {
  12343. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  12344. });
  12345. return this;
  12346. }
  12347. if ( type === "object" ) {
  12348. if ( red instanceof color ) {
  12349. each( spaces, function( spaceName, space ) {
  12350. if ( red[ space.cache ] ) {
  12351. inst[ space.cache ] = red[ space.cache ].slice();
  12352. }
  12353. });
  12354. } else {
  12355. each( spaces, function( spaceName, space ) {
  12356. var cache = space.cache;
  12357. each( space.props, function( key, prop ) {
  12358. // if the cache doesn't exist, and we know how to convert
  12359. if ( !inst[ cache ] && space.to ) {
  12360. // if the value was null, we don't need to copy it
  12361. // if the key was alpha, we don't need to copy it either
  12362. if ( key === "alpha" || red[ key ] == null ) {
  12363. return;
  12364. }
  12365. inst[ cache ] = space.to( inst._rgba );
  12366. }
  12367. // this is the only case where we allow nulls for ALL properties.
  12368. // call clamp with alwaysAllowEmpty
  12369. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  12370. });
  12371. // everything defined but alpha?
  12372. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  12373. // use the default of 1
  12374. inst[ cache ][ 3 ] = 1;
  12375. if ( space.from ) {
  12376. inst._rgba = space.from( inst[ cache ] );
  12377. }
  12378. }
  12379. });
  12380. }
  12381. return this;
  12382. }
  12383. },
  12384. is: function( compare ) {
  12385. var is = color( compare ),
  12386. same = true,
  12387. inst = this;
  12388. each( spaces, function( _, space ) {
  12389. var localCache,
  12390. isCache = is[ space.cache ];
  12391. if (isCache) {
  12392. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  12393. each( space.props, function( _, prop ) {
  12394. if ( isCache[ prop.idx ] != null ) {
  12395. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  12396. return same;
  12397. }
  12398. });
  12399. }
  12400. return same;
  12401. });
  12402. return same;
  12403. },
  12404. _space: function() {
  12405. var used = [],
  12406. inst = this;
  12407. each( spaces, function( spaceName, space ) {
  12408. if ( inst[ space.cache ] ) {
  12409. used.push( spaceName );
  12410. }
  12411. });
  12412. return used.pop();
  12413. },
  12414. transition: function( other, distance ) {
  12415. var end = color( other ),
  12416. spaceName = end._space(),
  12417. space = spaces[ spaceName ],
  12418. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  12419. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  12420. result = start.slice();
  12421. end = end[ space.cache ];
  12422. each( space.props, function( key, prop ) {
  12423. var index = prop.idx,
  12424. startValue = start[ index ],
  12425. endValue = end[ index ],
  12426. type = propTypes[ prop.type ] || {};
  12427. // if null, don't override start value
  12428. if ( endValue === null ) {
  12429. return;
  12430. }
  12431. // if null - use end
  12432. if ( startValue === null ) {
  12433. result[ index ] = endValue;
  12434. } else {
  12435. if ( type.mod ) {
  12436. if ( endValue - startValue > type.mod / 2 ) {
  12437. startValue += type.mod;
  12438. } else if ( startValue - endValue > type.mod / 2 ) {
  12439. startValue -= type.mod;
  12440. }
  12441. }
  12442. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  12443. }
  12444. });
  12445. return this[ spaceName ]( result );
  12446. },
  12447. blend: function( opaque ) {
  12448. // if we are already opaque - return ourself
  12449. if ( this._rgba[ 3 ] === 1 ) {
  12450. return this;
  12451. }
  12452. var rgb = this._rgba.slice(),
  12453. a = rgb.pop(),
  12454. blend = color( opaque )._rgba;
  12455. return color( jQuery.map( rgb, function( v, i ) {
  12456. return ( 1 - a ) * blend[ i ] + a * v;
  12457. }));
  12458. },
  12459. toRgbaString: function() {
  12460. var prefix = "rgba(",
  12461. rgba = jQuery.map( this._rgba, function( v, i ) {
  12462. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  12463. });
  12464. if ( rgba[ 3 ] === 1 ) {
  12465. rgba.pop();
  12466. prefix = "rgb(";
  12467. }
  12468. return prefix + rgba.join() + ")";
  12469. },
  12470. toHslaString: function() {
  12471. var prefix = "hsla(",
  12472. hsla = jQuery.map( this.hsla(), function( v, i ) {
  12473. if ( v == null ) {
  12474. v = i > 2 ? 1 : 0;
  12475. }
  12476. // catch 1 and 2
  12477. if ( i && i < 3 ) {
  12478. v = Math.round( v * 100 ) + "%";
  12479. }
  12480. return v;
  12481. });
  12482. if ( hsla[ 3 ] === 1 ) {
  12483. hsla.pop();
  12484. prefix = "hsl(";
  12485. }
  12486. return prefix + hsla.join() + ")";
  12487. },
  12488. toHexString: function( includeAlpha ) {
  12489. var rgba = this._rgba.slice(),
  12490. alpha = rgba.pop();
  12491. if ( includeAlpha ) {
  12492. rgba.push( ~~( alpha * 255 ) );
  12493. }
  12494. return "#" + jQuery.map( rgba, function( v ) {
  12495. // default to 0 when nulls exist
  12496. v = ( v || 0 ).toString( 16 );
  12497. return v.length === 1 ? "0" + v : v;
  12498. }).join("");
  12499. },
  12500. toString: function() {
  12501. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  12502. }
  12503. });
  12504. color.fn.parse.prototype = color.fn;
  12505. // hsla conversions adapted from:
  12506. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  12507. function hue2rgb( p, q, h ) {
  12508. h = ( h + 1 ) % 1;
  12509. if ( h * 6 < 1 ) {
  12510. return p + ( q - p ) * h * 6;
  12511. }
  12512. if ( h * 2 < 1) {
  12513. return q;
  12514. }
  12515. if ( h * 3 < 2 ) {
  12516. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  12517. }
  12518. return p;
  12519. }
  12520. spaces.hsla.to = function( rgba ) {
  12521. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  12522. return [ null, null, null, rgba[ 3 ] ];
  12523. }
  12524. var r = rgba[ 0 ] / 255,
  12525. g = rgba[ 1 ] / 255,
  12526. b = rgba[ 2 ] / 255,
  12527. a = rgba[ 3 ],
  12528. max = Math.max( r, g, b ),
  12529. min = Math.min( r, g, b ),
  12530. diff = max - min,
  12531. add = max + min,
  12532. l = add * 0.5,
  12533. h, s;
  12534. if ( min === max ) {
  12535. h = 0;
  12536. } else if ( r === max ) {
  12537. h = ( 60 * ( g - b ) / diff ) + 360;
  12538. } else if ( g === max ) {
  12539. h = ( 60 * ( b - r ) / diff ) + 120;
  12540. } else {
  12541. h = ( 60 * ( r - g ) / diff ) + 240;
  12542. }
  12543. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  12544. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  12545. if ( diff === 0 ) {
  12546. s = 0;
  12547. } else if ( l <= 0.5 ) {
  12548. s = diff / add;
  12549. } else {
  12550. s = diff / ( 2 - add );
  12551. }
  12552. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  12553. };
  12554. spaces.hsla.from = function( hsla ) {
  12555. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  12556. return [ null, null, null, hsla[ 3 ] ];
  12557. }
  12558. var h = hsla[ 0 ] / 360,
  12559. s = hsla[ 1 ],
  12560. l = hsla[ 2 ],
  12561. a = hsla[ 3 ],
  12562. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  12563. p = 2 * l - q;
  12564. return [
  12565. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  12566. Math.round( hue2rgb( p, q, h ) * 255 ),
  12567. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  12568. a
  12569. ];
  12570. };
  12571. each( spaces, function( spaceName, space ) {
  12572. var props = space.props,
  12573. cache = space.cache,
  12574. to = space.to,
  12575. from = space.from;
  12576. // makes rgba() and hsla()
  12577. color.fn[ spaceName ] = function( value ) {
  12578. // generate a cache for this space if it doesn't exist
  12579. if ( to && !this[ cache ] ) {
  12580. this[ cache ] = to( this._rgba );
  12581. }
  12582. if ( value === undefined ) {
  12583. return this[ cache ].slice();
  12584. }
  12585. var ret,
  12586. type = jQuery.type( value ),
  12587. arr = ( type === "array" || type === "object" ) ? value : arguments,
  12588. local = this[ cache ].slice();
  12589. each( props, function( key, prop ) {
  12590. var val = arr[ type === "object" ? key : prop.idx ];
  12591. if ( val == null ) {
  12592. val = local[ prop.idx ];
  12593. }
  12594. local[ prop.idx ] = clamp( val, prop );
  12595. });
  12596. if ( from ) {
  12597. ret = color( from( local ) );
  12598. ret[ cache ] = local;
  12599. return ret;
  12600. } else {
  12601. return color( local );
  12602. }
  12603. };
  12604. // makes red() green() blue() alpha() hue() saturation() lightness()
  12605. each( props, function( key, prop ) {
  12606. // alpha is included in more than one space
  12607. if ( color.fn[ key ] ) {
  12608. return;
  12609. }
  12610. color.fn[ key ] = function( value ) {
  12611. var vtype = jQuery.type( value ),
  12612. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  12613. local = this[ fn ](),
  12614. cur = local[ prop.idx ],
  12615. match;
  12616. if ( vtype === "undefined" ) {
  12617. return cur;
  12618. }
  12619. if ( vtype === "function" ) {
  12620. value = value.call( this, cur );
  12621. vtype = jQuery.type( value );
  12622. }
  12623. if ( value == null && prop.empty ) {
  12624. return this;
  12625. }
  12626. if ( vtype === "string" ) {
  12627. match = rplusequals.exec( value );
  12628. if ( match ) {
  12629. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  12630. }
  12631. }
  12632. local[ prop.idx ] = value;
  12633. return this[ fn ]( local );
  12634. };
  12635. });
  12636. });
  12637. // add cssHook and .fx.step function for each named hook.
  12638. // accept a space separated string of properties
  12639. color.hook = function( hook ) {
  12640. var hooks = hook.split( " " );
  12641. each( hooks, function( i, hook ) {
  12642. jQuery.cssHooks[ hook ] = {
  12643. set: function( elem, value ) {
  12644. var parsed, curElem,
  12645. backgroundColor = "";
  12646. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  12647. value = color( parsed || value );
  12648. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  12649. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  12650. while (
  12651. (backgroundColor === "" || backgroundColor === "transparent") &&
  12652. curElem && curElem.style
  12653. ) {
  12654. try {
  12655. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  12656. curElem = curElem.parentNode;
  12657. } catch ( e ) {
  12658. }
  12659. }
  12660. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  12661. backgroundColor :
  12662. "_default" );
  12663. }
  12664. value = value.toRgbaString();
  12665. }
  12666. try {
  12667. elem.style[ hook ] = value;
  12668. } catch ( e ) {
  12669. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  12670. }
  12671. }
  12672. };
  12673. jQuery.fx.step[ hook ] = function( fx ) {
  12674. if ( !fx.colorInit ) {
  12675. fx.start = color( fx.elem, hook );
  12676. fx.end = color( fx.end );
  12677. fx.colorInit = true;
  12678. }
  12679. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  12680. };
  12681. });
  12682. };
  12683. color.hook( stepHooks );
  12684. jQuery.cssHooks.borderColor = {
  12685. expand: function( value ) {
  12686. var expanded = {};
  12687. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  12688. expanded[ "border" + part + "Color" ] = value;
  12689. });
  12690. return expanded;
  12691. }
  12692. };
  12693. // Basic color names only.
  12694. // Usage of any of the other color names requires adding yourself or including
  12695. // jquery.color.svg-names.js.
  12696. colors = jQuery.Color.names = {
  12697. // 4.1. Basic color keywords
  12698. aqua: "#00ffff",
  12699. black: "#000000",
  12700. blue: "#0000ff",
  12701. fuchsia: "#ff00ff",
  12702. gray: "#808080",
  12703. green: "#008000",
  12704. lime: "#00ff00",
  12705. maroon: "#800000",
  12706. navy: "#000080",
  12707. olive: "#808000",
  12708. purple: "#800080",
  12709. red: "#ff0000",
  12710. silver: "#c0c0c0",
  12711. teal: "#008080",
  12712. white: "#ffffff",
  12713. yellow: "#ffff00",
  12714. // 4.2.3. "transparent" color keyword
  12715. transparent: [ null, null, null, 0 ],
  12716. _default: "#ffffff"
  12717. };
  12718. })( jQuery );
  12719. /******************************************************************************/
  12720. /****************************** CLASS ANIMATIONS ******************************/
  12721. /******************************************************************************/
  12722. (function() {
  12723. var classAnimationActions = [ "add", "remove", "toggle" ],
  12724. shorthandStyles = {
  12725. border: 1,
  12726. borderBottom: 1,
  12727. borderColor: 1,
  12728. borderLeft: 1,
  12729. borderRight: 1,
  12730. borderTop: 1,
  12731. borderWidth: 1,
  12732. margin: 1,
  12733. padding: 1
  12734. };
  12735. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  12736. $.fx.step[ prop ] = function( fx ) {
  12737. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  12738. jQuery.style( fx.elem, prop, fx.end );
  12739. fx.setAttr = true;
  12740. }
  12741. };
  12742. });
  12743. function getElementStyles( elem ) {
  12744. var key, len,
  12745. style = elem.ownerDocument.defaultView ?
  12746. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  12747. elem.currentStyle,
  12748. styles = {};
  12749. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  12750. len = style.length;
  12751. while ( len-- ) {
  12752. key = style[ len ];
  12753. if ( typeof style[ key ] === "string" ) {
  12754. styles[ $.camelCase( key ) ] = style[ key ];
  12755. }
  12756. }
  12757. // support: Opera, IE <9
  12758. } else {
  12759. for ( key in style ) {
  12760. if ( typeof style[ key ] === "string" ) {
  12761. styles[ key ] = style[ key ];
  12762. }
  12763. }
  12764. }
  12765. return styles;
  12766. }
  12767. function styleDifference( oldStyle, newStyle ) {
  12768. var diff = {},
  12769. name, value;
  12770. for ( name in newStyle ) {
  12771. value = newStyle[ name ];
  12772. if ( oldStyle[ name ] !== value ) {
  12773. if ( !shorthandStyles[ name ] ) {
  12774. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  12775. diff[ name ] = value;
  12776. }
  12777. }
  12778. }
  12779. }
  12780. return diff;
  12781. }
  12782. // support: jQuery <1.8
  12783. if ( !$.fn.addBack ) {
  12784. $.fn.addBack = function( selector ) {
  12785. return this.add( selector == null ?
  12786. this.prevObject : this.prevObject.filter( selector )
  12787. );
  12788. };
  12789. }
  12790. $.effects.animateClass = function( value, duration, easing, callback ) {
  12791. var o = $.speed( duration, easing, callback );
  12792. return this.queue( function() {
  12793. var animated = $( this ),
  12794. baseClass = animated.attr( "class" ) || "",
  12795. applyClassChange,
  12796. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  12797. // map the animated objects to store the original styles.
  12798. allAnimations = allAnimations.map(function() {
  12799. var el = $( this );
  12800. return {
  12801. el: el,
  12802. start: getElementStyles( this )
  12803. };
  12804. });
  12805. // apply class change
  12806. applyClassChange = function() {
  12807. $.each( classAnimationActions, function(i, action) {
  12808. if ( value[ action ] ) {
  12809. animated[ action + "Class" ]( value[ action ] );
  12810. }
  12811. });
  12812. };
  12813. applyClassChange();
  12814. // map all animated objects again - calculate new styles and diff
  12815. allAnimations = allAnimations.map(function() {
  12816. this.end = getElementStyles( this.el[ 0 ] );
  12817. this.diff = styleDifference( this.start, this.end );
  12818. return this;
  12819. });
  12820. // apply original class
  12821. animated.attr( "class", baseClass );
  12822. // map all animated objects again - this time collecting a promise
  12823. allAnimations = allAnimations.map(function() {
  12824. var styleInfo = this,
  12825. dfd = $.Deferred(),
  12826. opts = $.extend({}, o, {
  12827. queue: false,
  12828. complete: function() {
  12829. dfd.resolve( styleInfo );
  12830. }
  12831. });
  12832. this.el.animate( this.diff, opts );
  12833. return dfd.promise();
  12834. });
  12835. // once all animations have completed:
  12836. $.when.apply( $, allAnimations.get() ).done(function() {
  12837. // set the final class
  12838. applyClassChange();
  12839. // for each animated element,
  12840. // clear all css properties that were animated
  12841. $.each( arguments, function() {
  12842. var el = this.el;
  12843. $.each( this.diff, function(key) {
  12844. el.css( key, "" );
  12845. });
  12846. });
  12847. // this is guarnteed to be there if you use jQuery.speed()
  12848. // it also handles dequeuing the next anim...
  12849. o.complete.call( animated[ 0 ] );
  12850. });
  12851. });
  12852. };
  12853. $.fn.extend({
  12854. addClass: (function( orig ) {
  12855. return function( classNames, speed, easing, callback ) {
  12856. return speed ?
  12857. $.effects.animateClass.call( this,
  12858. { add: classNames }, speed, easing, callback ) :
  12859. orig.apply( this, arguments );
  12860. };
  12861. })( $.fn.addClass ),
  12862. removeClass: (function( orig ) {
  12863. return function( classNames, speed, easing, callback ) {
  12864. return arguments.length > 1 ?
  12865. $.effects.animateClass.call( this,
  12866. { remove: classNames }, speed, easing, callback ) :
  12867. orig.apply( this, arguments );
  12868. };
  12869. })( $.fn.removeClass ),
  12870. toggleClass: (function( orig ) {
  12871. return function( classNames, force, speed, easing, callback ) {
  12872. if ( typeof force === "boolean" || force === undefined ) {
  12873. if ( !speed ) {
  12874. // without speed parameter
  12875. return orig.apply( this, arguments );
  12876. } else {
  12877. return $.effects.animateClass.call( this,
  12878. (force ? { add: classNames } : { remove: classNames }),
  12879. speed, easing, callback );
  12880. }
  12881. } else {
  12882. // without force parameter
  12883. return $.effects.animateClass.call( this,
  12884. { toggle: classNames }, force, speed, easing );
  12885. }
  12886. };
  12887. })( $.fn.toggleClass ),
  12888. switchClass: function( remove, add, speed, easing, callback) {
  12889. return $.effects.animateClass.call( this, {
  12890. add: add,
  12891. remove: remove
  12892. }, speed, easing, callback );
  12893. }
  12894. });
  12895. })();
  12896. /******************************************************************************/
  12897. /*********************************** EFFECTS **********************************/
  12898. /******************************************************************************/
  12899. (function() {
  12900. $.extend( $.effects, {
  12901. version: "1.11.2",
  12902. // Saves a set of properties in a data storage
  12903. save: function( element, set ) {
  12904. for ( var i = 0; i < set.length; i++ ) {
  12905. if ( set[ i ] !== null ) {
  12906. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  12907. }
  12908. }
  12909. },
  12910. // Restores a set of previously saved properties from a data storage
  12911. restore: function( element, set ) {
  12912. var val, i;
  12913. for ( i = 0; i < set.length; i++ ) {
  12914. if ( set[ i ] !== null ) {
  12915. val = element.data( dataSpace + set[ i ] );
  12916. // support: jQuery 1.6.2
  12917. // http://bugs.jquery.com/ticket/9917
  12918. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  12919. // We can't differentiate between "" and 0 here, so we just assume
  12920. // empty string since it's likely to be a more common value...
  12921. if ( val === undefined ) {
  12922. val = "";
  12923. }
  12924. element.css( set[ i ], val );
  12925. }
  12926. }
  12927. },
  12928. setMode: function( el, mode ) {
  12929. if (mode === "toggle") {
  12930. mode = el.is( ":hidden" ) ? "show" : "hide";
  12931. }
  12932. return mode;
  12933. },
  12934. // Translates a [top,left] array into a baseline value
  12935. // this should be a little more flexible in the future to handle a string & hash
  12936. getBaseline: function( origin, original ) {
  12937. var y, x;
  12938. switch ( origin[ 0 ] ) {
  12939. case "top": y = 0; break;
  12940. case "middle": y = 0.5; break;
  12941. case "bottom": y = 1; break;
  12942. default: y = origin[ 0 ] / original.height;
  12943. }
  12944. switch ( origin[ 1 ] ) {
  12945. case "left": x = 0; break;
  12946. case "center": x = 0.5; break;
  12947. case "right": x = 1; break;
  12948. default: x = origin[ 1 ] / original.width;
  12949. }
  12950. return {
  12951. x: x,
  12952. y: y
  12953. };
  12954. },
  12955. // Wraps the element around a wrapper that copies position properties
  12956. createWrapper: function( element ) {
  12957. // if the element is already wrapped, return it
  12958. if ( element.parent().is( ".ui-effects-wrapper" )) {
  12959. return element.parent();
  12960. }
  12961. // wrap the element
  12962. var props = {
  12963. width: element.outerWidth(true),
  12964. height: element.outerHeight(true),
  12965. "float": element.css( "float" )
  12966. },
  12967. wrapper = $( "<div></div>" )
  12968. .addClass( "ui-effects-wrapper" )
  12969. .css({
  12970. fontSize: "100%",
  12971. background: "transparent",
  12972. border: "none",
  12973. margin: 0,
  12974. padding: 0
  12975. }),
  12976. // Store the size in case width/height are defined in % - Fixes #5245
  12977. size = {
  12978. width: element.width(),
  12979. height: element.height()
  12980. },
  12981. active = document.activeElement;
  12982. // support: Firefox
  12983. // Firefox incorrectly exposes anonymous content
  12984. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  12985. try {
  12986. active.id;
  12987. } catch ( e ) {
  12988. active = document.body;
  12989. }
  12990. element.wrap( wrapper );
  12991. // Fixes #7595 - Elements lose focus when wrapped.
  12992. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  12993. $( active ).focus();
  12994. }
  12995. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  12996. // transfer positioning properties to the wrapper
  12997. if ( element.css( "position" ) === "static" ) {
  12998. wrapper.css({ position: "relative" });
  12999. element.css({ position: "relative" });
  13000. } else {
  13001. $.extend( props, {
  13002. position: element.css( "position" ),
  13003. zIndex: element.css( "z-index" )
  13004. });
  13005. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  13006. props[ pos ] = element.css( pos );
  13007. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  13008. props[ pos ] = "auto";
  13009. }
  13010. });
  13011. element.css({
  13012. position: "relative",
  13013. top: 0,
  13014. left: 0,
  13015. right: "auto",
  13016. bottom: "auto"
  13017. });
  13018. }
  13019. element.css(size);
  13020. return wrapper.css( props ).show();
  13021. },
  13022. removeWrapper: function( element ) {
  13023. var active = document.activeElement;
  13024. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  13025. element.parent().replaceWith( element );
  13026. // Fixes #7595 - Elements lose focus when wrapped.
  13027. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  13028. $( active ).focus();
  13029. }
  13030. }
  13031. return element;
  13032. },
  13033. setTransition: function( element, list, factor, value ) {
  13034. value = value || {};
  13035. $.each( list, function( i, x ) {
  13036. var unit = element.cssUnit( x );
  13037. if ( unit[ 0 ] > 0 ) {
  13038. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  13039. }
  13040. });
  13041. return value;
  13042. }
  13043. });
  13044. // return an effect options object for the given parameters:
  13045. function _normalizeArguments( effect, options, speed, callback ) {
  13046. // allow passing all options as the first parameter
  13047. if ( $.isPlainObject( effect ) ) {
  13048. options = effect;
  13049. effect = effect.effect;
  13050. }
  13051. // convert to an object
  13052. effect = { effect: effect };
  13053. // catch (effect, null, ...)
  13054. if ( options == null ) {
  13055. options = {};
  13056. }
  13057. // catch (effect, callback)
  13058. if ( $.isFunction( options ) ) {
  13059. callback = options;
  13060. speed = null;
  13061. options = {};
  13062. }
  13063. // catch (effect, speed, ?)
  13064. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  13065. callback = speed;
  13066. speed = options;
  13067. options = {};
  13068. }
  13069. // catch (effect, options, callback)
  13070. if ( $.isFunction( speed ) ) {
  13071. callback = speed;
  13072. speed = null;
  13073. }
  13074. // add options to effect
  13075. if ( options ) {
  13076. $.extend( effect, options );
  13077. }
  13078. speed = speed || options.duration;
  13079. effect.duration = $.fx.off ? 0 :
  13080. typeof speed === "number" ? speed :
  13081. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  13082. $.fx.speeds._default;
  13083. effect.complete = callback || options.complete;
  13084. return effect;
  13085. }
  13086. function standardAnimationOption( option ) {
  13087. // Valid standard speeds (nothing, number, named speed)
  13088. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  13089. return true;
  13090. }
  13091. // Invalid strings - treat as "normal" speed
  13092. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  13093. return true;
  13094. }
  13095. // Complete callback
  13096. if ( $.isFunction( option ) ) {
  13097. return true;
  13098. }
  13099. // Options hash (but not naming an effect)
  13100. if ( typeof option === "object" && !option.effect ) {
  13101. return true;
  13102. }
  13103. // Didn't match any standard API
  13104. return false;
  13105. }
  13106. $.fn.extend({
  13107. effect: function( /* effect, options, speed, callback */ ) {
  13108. var args = _normalizeArguments.apply( this, arguments ),
  13109. mode = args.mode,
  13110. queue = args.queue,
  13111. effectMethod = $.effects.effect[ args.effect ];
  13112. if ( $.fx.off || !effectMethod ) {
  13113. // delegate to the original method (e.g., .show()) if possible
  13114. if ( mode ) {
  13115. return this[ mode ]( args.duration, args.complete );
  13116. } else {
  13117. return this.each( function() {
  13118. if ( args.complete ) {
  13119. args.complete.call( this );
  13120. }
  13121. });
  13122. }
  13123. }
  13124. function run( next ) {
  13125. var elem = $( this ),
  13126. complete = args.complete,
  13127. mode = args.mode;
  13128. function done() {
  13129. if ( $.isFunction( complete ) ) {
  13130. complete.call( elem[0] );
  13131. }
  13132. if ( $.isFunction( next ) ) {
  13133. next();
  13134. }
  13135. }
  13136. // If the element already has the correct final state, delegate to
  13137. // the core methods so the internal tracking of "olddisplay" works.
  13138. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  13139. elem[ mode ]();
  13140. done();
  13141. } else {
  13142. effectMethod.call( elem[0], args, done );
  13143. }
  13144. }
  13145. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  13146. },
  13147. show: (function( orig ) {
  13148. return function( option ) {
  13149. if ( standardAnimationOption( option ) ) {
  13150. return orig.apply( this, arguments );
  13151. } else {
  13152. var args = _normalizeArguments.apply( this, arguments );
  13153. args.mode = "show";
  13154. return this.effect.call( this, args );
  13155. }
  13156. };
  13157. })( $.fn.show ),
  13158. hide: (function( orig ) {
  13159. return function( option ) {
  13160. if ( standardAnimationOption( option ) ) {
  13161. return orig.apply( this, arguments );
  13162. } else {
  13163. var args = _normalizeArguments.apply( this, arguments );
  13164. args.mode = "hide";
  13165. return this.effect.call( this, args );
  13166. }
  13167. };
  13168. })( $.fn.hide ),
  13169. toggle: (function( orig ) {
  13170. return function( option ) {
  13171. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  13172. return orig.apply( this, arguments );
  13173. } else {
  13174. var args = _normalizeArguments.apply( this, arguments );
  13175. args.mode = "toggle";
  13176. return this.effect.call( this, args );
  13177. }
  13178. };
  13179. })( $.fn.toggle ),
  13180. // helper functions
  13181. cssUnit: function(key) {
  13182. var style = this.css( key ),
  13183. val = [];
  13184. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  13185. if ( style.indexOf( unit ) > 0 ) {
  13186. val = [ parseFloat( style ), unit ];
  13187. }
  13188. });
  13189. return val;
  13190. }
  13191. });
  13192. })();
  13193. /******************************************************************************/
  13194. /*********************************** EASING ***********************************/
  13195. /******************************************************************************/
  13196. (function() {
  13197. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  13198. var baseEasings = {};
  13199. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  13200. baseEasings[ name ] = function( p ) {
  13201. return Math.pow( p, i + 2 );
  13202. };
  13203. });
  13204. $.extend( baseEasings, {
  13205. Sine: function( p ) {
  13206. return 1 - Math.cos( p * Math.PI / 2 );
  13207. },
  13208. Circ: function( p ) {
  13209. return 1 - Math.sqrt( 1 - p * p );
  13210. },
  13211. Elastic: function( p ) {
  13212. return p === 0 || p === 1 ? p :
  13213. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  13214. },
  13215. Back: function( p ) {
  13216. return p * p * ( 3 * p - 2 );
  13217. },
  13218. Bounce: function( p ) {
  13219. var pow2,
  13220. bounce = 4;
  13221. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  13222. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  13223. }
  13224. });
  13225. $.each( baseEasings, function( name, easeIn ) {
  13226. $.easing[ "easeIn" + name ] = easeIn;
  13227. $.easing[ "easeOut" + name ] = function( p ) {
  13228. return 1 - easeIn( 1 - p );
  13229. };
  13230. $.easing[ "easeInOut" + name ] = function( p ) {
  13231. return p < 0.5 ?
  13232. easeIn( p * 2 ) / 2 :
  13233. 1 - easeIn( p * -2 + 2 ) / 2;
  13234. };
  13235. });
  13236. })();
  13237. var effect = $.effects;
  13238. /*!
  13239. * jQuery UI Effects Blind 1.11.2
  13240. * http://jqueryui.com
  13241. *
  13242. * Copyright 2014 jQuery Foundation and other contributors
  13243. * Released under the MIT license.
  13244. * http://jquery.org/license
  13245. *
  13246. * http://api.jqueryui.com/blind-effect/
  13247. */
  13248. var effectBlind = $.effects.effect.blind = function( o, done ) {
  13249. // Create element
  13250. var el = $( this ),
  13251. rvertical = /up|down|vertical/,
  13252. rpositivemotion = /up|left|vertical|horizontal/,
  13253. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13254. mode = $.effects.setMode( el, o.mode || "hide" ),
  13255. direction = o.direction || "up",
  13256. vertical = rvertical.test( direction ),
  13257. ref = vertical ? "height" : "width",
  13258. ref2 = vertical ? "top" : "left",
  13259. motion = rpositivemotion.test( direction ),
  13260. animation = {},
  13261. show = mode === "show",
  13262. wrapper, distance, margin;
  13263. // if already wrapped, the wrapper's properties are my property. #6245
  13264. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  13265. $.effects.save( el.parent(), props );
  13266. } else {
  13267. $.effects.save( el, props );
  13268. }
  13269. el.show();
  13270. wrapper = $.effects.createWrapper( el ).css({
  13271. overflow: "hidden"
  13272. });
  13273. distance = wrapper[ ref ]();
  13274. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  13275. animation[ ref ] = show ? distance : 0;
  13276. if ( !motion ) {
  13277. el
  13278. .css( vertical ? "bottom" : "right", 0 )
  13279. .css( vertical ? "top" : "left", "auto" )
  13280. .css({ position: "absolute" });
  13281. animation[ ref2 ] = show ? margin : distance + margin;
  13282. }
  13283. // start at 0 if we are showing
  13284. if ( show ) {
  13285. wrapper.css( ref, 0 );
  13286. if ( !motion ) {
  13287. wrapper.css( ref2, margin + distance );
  13288. }
  13289. }
  13290. // Animate
  13291. wrapper.animate( animation, {
  13292. duration: o.duration,
  13293. easing: o.easing,
  13294. queue: false,
  13295. complete: function() {
  13296. if ( mode === "hide" ) {
  13297. el.hide();
  13298. }
  13299. $.effects.restore( el, props );
  13300. $.effects.removeWrapper( el );
  13301. done();
  13302. }
  13303. });
  13304. };
  13305. /*!
  13306. * jQuery UI Effects Bounce 1.11.2
  13307. * http://jqueryui.com
  13308. *
  13309. * Copyright 2014 jQuery Foundation and other contributors
  13310. * Released under the MIT license.
  13311. * http://jquery.org/license
  13312. *
  13313. * http://api.jqueryui.com/bounce-effect/
  13314. */
  13315. var effectBounce = $.effects.effect.bounce = function( o, done ) {
  13316. var el = $( this ),
  13317. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13318. // defaults:
  13319. mode = $.effects.setMode( el, o.mode || "effect" ),
  13320. hide = mode === "hide",
  13321. show = mode === "show",
  13322. direction = o.direction || "up",
  13323. distance = o.distance,
  13324. times = o.times || 5,
  13325. // number of internal animations
  13326. anims = times * 2 + ( show || hide ? 1 : 0 ),
  13327. speed = o.duration / anims,
  13328. easing = o.easing,
  13329. // utility:
  13330. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  13331. motion = ( direction === "up" || direction === "left" ),
  13332. i,
  13333. upAnim,
  13334. downAnim,
  13335. // we will need to re-assemble the queue to stack our animations in place
  13336. queue = el.queue(),
  13337. queuelen = queue.length;
  13338. // Avoid touching opacity to prevent clearType and PNG issues in IE
  13339. if ( show || hide ) {
  13340. props.push( "opacity" );
  13341. }
  13342. $.effects.save( el, props );
  13343. el.show();
  13344. $.effects.createWrapper( el ); // Create Wrapper
  13345. // default distance for the BIGGEST bounce is the outer Distance / 3
  13346. if ( !distance ) {
  13347. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  13348. }
  13349. if ( show ) {
  13350. downAnim = { opacity: 1 };
  13351. downAnim[ ref ] = 0;
  13352. // if we are showing, force opacity 0 and set the initial position
  13353. // then do the "first" animation
  13354. el.css( "opacity", 0 )
  13355. .css( ref, motion ? -distance * 2 : distance * 2 )
  13356. .animate( downAnim, speed, easing );
  13357. }
  13358. // start at the smallest distance if we are hiding
  13359. if ( hide ) {
  13360. distance = distance / Math.pow( 2, times - 1 );
  13361. }
  13362. downAnim = {};
  13363. downAnim[ ref ] = 0;
  13364. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  13365. for ( i = 0; i < times; i++ ) {
  13366. upAnim = {};
  13367. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  13368. el.animate( upAnim, speed, easing )
  13369. .animate( downAnim, speed, easing );
  13370. distance = hide ? distance * 2 : distance / 2;
  13371. }
  13372. // Last Bounce when Hiding
  13373. if ( hide ) {
  13374. upAnim = { opacity: 0 };
  13375. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  13376. el.animate( upAnim, speed, easing );
  13377. }
  13378. el.queue(function() {
  13379. if ( hide ) {
  13380. el.hide();
  13381. }
  13382. $.effects.restore( el, props );
  13383. $.effects.removeWrapper( el );
  13384. done();
  13385. });
  13386. // inject all the animations we just queued to be first in line (after "inprogress")
  13387. if ( queuelen > 1) {
  13388. queue.splice.apply( queue,
  13389. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  13390. }
  13391. el.dequeue();
  13392. };
  13393. /*!
  13394. * jQuery UI Effects Clip 1.11.2
  13395. * http://jqueryui.com
  13396. *
  13397. * Copyright 2014 jQuery Foundation and other contributors
  13398. * Released under the MIT license.
  13399. * http://jquery.org/license
  13400. *
  13401. * http://api.jqueryui.com/clip-effect/
  13402. */
  13403. var effectClip = $.effects.effect.clip = function( o, done ) {
  13404. // Create element
  13405. var el = $( this ),
  13406. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13407. mode = $.effects.setMode( el, o.mode || "hide" ),
  13408. show = mode === "show",
  13409. direction = o.direction || "vertical",
  13410. vert = direction === "vertical",
  13411. size = vert ? "height" : "width",
  13412. position = vert ? "top" : "left",
  13413. animation = {},
  13414. wrapper, animate, distance;
  13415. // Save & Show
  13416. $.effects.save( el, props );
  13417. el.show();
  13418. // Create Wrapper
  13419. wrapper = $.effects.createWrapper( el ).css({
  13420. overflow: "hidden"
  13421. });
  13422. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  13423. distance = animate[ size ]();
  13424. // Shift
  13425. if ( show ) {
  13426. animate.css( size, 0 );
  13427. animate.css( position, distance / 2 );
  13428. }
  13429. // Create Animation Object:
  13430. animation[ size ] = show ? distance : 0;
  13431. animation[ position ] = show ? 0 : distance / 2;
  13432. // Animate
  13433. animate.animate( animation, {
  13434. queue: false,
  13435. duration: o.duration,
  13436. easing: o.easing,
  13437. complete: function() {
  13438. if ( !show ) {
  13439. el.hide();
  13440. }
  13441. $.effects.restore( el, props );
  13442. $.effects.removeWrapper( el );
  13443. done();
  13444. }
  13445. });
  13446. };
  13447. /*!
  13448. * jQuery UI Effects Drop 1.11.2
  13449. * http://jqueryui.com
  13450. *
  13451. * Copyright 2014 jQuery Foundation and other contributors
  13452. * Released under the MIT license.
  13453. * http://jquery.org/license
  13454. *
  13455. * http://api.jqueryui.com/drop-effect/
  13456. */
  13457. var effectDrop = $.effects.effect.drop = function( o, done ) {
  13458. var el = $( this ),
  13459. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  13460. mode = $.effects.setMode( el, o.mode || "hide" ),
  13461. show = mode === "show",
  13462. direction = o.direction || "left",
  13463. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  13464. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  13465. animation = {
  13466. opacity: show ? 1 : 0
  13467. },
  13468. distance;
  13469. // Adjust
  13470. $.effects.save( el, props );
  13471. el.show();
  13472. $.effects.createWrapper( el );
  13473. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  13474. if ( show ) {
  13475. el
  13476. .css( "opacity", 0 )
  13477. .css( ref, motion === "pos" ? -distance : distance );
  13478. }
  13479. // Animation
  13480. animation[ ref ] = ( show ?
  13481. ( motion === "pos" ? "+=" : "-=" ) :
  13482. ( motion === "pos" ? "-=" : "+=" ) ) +
  13483. distance;
  13484. // Animate
  13485. el.animate( animation, {
  13486. queue: false,
  13487. duration: o.duration,
  13488. easing: o.easing,
  13489. complete: function() {
  13490. if ( mode === "hide" ) {
  13491. el.hide();
  13492. }
  13493. $.effects.restore( el, props );
  13494. $.effects.removeWrapper( el );
  13495. done();
  13496. }
  13497. });
  13498. };
  13499. /*!
  13500. * jQuery UI Effects Explode 1.11.2
  13501. * http://jqueryui.com
  13502. *
  13503. * Copyright 2014 jQuery Foundation and other contributors
  13504. * Released under the MIT license.
  13505. * http://jquery.org/license
  13506. *
  13507. * http://api.jqueryui.com/explode-effect/
  13508. */
  13509. var effectExplode = $.effects.effect.explode = function( o, done ) {
  13510. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  13511. cells = rows,
  13512. el = $( this ),
  13513. mode = $.effects.setMode( el, o.mode || "hide" ),
  13514. show = mode === "show",
  13515. // show and then visibility:hidden the element before calculating offset
  13516. offset = el.show().css( "visibility", "hidden" ).offset(),
  13517. // width and height of a piece
  13518. width = Math.ceil( el.outerWidth() / cells ),
  13519. height = Math.ceil( el.outerHeight() / rows ),
  13520. pieces = [],
  13521. // loop
  13522. i, j, left, top, mx, my;
  13523. // children animate complete:
  13524. function childComplete() {
  13525. pieces.push( this );
  13526. if ( pieces.length === rows * cells ) {
  13527. animComplete();
  13528. }
  13529. }
  13530. // clone the element for each row and cell.
  13531. for ( i = 0; i < rows ; i++ ) { // ===>
  13532. top = offset.top + i * height;
  13533. my = i - ( rows - 1 ) / 2 ;
  13534. for ( j = 0; j < cells ; j++ ) { // |||
  13535. left = offset.left + j * width;
  13536. mx = j - ( cells - 1 ) / 2 ;
  13537. // Create a clone of the now hidden main element that will be absolute positioned
  13538. // within a wrapper div off the -left and -top equal to size of our pieces
  13539. el
  13540. .clone()
  13541. .appendTo( "body" )
  13542. .wrap( "<div></div>" )
  13543. .css({
  13544. position: "absolute",
  13545. visibility: "visible",
  13546. left: -j * width,
  13547. top: -i * height
  13548. })
  13549. // select the wrapper - make it overflow: hidden and absolute positioned based on
  13550. // where the original was located +left and +top equal to the size of pieces
  13551. .parent()
  13552. .addClass( "ui-effects-explode" )
  13553. .css({
  13554. position: "absolute",
  13555. overflow: "hidden",
  13556. width: width,
  13557. height: height,
  13558. left: left + ( show ? mx * width : 0 ),
  13559. top: top + ( show ? my * height : 0 ),
  13560. opacity: show ? 0 : 1
  13561. }).animate({
  13562. left: left + ( show ? 0 : mx * width ),
  13563. top: top + ( show ? 0 : my * height ),
  13564. opacity: show ? 1 : 0
  13565. }, o.duration || 500, o.easing, childComplete );
  13566. }
  13567. }
  13568. function animComplete() {
  13569. el.css({
  13570. visibility: "visible"
  13571. });
  13572. $( pieces ).remove();
  13573. if ( !show ) {
  13574. el.hide();
  13575. }
  13576. done();
  13577. }
  13578. };
  13579. /*!
  13580. * jQuery UI Effects Fade 1.11.2
  13581. * http://jqueryui.com
  13582. *
  13583. * Copyright 2014 jQuery Foundation and other contributors
  13584. * Released under the MIT license.
  13585. * http://jquery.org/license
  13586. *
  13587. * http://api.jqueryui.com/fade-effect/
  13588. */
  13589. var effectFade = $.effects.effect.fade = function( o, done ) {
  13590. var el = $( this ),
  13591. mode = $.effects.setMode( el, o.mode || "toggle" );
  13592. el.animate({
  13593. opacity: mode
  13594. }, {
  13595. queue: false,
  13596. duration: o.duration,
  13597. easing: o.easing,
  13598. complete: done
  13599. });
  13600. };
  13601. /*!
  13602. * jQuery UI Effects Fold 1.11.2
  13603. * http://jqueryui.com
  13604. *
  13605. * Copyright 2014 jQuery Foundation and other contributors
  13606. * Released under the MIT license.
  13607. * http://jquery.org/license
  13608. *
  13609. * http://api.jqueryui.com/fold-effect/
  13610. */
  13611. var effectFold = $.effects.effect.fold = function( o, done ) {
  13612. // Create element
  13613. var el = $( this ),
  13614. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  13615. mode = $.effects.setMode( el, o.mode || "hide" ),
  13616. show = mode === "show",
  13617. hide = mode === "hide",
  13618. size = o.size || 15,
  13619. percent = /([0-9]+)%/.exec( size ),
  13620. horizFirst = !!o.horizFirst,
  13621. widthFirst = show !== horizFirst,
  13622. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  13623. duration = o.duration / 2,
  13624. wrapper, distance,
  13625. animation1 = {},
  13626. animation2 = {};
  13627. $.effects.save( el, props );
  13628. el.show();
  13629. // Create Wrapper
  13630. wrapper = $.effects.createWrapper( el ).css({
  13631. overflow: "hidden"
  13632. });
  13633. distance = widthFirst ?
  13634. [ wrapper.width(), wrapper.height() ] :
  13635. [ wrapper.height(), wrapper.width() ];
  13636. if ( percent ) {
  13637. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  13638. }
  13639. if ( show ) {
  13640. wrapper.css( horizFirst ? {
  13641. height: 0,
  13642. width: size
  13643. } : {
  13644. height: size,
  13645. width: 0
  13646. });
  13647. }
  13648. // Animation
  13649. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  13650. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  13651. // Animate
  13652. wrapper
  13653. .animate( animation1, duration, o.easing )
  13654. .animate( animation2, duration, o.easing, function() {
  13655. if ( hide ) {
  13656. el.hide();
  13657. }
  13658. $.effects.restore( el, props );
  13659. $.effects.removeWrapper( el );
  13660. done();
  13661. });
  13662. };
  13663. /*!
  13664. * jQuery UI Effects Highlight 1.11.2
  13665. * http://jqueryui.com
  13666. *
  13667. * Copyright 2014 jQuery Foundation and other contributors
  13668. * Released under the MIT license.
  13669. * http://jquery.org/license
  13670. *
  13671. * http://api.jqueryui.com/highlight-effect/
  13672. */
  13673. var effectHighlight = $.effects.effect.highlight = function( o, done ) {
  13674. var elem = $( this ),
  13675. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  13676. mode = $.effects.setMode( elem, o.mode || "show" ),
  13677. animation = {
  13678. backgroundColor: elem.css( "backgroundColor" )
  13679. };
  13680. if (mode === "hide") {
  13681. animation.opacity = 0;
  13682. }
  13683. $.effects.save( elem, props );
  13684. elem
  13685. .show()
  13686. .css({
  13687. backgroundImage: "none",
  13688. backgroundColor: o.color || "#ffff99"
  13689. })
  13690. .animate( animation, {
  13691. queue: false,
  13692. duration: o.duration,
  13693. easing: o.easing,
  13694. complete: function() {
  13695. if ( mode === "hide" ) {
  13696. elem.hide();
  13697. }
  13698. $.effects.restore( elem, props );
  13699. done();
  13700. }
  13701. });
  13702. };
  13703. /*!
  13704. * jQuery UI Effects Size 1.11.2
  13705. * http://jqueryui.com
  13706. *
  13707. * Copyright 2014 jQuery Foundation and other contributors
  13708. * Released under the MIT license.
  13709. * http://jquery.org/license
  13710. *
  13711. * http://api.jqueryui.com/size-effect/
  13712. */
  13713. var effectSize = $.effects.effect.size = function( o, done ) {
  13714. // Create element
  13715. var original, baseline, factor,
  13716. el = $( this ),
  13717. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  13718. // Always restore
  13719. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  13720. // Copy for children
  13721. props2 = [ "width", "height", "overflow" ],
  13722. cProps = [ "fontSize" ],
  13723. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  13724. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  13725. // Set options
  13726. mode = $.effects.setMode( el, o.mode || "effect" ),
  13727. restore = o.restore || mode !== "effect",
  13728. scale = o.scale || "both",
  13729. origin = o.origin || [ "middle", "center" ],
  13730. position = el.css( "position" ),
  13731. props = restore ? props0 : props1,
  13732. zero = {
  13733. height: 0,
  13734. width: 0,
  13735. outerHeight: 0,
  13736. outerWidth: 0
  13737. };
  13738. if ( mode === "show" ) {
  13739. el.show();
  13740. }
  13741. original = {
  13742. height: el.height(),
  13743. width: el.width(),
  13744. outerHeight: el.outerHeight(),
  13745. outerWidth: el.outerWidth()
  13746. };
  13747. if ( o.mode === "toggle" && mode === "show" ) {
  13748. el.from = o.to || zero;
  13749. el.to = o.from || original;
  13750. } else {
  13751. el.from = o.from || ( mode === "show" ? zero : original );
  13752. el.to = o.to || ( mode === "hide" ? zero : original );
  13753. }
  13754. // Set scaling factor
  13755. factor = {
  13756. from: {
  13757. y: el.from.height / original.height,
  13758. x: el.from.width / original.width
  13759. },
  13760. to: {
  13761. y: el.to.height / original.height,
  13762. x: el.to.width / original.width
  13763. }
  13764. };
  13765. // Scale the css box
  13766. if ( scale === "box" || scale === "both" ) {
  13767. // Vertical props scaling
  13768. if ( factor.from.y !== factor.to.y ) {
  13769. props = props.concat( vProps );
  13770. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  13771. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  13772. }
  13773. // Horizontal props scaling
  13774. if ( factor.from.x !== factor.to.x ) {
  13775. props = props.concat( hProps );
  13776. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  13777. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  13778. }
  13779. }
  13780. // Scale the content
  13781. if ( scale === "content" || scale === "both" ) {
  13782. // Vertical props scaling
  13783. if ( factor.from.y !== factor.to.y ) {
  13784. props = props.concat( cProps ).concat( props2 );
  13785. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  13786. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  13787. }
  13788. }
  13789. $.effects.save( el, props );
  13790. el.show();
  13791. $.effects.createWrapper( el );
  13792. el.css( "overflow", "hidden" ).css( el.from );
  13793. // Adjust
  13794. if (origin) { // Calculate baseline shifts
  13795. baseline = $.effects.getBaseline( origin, original );
  13796. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  13797. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  13798. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  13799. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  13800. }
  13801. el.css( el.from ); // set top & left
  13802. // Animate
  13803. if ( scale === "content" || scale === "both" ) { // Scale the children
  13804. // Add margins/font-size
  13805. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  13806. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  13807. props2 = props0.concat(vProps).concat(hProps);
  13808. el.find( "*[width]" ).each( function() {
  13809. var child = $( this ),
  13810. c_original = {
  13811. height: child.height(),
  13812. width: child.width(),
  13813. outerHeight: child.outerHeight(),
  13814. outerWidth: child.outerWidth()
  13815. };
  13816. if (restore) {
  13817. $.effects.save(child, props2);
  13818. }
  13819. child.from = {
  13820. height: c_original.height * factor.from.y,
  13821. width: c_original.width * factor.from.x,
  13822. outerHeight: c_original.outerHeight * factor.from.y,
  13823. outerWidth: c_original.outerWidth * factor.from.x
  13824. };
  13825. child.to = {
  13826. height: c_original.height * factor.to.y,
  13827. width: c_original.width * factor.to.x,
  13828. outerHeight: c_original.height * factor.to.y,
  13829. outerWidth: c_original.width * factor.to.x
  13830. };
  13831. // Vertical props scaling
  13832. if ( factor.from.y !== factor.to.y ) {
  13833. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  13834. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  13835. }
  13836. // Horizontal props scaling
  13837. if ( factor.from.x !== factor.to.x ) {
  13838. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  13839. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  13840. }
  13841. // Animate children
  13842. child.css( child.from );
  13843. child.animate( child.to, o.duration, o.easing, function() {
  13844. // Restore children
  13845. if ( restore ) {
  13846. $.effects.restore( child, props2 );
  13847. }
  13848. });
  13849. });
  13850. }
  13851. // Animate
  13852. el.animate( el.to, {
  13853. queue: false,
  13854. duration: o.duration,
  13855. easing: o.easing,
  13856. complete: function() {
  13857. if ( el.to.opacity === 0 ) {
  13858. el.css( "opacity", el.from.opacity );
  13859. }
  13860. if ( mode === "hide" ) {
  13861. el.hide();
  13862. }
  13863. $.effects.restore( el, props );
  13864. if ( !restore ) {
  13865. // we need to calculate our new positioning based on the scaling
  13866. if ( position === "static" ) {
  13867. el.css({
  13868. position: "relative",
  13869. top: el.to.top,
  13870. left: el.to.left
  13871. });
  13872. } else {
  13873. $.each([ "top", "left" ], function( idx, pos ) {
  13874. el.css( pos, function( _, str ) {
  13875. var val = parseInt( str, 10 ),
  13876. toRef = idx ? el.to.left : el.to.top;
  13877. // if original was "auto", recalculate the new value from wrapper
  13878. if ( str === "auto" ) {
  13879. return toRef + "px";
  13880. }
  13881. return val + toRef + "px";
  13882. });
  13883. });
  13884. }
  13885. }
  13886. $.effects.removeWrapper( el );
  13887. done();
  13888. }
  13889. });
  13890. };
  13891. /*!
  13892. * jQuery UI Effects Scale 1.11.2
  13893. * http://jqueryui.com
  13894. *
  13895. * Copyright 2014 jQuery Foundation and other contributors
  13896. * Released under the MIT license.
  13897. * http://jquery.org/license
  13898. *
  13899. * http://api.jqueryui.com/scale-effect/
  13900. */
  13901. var effectScale = $.effects.effect.scale = function( o, done ) {
  13902. // Create element
  13903. var el = $( this ),
  13904. options = $.extend( true, {}, o ),
  13905. mode = $.effects.setMode( el, o.mode || "effect" ),
  13906. percent = parseInt( o.percent, 10 ) ||
  13907. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  13908. direction = o.direction || "both",
  13909. origin = o.origin,
  13910. original = {
  13911. height: el.height(),
  13912. width: el.width(),
  13913. outerHeight: el.outerHeight(),
  13914. outerWidth: el.outerWidth()
  13915. },
  13916. factor = {
  13917. y: direction !== "horizontal" ? (percent / 100) : 1,
  13918. x: direction !== "vertical" ? (percent / 100) : 1
  13919. };
  13920. // We are going to pass this effect to the size effect:
  13921. options.effect = "size";
  13922. options.queue = false;
  13923. options.complete = done;
  13924. // Set default origin and restore for show/hide
  13925. if ( mode !== "effect" ) {
  13926. options.origin = origin || [ "middle", "center" ];
  13927. options.restore = true;
  13928. }
  13929. options.from = o.from || ( mode === "show" ? {
  13930. height: 0,
  13931. width: 0,
  13932. outerHeight: 0,
  13933. outerWidth: 0
  13934. } : original );
  13935. options.to = {
  13936. height: original.height * factor.y,
  13937. width: original.width * factor.x,
  13938. outerHeight: original.outerHeight * factor.y,
  13939. outerWidth: original.outerWidth * factor.x
  13940. };
  13941. // Fade option to support puff
  13942. if ( options.fade ) {
  13943. if ( mode === "show" ) {
  13944. options.from.opacity = 0;
  13945. options.to.opacity = 1;
  13946. }
  13947. if ( mode === "hide" ) {
  13948. options.from.opacity = 1;
  13949. options.to.opacity = 0;
  13950. }
  13951. }
  13952. // Animate
  13953. el.effect( options );
  13954. };
  13955. /*!
  13956. * jQuery UI Effects Puff 1.11.2
  13957. * http://jqueryui.com
  13958. *
  13959. * Copyright 2014 jQuery Foundation and other contributors
  13960. * Released under the MIT license.
  13961. * http://jquery.org/license
  13962. *
  13963. * http://api.jqueryui.com/puff-effect/
  13964. */
  13965. var effectPuff = $.effects.effect.puff = function( o, done ) {
  13966. var elem = $( this ),
  13967. mode = $.effects.setMode( elem, o.mode || "hide" ),
  13968. hide = mode === "hide",
  13969. percent = parseInt( o.percent, 10 ) || 150,
  13970. factor = percent / 100,
  13971. original = {
  13972. height: elem.height(),
  13973. width: elem.width(),
  13974. outerHeight: elem.outerHeight(),
  13975. outerWidth: elem.outerWidth()
  13976. };
  13977. $.extend( o, {
  13978. effect: "scale",
  13979. queue: false,
  13980. fade: true,
  13981. mode: mode,
  13982. complete: done,
  13983. percent: hide ? percent : 100,
  13984. from: hide ?
  13985. original :
  13986. {
  13987. height: original.height * factor,
  13988. width: original.width * factor,
  13989. outerHeight: original.outerHeight * factor,
  13990. outerWidth: original.outerWidth * factor
  13991. }
  13992. });
  13993. elem.effect( o );
  13994. };
  13995. /*!
  13996. * jQuery UI Effects Pulsate 1.11.2
  13997. * http://jqueryui.com
  13998. *
  13999. * Copyright 2014 jQuery Foundation and other contributors
  14000. * Released under the MIT license.
  14001. * http://jquery.org/license
  14002. *
  14003. * http://api.jqueryui.com/pulsate-effect/
  14004. */
  14005. var effectPulsate = $.effects.effect.pulsate = function( o, done ) {
  14006. var elem = $( this ),
  14007. mode = $.effects.setMode( elem, o.mode || "show" ),
  14008. show = mode === "show",
  14009. hide = mode === "hide",
  14010. showhide = ( show || mode === "hide" ),
  14011. // showing or hiding leaves of the "last" animation
  14012. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  14013. duration = o.duration / anims,
  14014. animateTo = 0,
  14015. queue = elem.queue(),
  14016. queuelen = queue.length,
  14017. i;
  14018. if ( show || !elem.is(":visible")) {
  14019. elem.css( "opacity", 0 ).show();
  14020. animateTo = 1;
  14021. }
  14022. // anims - 1 opacity "toggles"
  14023. for ( i = 1; i < anims; i++ ) {
  14024. elem.animate({
  14025. opacity: animateTo
  14026. }, duration, o.easing );
  14027. animateTo = 1 - animateTo;
  14028. }
  14029. elem.animate({
  14030. opacity: animateTo
  14031. }, duration, o.easing);
  14032. elem.queue(function() {
  14033. if ( hide ) {
  14034. elem.hide();
  14035. }
  14036. done();
  14037. });
  14038. // We just queued up "anims" animations, we need to put them next in the queue
  14039. if ( queuelen > 1 ) {
  14040. queue.splice.apply( queue,
  14041. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  14042. }
  14043. elem.dequeue();
  14044. };
  14045. /*!
  14046. * jQuery UI Effects Shake 1.11.2
  14047. * http://jqueryui.com
  14048. *
  14049. * Copyright 2014 jQuery Foundation and other contributors
  14050. * Released under the MIT license.
  14051. * http://jquery.org/license
  14052. *
  14053. * http://api.jqueryui.com/shake-effect/
  14054. */
  14055. var effectShake = $.effects.effect.shake = function( o, done ) {
  14056. var el = $( this ),
  14057. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  14058. mode = $.effects.setMode( el, o.mode || "effect" ),
  14059. direction = o.direction || "left",
  14060. distance = o.distance || 20,
  14061. times = o.times || 3,
  14062. anims = times * 2 + 1,
  14063. speed = Math.round( o.duration / anims ),
  14064. ref = (direction === "up" || direction === "down") ? "top" : "left",
  14065. positiveMotion = (direction === "up" || direction === "left"),
  14066. animation = {},
  14067. animation1 = {},
  14068. animation2 = {},
  14069. i,
  14070. // we will need to re-assemble the queue to stack our animations in place
  14071. queue = el.queue(),
  14072. queuelen = queue.length;
  14073. $.effects.save( el, props );
  14074. el.show();
  14075. $.effects.createWrapper( el );
  14076. // Animation
  14077. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  14078. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  14079. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  14080. // Animate
  14081. el.animate( animation, speed, o.easing );
  14082. // Shakes
  14083. for ( i = 1; i < times; i++ ) {
  14084. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  14085. }
  14086. el
  14087. .animate( animation1, speed, o.easing )
  14088. .animate( animation, speed / 2, o.easing )
  14089. .queue(function() {
  14090. if ( mode === "hide" ) {
  14091. el.hide();
  14092. }
  14093. $.effects.restore( el, props );
  14094. $.effects.removeWrapper( el );
  14095. done();
  14096. });
  14097. // inject all the animations we just queued to be first in line (after "inprogress")
  14098. if ( queuelen > 1) {
  14099. queue.splice.apply( queue,
  14100. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  14101. }
  14102. el.dequeue();
  14103. };
  14104. /*!
  14105. * jQuery UI Effects Slide 1.11.2
  14106. * http://jqueryui.com
  14107. *
  14108. * Copyright 2014 jQuery Foundation and other contributors
  14109. * Released under the MIT license.
  14110. * http://jquery.org/license
  14111. *
  14112. * http://api.jqueryui.com/slide-effect/
  14113. */
  14114. var effectSlide = $.effects.effect.slide = function( o, done ) {
  14115. // Create element
  14116. var el = $( this ),
  14117. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  14118. mode = $.effects.setMode( el, o.mode || "show" ),
  14119. show = mode === "show",
  14120. direction = o.direction || "left",
  14121. ref = (direction === "up" || direction === "down") ? "top" : "left",
  14122. positiveMotion = (direction === "up" || direction === "left"),
  14123. distance,
  14124. animation = {};
  14125. // Adjust
  14126. $.effects.save( el, props );
  14127. el.show();
  14128. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  14129. $.effects.createWrapper( el ).css({
  14130. overflow: "hidden"
  14131. });
  14132. if ( show ) {
  14133. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  14134. }
  14135. // Animation
  14136. animation[ ref ] = ( show ?
  14137. ( positiveMotion ? "+=" : "-=") :
  14138. ( positiveMotion ? "-=" : "+=")) +
  14139. distance;
  14140. // Animate
  14141. el.animate( animation, {
  14142. queue: false,
  14143. duration: o.duration,
  14144. easing: o.easing,
  14145. complete: function() {
  14146. if ( mode === "hide" ) {
  14147. el.hide();
  14148. }
  14149. $.effects.restore( el, props );
  14150. $.effects.removeWrapper( el );
  14151. done();
  14152. }
  14153. });
  14154. };
  14155. /*!
  14156. * jQuery UI Effects Transfer 1.11.2
  14157. * http://jqueryui.com
  14158. *
  14159. * Copyright 2014 jQuery Foundation and other contributors
  14160. * Released under the MIT license.
  14161. * http://jquery.org/license
  14162. *
  14163. * http://api.jqueryui.com/transfer-effect/
  14164. */
  14165. var effectTransfer = $.effects.effect.transfer = function( o, done ) {
  14166. var elem = $( this ),
  14167. target = $( o.to ),
  14168. targetFixed = target.css( "position" ) === "fixed",
  14169. body = $("body"),
  14170. fixTop = targetFixed ? body.scrollTop() : 0,
  14171. fixLeft = targetFixed ? body.scrollLeft() : 0,
  14172. endPosition = target.offset(),
  14173. animation = {
  14174. top: endPosition.top - fixTop,
  14175. left: endPosition.left - fixLeft,
  14176. height: target.innerHeight(),
  14177. width: target.innerWidth()
  14178. },
  14179. startPosition = elem.offset(),
  14180. transfer = $( "<div class='ui-effects-transfer'></div>" )
  14181. .appendTo( document.body )
  14182. .addClass( o.className )
  14183. .css({
  14184. top: startPosition.top - fixTop,
  14185. left: startPosition.left - fixLeft,
  14186. height: elem.innerHeight(),
  14187. width: elem.innerWidth(),
  14188. position: targetFixed ? "fixed" : "absolute"
  14189. })
  14190. .animate( animation, o.duration, o.easing, function() {
  14191. transfer.remove();
  14192. done();
  14193. });
  14194. };
  14195. }));