jquery-ui.js 454 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375
  1. /*! jQuery UI - v1.11.1 - 2014-08-13
  2. * http://jqueryui.com
  3. * Includes: core.js, widget.js, mouse.js, position.js, accordion.js, autocomplete.js, button.js, datepicker.js, dialog.js, draggable.js, droppable.js, effect.js, effect-blind.js, effect-bounce.js, effect-clip.js, effect-drop.js, effect-explode.js, effect-fade.js, effect-fold.js, effect-highlight.js, effect-puff.js, effect-pulsate.js, effect-scale.js, effect-shake.js, effect-size.js, effect-slide.js, effect-transfer.js, menu.js, progressbar.js, resizable.js, selectable.js, selectmenu.js, slider.js, sortable.js, spinner.js, tabs.js, tooltip.js
  4. * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
  5. (function( factory ) {
  6. if ( typeof define === "function" && define.amd ) {
  7. // AMD. Register as an anonymous module.
  8. define([ "jquery" ], factory );
  9. } else {
  10. // Browser globals
  11. factory( jQuery );
  12. }
  13. }(function( $ ) {
  14. /*!
  15. * jQuery UI Core 1.11.1
  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.1",
  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.1
  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.options = $.widget.extend( {},
  491. this.options,
  492. this._getCreateOptions(),
  493. options );
  494. this.bindings = $();
  495. this.hoverable = $();
  496. this.focusable = $();
  497. if ( element !== this ) {
  498. $.data( element, this.widgetFullName, this );
  499. this._on( true, this.element, {
  500. remove: function( event ) {
  501. if ( event.target === element ) {
  502. this.destroy();
  503. }
  504. }
  505. });
  506. this.document = $( element.style ?
  507. // element within the document
  508. element.ownerDocument :
  509. // element is window or document
  510. element.document || element );
  511. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  512. }
  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 + " " ) + this.eventNamespace;
  655. element.unbind( eventName ).undelegate( eventName );
  656. },
  657. _delay: function( handler, delay ) {
  658. function handlerProxy() {
  659. return ( typeof handler === "string" ? instance[ handler ] : handler )
  660. .apply( instance, arguments );
  661. }
  662. var instance = this;
  663. return setTimeout( handlerProxy, delay || 0 );
  664. },
  665. _hoverable: function( element ) {
  666. this.hoverable = this.hoverable.add( element );
  667. this._on( element, {
  668. mouseenter: function( event ) {
  669. $( event.currentTarget ).addClass( "ui-state-hover" );
  670. },
  671. mouseleave: function( event ) {
  672. $( event.currentTarget ).removeClass( "ui-state-hover" );
  673. }
  674. });
  675. },
  676. _focusable: function( element ) {
  677. this.focusable = this.focusable.add( element );
  678. this._on( element, {
  679. focusin: function( event ) {
  680. $( event.currentTarget ).addClass( "ui-state-focus" );
  681. },
  682. focusout: function( event ) {
  683. $( event.currentTarget ).removeClass( "ui-state-focus" );
  684. }
  685. });
  686. },
  687. _trigger: function( type, event, data ) {
  688. var prop, orig,
  689. callback = this.options[ type ];
  690. data = data || {};
  691. event = $.Event( event );
  692. event.type = ( type === this.widgetEventPrefix ?
  693. type :
  694. this.widgetEventPrefix + type ).toLowerCase();
  695. // the original event may come from any element
  696. // so we need to reset the target on the new event
  697. event.target = this.element[ 0 ];
  698. // copy original event properties over to the new event
  699. orig = event.originalEvent;
  700. if ( orig ) {
  701. for ( prop in orig ) {
  702. if ( !( prop in event ) ) {
  703. event[ prop ] = orig[ prop ];
  704. }
  705. }
  706. }
  707. this.element.trigger( event, data );
  708. return !( $.isFunction( callback ) &&
  709. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  710. event.isDefaultPrevented() );
  711. }
  712. };
  713. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  714. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  715. if ( typeof options === "string" ) {
  716. options = { effect: options };
  717. }
  718. var hasOptions,
  719. effectName = !options ?
  720. method :
  721. options === true || typeof options === "number" ?
  722. defaultEffect :
  723. options.effect || defaultEffect;
  724. options = options || {};
  725. if ( typeof options === "number" ) {
  726. options = { duration: options };
  727. }
  728. hasOptions = !$.isEmptyObject( options );
  729. options.complete = callback;
  730. if ( options.delay ) {
  731. element.delay( options.delay );
  732. }
  733. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  734. element[ method ]( options );
  735. } else if ( effectName !== method && element[ effectName ] ) {
  736. element[ effectName ]( options.duration, options.easing, callback );
  737. } else {
  738. element.queue(function( next ) {
  739. $( this )[ method ]();
  740. if ( callback ) {
  741. callback.call( element[ 0 ] );
  742. }
  743. next();
  744. });
  745. }
  746. };
  747. });
  748. var widget = $.widget;
  749. /*!
  750. * jQuery UI Mouse 1.11.1
  751. * http://jqueryui.com
  752. *
  753. * Copyright 2014 jQuery Foundation and other contributors
  754. * Released under the MIT license.
  755. * http://jquery.org/license
  756. *
  757. * http://api.jqueryui.com/mouse/
  758. */
  759. var mouseHandled = false;
  760. $( document ).mouseup( function() {
  761. mouseHandled = false;
  762. });
  763. var mouse = $.widget("ui.mouse", {
  764. version: "1.11.1",
  765. options: {
  766. cancel: "input,textarea,button,select,option",
  767. distance: 1,
  768. delay: 0
  769. },
  770. _mouseInit: function() {
  771. var that = this;
  772. this.element
  773. .bind("mousedown." + this.widgetName, function(event) {
  774. return that._mouseDown(event);
  775. })
  776. .bind("click." + this.widgetName, function(event) {
  777. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  778. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  779. event.stopImmediatePropagation();
  780. return false;
  781. }
  782. });
  783. this.started = false;
  784. },
  785. // TODO: make sure destroying one instance of mouse doesn't mess with
  786. // other instances of mouse
  787. _mouseDestroy: function() {
  788. this.element.unbind("." + this.widgetName);
  789. if ( this._mouseMoveDelegate ) {
  790. this.document
  791. .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate)
  792. .unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
  793. }
  794. },
  795. _mouseDown: function(event) {
  796. // don't let more than one widget handle mouseStart
  797. if ( mouseHandled ) {
  798. return;
  799. }
  800. // we may have missed mouseup (out of window)
  801. (this._mouseStarted && this._mouseUp(event));
  802. this._mouseDownEvent = event;
  803. var that = this,
  804. btnIsLeft = (event.which === 1),
  805. // event.target.nodeName works around a bug in IE 8 with
  806. // disabled inputs (#7620)
  807. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  808. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  809. return true;
  810. }
  811. this.mouseDelayMet = !this.options.delay;
  812. if (!this.mouseDelayMet) {
  813. this._mouseDelayTimer = setTimeout(function() {
  814. that.mouseDelayMet = true;
  815. }, this.options.delay);
  816. }
  817. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  818. this._mouseStarted = (this._mouseStart(event) !== false);
  819. if (!this._mouseStarted) {
  820. event.preventDefault();
  821. return true;
  822. }
  823. }
  824. // Click event may never have fired (Gecko & Opera)
  825. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  826. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  827. }
  828. // these delegates are required to keep context
  829. this._mouseMoveDelegate = function(event) {
  830. return that._mouseMove(event);
  831. };
  832. this._mouseUpDelegate = function(event) {
  833. return that._mouseUp(event);
  834. };
  835. this.document
  836. .bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  837. .bind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  838. event.preventDefault();
  839. mouseHandled = true;
  840. return true;
  841. },
  842. _mouseMove: function(event) {
  843. // IE mouseup check - mouseup happened when mouse was out of window
  844. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  845. return this._mouseUp(event);
  846. // Iframe mouseup check - mouseup occurred in another document
  847. } else if ( !event.which ) {
  848. return this._mouseUp( event );
  849. }
  850. if (this._mouseStarted) {
  851. this._mouseDrag(event);
  852. return event.preventDefault();
  853. }
  854. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  855. this._mouseStarted =
  856. (this._mouseStart(this._mouseDownEvent, event) !== false);
  857. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  858. }
  859. return !this._mouseStarted;
  860. },
  861. _mouseUp: function(event) {
  862. this.document
  863. .unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  864. .unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  865. if (this._mouseStarted) {
  866. this._mouseStarted = false;
  867. if (event.target === this._mouseDownEvent.target) {
  868. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  869. }
  870. this._mouseStop(event);
  871. }
  872. mouseHandled = false;
  873. return false;
  874. },
  875. _mouseDistanceMet: function(event) {
  876. return (Math.max(
  877. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  878. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  879. ) >= this.options.distance
  880. );
  881. },
  882. _mouseDelayMet: function(/* event */) {
  883. return this.mouseDelayMet;
  884. },
  885. // These are placeholder methods, to be overriden by extending plugin
  886. _mouseStart: function(/* event */) {},
  887. _mouseDrag: function(/* event */) {},
  888. _mouseStop: function(/* event */) {},
  889. _mouseCapture: function(/* event */) { return true; }
  890. });
  891. /*!
  892. * jQuery UI Position 1.11.1
  893. * http://jqueryui.com
  894. *
  895. * Copyright 2014 jQuery Foundation and other contributors
  896. * Released under the MIT license.
  897. * http://jquery.org/license
  898. *
  899. * http://api.jqueryui.com/position/
  900. */
  901. (function() {
  902. $.ui = $.ui || {};
  903. var cachedScrollbarWidth, supportsOffsetFractions,
  904. max = Math.max,
  905. abs = Math.abs,
  906. round = Math.round,
  907. rhorizontal = /left|center|right/,
  908. rvertical = /top|center|bottom/,
  909. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  910. rposition = /^\w+/,
  911. rpercent = /%$/,
  912. _position = $.fn.position;
  913. function getOffsets( offsets, width, height ) {
  914. return [
  915. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  916. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  917. ];
  918. }
  919. function parseCss( element, property ) {
  920. return parseInt( $.css( element, property ), 10 ) || 0;
  921. }
  922. function getDimensions( elem ) {
  923. var raw = elem[0];
  924. if ( raw.nodeType === 9 ) {
  925. return {
  926. width: elem.width(),
  927. height: elem.height(),
  928. offset: { top: 0, left: 0 }
  929. };
  930. }
  931. if ( $.isWindow( raw ) ) {
  932. return {
  933. width: elem.width(),
  934. height: elem.height(),
  935. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  936. };
  937. }
  938. if ( raw.preventDefault ) {
  939. return {
  940. width: 0,
  941. height: 0,
  942. offset: { top: raw.pageY, left: raw.pageX }
  943. };
  944. }
  945. return {
  946. width: elem.outerWidth(),
  947. height: elem.outerHeight(),
  948. offset: elem.offset()
  949. };
  950. }
  951. $.position = {
  952. scrollbarWidth: function() {
  953. if ( cachedScrollbarWidth !== undefined ) {
  954. return cachedScrollbarWidth;
  955. }
  956. var w1, w2,
  957. div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  958. innerDiv = div.children()[0];
  959. $( "body" ).append( div );
  960. w1 = innerDiv.offsetWidth;
  961. div.css( "overflow", "scroll" );
  962. w2 = innerDiv.offsetWidth;
  963. if ( w1 === w2 ) {
  964. w2 = div[0].clientWidth;
  965. }
  966. div.remove();
  967. return (cachedScrollbarWidth = w1 - w2);
  968. },
  969. getScrollInfo: function( within ) {
  970. var overflowX = within.isWindow || within.isDocument ? "" :
  971. within.element.css( "overflow-x" ),
  972. overflowY = within.isWindow || within.isDocument ? "" :
  973. within.element.css( "overflow-y" ),
  974. hasOverflowX = overflowX === "scroll" ||
  975. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  976. hasOverflowY = overflowY === "scroll" ||
  977. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  978. return {
  979. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  980. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  981. };
  982. },
  983. getWithinInfo: function( element ) {
  984. var withinElement = $( element || window ),
  985. isWindow = $.isWindow( withinElement[0] ),
  986. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
  987. return {
  988. element: withinElement,
  989. isWindow: isWindow,
  990. isDocument: isDocument,
  991. offset: withinElement.offset() || { left: 0, top: 0 },
  992. scrollLeft: withinElement.scrollLeft(),
  993. scrollTop: withinElement.scrollTop(),
  994. // support: jQuery 1.6.x
  995. // jQuery 1.6 doesn't support .outerWidth/Height() on documents or windows
  996. width: isWindow || isDocument ? withinElement.width() : withinElement.outerWidth(),
  997. height: isWindow || isDocument ? withinElement.height() : withinElement.outerHeight()
  998. };
  999. }
  1000. };
  1001. $.fn.position = function( options ) {
  1002. if ( !options || !options.of ) {
  1003. return _position.apply( this, arguments );
  1004. }
  1005. // make a copy, we don't want to modify arguments
  1006. options = $.extend( {}, options );
  1007. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  1008. target = $( options.of ),
  1009. within = $.position.getWithinInfo( options.within ),
  1010. scrollInfo = $.position.getScrollInfo( within ),
  1011. collision = ( options.collision || "flip" ).split( " " ),
  1012. offsets = {};
  1013. dimensions = getDimensions( target );
  1014. if ( target[0].preventDefault ) {
  1015. // force left top to allow flipping
  1016. options.at = "left top";
  1017. }
  1018. targetWidth = dimensions.width;
  1019. targetHeight = dimensions.height;
  1020. targetOffset = dimensions.offset;
  1021. // clone to reuse original targetOffset later
  1022. basePosition = $.extend( {}, targetOffset );
  1023. // force my and at to have valid horizontal and vertical positions
  1024. // if a value is missing or invalid, it will be converted to center
  1025. $.each( [ "my", "at" ], function() {
  1026. var pos = ( options[ this ] || "" ).split( " " ),
  1027. horizontalOffset,
  1028. verticalOffset;
  1029. if ( pos.length === 1) {
  1030. pos = rhorizontal.test( pos[ 0 ] ) ?
  1031. pos.concat( [ "center" ] ) :
  1032. rvertical.test( pos[ 0 ] ) ?
  1033. [ "center" ].concat( pos ) :
  1034. [ "center", "center" ];
  1035. }
  1036. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  1037. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  1038. // calculate offsets
  1039. horizontalOffset = roffset.exec( pos[ 0 ] );
  1040. verticalOffset = roffset.exec( pos[ 1 ] );
  1041. offsets[ this ] = [
  1042. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  1043. verticalOffset ? verticalOffset[ 0 ] : 0
  1044. ];
  1045. // reduce to just the positions without the offsets
  1046. options[ this ] = [
  1047. rposition.exec( pos[ 0 ] )[ 0 ],
  1048. rposition.exec( pos[ 1 ] )[ 0 ]
  1049. ];
  1050. });
  1051. // normalize collision option
  1052. if ( collision.length === 1 ) {
  1053. collision[ 1 ] = collision[ 0 ];
  1054. }
  1055. if ( options.at[ 0 ] === "right" ) {
  1056. basePosition.left += targetWidth;
  1057. } else if ( options.at[ 0 ] === "center" ) {
  1058. basePosition.left += targetWidth / 2;
  1059. }
  1060. if ( options.at[ 1 ] === "bottom" ) {
  1061. basePosition.top += targetHeight;
  1062. } else if ( options.at[ 1 ] === "center" ) {
  1063. basePosition.top += targetHeight / 2;
  1064. }
  1065. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  1066. basePosition.left += atOffset[ 0 ];
  1067. basePosition.top += atOffset[ 1 ];
  1068. return this.each(function() {
  1069. var collisionPosition, using,
  1070. elem = $( this ),
  1071. elemWidth = elem.outerWidth(),
  1072. elemHeight = elem.outerHeight(),
  1073. marginLeft = parseCss( this, "marginLeft" ),
  1074. marginTop = parseCss( this, "marginTop" ),
  1075. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  1076. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  1077. position = $.extend( {}, basePosition ),
  1078. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  1079. if ( options.my[ 0 ] === "right" ) {
  1080. position.left -= elemWidth;
  1081. } else if ( options.my[ 0 ] === "center" ) {
  1082. position.left -= elemWidth / 2;
  1083. }
  1084. if ( options.my[ 1 ] === "bottom" ) {
  1085. position.top -= elemHeight;
  1086. } else if ( options.my[ 1 ] === "center" ) {
  1087. position.top -= elemHeight / 2;
  1088. }
  1089. position.left += myOffset[ 0 ];
  1090. position.top += myOffset[ 1 ];
  1091. // if the browser doesn't support fractions, then round for consistent results
  1092. if ( !supportsOffsetFractions ) {
  1093. position.left = round( position.left );
  1094. position.top = round( position.top );
  1095. }
  1096. collisionPosition = {
  1097. marginLeft: marginLeft,
  1098. marginTop: marginTop
  1099. };
  1100. $.each( [ "left", "top" ], function( i, dir ) {
  1101. if ( $.ui.position[ collision[ i ] ] ) {
  1102. $.ui.position[ collision[ i ] ][ dir ]( position, {
  1103. targetWidth: targetWidth,
  1104. targetHeight: targetHeight,
  1105. elemWidth: elemWidth,
  1106. elemHeight: elemHeight,
  1107. collisionPosition: collisionPosition,
  1108. collisionWidth: collisionWidth,
  1109. collisionHeight: collisionHeight,
  1110. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  1111. my: options.my,
  1112. at: options.at,
  1113. within: within,
  1114. elem: elem
  1115. });
  1116. }
  1117. });
  1118. if ( options.using ) {
  1119. // adds feedback as second argument to using callback, if present
  1120. using = function( props ) {
  1121. var left = targetOffset.left - position.left,
  1122. right = left + targetWidth - elemWidth,
  1123. top = targetOffset.top - position.top,
  1124. bottom = top + targetHeight - elemHeight,
  1125. feedback = {
  1126. target: {
  1127. element: target,
  1128. left: targetOffset.left,
  1129. top: targetOffset.top,
  1130. width: targetWidth,
  1131. height: targetHeight
  1132. },
  1133. element: {
  1134. element: elem,
  1135. left: position.left,
  1136. top: position.top,
  1137. width: elemWidth,
  1138. height: elemHeight
  1139. },
  1140. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1141. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1142. };
  1143. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1144. feedback.horizontal = "center";
  1145. }
  1146. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1147. feedback.vertical = "middle";
  1148. }
  1149. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1150. feedback.important = "horizontal";
  1151. } else {
  1152. feedback.important = "vertical";
  1153. }
  1154. options.using.call( this, props, feedback );
  1155. };
  1156. }
  1157. elem.offset( $.extend( position, { using: using } ) );
  1158. });
  1159. };
  1160. $.ui.position = {
  1161. fit: {
  1162. left: function( position, data ) {
  1163. var within = data.within,
  1164. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1165. outerWidth = within.width,
  1166. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1167. overLeft = withinOffset - collisionPosLeft,
  1168. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1169. newOverRight;
  1170. // element is wider than within
  1171. if ( data.collisionWidth > outerWidth ) {
  1172. // element is initially over the left side of within
  1173. if ( overLeft > 0 && overRight <= 0 ) {
  1174. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1175. position.left += overLeft - newOverRight;
  1176. // element is initially over right side of within
  1177. } else if ( overRight > 0 && overLeft <= 0 ) {
  1178. position.left = withinOffset;
  1179. // element is initially over both left and right sides of within
  1180. } else {
  1181. if ( overLeft > overRight ) {
  1182. position.left = withinOffset + outerWidth - data.collisionWidth;
  1183. } else {
  1184. position.left = withinOffset;
  1185. }
  1186. }
  1187. // too far left -> align with left edge
  1188. } else if ( overLeft > 0 ) {
  1189. position.left += overLeft;
  1190. // too far right -> align with right edge
  1191. } else if ( overRight > 0 ) {
  1192. position.left -= overRight;
  1193. // adjust based on position and margin
  1194. } else {
  1195. position.left = max( position.left - collisionPosLeft, position.left );
  1196. }
  1197. },
  1198. top: function( position, data ) {
  1199. var within = data.within,
  1200. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1201. outerHeight = data.within.height,
  1202. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1203. overTop = withinOffset - collisionPosTop,
  1204. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1205. newOverBottom;
  1206. // element is taller than within
  1207. if ( data.collisionHeight > outerHeight ) {
  1208. // element is initially over the top of within
  1209. if ( overTop > 0 && overBottom <= 0 ) {
  1210. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1211. position.top += overTop - newOverBottom;
  1212. // element is initially over bottom of within
  1213. } else if ( overBottom > 0 && overTop <= 0 ) {
  1214. position.top = withinOffset;
  1215. // element is initially over both top and bottom of within
  1216. } else {
  1217. if ( overTop > overBottom ) {
  1218. position.top = withinOffset + outerHeight - data.collisionHeight;
  1219. } else {
  1220. position.top = withinOffset;
  1221. }
  1222. }
  1223. // too far up -> align with top
  1224. } else if ( overTop > 0 ) {
  1225. position.top += overTop;
  1226. // too far down -> align with bottom edge
  1227. } else if ( overBottom > 0 ) {
  1228. position.top -= overBottom;
  1229. // adjust based on position and margin
  1230. } else {
  1231. position.top = max( position.top - collisionPosTop, position.top );
  1232. }
  1233. }
  1234. },
  1235. flip: {
  1236. left: function( position, data ) {
  1237. var within = data.within,
  1238. withinOffset = within.offset.left + within.scrollLeft,
  1239. outerWidth = within.width,
  1240. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1241. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1242. overLeft = collisionPosLeft - offsetLeft,
  1243. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1244. myOffset = data.my[ 0 ] === "left" ?
  1245. -data.elemWidth :
  1246. data.my[ 0 ] === "right" ?
  1247. data.elemWidth :
  1248. 0,
  1249. atOffset = data.at[ 0 ] === "left" ?
  1250. data.targetWidth :
  1251. data.at[ 0 ] === "right" ?
  1252. -data.targetWidth :
  1253. 0,
  1254. offset = -2 * data.offset[ 0 ],
  1255. newOverRight,
  1256. newOverLeft;
  1257. if ( overLeft < 0 ) {
  1258. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1259. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1260. position.left += myOffset + atOffset + offset;
  1261. }
  1262. } else if ( overRight > 0 ) {
  1263. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1264. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1265. position.left += myOffset + atOffset + offset;
  1266. }
  1267. }
  1268. },
  1269. top: function( position, data ) {
  1270. var within = data.within,
  1271. withinOffset = within.offset.top + within.scrollTop,
  1272. outerHeight = within.height,
  1273. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1274. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1275. overTop = collisionPosTop - offsetTop,
  1276. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1277. top = data.my[ 1 ] === "top",
  1278. myOffset = top ?
  1279. -data.elemHeight :
  1280. data.my[ 1 ] === "bottom" ?
  1281. data.elemHeight :
  1282. 0,
  1283. atOffset = data.at[ 1 ] === "top" ?
  1284. data.targetHeight :
  1285. data.at[ 1 ] === "bottom" ?
  1286. -data.targetHeight :
  1287. 0,
  1288. offset = -2 * data.offset[ 1 ],
  1289. newOverTop,
  1290. newOverBottom;
  1291. if ( overTop < 0 ) {
  1292. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1293. if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
  1294. position.top += myOffset + atOffset + offset;
  1295. }
  1296. } else if ( overBottom > 0 ) {
  1297. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1298. if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
  1299. position.top += myOffset + atOffset + offset;
  1300. }
  1301. }
  1302. }
  1303. },
  1304. flipfit: {
  1305. left: function() {
  1306. $.ui.position.flip.left.apply( this, arguments );
  1307. $.ui.position.fit.left.apply( this, arguments );
  1308. },
  1309. top: function() {
  1310. $.ui.position.flip.top.apply( this, arguments );
  1311. $.ui.position.fit.top.apply( this, arguments );
  1312. }
  1313. }
  1314. };
  1315. // fraction support test
  1316. (function() {
  1317. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1318. body = document.getElementsByTagName( "body" )[ 0 ],
  1319. div = document.createElement( "div" );
  1320. //Create a "fake body" for testing based on method used in jQuery.support
  1321. testElement = document.createElement( body ? "div" : "body" );
  1322. testElementStyle = {
  1323. visibility: "hidden",
  1324. width: 0,
  1325. height: 0,
  1326. border: 0,
  1327. margin: 0,
  1328. background: "none"
  1329. };
  1330. if ( body ) {
  1331. $.extend( testElementStyle, {
  1332. position: "absolute",
  1333. left: "-1000px",
  1334. top: "-1000px"
  1335. });
  1336. }
  1337. for ( i in testElementStyle ) {
  1338. testElement.style[ i ] = testElementStyle[ i ];
  1339. }
  1340. testElement.appendChild( div );
  1341. testElementParent = body || document.documentElement;
  1342. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1343. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1344. offsetLeft = $( div ).offset().left;
  1345. supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1346. testElement.innerHTML = "";
  1347. testElementParent.removeChild( testElement );
  1348. })();
  1349. })();
  1350. var position = $.ui.position;
  1351. /*!
  1352. * jQuery UI Accordion 1.11.1
  1353. * http://jqueryui.com
  1354. *
  1355. * Copyright 2014 jQuery Foundation and other contributors
  1356. * Released under the MIT license.
  1357. * http://jquery.org/license
  1358. *
  1359. * http://api.jqueryui.com/accordion/
  1360. */
  1361. var accordion = $.widget( "ui.accordion", {
  1362. version: "1.11.1",
  1363. options: {
  1364. active: 0,
  1365. animate: {},
  1366. collapsible: false,
  1367. event: "click",
  1368. header: "> li > :first-child,> :not(li):even",
  1369. heightStyle: "auto",
  1370. icons: {
  1371. activeHeader: "ui-icon-triangle-1-s",
  1372. header: "ui-icon-triangle-1-e"
  1373. },
  1374. // callbacks
  1375. activate: null,
  1376. beforeActivate: null
  1377. },
  1378. hideProps: {
  1379. borderTopWidth: "hide",
  1380. borderBottomWidth: "hide",
  1381. paddingTop: "hide",
  1382. paddingBottom: "hide",
  1383. height: "hide"
  1384. },
  1385. showProps: {
  1386. borderTopWidth: "show",
  1387. borderBottomWidth: "show",
  1388. paddingTop: "show",
  1389. paddingBottom: "show",
  1390. height: "show"
  1391. },
  1392. _create: function() {
  1393. var options = this.options;
  1394. this.prevShow = this.prevHide = $();
  1395. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  1396. // ARIA
  1397. .attr( "role", "tablist" );
  1398. // don't allow collapsible: false and active: false / null
  1399. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  1400. options.active = 0;
  1401. }
  1402. this._processPanels();
  1403. // handle negative values
  1404. if ( options.active < 0 ) {
  1405. options.active += this.headers.length;
  1406. }
  1407. this._refresh();
  1408. },
  1409. _getCreateEventData: function() {
  1410. return {
  1411. header: this.active,
  1412. panel: !this.active.length ? $() : this.active.next()
  1413. };
  1414. },
  1415. _createIcons: function() {
  1416. var icons = this.options.icons;
  1417. if ( icons ) {
  1418. $( "<span>" )
  1419. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  1420. .prependTo( this.headers );
  1421. this.active.children( ".ui-accordion-header-icon" )
  1422. .removeClass( icons.header )
  1423. .addClass( icons.activeHeader );
  1424. this.headers.addClass( "ui-accordion-icons" );
  1425. }
  1426. },
  1427. _destroyIcons: function() {
  1428. this.headers
  1429. .removeClass( "ui-accordion-icons" )
  1430. .children( ".ui-accordion-header-icon" )
  1431. .remove();
  1432. },
  1433. _destroy: function() {
  1434. var contents;
  1435. // clean up main element
  1436. this.element
  1437. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  1438. .removeAttr( "role" );
  1439. // clean up headers
  1440. this.headers
  1441. .removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " +
  1442. "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
  1443. .removeAttr( "role" )
  1444. .removeAttr( "aria-expanded" )
  1445. .removeAttr( "aria-selected" )
  1446. .removeAttr( "aria-controls" )
  1447. .removeAttr( "tabIndex" )
  1448. .removeUniqueId();
  1449. this._destroyIcons();
  1450. // clean up content panels
  1451. contents = this.headers.next()
  1452. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " +
  1453. "ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  1454. .css( "display", "" )
  1455. .removeAttr( "role" )
  1456. .removeAttr( "aria-hidden" )
  1457. .removeAttr( "aria-labelledby" )
  1458. .removeUniqueId();
  1459. if ( this.options.heightStyle !== "content" ) {
  1460. contents.css( "height", "" );
  1461. }
  1462. },
  1463. _setOption: function( key, value ) {
  1464. if ( key === "active" ) {
  1465. // _activate() will handle invalid values and update this.options
  1466. this._activate( value );
  1467. return;
  1468. }
  1469. if ( key === "event" ) {
  1470. if ( this.options.event ) {
  1471. this._off( this.headers, this.options.event );
  1472. }
  1473. this._setupEvents( value );
  1474. }
  1475. this._super( key, value );
  1476. // setting collapsible: false while collapsed; open first panel
  1477. if ( key === "collapsible" && !value && this.options.active === false ) {
  1478. this._activate( 0 );
  1479. }
  1480. if ( key === "icons" ) {
  1481. this._destroyIcons();
  1482. if ( value ) {
  1483. this._createIcons();
  1484. }
  1485. }
  1486. // #5332 - opacity doesn't cascade to positioned elements in IE
  1487. // so we need to add the disabled class to the headers and panels
  1488. if ( key === "disabled" ) {
  1489. this.element
  1490. .toggleClass( "ui-state-disabled", !!value )
  1491. .attr( "aria-disabled", value );
  1492. this.headers.add( this.headers.next() )
  1493. .toggleClass( "ui-state-disabled", !!value );
  1494. }
  1495. },
  1496. _keydown: function( event ) {
  1497. if ( event.altKey || event.ctrlKey ) {
  1498. return;
  1499. }
  1500. var keyCode = $.ui.keyCode,
  1501. length = this.headers.length,
  1502. currentIndex = this.headers.index( event.target ),
  1503. toFocus = false;
  1504. switch ( event.keyCode ) {
  1505. case keyCode.RIGHT:
  1506. case keyCode.DOWN:
  1507. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  1508. break;
  1509. case keyCode.LEFT:
  1510. case keyCode.UP:
  1511. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  1512. break;
  1513. case keyCode.SPACE:
  1514. case keyCode.ENTER:
  1515. this._eventHandler( event );
  1516. break;
  1517. case keyCode.HOME:
  1518. toFocus = this.headers[ 0 ];
  1519. break;
  1520. case keyCode.END:
  1521. toFocus = this.headers[ length - 1 ];
  1522. break;
  1523. }
  1524. if ( toFocus ) {
  1525. $( event.target ).attr( "tabIndex", -1 );
  1526. $( toFocus ).attr( "tabIndex", 0 );
  1527. toFocus.focus();
  1528. event.preventDefault();
  1529. }
  1530. },
  1531. _panelKeyDown: function( event ) {
  1532. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  1533. $( event.currentTarget ).prev().focus();
  1534. }
  1535. },
  1536. refresh: function() {
  1537. var options = this.options;
  1538. this._processPanels();
  1539. // was collapsed or no panel
  1540. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  1541. options.active = false;
  1542. this.active = $();
  1543. // active false only when collapsible is true
  1544. } else if ( options.active === false ) {
  1545. this._activate( 0 );
  1546. // was active, but active panel is gone
  1547. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  1548. // all remaining panel are disabled
  1549. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  1550. options.active = false;
  1551. this.active = $();
  1552. // activate previous panel
  1553. } else {
  1554. this._activate( Math.max( 0, options.active - 1 ) );
  1555. }
  1556. // was active, active panel still exists
  1557. } else {
  1558. // make sure active index is correct
  1559. options.active = this.headers.index( this.active );
  1560. }
  1561. this._destroyIcons();
  1562. this._refresh();
  1563. },
  1564. _processPanels: function() {
  1565. this.headers = this.element.find( this.options.header )
  1566. .addClass( "ui-accordion-header ui-state-default ui-corner-all" );
  1567. this.headers.next()
  1568. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  1569. .filter( ":not(.ui-accordion-content-active)" )
  1570. .hide();
  1571. },
  1572. _refresh: function() {
  1573. var maxHeight,
  1574. options = this.options,
  1575. heightStyle = options.heightStyle,
  1576. parent = this.element.parent();
  1577. this.active = this._findActive( options.active )
  1578. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  1579. .removeClass( "ui-corner-all" );
  1580. this.active.next()
  1581. .addClass( "ui-accordion-content-active" )
  1582. .show();
  1583. this.headers
  1584. .attr( "role", "tab" )
  1585. .each(function() {
  1586. var header = $( this ),
  1587. headerId = header.uniqueId().attr( "id" ),
  1588. panel = header.next(),
  1589. panelId = panel.uniqueId().attr( "id" );
  1590. header.attr( "aria-controls", panelId );
  1591. panel.attr( "aria-labelledby", headerId );
  1592. })
  1593. .next()
  1594. .attr( "role", "tabpanel" );
  1595. this.headers
  1596. .not( this.active )
  1597. .attr({
  1598. "aria-selected": "false",
  1599. "aria-expanded": "false",
  1600. tabIndex: -1
  1601. })
  1602. .next()
  1603. .attr({
  1604. "aria-hidden": "true"
  1605. })
  1606. .hide();
  1607. // make sure at least one header is in the tab order
  1608. if ( !this.active.length ) {
  1609. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  1610. } else {
  1611. this.active.attr({
  1612. "aria-selected": "true",
  1613. "aria-expanded": "true",
  1614. tabIndex: 0
  1615. })
  1616. .next()
  1617. .attr({
  1618. "aria-hidden": "false"
  1619. });
  1620. }
  1621. this._createIcons();
  1622. this._setupEvents( options.event );
  1623. if ( heightStyle === "fill" ) {
  1624. maxHeight = parent.height();
  1625. this.element.siblings( ":visible" ).each(function() {
  1626. var elem = $( this ),
  1627. position = elem.css( "position" );
  1628. if ( position === "absolute" || position === "fixed" ) {
  1629. return;
  1630. }
  1631. maxHeight -= elem.outerHeight( true );
  1632. });
  1633. this.headers.each(function() {
  1634. maxHeight -= $( this ).outerHeight( true );
  1635. });
  1636. this.headers.next()
  1637. .each(function() {
  1638. $( this ).height( Math.max( 0, maxHeight -
  1639. $( this ).innerHeight() + $( this ).height() ) );
  1640. })
  1641. .css( "overflow", "auto" );
  1642. } else if ( heightStyle === "auto" ) {
  1643. maxHeight = 0;
  1644. this.headers.next()
  1645. .each(function() {
  1646. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  1647. })
  1648. .height( maxHeight );
  1649. }
  1650. },
  1651. _activate: function( index ) {
  1652. var active = this._findActive( index )[ 0 ];
  1653. // trying to activate the already active panel
  1654. if ( active === this.active[ 0 ] ) {
  1655. return;
  1656. }
  1657. // trying to collapse, simulate a click on the currently active header
  1658. active = active || this.active[ 0 ];
  1659. this._eventHandler({
  1660. target: active,
  1661. currentTarget: active,
  1662. preventDefault: $.noop
  1663. });
  1664. },
  1665. _findActive: function( selector ) {
  1666. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  1667. },
  1668. _setupEvents: function( event ) {
  1669. var events = {
  1670. keydown: "_keydown"
  1671. };
  1672. if ( event ) {
  1673. $.each( event.split( " " ), function( index, eventName ) {
  1674. events[ eventName ] = "_eventHandler";
  1675. });
  1676. }
  1677. this._off( this.headers.add( this.headers.next() ) );
  1678. this._on( this.headers, events );
  1679. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  1680. this._hoverable( this.headers );
  1681. this._focusable( this.headers );
  1682. },
  1683. _eventHandler: function( event ) {
  1684. var options = this.options,
  1685. active = this.active,
  1686. clicked = $( event.currentTarget ),
  1687. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  1688. collapsing = clickedIsActive && options.collapsible,
  1689. toShow = collapsing ? $() : clicked.next(),
  1690. toHide = active.next(),
  1691. eventData = {
  1692. oldHeader: active,
  1693. oldPanel: toHide,
  1694. newHeader: collapsing ? $() : clicked,
  1695. newPanel: toShow
  1696. };
  1697. event.preventDefault();
  1698. if (
  1699. // click on active header, but not collapsible
  1700. ( clickedIsActive && !options.collapsible ) ||
  1701. // allow canceling activation
  1702. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  1703. return;
  1704. }
  1705. options.active = collapsing ? false : this.headers.index( clicked );
  1706. // when the call to ._toggle() comes after the class changes
  1707. // it causes a very odd bug in IE 8 (see #6720)
  1708. this.active = clickedIsActive ? $() : clicked;
  1709. this._toggle( eventData );
  1710. // switch classes
  1711. // corner classes on the previously active header stay after the animation
  1712. active.removeClass( "ui-accordion-header-active ui-state-active" );
  1713. if ( options.icons ) {
  1714. active.children( ".ui-accordion-header-icon" )
  1715. .removeClass( options.icons.activeHeader )
  1716. .addClass( options.icons.header );
  1717. }
  1718. if ( !clickedIsActive ) {
  1719. clicked
  1720. .removeClass( "ui-corner-all" )
  1721. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  1722. if ( options.icons ) {
  1723. clicked.children( ".ui-accordion-header-icon" )
  1724. .removeClass( options.icons.header )
  1725. .addClass( options.icons.activeHeader );
  1726. }
  1727. clicked
  1728. .next()
  1729. .addClass( "ui-accordion-content-active" );
  1730. }
  1731. },
  1732. _toggle: function( data ) {
  1733. var toShow = data.newPanel,
  1734. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  1735. // handle activating a panel during the animation for another activation
  1736. this.prevShow.add( this.prevHide ).stop( true, true );
  1737. this.prevShow = toShow;
  1738. this.prevHide = toHide;
  1739. if ( this.options.animate ) {
  1740. this._animate( toShow, toHide, data );
  1741. } else {
  1742. toHide.hide();
  1743. toShow.show();
  1744. this._toggleComplete( data );
  1745. }
  1746. toHide.attr({
  1747. "aria-hidden": "true"
  1748. });
  1749. toHide.prev().attr( "aria-selected", "false" );
  1750. // if we're switching panels, remove the old header from the tab order
  1751. // if we're opening from collapsed state, remove the previous header from the tab order
  1752. // if we're collapsing, then keep the collapsing header in the tab order
  1753. if ( toShow.length && toHide.length ) {
  1754. toHide.prev().attr({
  1755. "tabIndex": -1,
  1756. "aria-expanded": "false"
  1757. });
  1758. } else if ( toShow.length ) {
  1759. this.headers.filter(function() {
  1760. return $( this ).attr( "tabIndex" ) === 0;
  1761. })
  1762. .attr( "tabIndex", -1 );
  1763. }
  1764. toShow
  1765. .attr( "aria-hidden", "false" )
  1766. .prev()
  1767. .attr({
  1768. "aria-selected": "true",
  1769. tabIndex: 0,
  1770. "aria-expanded": "true"
  1771. });
  1772. },
  1773. _animate: function( toShow, toHide, data ) {
  1774. var total, easing, duration,
  1775. that = this,
  1776. adjust = 0,
  1777. down = toShow.length &&
  1778. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  1779. animate = this.options.animate || {},
  1780. options = down && animate.down || animate,
  1781. complete = function() {
  1782. that._toggleComplete( data );
  1783. };
  1784. if ( typeof options === "number" ) {
  1785. duration = options;
  1786. }
  1787. if ( typeof options === "string" ) {
  1788. easing = options;
  1789. }
  1790. // fall back from options to animation in case of partial down settings
  1791. easing = easing || options.easing || animate.easing;
  1792. duration = duration || options.duration || animate.duration;
  1793. if ( !toHide.length ) {
  1794. return toShow.animate( this.showProps, duration, easing, complete );
  1795. }
  1796. if ( !toShow.length ) {
  1797. return toHide.animate( this.hideProps, duration, easing, complete );
  1798. }
  1799. total = toShow.show().outerHeight();
  1800. toHide.animate( this.hideProps, {
  1801. duration: duration,
  1802. easing: easing,
  1803. step: function( now, fx ) {
  1804. fx.now = Math.round( now );
  1805. }
  1806. });
  1807. toShow
  1808. .hide()
  1809. .animate( this.showProps, {
  1810. duration: duration,
  1811. easing: easing,
  1812. complete: complete,
  1813. step: function( now, fx ) {
  1814. fx.now = Math.round( now );
  1815. if ( fx.prop !== "height" ) {
  1816. adjust += fx.now;
  1817. } else if ( that.options.heightStyle !== "content" ) {
  1818. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  1819. adjust = 0;
  1820. }
  1821. }
  1822. });
  1823. },
  1824. _toggleComplete: function( data ) {
  1825. var toHide = data.oldPanel;
  1826. toHide
  1827. .removeClass( "ui-accordion-content-active" )
  1828. .prev()
  1829. .removeClass( "ui-corner-top" )
  1830. .addClass( "ui-corner-all" );
  1831. // Work around for rendering bug in IE (#5421)
  1832. if ( toHide.length ) {
  1833. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  1834. }
  1835. this._trigger( "activate", null, data );
  1836. }
  1837. });
  1838. /*!
  1839. * jQuery UI Menu 1.11.1
  1840. * http://jqueryui.com
  1841. *
  1842. * Copyright 2014 jQuery Foundation and other contributors
  1843. * Released under the MIT license.
  1844. * http://jquery.org/license
  1845. *
  1846. * http://api.jqueryui.com/menu/
  1847. */
  1848. var menu = $.widget( "ui.menu", {
  1849. version: "1.11.1",
  1850. defaultElement: "<ul>",
  1851. delay: 300,
  1852. options: {
  1853. icons: {
  1854. submenu: "ui-icon-carat-1-e"
  1855. },
  1856. items: "> *",
  1857. menus: "ul",
  1858. position: {
  1859. my: "left-1 top",
  1860. at: "right top"
  1861. },
  1862. role: "menu",
  1863. // callbacks
  1864. blur: null,
  1865. focus: null,
  1866. select: null
  1867. },
  1868. _create: function() {
  1869. this.activeMenu = this.element;
  1870. // Flag used to prevent firing of the click handler
  1871. // as the event bubbles up through nested menus
  1872. this.mouseHandled = false;
  1873. this.element
  1874. .uniqueId()
  1875. .addClass( "ui-menu ui-widget ui-widget-content" )
  1876. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  1877. .attr({
  1878. role: this.options.role,
  1879. tabIndex: 0
  1880. });
  1881. if ( this.options.disabled ) {
  1882. this.element
  1883. .addClass( "ui-state-disabled" )
  1884. .attr( "aria-disabled", "true" );
  1885. }
  1886. this._on({
  1887. // Prevent focus from sticking to links inside menu after clicking
  1888. // them (focus should always stay on UL during navigation).
  1889. "mousedown .ui-menu-item": function( event ) {
  1890. event.preventDefault();
  1891. },
  1892. "click .ui-menu-item": function( event ) {
  1893. var target = $( event.target );
  1894. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  1895. this.select( event );
  1896. // Only set the mouseHandled flag if the event will bubble, see #9469.
  1897. if ( !event.isPropagationStopped() ) {
  1898. this.mouseHandled = true;
  1899. }
  1900. // Open submenu on click
  1901. if ( target.has( ".ui-menu" ).length ) {
  1902. this.expand( event );
  1903. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  1904. // Redirect focus to the menu
  1905. this.element.trigger( "focus", [ true ] );
  1906. // If the active item is on the top level, let it stay active.
  1907. // Otherwise, blur the active item since it is no longer visible.
  1908. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  1909. clearTimeout( this.timer );
  1910. }
  1911. }
  1912. }
  1913. },
  1914. "mouseenter .ui-menu-item": function( event ) {
  1915. var target = $( event.currentTarget );
  1916. // Remove ui-state-active class from siblings of the newly focused menu item
  1917. // to avoid a jump caused by adjacent elements both having a class with a border
  1918. target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
  1919. this.focus( event, target );
  1920. },
  1921. mouseleave: "collapseAll",
  1922. "mouseleave .ui-menu": "collapseAll",
  1923. focus: function( event, keepActiveItem ) {
  1924. // If there's already an active item, keep it active
  1925. // If not, activate the first item
  1926. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  1927. if ( !keepActiveItem ) {
  1928. this.focus( event, item );
  1929. }
  1930. },
  1931. blur: function( event ) {
  1932. this._delay(function() {
  1933. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  1934. this.collapseAll( event );
  1935. }
  1936. });
  1937. },
  1938. keydown: "_keydown"
  1939. });
  1940. this.refresh();
  1941. // Clicks outside of a menu collapse any open menus
  1942. this._on( this.document, {
  1943. click: function( event ) {
  1944. if ( this._closeOnDocumentClick( event ) ) {
  1945. this.collapseAll( event );
  1946. }
  1947. // Reset the mouseHandled flag
  1948. this.mouseHandled = false;
  1949. }
  1950. });
  1951. },
  1952. _destroy: function() {
  1953. // Destroy (sub)menus
  1954. this.element
  1955. .removeAttr( "aria-activedescendant" )
  1956. .find( ".ui-menu" ).addBack()
  1957. .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
  1958. .removeAttr( "role" )
  1959. .removeAttr( "tabIndex" )
  1960. .removeAttr( "aria-labelledby" )
  1961. .removeAttr( "aria-expanded" )
  1962. .removeAttr( "aria-hidden" )
  1963. .removeAttr( "aria-disabled" )
  1964. .removeUniqueId()
  1965. .show();
  1966. // Destroy menu items
  1967. this.element.find( ".ui-menu-item" )
  1968. .removeClass( "ui-menu-item" )
  1969. .removeAttr( "role" )
  1970. .removeAttr( "aria-disabled" )
  1971. .removeUniqueId()
  1972. .removeClass( "ui-state-hover" )
  1973. .removeAttr( "tabIndex" )
  1974. .removeAttr( "role" )
  1975. .removeAttr( "aria-haspopup" )
  1976. .children().each( function() {
  1977. var elem = $( this );
  1978. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  1979. elem.remove();
  1980. }
  1981. });
  1982. // Destroy menu dividers
  1983. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  1984. },
  1985. _keydown: function( event ) {
  1986. var match, prev, character, skip, regex,
  1987. preventDefault = true;
  1988. function escape( value ) {
  1989. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  1990. }
  1991. switch ( event.keyCode ) {
  1992. case $.ui.keyCode.PAGE_UP:
  1993. this.previousPage( event );
  1994. break;
  1995. case $.ui.keyCode.PAGE_DOWN:
  1996. this.nextPage( event );
  1997. break;
  1998. case $.ui.keyCode.HOME:
  1999. this._move( "first", "first", event );
  2000. break;
  2001. case $.ui.keyCode.END:
  2002. this._move( "last", "last", event );
  2003. break;
  2004. case $.ui.keyCode.UP:
  2005. this.previous( event );
  2006. break;
  2007. case $.ui.keyCode.DOWN:
  2008. this.next( event );
  2009. break;
  2010. case $.ui.keyCode.LEFT:
  2011. this.collapse( event );
  2012. break;
  2013. case $.ui.keyCode.RIGHT:
  2014. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  2015. this.expand( event );
  2016. }
  2017. break;
  2018. case $.ui.keyCode.ENTER:
  2019. case $.ui.keyCode.SPACE:
  2020. this._activate( event );
  2021. break;
  2022. case $.ui.keyCode.ESCAPE:
  2023. this.collapse( event );
  2024. break;
  2025. default:
  2026. preventDefault = false;
  2027. prev = this.previousFilter || "";
  2028. character = String.fromCharCode( event.keyCode );
  2029. skip = false;
  2030. clearTimeout( this.filterTimer );
  2031. if ( character === prev ) {
  2032. skip = true;
  2033. } else {
  2034. character = prev + character;
  2035. }
  2036. regex = new RegExp( "^" + escape( character ), "i" );
  2037. match = this.activeMenu.find( this.options.items ).filter(function() {
  2038. return regex.test( $( this ).text() );
  2039. });
  2040. match = skip && match.index( this.active.next() ) !== -1 ?
  2041. this.active.nextAll( ".ui-menu-item" ) :
  2042. match;
  2043. // If no matches on the current filter, reset to the last character pressed
  2044. // to move down the menu to the first item that starts with that character
  2045. if ( !match.length ) {
  2046. character = String.fromCharCode( event.keyCode );
  2047. regex = new RegExp( "^" + escape( character ), "i" );
  2048. match = this.activeMenu.find( this.options.items ).filter(function() {
  2049. return regex.test( $( this ).text() );
  2050. });
  2051. }
  2052. if ( match.length ) {
  2053. this.focus( event, match );
  2054. if ( match.length > 1 ) {
  2055. this.previousFilter = character;
  2056. this.filterTimer = this._delay(function() {
  2057. delete this.previousFilter;
  2058. }, 1000 );
  2059. } else {
  2060. delete this.previousFilter;
  2061. }
  2062. } else {
  2063. delete this.previousFilter;
  2064. }
  2065. }
  2066. if ( preventDefault ) {
  2067. event.preventDefault();
  2068. }
  2069. },
  2070. _activate: function( event ) {
  2071. if ( !this.active.is( ".ui-state-disabled" ) ) {
  2072. if ( this.active.is( "[aria-haspopup='true']" ) ) {
  2073. this.expand( event );
  2074. } else {
  2075. this.select( event );
  2076. }
  2077. }
  2078. },
  2079. refresh: function() {
  2080. var menus, items,
  2081. that = this,
  2082. icon = this.options.icons.submenu,
  2083. submenus = this.element.find( this.options.menus );
  2084. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  2085. // Initialize nested menus
  2086. submenus.filter( ":not(.ui-menu)" )
  2087. .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
  2088. .hide()
  2089. .attr({
  2090. role: this.options.role,
  2091. "aria-hidden": "true",
  2092. "aria-expanded": "false"
  2093. })
  2094. .each(function() {
  2095. var menu = $( this ),
  2096. item = menu.parent(),
  2097. submenuCarat = $( "<span>" )
  2098. .addClass( "ui-menu-icon ui-icon " + icon )
  2099. .data( "ui-menu-submenu-carat", true );
  2100. item
  2101. .attr( "aria-haspopup", "true" )
  2102. .prepend( submenuCarat );
  2103. menu.attr( "aria-labelledby", item.attr( "id" ) );
  2104. });
  2105. menus = submenus.add( this.element );
  2106. items = menus.find( this.options.items );
  2107. // Initialize menu-items containing spaces and/or dashes only as dividers
  2108. items.not( ".ui-menu-item" ).each(function() {
  2109. var item = $( this );
  2110. if ( that._isDivider( item ) ) {
  2111. item.addClass( "ui-widget-content ui-menu-divider" );
  2112. }
  2113. });
  2114. // Don't refresh list items that are already adapted
  2115. items.not( ".ui-menu-item, .ui-menu-divider" )
  2116. .addClass( "ui-menu-item" )
  2117. .uniqueId()
  2118. .attr({
  2119. tabIndex: -1,
  2120. role: this._itemRole()
  2121. });
  2122. // Add aria-disabled attribute to any disabled menu item
  2123. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  2124. // If the active item has been removed, blur the menu
  2125. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  2126. this.blur();
  2127. }
  2128. },
  2129. _itemRole: function() {
  2130. return {
  2131. menu: "menuitem",
  2132. listbox: "option"
  2133. }[ this.options.role ];
  2134. },
  2135. _setOption: function( key, value ) {
  2136. if ( key === "icons" ) {
  2137. this.element.find( ".ui-menu-icon" )
  2138. .removeClass( this.options.icons.submenu )
  2139. .addClass( value.submenu );
  2140. }
  2141. if ( key === "disabled" ) {
  2142. this.element
  2143. .toggleClass( "ui-state-disabled", !!value )
  2144. .attr( "aria-disabled", value );
  2145. }
  2146. this._super( key, value );
  2147. },
  2148. focus: function( event, item ) {
  2149. var nested, focused;
  2150. this.blur( event, event && event.type === "focus" );
  2151. this._scrollIntoView( item );
  2152. this.active = item.first();
  2153. focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
  2154. // Only update aria-activedescendant if there's a role
  2155. // otherwise we assume focus is managed elsewhere
  2156. if ( this.options.role ) {
  2157. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  2158. }
  2159. // Highlight active parent menu item, if any
  2160. this.active
  2161. .parent()
  2162. .closest( ".ui-menu-item" )
  2163. .addClass( "ui-state-active" );
  2164. if ( event && event.type === "keydown" ) {
  2165. this._close();
  2166. } else {
  2167. this.timer = this._delay(function() {
  2168. this._close();
  2169. }, this.delay );
  2170. }
  2171. nested = item.children( ".ui-menu" );
  2172. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  2173. this._startOpening(nested);
  2174. }
  2175. this.activeMenu = item.parent();
  2176. this._trigger( "focus", event, { item: item } );
  2177. },
  2178. _scrollIntoView: function( item ) {
  2179. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  2180. if ( this._hasScroll() ) {
  2181. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  2182. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  2183. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  2184. scroll = this.activeMenu.scrollTop();
  2185. elementHeight = this.activeMenu.height();
  2186. itemHeight = item.outerHeight();
  2187. if ( offset < 0 ) {
  2188. this.activeMenu.scrollTop( scroll + offset );
  2189. } else if ( offset + itemHeight > elementHeight ) {
  2190. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  2191. }
  2192. }
  2193. },
  2194. blur: function( event, fromFocus ) {
  2195. if ( !fromFocus ) {
  2196. clearTimeout( this.timer );
  2197. }
  2198. if ( !this.active ) {
  2199. return;
  2200. }
  2201. this.active.removeClass( "ui-state-focus" );
  2202. this.active = null;
  2203. this._trigger( "blur", event, { item: this.active } );
  2204. },
  2205. _startOpening: function( submenu ) {
  2206. clearTimeout( this.timer );
  2207. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  2208. // shift in the submenu position when mousing over the carat icon
  2209. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  2210. return;
  2211. }
  2212. this.timer = this._delay(function() {
  2213. this._close();
  2214. this._open( submenu );
  2215. }, this.delay );
  2216. },
  2217. _open: function( submenu ) {
  2218. var position = $.extend({
  2219. of: this.active
  2220. }, this.options.position );
  2221. clearTimeout( this.timer );
  2222. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  2223. .hide()
  2224. .attr( "aria-hidden", "true" );
  2225. submenu
  2226. .show()
  2227. .removeAttr( "aria-hidden" )
  2228. .attr( "aria-expanded", "true" )
  2229. .position( position );
  2230. },
  2231. collapseAll: function( event, all ) {
  2232. clearTimeout( this.timer );
  2233. this.timer = this._delay(function() {
  2234. // If we were passed an event, look for the submenu that contains the event
  2235. var currentMenu = all ? this.element :
  2236. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  2237. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  2238. if ( !currentMenu.length ) {
  2239. currentMenu = this.element;
  2240. }
  2241. this._close( currentMenu );
  2242. this.blur( event );
  2243. this.activeMenu = currentMenu;
  2244. }, this.delay );
  2245. },
  2246. // With no arguments, closes the currently active menu - if nothing is active
  2247. // it closes all menus. If passed an argument, it will search for menus BELOW
  2248. _close: function( startMenu ) {
  2249. if ( !startMenu ) {
  2250. startMenu = this.active ? this.active.parent() : this.element;
  2251. }
  2252. startMenu
  2253. .find( ".ui-menu" )
  2254. .hide()
  2255. .attr( "aria-hidden", "true" )
  2256. .attr( "aria-expanded", "false" )
  2257. .end()
  2258. .find( ".ui-state-active" ).not( ".ui-state-focus" )
  2259. .removeClass( "ui-state-active" );
  2260. },
  2261. _closeOnDocumentClick: function( event ) {
  2262. return !$( event.target ).closest( ".ui-menu" ).length;
  2263. },
  2264. _isDivider: function( item ) {
  2265. // Match hyphen, em dash, en dash
  2266. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  2267. },
  2268. collapse: function( event ) {
  2269. var newItem = this.active &&
  2270. this.active.parent().closest( ".ui-menu-item", this.element );
  2271. if ( newItem && newItem.length ) {
  2272. this._close();
  2273. this.focus( event, newItem );
  2274. }
  2275. },
  2276. expand: function( event ) {
  2277. var newItem = this.active &&
  2278. this.active
  2279. .children( ".ui-menu " )
  2280. .find( this.options.items )
  2281. .first();
  2282. if ( newItem && newItem.length ) {
  2283. this._open( newItem.parent() );
  2284. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  2285. this._delay(function() {
  2286. this.focus( event, newItem );
  2287. });
  2288. }
  2289. },
  2290. next: function( event ) {
  2291. this._move( "next", "first", event );
  2292. },
  2293. previous: function( event ) {
  2294. this._move( "prev", "last", event );
  2295. },
  2296. isFirstItem: function() {
  2297. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  2298. },
  2299. isLastItem: function() {
  2300. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  2301. },
  2302. _move: function( direction, filter, event ) {
  2303. var next;
  2304. if ( this.active ) {
  2305. if ( direction === "first" || direction === "last" ) {
  2306. next = this.active
  2307. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  2308. .eq( -1 );
  2309. } else {
  2310. next = this.active
  2311. [ direction + "All" ]( ".ui-menu-item" )
  2312. .eq( 0 );
  2313. }
  2314. }
  2315. if ( !next || !next.length || !this.active ) {
  2316. next = this.activeMenu.find( this.options.items )[ filter ]();
  2317. }
  2318. this.focus( event, next );
  2319. },
  2320. nextPage: function( event ) {
  2321. var item, base, height;
  2322. if ( !this.active ) {
  2323. this.next( event );
  2324. return;
  2325. }
  2326. if ( this.isLastItem() ) {
  2327. return;
  2328. }
  2329. if ( this._hasScroll() ) {
  2330. base = this.active.offset().top;
  2331. height = this.element.height();
  2332. this.active.nextAll( ".ui-menu-item" ).each(function() {
  2333. item = $( this );
  2334. return item.offset().top - base - height < 0;
  2335. });
  2336. this.focus( event, item );
  2337. } else {
  2338. this.focus( event, this.activeMenu.find( this.options.items )
  2339. [ !this.active ? "first" : "last" ]() );
  2340. }
  2341. },
  2342. previousPage: function( event ) {
  2343. var item, base, height;
  2344. if ( !this.active ) {
  2345. this.next( event );
  2346. return;
  2347. }
  2348. if ( this.isFirstItem() ) {
  2349. return;
  2350. }
  2351. if ( this._hasScroll() ) {
  2352. base = this.active.offset().top;
  2353. height = this.element.height();
  2354. this.active.prevAll( ".ui-menu-item" ).each(function() {
  2355. item = $( this );
  2356. return item.offset().top - base + height > 0;
  2357. });
  2358. this.focus( event, item );
  2359. } else {
  2360. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  2361. }
  2362. },
  2363. _hasScroll: function() {
  2364. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  2365. },
  2366. select: function( event ) {
  2367. // TODO: It should never be possible to not have an active item at this
  2368. // point, but the tests don't trigger mouseenter before click.
  2369. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  2370. var ui = { item: this.active };
  2371. if ( !this.active.has( ".ui-menu" ).length ) {
  2372. this.collapseAll( event, true );
  2373. }
  2374. this._trigger( "select", event, ui );
  2375. }
  2376. });
  2377. /*!
  2378. * jQuery UI Autocomplete 1.11.1
  2379. * http://jqueryui.com
  2380. *
  2381. * Copyright 2014 jQuery Foundation and other contributors
  2382. * Released under the MIT license.
  2383. * http://jquery.org/license
  2384. *
  2385. * http://api.jqueryui.com/autocomplete/
  2386. */
  2387. $.widget( "ui.autocomplete", {
  2388. version: "1.11.1",
  2389. defaultElement: "<input>",
  2390. options: {
  2391. appendTo: null,
  2392. autoFocus: false,
  2393. delay: 300,
  2394. minLength: 1,
  2395. position: {
  2396. my: "left top",
  2397. at: "left bottom",
  2398. collision: "none"
  2399. },
  2400. source: null,
  2401. // callbacks
  2402. change: null,
  2403. close: null,
  2404. focus: null,
  2405. open: null,
  2406. response: null,
  2407. search: null,
  2408. select: null
  2409. },
  2410. requestIndex: 0,
  2411. pending: 0,
  2412. _create: function() {
  2413. // Some browsers only repeat keydown events, not keypress events,
  2414. // so we use the suppressKeyPress flag to determine if we've already
  2415. // handled the keydown event. #7269
  2416. // Unfortunately the code for & in keypress is the same as the up arrow,
  2417. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  2418. // events when we know the keydown event was used to modify the
  2419. // search term. #7799
  2420. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  2421. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  2422. isTextarea = nodeName === "textarea",
  2423. isInput = nodeName === "input";
  2424. this.isMultiLine =
  2425. // Textareas are always multi-line
  2426. isTextarea ? true :
  2427. // Inputs are always single-line, even if inside a contentEditable element
  2428. // IE also treats inputs as contentEditable
  2429. isInput ? false :
  2430. // All other element types are determined by whether or not they're contentEditable
  2431. this.element.prop( "isContentEditable" );
  2432. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  2433. this.isNewMenu = true;
  2434. this.element
  2435. .addClass( "ui-autocomplete-input" )
  2436. .attr( "autocomplete", "off" );
  2437. this._on( this.element, {
  2438. keydown: function( event ) {
  2439. if ( this.element.prop( "readOnly" ) ) {
  2440. suppressKeyPress = true;
  2441. suppressInput = true;
  2442. suppressKeyPressRepeat = true;
  2443. return;
  2444. }
  2445. suppressKeyPress = false;
  2446. suppressInput = false;
  2447. suppressKeyPressRepeat = false;
  2448. var keyCode = $.ui.keyCode;
  2449. switch ( event.keyCode ) {
  2450. case keyCode.PAGE_UP:
  2451. suppressKeyPress = true;
  2452. this._move( "previousPage", event );
  2453. break;
  2454. case keyCode.PAGE_DOWN:
  2455. suppressKeyPress = true;
  2456. this._move( "nextPage", event );
  2457. break;
  2458. case keyCode.UP:
  2459. suppressKeyPress = true;
  2460. this._keyEvent( "previous", event );
  2461. break;
  2462. case keyCode.DOWN:
  2463. suppressKeyPress = true;
  2464. this._keyEvent( "next", event );
  2465. break;
  2466. case keyCode.ENTER:
  2467. // when menu is open and has focus
  2468. if ( this.menu.active ) {
  2469. // #6055 - Opera still allows the keypress to occur
  2470. // which causes forms to submit
  2471. suppressKeyPress = true;
  2472. event.preventDefault();
  2473. this.menu.select( event );
  2474. }
  2475. break;
  2476. case keyCode.TAB:
  2477. if ( this.menu.active ) {
  2478. this.menu.select( event );
  2479. }
  2480. break;
  2481. case keyCode.ESCAPE:
  2482. if ( this.menu.element.is( ":visible" ) ) {
  2483. if ( !this.isMultiLine ) {
  2484. this._value( this.term );
  2485. }
  2486. this.close( event );
  2487. // Different browsers have different default behavior for escape
  2488. // Single press can mean undo or clear
  2489. // Double press in IE means clear the whole form
  2490. event.preventDefault();
  2491. }
  2492. break;
  2493. default:
  2494. suppressKeyPressRepeat = true;
  2495. // search timeout should be triggered before the input value is changed
  2496. this._searchTimeout( event );
  2497. break;
  2498. }
  2499. },
  2500. keypress: function( event ) {
  2501. if ( suppressKeyPress ) {
  2502. suppressKeyPress = false;
  2503. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2504. event.preventDefault();
  2505. }
  2506. return;
  2507. }
  2508. if ( suppressKeyPressRepeat ) {
  2509. return;
  2510. }
  2511. // replicate some key handlers to allow them to repeat in Firefox and Opera
  2512. var keyCode = $.ui.keyCode;
  2513. switch ( event.keyCode ) {
  2514. case keyCode.PAGE_UP:
  2515. this._move( "previousPage", event );
  2516. break;
  2517. case keyCode.PAGE_DOWN:
  2518. this._move( "nextPage", event );
  2519. break;
  2520. case keyCode.UP:
  2521. this._keyEvent( "previous", event );
  2522. break;
  2523. case keyCode.DOWN:
  2524. this._keyEvent( "next", event );
  2525. break;
  2526. }
  2527. },
  2528. input: function( event ) {
  2529. if ( suppressInput ) {
  2530. suppressInput = false;
  2531. event.preventDefault();
  2532. return;
  2533. }
  2534. this._searchTimeout( event );
  2535. },
  2536. focus: function() {
  2537. this.selectedItem = null;
  2538. this.previous = this._value();
  2539. },
  2540. blur: function( event ) {
  2541. if ( this.cancelBlur ) {
  2542. delete this.cancelBlur;
  2543. return;
  2544. }
  2545. clearTimeout( this.searching );
  2546. this.close( event );
  2547. this._change( event );
  2548. }
  2549. });
  2550. this._initSource();
  2551. this.menu = $( "<ul>" )
  2552. .addClass( "ui-autocomplete ui-front" )
  2553. .appendTo( this._appendTo() )
  2554. .menu({
  2555. // disable ARIA support, the live region takes care of that
  2556. role: null
  2557. })
  2558. .hide()
  2559. .menu( "instance" );
  2560. this._on( this.menu.element, {
  2561. mousedown: function( event ) {
  2562. // prevent moving focus out of the text field
  2563. event.preventDefault();
  2564. // IE doesn't prevent moving focus even with event.preventDefault()
  2565. // so we set a flag to know when we should ignore the blur event
  2566. this.cancelBlur = true;
  2567. this._delay(function() {
  2568. delete this.cancelBlur;
  2569. });
  2570. // clicking on the scrollbar causes focus to shift to the body
  2571. // but we can't detect a mouseup or a click immediately afterward
  2572. // so we have to track the next mousedown and close the menu if
  2573. // the user clicks somewhere outside of the autocomplete
  2574. var menuElement = this.menu.element[ 0 ];
  2575. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  2576. this._delay(function() {
  2577. var that = this;
  2578. this.document.one( "mousedown", function( event ) {
  2579. if ( event.target !== that.element[ 0 ] &&
  2580. event.target !== menuElement &&
  2581. !$.contains( menuElement, event.target ) ) {
  2582. that.close();
  2583. }
  2584. });
  2585. });
  2586. }
  2587. },
  2588. menufocus: function( event, ui ) {
  2589. var label, item;
  2590. // support: Firefox
  2591. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  2592. if ( this.isNewMenu ) {
  2593. this.isNewMenu = false;
  2594. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  2595. this.menu.blur();
  2596. this.document.one( "mousemove", function() {
  2597. $( event.target ).trigger( event.originalEvent );
  2598. });
  2599. return;
  2600. }
  2601. }
  2602. item = ui.item.data( "ui-autocomplete-item" );
  2603. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  2604. // use value to match what will end up in the input, if it was a key event
  2605. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  2606. this._value( item.value );
  2607. }
  2608. }
  2609. // Announce the value in the liveRegion
  2610. label = ui.item.attr( "aria-label" ) || item.value;
  2611. if ( label && $.trim( label ).length ) {
  2612. this.liveRegion.children().hide();
  2613. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  2614. }
  2615. },
  2616. menuselect: function( event, ui ) {
  2617. var item = ui.item.data( "ui-autocomplete-item" ),
  2618. previous = this.previous;
  2619. // only trigger when focus was lost (click on menu)
  2620. if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
  2621. this.element.focus();
  2622. this.previous = previous;
  2623. // #6109 - IE triggers two focus events and the second
  2624. // is asynchronous, so we need to reset the previous
  2625. // term synchronously and asynchronously :-(
  2626. this._delay(function() {
  2627. this.previous = previous;
  2628. this.selectedItem = item;
  2629. });
  2630. }
  2631. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  2632. this._value( item.value );
  2633. }
  2634. // reset the term after the select event
  2635. // this allows custom select handling to work properly
  2636. this.term = this._value();
  2637. this.close( event );
  2638. this.selectedItem = item;
  2639. }
  2640. });
  2641. this.liveRegion = $( "<span>", {
  2642. role: "status",
  2643. "aria-live": "assertive",
  2644. "aria-relevant": "additions"
  2645. })
  2646. .addClass( "ui-helper-hidden-accessible" )
  2647. .appendTo( this.document[ 0 ].body );
  2648. // turning off autocomplete prevents the browser from remembering the
  2649. // value when navigating through history, so we re-enable autocomplete
  2650. // if the page is unloaded before the widget is destroyed. #7790
  2651. this._on( this.window, {
  2652. beforeunload: function() {
  2653. this.element.removeAttr( "autocomplete" );
  2654. }
  2655. });
  2656. },
  2657. _destroy: function() {
  2658. clearTimeout( this.searching );
  2659. this.element
  2660. .removeClass( "ui-autocomplete-input" )
  2661. .removeAttr( "autocomplete" );
  2662. this.menu.element.remove();
  2663. this.liveRegion.remove();
  2664. },
  2665. _setOption: function( key, value ) {
  2666. this._super( key, value );
  2667. if ( key === "source" ) {
  2668. this._initSource();
  2669. }
  2670. if ( key === "appendTo" ) {
  2671. this.menu.element.appendTo( this._appendTo() );
  2672. }
  2673. if ( key === "disabled" && value && this.xhr ) {
  2674. this.xhr.abort();
  2675. }
  2676. },
  2677. _appendTo: function() {
  2678. var element = this.options.appendTo;
  2679. if ( element ) {
  2680. element = element.jquery || element.nodeType ?
  2681. $( element ) :
  2682. this.document.find( element ).eq( 0 );
  2683. }
  2684. if ( !element || !element[ 0 ] ) {
  2685. element = this.element.closest( ".ui-front" );
  2686. }
  2687. if ( !element.length ) {
  2688. element = this.document[ 0 ].body;
  2689. }
  2690. return element;
  2691. },
  2692. _initSource: function() {
  2693. var array, url,
  2694. that = this;
  2695. if ( $.isArray( this.options.source ) ) {
  2696. array = this.options.source;
  2697. this.source = function( request, response ) {
  2698. response( $.ui.autocomplete.filter( array, request.term ) );
  2699. };
  2700. } else if ( typeof this.options.source === "string" ) {
  2701. url = this.options.source;
  2702. this.source = function( request, response ) {
  2703. if ( that.xhr ) {
  2704. that.xhr.abort();
  2705. }
  2706. that.xhr = $.ajax({
  2707. url: url,
  2708. data: request,
  2709. dataType: "json",
  2710. success: function( data ) {
  2711. response( data );
  2712. },
  2713. error: function() {
  2714. response([]);
  2715. }
  2716. });
  2717. };
  2718. } else {
  2719. this.source = this.options.source;
  2720. }
  2721. },
  2722. _searchTimeout: function( event ) {
  2723. clearTimeout( this.searching );
  2724. this.searching = this._delay(function() {
  2725. // Search if the value has changed, or if the user retypes the same value (see #7434)
  2726. var equalValues = this.term === this._value(),
  2727. menuVisible = this.menu.element.is( ":visible" ),
  2728. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  2729. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  2730. this.selectedItem = null;
  2731. this.search( null, event );
  2732. }
  2733. }, this.options.delay );
  2734. },
  2735. search: function( value, event ) {
  2736. value = value != null ? value : this._value();
  2737. // always save the actual value, not the one passed as an argument
  2738. this.term = this._value();
  2739. if ( value.length < this.options.minLength ) {
  2740. return this.close( event );
  2741. }
  2742. if ( this._trigger( "search", event ) === false ) {
  2743. return;
  2744. }
  2745. return this._search( value );
  2746. },
  2747. _search: function( value ) {
  2748. this.pending++;
  2749. this.element.addClass( "ui-autocomplete-loading" );
  2750. this.cancelSearch = false;
  2751. this.source( { term: value }, this._response() );
  2752. },
  2753. _response: function() {
  2754. var index = ++this.requestIndex;
  2755. return $.proxy(function( content ) {
  2756. if ( index === this.requestIndex ) {
  2757. this.__response( content );
  2758. }
  2759. this.pending--;
  2760. if ( !this.pending ) {
  2761. this.element.removeClass( "ui-autocomplete-loading" );
  2762. }
  2763. }, this );
  2764. },
  2765. __response: function( content ) {
  2766. if ( content ) {
  2767. content = this._normalize( content );
  2768. }
  2769. this._trigger( "response", null, { content: content } );
  2770. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  2771. this._suggest( content );
  2772. this._trigger( "open" );
  2773. } else {
  2774. // use ._close() instead of .close() so we don't cancel future searches
  2775. this._close();
  2776. }
  2777. },
  2778. close: function( event ) {
  2779. this.cancelSearch = true;
  2780. this._close( event );
  2781. },
  2782. _close: function( event ) {
  2783. if ( this.menu.element.is( ":visible" ) ) {
  2784. this.menu.element.hide();
  2785. this.menu.blur();
  2786. this.isNewMenu = true;
  2787. this._trigger( "close", event );
  2788. }
  2789. },
  2790. _change: function( event ) {
  2791. if ( this.previous !== this._value() ) {
  2792. this._trigger( "change", event, { item: this.selectedItem } );
  2793. }
  2794. },
  2795. _normalize: function( items ) {
  2796. // assume all items have the right format when the first item is complete
  2797. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  2798. return items;
  2799. }
  2800. return $.map( items, function( item ) {
  2801. if ( typeof item === "string" ) {
  2802. return {
  2803. label: item,
  2804. value: item
  2805. };
  2806. }
  2807. return $.extend( {}, item, {
  2808. label: item.label || item.value,
  2809. value: item.value || item.label
  2810. });
  2811. });
  2812. },
  2813. _suggest: function( items ) {
  2814. var ul = this.menu.element.empty();
  2815. this._renderMenu( ul, items );
  2816. this.isNewMenu = true;
  2817. this.menu.refresh();
  2818. // size and position menu
  2819. ul.show();
  2820. this._resizeMenu();
  2821. ul.position( $.extend({
  2822. of: this.element
  2823. }, this.options.position ) );
  2824. if ( this.options.autoFocus ) {
  2825. this.menu.next();
  2826. }
  2827. },
  2828. _resizeMenu: function() {
  2829. var ul = this.menu.element;
  2830. ul.outerWidth( Math.max(
  2831. // Firefox wraps long text (possibly a rounding bug)
  2832. // so we add 1px to avoid the wrapping (#7513)
  2833. ul.width( "" ).outerWidth() + 1,
  2834. this.element.outerWidth()
  2835. ) );
  2836. },
  2837. _renderMenu: function( ul, items ) {
  2838. var that = this;
  2839. $.each( items, function( index, item ) {
  2840. that._renderItemData( ul, item );
  2841. });
  2842. },
  2843. _renderItemData: function( ul, item ) {
  2844. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  2845. },
  2846. _renderItem: function( ul, item ) {
  2847. return $( "<li>" ).text( item.label ).appendTo( ul );
  2848. },
  2849. _move: function( direction, event ) {
  2850. if ( !this.menu.element.is( ":visible" ) ) {
  2851. this.search( null, event );
  2852. return;
  2853. }
  2854. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  2855. this.menu.isLastItem() && /^next/.test( direction ) ) {
  2856. if ( !this.isMultiLine ) {
  2857. this._value( this.term );
  2858. }
  2859. this.menu.blur();
  2860. return;
  2861. }
  2862. this.menu[ direction ]( event );
  2863. },
  2864. widget: function() {
  2865. return this.menu.element;
  2866. },
  2867. _value: function() {
  2868. return this.valueMethod.apply( this.element, arguments );
  2869. },
  2870. _keyEvent: function( keyEvent, event ) {
  2871. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2872. this._move( keyEvent, event );
  2873. // prevents moving cursor to beginning/end of the text field in some browsers
  2874. event.preventDefault();
  2875. }
  2876. }
  2877. });
  2878. $.extend( $.ui.autocomplete, {
  2879. escapeRegex: function( value ) {
  2880. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  2881. },
  2882. filter: function( array, term ) {
  2883. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  2884. return $.grep( array, function( value ) {
  2885. return matcher.test( value.label || value.value || value );
  2886. });
  2887. }
  2888. });
  2889. // live region extension, adding a `messages` option
  2890. // NOTE: This is an experimental API. We are still investigating
  2891. // a full solution for string manipulation and internationalization.
  2892. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  2893. options: {
  2894. messages: {
  2895. noResults: "No search results.",
  2896. results: function( amount ) {
  2897. return amount + ( amount > 1 ? " results are" : " result is" ) +
  2898. " available, use up and down arrow keys to navigate.";
  2899. }
  2900. }
  2901. },
  2902. __response: function( content ) {
  2903. var message;
  2904. this._superApply( arguments );
  2905. if ( this.options.disabled || this.cancelSearch ) {
  2906. return;
  2907. }
  2908. if ( content && content.length ) {
  2909. message = this.options.messages.results( content.length );
  2910. } else {
  2911. message = this.options.messages.noResults;
  2912. }
  2913. this.liveRegion.children().hide();
  2914. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  2915. }
  2916. });
  2917. var autocomplete = $.ui.autocomplete;
  2918. /*!
  2919. * jQuery UI Button 1.11.1
  2920. * http://jqueryui.com
  2921. *
  2922. * Copyright 2014 jQuery Foundation and other contributors
  2923. * Released under the MIT license.
  2924. * http://jquery.org/license
  2925. *
  2926. * http://api.jqueryui.com/button/
  2927. */
  2928. var lastActive,
  2929. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  2930. 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",
  2931. formResetHandler = function() {
  2932. var form = $( this );
  2933. setTimeout(function() {
  2934. form.find( ":ui-button" ).button( "refresh" );
  2935. }, 1 );
  2936. },
  2937. radioGroup = function( radio ) {
  2938. var name = radio.name,
  2939. form = radio.form,
  2940. radios = $( [] );
  2941. if ( name ) {
  2942. name = name.replace( /'/g, "\\'" );
  2943. if ( form ) {
  2944. radios = $( form ).find( "[name='" + name + "'][type=radio]" );
  2945. } else {
  2946. radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
  2947. .filter(function() {
  2948. return !this.form;
  2949. });
  2950. }
  2951. }
  2952. return radios;
  2953. };
  2954. $.widget( "ui.button", {
  2955. version: "1.11.1",
  2956. defaultElement: "<button>",
  2957. options: {
  2958. disabled: null,
  2959. text: true,
  2960. label: null,
  2961. icons: {
  2962. primary: null,
  2963. secondary: null
  2964. }
  2965. },
  2966. _create: function() {
  2967. this.element.closest( "form" )
  2968. .unbind( "reset" + this.eventNamespace )
  2969. .bind( "reset" + this.eventNamespace, formResetHandler );
  2970. if ( typeof this.options.disabled !== "boolean" ) {
  2971. this.options.disabled = !!this.element.prop( "disabled" );
  2972. } else {
  2973. this.element.prop( "disabled", this.options.disabled );
  2974. }
  2975. this._determineButtonType();
  2976. this.hasTitle = !!this.buttonElement.attr( "title" );
  2977. var that = this,
  2978. options = this.options,
  2979. toggleButton = this.type === "checkbox" || this.type === "radio",
  2980. activeClass = !toggleButton ? "ui-state-active" : "";
  2981. if ( options.label === null ) {
  2982. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  2983. }
  2984. this._hoverable( this.buttonElement );
  2985. this.buttonElement
  2986. .addClass( baseClasses )
  2987. .attr( "role", "button" )
  2988. .bind( "mouseenter" + this.eventNamespace, function() {
  2989. if ( options.disabled ) {
  2990. return;
  2991. }
  2992. if ( this === lastActive ) {
  2993. $( this ).addClass( "ui-state-active" );
  2994. }
  2995. })
  2996. .bind( "mouseleave" + this.eventNamespace, function() {
  2997. if ( options.disabled ) {
  2998. return;
  2999. }
  3000. $( this ).removeClass( activeClass );
  3001. })
  3002. .bind( "click" + this.eventNamespace, function( event ) {
  3003. if ( options.disabled ) {
  3004. event.preventDefault();
  3005. event.stopImmediatePropagation();
  3006. }
  3007. });
  3008. // Can't use _focusable() because the element that receives focus
  3009. // and the element that gets the ui-state-focus class are different
  3010. this._on({
  3011. focus: function() {
  3012. this.buttonElement.addClass( "ui-state-focus" );
  3013. },
  3014. blur: function() {
  3015. this.buttonElement.removeClass( "ui-state-focus" );
  3016. }
  3017. });
  3018. if ( toggleButton ) {
  3019. this.element.bind( "change" + this.eventNamespace, function() {
  3020. that.refresh();
  3021. });
  3022. }
  3023. if ( this.type === "checkbox" ) {
  3024. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  3025. if ( options.disabled ) {
  3026. return false;
  3027. }
  3028. });
  3029. } else if ( this.type === "radio" ) {
  3030. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  3031. if ( options.disabled ) {
  3032. return false;
  3033. }
  3034. $( this ).addClass( "ui-state-active" );
  3035. that.buttonElement.attr( "aria-pressed", "true" );
  3036. var radio = that.element[ 0 ];
  3037. radioGroup( radio )
  3038. .not( radio )
  3039. .map(function() {
  3040. return $( this ).button( "widget" )[ 0 ];
  3041. })
  3042. .removeClass( "ui-state-active" )
  3043. .attr( "aria-pressed", "false" );
  3044. });
  3045. } else {
  3046. this.buttonElement
  3047. .bind( "mousedown" + this.eventNamespace, function() {
  3048. if ( options.disabled ) {
  3049. return false;
  3050. }
  3051. $( this ).addClass( "ui-state-active" );
  3052. lastActive = this;
  3053. that.document.one( "mouseup", function() {
  3054. lastActive = null;
  3055. });
  3056. })
  3057. .bind( "mouseup" + this.eventNamespace, function() {
  3058. if ( options.disabled ) {
  3059. return false;
  3060. }
  3061. $( this ).removeClass( "ui-state-active" );
  3062. })
  3063. .bind( "keydown" + this.eventNamespace, function(event) {
  3064. if ( options.disabled ) {
  3065. return false;
  3066. }
  3067. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  3068. $( this ).addClass( "ui-state-active" );
  3069. }
  3070. })
  3071. // see #8559, we bind to blur here in case the button element loses
  3072. // focus between keydown and keyup, it would be left in an "active" state
  3073. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  3074. $( this ).removeClass( "ui-state-active" );
  3075. });
  3076. if ( this.buttonElement.is("a") ) {
  3077. this.buttonElement.keyup(function(event) {
  3078. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  3079. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  3080. $( this ).click();
  3081. }
  3082. });
  3083. }
  3084. }
  3085. this._setOption( "disabled", options.disabled );
  3086. this._resetButton();
  3087. },
  3088. _determineButtonType: function() {
  3089. var ancestor, labelSelector, checked;
  3090. if ( this.element.is("[type=checkbox]") ) {
  3091. this.type = "checkbox";
  3092. } else if ( this.element.is("[type=radio]") ) {
  3093. this.type = "radio";
  3094. } else if ( this.element.is("input") ) {
  3095. this.type = "input";
  3096. } else {
  3097. this.type = "button";
  3098. }
  3099. if ( this.type === "checkbox" || this.type === "radio" ) {
  3100. // we don't search against the document in case the element
  3101. // is disconnected from the DOM
  3102. ancestor = this.element.parents().last();
  3103. labelSelector = "label[for='" + this.element.attr("id") + "']";
  3104. this.buttonElement = ancestor.find( labelSelector );
  3105. if ( !this.buttonElement.length ) {
  3106. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  3107. this.buttonElement = ancestor.filter( labelSelector );
  3108. if ( !this.buttonElement.length ) {
  3109. this.buttonElement = ancestor.find( labelSelector );
  3110. }
  3111. }
  3112. this.element.addClass( "ui-helper-hidden-accessible" );
  3113. checked = this.element.is( ":checked" );
  3114. if ( checked ) {
  3115. this.buttonElement.addClass( "ui-state-active" );
  3116. }
  3117. this.buttonElement.prop( "aria-pressed", checked );
  3118. } else {
  3119. this.buttonElement = this.element;
  3120. }
  3121. },
  3122. widget: function() {
  3123. return this.buttonElement;
  3124. },
  3125. _destroy: function() {
  3126. this.element
  3127. .removeClass( "ui-helper-hidden-accessible" );
  3128. this.buttonElement
  3129. .removeClass( baseClasses + " ui-state-active " + typeClasses )
  3130. .removeAttr( "role" )
  3131. .removeAttr( "aria-pressed" )
  3132. .html( this.buttonElement.find(".ui-button-text").html() );
  3133. if ( !this.hasTitle ) {
  3134. this.buttonElement.removeAttr( "title" );
  3135. }
  3136. },
  3137. _setOption: function( key, value ) {
  3138. this._super( key, value );
  3139. if ( key === "disabled" ) {
  3140. this.widget().toggleClass( "ui-state-disabled", !!value );
  3141. this.element.prop( "disabled", !!value );
  3142. if ( value ) {
  3143. if ( this.type === "checkbox" || this.type === "radio" ) {
  3144. this.buttonElement.removeClass( "ui-state-focus" );
  3145. } else {
  3146. this.buttonElement.removeClass( "ui-state-focus ui-state-active" );
  3147. }
  3148. }
  3149. return;
  3150. }
  3151. this._resetButton();
  3152. },
  3153. refresh: function() {
  3154. //See #8237 & #8828
  3155. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  3156. if ( isDisabled !== this.options.disabled ) {
  3157. this._setOption( "disabled", isDisabled );
  3158. }
  3159. if ( this.type === "radio" ) {
  3160. radioGroup( this.element[0] ).each(function() {
  3161. if ( $( this ).is( ":checked" ) ) {
  3162. $( this ).button( "widget" )
  3163. .addClass( "ui-state-active" )
  3164. .attr( "aria-pressed", "true" );
  3165. } else {
  3166. $( this ).button( "widget" )
  3167. .removeClass( "ui-state-active" )
  3168. .attr( "aria-pressed", "false" );
  3169. }
  3170. });
  3171. } else if ( this.type === "checkbox" ) {
  3172. if ( this.element.is( ":checked" ) ) {
  3173. this.buttonElement
  3174. .addClass( "ui-state-active" )
  3175. .attr( "aria-pressed", "true" );
  3176. } else {
  3177. this.buttonElement
  3178. .removeClass( "ui-state-active" )
  3179. .attr( "aria-pressed", "false" );
  3180. }
  3181. }
  3182. },
  3183. _resetButton: function() {
  3184. if ( this.type === "input" ) {
  3185. if ( this.options.label ) {
  3186. this.element.val( this.options.label );
  3187. }
  3188. return;
  3189. }
  3190. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  3191. buttonText = $( "<span></span>", this.document[0] )
  3192. .addClass( "ui-button-text" )
  3193. .html( this.options.label )
  3194. .appendTo( buttonElement.empty() )
  3195. .text(),
  3196. icons = this.options.icons,
  3197. multipleIcons = icons.primary && icons.secondary,
  3198. buttonClasses = [];
  3199. if ( icons.primary || icons.secondary ) {
  3200. if ( this.options.text ) {
  3201. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  3202. }
  3203. if ( icons.primary ) {
  3204. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  3205. }
  3206. if ( icons.secondary ) {
  3207. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  3208. }
  3209. if ( !this.options.text ) {
  3210. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  3211. if ( !this.hasTitle ) {
  3212. buttonElement.attr( "title", $.trim( buttonText ) );
  3213. }
  3214. }
  3215. } else {
  3216. buttonClasses.push( "ui-button-text-only" );
  3217. }
  3218. buttonElement.addClass( buttonClasses.join( " " ) );
  3219. }
  3220. });
  3221. $.widget( "ui.buttonset", {
  3222. version: "1.11.1",
  3223. options: {
  3224. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  3225. },
  3226. _create: function() {
  3227. this.element.addClass( "ui-buttonset" );
  3228. },
  3229. _init: function() {
  3230. this.refresh();
  3231. },
  3232. _setOption: function( key, value ) {
  3233. if ( key === "disabled" ) {
  3234. this.buttons.button( "option", key, value );
  3235. }
  3236. this._super( key, value );
  3237. },
  3238. refresh: function() {
  3239. var rtl = this.element.css( "direction" ) === "rtl",
  3240. allButtons = this.element.find( this.options.items ),
  3241. existingButtons = allButtons.filter( ":ui-button" );
  3242. // Initialize new buttons
  3243. allButtons.not( ":ui-button" ).button();
  3244. // Refresh existing buttons
  3245. existingButtons.button( "refresh" );
  3246. this.buttons = allButtons
  3247. .map(function() {
  3248. return $( this ).button( "widget" )[ 0 ];
  3249. })
  3250. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  3251. .filter( ":first" )
  3252. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  3253. .end()
  3254. .filter( ":last" )
  3255. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  3256. .end()
  3257. .end();
  3258. },
  3259. _destroy: function() {
  3260. this.element.removeClass( "ui-buttonset" );
  3261. this.buttons
  3262. .map(function() {
  3263. return $( this ).button( "widget" )[ 0 ];
  3264. })
  3265. .removeClass( "ui-corner-left ui-corner-right" )
  3266. .end()
  3267. .button( "destroy" );
  3268. }
  3269. });
  3270. var button = $.ui.button;
  3271. /*!
  3272. * jQuery UI Datepicker 1.11.1
  3273. * http://jqueryui.com
  3274. *
  3275. * Copyright 2014 jQuery Foundation and other contributors
  3276. * Released under the MIT license.
  3277. * http://jquery.org/license
  3278. *
  3279. * http://api.jqueryui.com/datepicker/
  3280. */
  3281. $.extend($.ui, { datepicker: { version: "1.11.1" } });
  3282. var datepicker_instActive;
  3283. function datepicker_getZindex( elem ) {
  3284. var position, value;
  3285. while ( elem.length && elem[ 0 ] !== document ) {
  3286. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  3287. // This makes behavior of this function consistent across browsers
  3288. // WebKit always returns auto if the element is positioned
  3289. position = elem.css( "position" );
  3290. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  3291. // IE returns 0 when zIndex is not specified
  3292. // other browsers return a string
  3293. // we ignore the case of nested elements with an explicit value of 0
  3294. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  3295. value = parseInt( elem.css( "zIndex" ), 10 );
  3296. if ( !isNaN( value ) && value !== 0 ) {
  3297. return value;
  3298. }
  3299. }
  3300. elem = elem.parent();
  3301. }
  3302. return 0;
  3303. }
  3304. /* Date picker manager.
  3305. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  3306. Settings for (groups of) date pickers are maintained in an instance object,
  3307. allowing multiple different settings on the same page. */
  3308. function Datepicker() {
  3309. this._curInst = null; // The current instance in use
  3310. this._keyEvent = false; // If the last event was a key event
  3311. this._disabledInputs = []; // List of date picker inputs that have been disabled
  3312. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  3313. this._inDialog = false; // True if showing within a "dialog", false if not
  3314. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  3315. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  3316. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  3317. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  3318. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  3319. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  3320. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  3321. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  3322. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  3323. this.regional = []; // Available regional settings, indexed by language code
  3324. this.regional[""] = { // Default regional settings
  3325. closeText: "Done", // Display text for close link
  3326. prevText: "Prev", // Display text for previous month link
  3327. nextText: "Next", // Display text for next month link
  3328. currentText: "Today", // Display text for current month link
  3329. monthNames: ["January","February","March","April","May","June",
  3330. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  3331. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  3332. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  3333. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  3334. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  3335. weekHeader: "Wk", // Column header for week of the year
  3336. dateFormat: "mm/dd/yy", // See format options on parseDate
  3337. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  3338. isRTL: false, // True if right-to-left language, false if left-to-right
  3339. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  3340. yearSuffix: "" // Additional text to append to the year in the month headers
  3341. };
  3342. this._defaults = { // Global defaults for all the date picker instances
  3343. showOn: "focus", // "focus" for popup on focus,
  3344. // "button" for trigger button, or "both" for either
  3345. showAnim: "fadeIn", // Name of jQuery animation for popup
  3346. showOptions: {}, // Options for enhanced animations
  3347. defaultDate: null, // Used when field is blank: actual date,
  3348. // +/-number for offset from today, null for today
  3349. appendText: "", // Display text following the input box, e.g. showing the format
  3350. buttonText: "...", // Text for trigger button
  3351. buttonImage: "", // URL for trigger button image
  3352. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  3353. hideIfNoPrevNext: false, // True to hide next/previous month links
  3354. // if not applicable, false to just disable them
  3355. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  3356. gotoCurrent: false, // True if today link goes back to current selection instead
  3357. changeMonth: false, // True if month can be selected directly, false if only prev/next
  3358. changeYear: false, // True if year can be selected directly, false if only prev/next
  3359. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  3360. // either relative to today's year (-nn:+nn), relative to currently displayed year
  3361. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  3362. showOtherMonths: false, // True to show dates in other months, false to leave blank
  3363. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  3364. showWeek: false, // True to show week of the year, false to not show it
  3365. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  3366. // takes a Date and returns the number of the week for it
  3367. shortYearCutoff: "+10", // Short year values < this are in the current century,
  3368. // > this are in the previous century,
  3369. // string value starting with "+" for current year + value
  3370. minDate: null, // The earliest selectable date, or null for no limit
  3371. maxDate: null, // The latest selectable date, or null for no limit
  3372. duration: "fast", // Duration of display/closure
  3373. beforeShowDay: null, // Function that takes a date and returns an array with
  3374. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  3375. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  3376. beforeShow: null, // Function that takes an input field and
  3377. // returns a set of custom settings for the date picker
  3378. onSelect: null, // Define a callback function when a date is selected
  3379. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  3380. onClose: null, // Define a callback function when the datepicker is closed
  3381. numberOfMonths: 1, // Number of months to show at a time
  3382. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  3383. stepMonths: 1, // Number of months to step back/forward
  3384. stepBigMonths: 12, // Number of months to step back/forward for the big links
  3385. altField: "", // Selector for an alternate field to store selected dates into
  3386. altFormat: "", // The date format to use for the alternate field
  3387. constrainInput: true, // The input is constrained by the current date format
  3388. showButtonPanel: false, // True to show button panel, false to not show it
  3389. autoSize: false, // True to size the input for the date format, false to leave as is
  3390. disabled: false // The initial disabled state
  3391. };
  3392. $.extend(this._defaults, this.regional[""]);
  3393. this.regional.en = $.extend( true, {}, this.regional[ "" ]);
  3394. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  3395. this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  3396. }
  3397. $.extend(Datepicker.prototype, {
  3398. /* Class name added to elements to indicate already configured with a date picker. */
  3399. markerClassName: "hasDatepicker",
  3400. //Keep track of the maximum number of rows displayed (see #7043)
  3401. maxRows: 4,
  3402. // TODO rename to "widget" when switching to widget factory
  3403. _widgetDatepicker: function() {
  3404. return this.dpDiv;
  3405. },
  3406. /* Override the default settings for all instances of the date picker.
  3407. * @param settings object - the new settings to use as defaults (anonymous object)
  3408. * @return the manager object
  3409. */
  3410. setDefaults: function(settings) {
  3411. datepicker_extendRemove(this._defaults, settings || {});
  3412. return this;
  3413. },
  3414. /* Attach the date picker to a jQuery selection.
  3415. * @param target element - the target input field or division or span
  3416. * @param settings object - the new settings to use for this date picker instance (anonymous)
  3417. */
  3418. _attachDatepicker: function(target, settings) {
  3419. var nodeName, inline, inst;
  3420. nodeName = target.nodeName.toLowerCase();
  3421. inline = (nodeName === "div" || nodeName === "span");
  3422. if (!target.id) {
  3423. this.uuid += 1;
  3424. target.id = "dp" + this.uuid;
  3425. }
  3426. inst = this._newInst($(target), inline);
  3427. inst.settings = $.extend({}, settings || {});
  3428. if (nodeName === "input") {
  3429. this._connectDatepicker(target, inst);
  3430. } else if (inline) {
  3431. this._inlineDatepicker(target, inst);
  3432. }
  3433. },
  3434. /* Create a new instance object. */
  3435. _newInst: function(target, inline) {
  3436. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  3437. return {id: id, input: target, // associated target
  3438. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  3439. drawMonth: 0, drawYear: 0, // month being drawn
  3440. inline: inline, // is datepicker inline or not
  3441. dpDiv: (!inline ? this.dpDiv : // presentation div
  3442. datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  3443. },
  3444. /* Attach the date picker to an input field. */
  3445. _connectDatepicker: function(target, inst) {
  3446. var input = $(target);
  3447. inst.append = $([]);
  3448. inst.trigger = $([]);
  3449. if (input.hasClass(this.markerClassName)) {
  3450. return;
  3451. }
  3452. this._attachments(input, inst);
  3453. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  3454. keypress(this._doKeyPress).keyup(this._doKeyUp);
  3455. this._autoSize(inst);
  3456. $.data(target, "datepicker", inst);
  3457. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  3458. if( inst.settings.disabled ) {
  3459. this._disableDatepicker( target );
  3460. }
  3461. },
  3462. /* Make attachments based on settings. */
  3463. _attachments: function(input, inst) {
  3464. var showOn, buttonText, buttonImage,
  3465. appendText = this._get(inst, "appendText"),
  3466. isRTL = this._get(inst, "isRTL");
  3467. if (inst.append) {
  3468. inst.append.remove();
  3469. }
  3470. if (appendText) {
  3471. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  3472. input[isRTL ? "before" : "after"](inst.append);
  3473. }
  3474. input.unbind("focus", this._showDatepicker);
  3475. if (inst.trigger) {
  3476. inst.trigger.remove();
  3477. }
  3478. showOn = this._get(inst, "showOn");
  3479. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  3480. input.focus(this._showDatepicker);
  3481. }
  3482. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  3483. buttonText = this._get(inst, "buttonText");
  3484. buttonImage = this._get(inst, "buttonImage");
  3485. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  3486. $("<img/>").addClass(this._triggerClass).
  3487. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  3488. $("<button type='button'></button>").addClass(this._triggerClass).
  3489. html(!buttonImage ? buttonText : $("<img/>").attr(
  3490. { src:buttonImage, alt:buttonText, title:buttonText })));
  3491. input[isRTL ? "before" : "after"](inst.trigger);
  3492. inst.trigger.click(function() {
  3493. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  3494. $.datepicker._hideDatepicker();
  3495. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  3496. $.datepicker._hideDatepicker();
  3497. $.datepicker._showDatepicker(input[0]);
  3498. } else {
  3499. $.datepicker._showDatepicker(input[0]);
  3500. }
  3501. return false;
  3502. });
  3503. }
  3504. },
  3505. /* Apply the maximum length for the date format. */
  3506. _autoSize: function(inst) {
  3507. if (this._get(inst, "autoSize") && !inst.inline) {
  3508. var findMax, max, maxI, i,
  3509. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  3510. dateFormat = this._get(inst, "dateFormat");
  3511. if (dateFormat.match(/[DM]/)) {
  3512. findMax = function(names) {
  3513. max = 0;
  3514. maxI = 0;
  3515. for (i = 0; i < names.length; i++) {
  3516. if (names[i].length > max) {
  3517. max = names[i].length;
  3518. maxI = i;
  3519. }
  3520. }
  3521. return maxI;
  3522. };
  3523. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  3524. "monthNames" : "monthNamesShort"))));
  3525. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  3526. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  3527. }
  3528. inst.input.attr("size", this._formatDate(inst, date).length);
  3529. }
  3530. },
  3531. /* Attach an inline date picker to a div. */
  3532. _inlineDatepicker: function(target, inst) {
  3533. var divSpan = $(target);
  3534. if (divSpan.hasClass(this.markerClassName)) {
  3535. return;
  3536. }
  3537. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  3538. $.data(target, "datepicker", inst);
  3539. this._setDate(inst, this._getDefaultDate(inst), true);
  3540. this._updateDatepicker(inst);
  3541. this._updateAlternate(inst);
  3542. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  3543. if( inst.settings.disabled ) {
  3544. this._disableDatepicker( target );
  3545. }
  3546. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  3547. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  3548. inst.dpDiv.css( "display", "block" );
  3549. },
  3550. /* Pop-up the date picker in a "dialog" box.
  3551. * @param input element - ignored
  3552. * @param date string or Date - the initial date to display
  3553. * @param onSelect function - the function to call when a date is selected
  3554. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  3555. * @param pos int[2] - coordinates for the dialog's position within the screen or
  3556. * event - with x/y coordinates or
  3557. * leave empty for default (screen centre)
  3558. * @return the manager object
  3559. */
  3560. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  3561. var id, browserWidth, browserHeight, scrollX, scrollY,
  3562. inst = this._dialogInst; // internal instance
  3563. if (!inst) {
  3564. this.uuid += 1;
  3565. id = "dp" + this.uuid;
  3566. this._dialogInput = $("<input type='text' id='" + id +
  3567. "' style='position: absolute; top: -100px; width: 0px;'/>");
  3568. this._dialogInput.keydown(this._doKeyDown);
  3569. $("body").append(this._dialogInput);
  3570. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  3571. inst.settings = {};
  3572. $.data(this._dialogInput[0], "datepicker", inst);
  3573. }
  3574. datepicker_extendRemove(inst.settings, settings || {});
  3575. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  3576. this._dialogInput.val(date);
  3577. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  3578. if (!this._pos) {
  3579. browserWidth = document.documentElement.clientWidth;
  3580. browserHeight = document.documentElement.clientHeight;
  3581. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  3582. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  3583. this._pos = // should use actual width/height below
  3584. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  3585. }
  3586. // move input on screen for focus, but hidden behind dialog
  3587. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  3588. inst.settings.onSelect = onSelect;
  3589. this._inDialog = true;
  3590. this.dpDiv.addClass(this._dialogClass);
  3591. this._showDatepicker(this._dialogInput[0]);
  3592. if ($.blockUI) {
  3593. $.blockUI(this.dpDiv);
  3594. }
  3595. $.data(this._dialogInput[0], "datepicker", inst);
  3596. return this;
  3597. },
  3598. /* Detach a datepicker from its control.
  3599. * @param target element - the target input field or division or span
  3600. */
  3601. _destroyDatepicker: function(target) {
  3602. var nodeName,
  3603. $target = $(target),
  3604. inst = $.data(target, "datepicker");
  3605. if (!$target.hasClass(this.markerClassName)) {
  3606. return;
  3607. }
  3608. nodeName = target.nodeName.toLowerCase();
  3609. $.removeData(target, "datepicker");
  3610. if (nodeName === "input") {
  3611. inst.append.remove();
  3612. inst.trigger.remove();
  3613. $target.removeClass(this.markerClassName).
  3614. unbind("focus", this._showDatepicker).
  3615. unbind("keydown", this._doKeyDown).
  3616. unbind("keypress", this._doKeyPress).
  3617. unbind("keyup", this._doKeyUp);
  3618. } else if (nodeName === "div" || nodeName === "span") {
  3619. $target.removeClass(this.markerClassName).empty();
  3620. }
  3621. },
  3622. /* Enable the date picker to a jQuery selection.
  3623. * @param target element - the target input field or division or span
  3624. */
  3625. _enableDatepicker: function(target) {
  3626. var nodeName, inline,
  3627. $target = $(target),
  3628. inst = $.data(target, "datepicker");
  3629. if (!$target.hasClass(this.markerClassName)) {
  3630. return;
  3631. }
  3632. nodeName = target.nodeName.toLowerCase();
  3633. if (nodeName === "input") {
  3634. target.disabled = false;
  3635. inst.trigger.filter("button").
  3636. each(function() { this.disabled = false; }).end().
  3637. filter("img").css({opacity: "1.0", cursor: ""});
  3638. } else if (nodeName === "div" || nodeName === "span") {
  3639. inline = $target.children("." + this._inlineClass);
  3640. inline.children().removeClass("ui-state-disabled");
  3641. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3642. prop("disabled", false);
  3643. }
  3644. this._disabledInputs = $.map(this._disabledInputs,
  3645. function(value) { return (value === target ? null : value); }); // delete entry
  3646. },
  3647. /* Disable the date picker to a jQuery selection.
  3648. * @param target element - the target input field or division or span
  3649. */
  3650. _disableDatepicker: function(target) {
  3651. var nodeName, inline,
  3652. $target = $(target),
  3653. inst = $.data(target, "datepicker");
  3654. if (!$target.hasClass(this.markerClassName)) {
  3655. return;
  3656. }
  3657. nodeName = target.nodeName.toLowerCase();
  3658. if (nodeName === "input") {
  3659. target.disabled = true;
  3660. inst.trigger.filter("button").
  3661. each(function() { this.disabled = true; }).end().
  3662. filter("img").css({opacity: "0.5", cursor: "default"});
  3663. } else if (nodeName === "div" || nodeName === "span") {
  3664. inline = $target.children("." + this._inlineClass);
  3665. inline.children().addClass("ui-state-disabled");
  3666. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3667. prop("disabled", true);
  3668. }
  3669. this._disabledInputs = $.map(this._disabledInputs,
  3670. function(value) { return (value === target ? null : value); }); // delete entry
  3671. this._disabledInputs[this._disabledInputs.length] = target;
  3672. },
  3673. /* Is the first field in a jQuery collection disabled as a datepicker?
  3674. * @param target element - the target input field or division or span
  3675. * @return boolean - true if disabled, false if enabled
  3676. */
  3677. _isDisabledDatepicker: function(target) {
  3678. if (!target) {
  3679. return false;
  3680. }
  3681. for (var i = 0; i < this._disabledInputs.length; i++) {
  3682. if (this._disabledInputs[i] === target) {
  3683. return true;
  3684. }
  3685. }
  3686. return false;
  3687. },
  3688. /* Retrieve the instance data for the target control.
  3689. * @param target element - the target input field or division or span
  3690. * @return object - the associated instance data
  3691. * @throws error if a jQuery problem getting data
  3692. */
  3693. _getInst: function(target) {
  3694. try {
  3695. return $.data(target, "datepicker");
  3696. }
  3697. catch (err) {
  3698. throw "Missing instance data for this datepicker";
  3699. }
  3700. },
  3701. /* Update or retrieve the settings for a date picker attached to an input field or division.
  3702. * @param target element - the target input field or division or span
  3703. * @param name object - the new settings to update or
  3704. * string - the name of the setting to change or retrieve,
  3705. * when retrieving also "all" for all instance settings or
  3706. * "defaults" for all global defaults
  3707. * @param value any - the new value for the setting
  3708. * (omit if above is an object or to retrieve a value)
  3709. */
  3710. _optionDatepicker: function(target, name, value) {
  3711. var settings, date, minDate, maxDate,
  3712. inst = this._getInst(target);
  3713. if (arguments.length === 2 && typeof name === "string") {
  3714. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  3715. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  3716. this._get(inst, name)) : null));
  3717. }
  3718. settings = name || {};
  3719. if (typeof name === "string") {
  3720. settings = {};
  3721. settings[name] = value;
  3722. }
  3723. if (inst) {
  3724. if (this._curInst === inst) {
  3725. this._hideDatepicker();
  3726. }
  3727. date = this._getDateDatepicker(target, true);
  3728. minDate = this._getMinMaxDate(inst, "min");
  3729. maxDate = this._getMinMaxDate(inst, "max");
  3730. datepicker_extendRemove(inst.settings, settings);
  3731. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  3732. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  3733. inst.settings.minDate = this._formatDate(inst, minDate);
  3734. }
  3735. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  3736. inst.settings.maxDate = this._formatDate(inst, maxDate);
  3737. }
  3738. if ( "disabled" in settings ) {
  3739. if ( settings.disabled ) {
  3740. this._disableDatepicker(target);
  3741. } else {
  3742. this._enableDatepicker(target);
  3743. }
  3744. }
  3745. this._attachments($(target), inst);
  3746. this._autoSize(inst);
  3747. this._setDate(inst, date);
  3748. this._updateAlternate(inst);
  3749. this._updateDatepicker(inst);
  3750. }
  3751. },
  3752. // change method deprecated
  3753. _changeDatepicker: function(target, name, value) {
  3754. this._optionDatepicker(target, name, value);
  3755. },
  3756. /* Redraw the date picker attached to an input field or division.
  3757. * @param target element - the target input field or division or span
  3758. */
  3759. _refreshDatepicker: function(target) {
  3760. var inst = this._getInst(target);
  3761. if (inst) {
  3762. this._updateDatepicker(inst);
  3763. }
  3764. },
  3765. /* Set the dates for a jQuery selection.
  3766. * @param target element - the target input field or division or span
  3767. * @param date Date - the new date
  3768. */
  3769. _setDateDatepicker: function(target, date) {
  3770. var inst = this._getInst(target);
  3771. if (inst) {
  3772. this._setDate(inst, date);
  3773. this._updateDatepicker(inst);
  3774. this._updateAlternate(inst);
  3775. }
  3776. },
  3777. /* Get the date(s) for the first entry in a jQuery selection.
  3778. * @param target element - the target input field or division or span
  3779. * @param noDefault boolean - true if no default date is to be used
  3780. * @return Date - the current date
  3781. */
  3782. _getDateDatepicker: function(target, noDefault) {
  3783. var inst = this._getInst(target);
  3784. if (inst && !inst.inline) {
  3785. this._setDateFromField(inst, noDefault);
  3786. }
  3787. return (inst ? this._getDate(inst) : null);
  3788. },
  3789. /* Handle keystrokes. */
  3790. _doKeyDown: function(event) {
  3791. var onSelect, dateStr, sel,
  3792. inst = $.datepicker._getInst(event.target),
  3793. handled = true,
  3794. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  3795. inst._keyEvent = true;
  3796. if ($.datepicker._datepickerShowing) {
  3797. switch (event.keyCode) {
  3798. case 9: $.datepicker._hideDatepicker();
  3799. handled = false;
  3800. break; // hide on tab out
  3801. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  3802. $.datepicker._currentClass + ")", inst.dpDiv);
  3803. if (sel[0]) {
  3804. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  3805. }
  3806. onSelect = $.datepicker._get(inst, "onSelect");
  3807. if (onSelect) {
  3808. dateStr = $.datepicker._formatDate(inst);
  3809. // trigger custom callback
  3810. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  3811. } else {
  3812. $.datepicker._hideDatepicker();
  3813. }
  3814. return false; // don't submit the form
  3815. case 27: $.datepicker._hideDatepicker();
  3816. break; // hide on escape
  3817. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3818. -$.datepicker._get(inst, "stepBigMonths") :
  3819. -$.datepicker._get(inst, "stepMonths")), "M");
  3820. break; // previous month/year on page up/+ ctrl
  3821. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3822. +$.datepicker._get(inst, "stepBigMonths") :
  3823. +$.datepicker._get(inst, "stepMonths")), "M");
  3824. break; // next month/year on page down/+ ctrl
  3825. case 35: if (event.ctrlKey || event.metaKey) {
  3826. $.datepicker._clearDate(event.target);
  3827. }
  3828. handled = event.ctrlKey || event.metaKey;
  3829. break; // clear on ctrl or command +end
  3830. case 36: if (event.ctrlKey || event.metaKey) {
  3831. $.datepicker._gotoToday(event.target);
  3832. }
  3833. handled = event.ctrlKey || event.metaKey;
  3834. break; // current on ctrl or command +home
  3835. case 37: if (event.ctrlKey || event.metaKey) {
  3836. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  3837. }
  3838. handled = event.ctrlKey || event.metaKey;
  3839. // -1 day on ctrl or command +left
  3840. if (event.originalEvent.altKey) {
  3841. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3842. -$.datepicker._get(inst, "stepBigMonths") :
  3843. -$.datepicker._get(inst, "stepMonths")), "M");
  3844. }
  3845. // next month/year on alt +left on Mac
  3846. break;
  3847. case 38: if (event.ctrlKey || event.metaKey) {
  3848. $.datepicker._adjustDate(event.target, -7, "D");
  3849. }
  3850. handled = event.ctrlKey || event.metaKey;
  3851. break; // -1 week on ctrl or command +up
  3852. case 39: if (event.ctrlKey || event.metaKey) {
  3853. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  3854. }
  3855. handled = event.ctrlKey || event.metaKey;
  3856. // +1 day on ctrl or command +right
  3857. if (event.originalEvent.altKey) {
  3858. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3859. +$.datepicker._get(inst, "stepBigMonths") :
  3860. +$.datepicker._get(inst, "stepMonths")), "M");
  3861. }
  3862. // next month/year on alt +right
  3863. break;
  3864. case 40: if (event.ctrlKey || event.metaKey) {
  3865. $.datepicker._adjustDate(event.target, +7, "D");
  3866. }
  3867. handled = event.ctrlKey || event.metaKey;
  3868. break; // +1 week on ctrl or command +down
  3869. default: handled = false;
  3870. }
  3871. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  3872. $.datepicker._showDatepicker(this);
  3873. } else {
  3874. handled = false;
  3875. }
  3876. if (handled) {
  3877. event.preventDefault();
  3878. event.stopPropagation();
  3879. }
  3880. },
  3881. /* Filter entered characters - based on date format. */
  3882. _doKeyPress: function(event) {
  3883. var chars, chr,
  3884. inst = $.datepicker._getInst(event.target);
  3885. if ($.datepicker._get(inst, "constrainInput")) {
  3886. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  3887. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  3888. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  3889. }
  3890. },
  3891. /* Synchronise manual entry and field/alternate field. */
  3892. _doKeyUp: function(event) {
  3893. var date,
  3894. inst = $.datepicker._getInst(event.target);
  3895. if (inst.input.val() !== inst.lastVal) {
  3896. try {
  3897. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  3898. (inst.input ? inst.input.val() : null),
  3899. $.datepicker._getFormatConfig(inst));
  3900. if (date) { // only if valid
  3901. $.datepicker._setDateFromField(inst);
  3902. $.datepicker._updateAlternate(inst);
  3903. $.datepicker._updateDatepicker(inst);
  3904. }
  3905. }
  3906. catch (err) {
  3907. }
  3908. }
  3909. return true;
  3910. },
  3911. /* Pop-up the date picker for a given input field.
  3912. * If false returned from beforeShow event handler do not show.
  3913. * @param input element - the input field attached to the date picker or
  3914. * event - if triggered by focus
  3915. */
  3916. _showDatepicker: function(input) {
  3917. input = input.target || input;
  3918. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  3919. input = $("input", input.parentNode)[0];
  3920. }
  3921. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  3922. return;
  3923. }
  3924. var inst, beforeShow, beforeShowSettings, isFixed,
  3925. offset, showAnim, duration;
  3926. inst = $.datepicker._getInst(input);
  3927. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  3928. $.datepicker._curInst.dpDiv.stop(true, true);
  3929. if ( inst && $.datepicker._datepickerShowing ) {
  3930. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  3931. }
  3932. }
  3933. beforeShow = $.datepicker._get(inst, "beforeShow");
  3934. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  3935. if(beforeShowSettings === false){
  3936. return;
  3937. }
  3938. datepicker_extendRemove(inst.settings, beforeShowSettings);
  3939. inst.lastVal = null;
  3940. $.datepicker._lastInput = input;
  3941. $.datepicker._setDateFromField(inst);
  3942. if ($.datepicker._inDialog) { // hide cursor
  3943. input.value = "";
  3944. }
  3945. if (!$.datepicker._pos) { // position below input
  3946. $.datepicker._pos = $.datepicker._findPos(input);
  3947. $.datepicker._pos[1] += input.offsetHeight; // add the height
  3948. }
  3949. isFixed = false;
  3950. $(input).parents().each(function() {
  3951. isFixed |= $(this).css("position") === "fixed";
  3952. return !isFixed;
  3953. });
  3954. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  3955. $.datepicker._pos = null;
  3956. //to avoid flashes on Firefox
  3957. inst.dpDiv.empty();
  3958. // determine sizing offscreen
  3959. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  3960. $.datepicker._updateDatepicker(inst);
  3961. // fix width for dynamic number of date pickers
  3962. // and adjust position before showing
  3963. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  3964. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  3965. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  3966. left: offset.left + "px", top: offset.top + "px"});
  3967. if (!inst.inline) {
  3968. showAnim = $.datepicker._get(inst, "showAnim");
  3969. duration = $.datepicker._get(inst, "duration");
  3970. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  3971. $.datepicker._datepickerShowing = true;
  3972. if ( $.effects && $.effects.effect[ showAnim ] ) {
  3973. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  3974. } else {
  3975. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  3976. }
  3977. if ( $.datepicker._shouldFocusInput( inst ) ) {
  3978. inst.input.focus();
  3979. }
  3980. $.datepicker._curInst = inst;
  3981. }
  3982. },
  3983. /* Generate the date picker content. */
  3984. _updateDatepicker: function(inst) {
  3985. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  3986. datepicker_instActive = inst; // for delegate hover events
  3987. inst.dpDiv.empty().append(this._generateHTML(inst));
  3988. this._attachHandlers(inst);
  3989. var origyearshtml,
  3990. numMonths = this._getNumberOfMonths(inst),
  3991. cols = numMonths[1],
  3992. width = 17,
  3993. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
  3994. if ( activeCell.length > 0 ) {
  3995. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  3996. }
  3997. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  3998. if (cols > 1) {
  3999. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  4000. }
  4001. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  4002. "Class"]("ui-datepicker-multi");
  4003. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  4004. "Class"]("ui-datepicker-rtl");
  4005. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  4006. inst.input.focus();
  4007. }
  4008. // deffered render of the years select (to avoid flashes on Firefox)
  4009. if( inst.yearshtml ){
  4010. origyearshtml = inst.yearshtml;
  4011. setTimeout(function(){
  4012. //assure that inst.yearshtml didn't change.
  4013. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  4014. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  4015. }
  4016. origyearshtml = inst.yearshtml = null;
  4017. }, 0);
  4018. }
  4019. },
  4020. // #6694 - don't focus the input if it's already focused
  4021. // this breaks the change event in IE
  4022. // Support: IE and jQuery <1.9
  4023. _shouldFocusInput: function( inst ) {
  4024. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  4025. },
  4026. /* Check positioning to remain on screen. */
  4027. _checkOffset: function(inst, offset, isFixed) {
  4028. var dpWidth = inst.dpDiv.outerWidth(),
  4029. dpHeight = inst.dpDiv.outerHeight(),
  4030. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  4031. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  4032. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  4033. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  4034. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  4035. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  4036. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  4037. // now check if datepicker is showing outside window viewport - move to a better place if so.
  4038. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  4039. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  4040. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  4041. Math.abs(dpHeight + inputHeight) : 0);
  4042. return offset;
  4043. },
  4044. /* Find an object's position on the screen. */
  4045. _findPos: function(obj) {
  4046. var position,
  4047. inst = this._getInst(obj),
  4048. isRTL = this._get(inst, "isRTL");
  4049. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  4050. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  4051. }
  4052. position = $(obj).offset();
  4053. return [position.left, position.top];
  4054. },
  4055. /* Hide the date picker from view.
  4056. * @param input element - the input field attached to the date picker
  4057. */
  4058. _hideDatepicker: function(input) {
  4059. var showAnim, duration, postProcess, onClose,
  4060. inst = this._curInst;
  4061. if (!inst || (input && inst !== $.data(input, "datepicker"))) {
  4062. return;
  4063. }
  4064. if (this._datepickerShowing) {
  4065. showAnim = this._get(inst, "showAnim");
  4066. duration = this._get(inst, "duration");
  4067. postProcess = function() {
  4068. $.datepicker._tidyDialog(inst);
  4069. };
  4070. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  4071. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  4072. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  4073. } else {
  4074. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  4075. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  4076. }
  4077. if (!showAnim) {
  4078. postProcess();
  4079. }
  4080. this._datepickerShowing = false;
  4081. onClose = this._get(inst, "onClose");
  4082. if (onClose) {
  4083. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  4084. }
  4085. this._lastInput = null;
  4086. if (this._inDialog) {
  4087. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  4088. if ($.blockUI) {
  4089. $.unblockUI();
  4090. $("body").append(this.dpDiv);
  4091. }
  4092. }
  4093. this._inDialog = false;
  4094. }
  4095. },
  4096. /* Tidy up after a dialog display. */
  4097. _tidyDialog: function(inst) {
  4098. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  4099. },
  4100. /* Close date picker if clicked elsewhere. */
  4101. _checkExternalClick: function(event) {
  4102. if (!$.datepicker._curInst) {
  4103. return;
  4104. }
  4105. var $target = $(event.target),
  4106. inst = $.datepicker._getInst($target[0]);
  4107. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  4108. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  4109. !$target.hasClass($.datepicker.markerClassName) &&
  4110. !$target.closest("." + $.datepicker._triggerClass).length &&
  4111. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  4112. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  4113. $.datepicker._hideDatepicker();
  4114. }
  4115. },
  4116. /* Adjust one of the date sub-fields. */
  4117. _adjustDate: function(id, offset, period) {
  4118. var target = $(id),
  4119. inst = this._getInst(target[0]);
  4120. if (this._isDisabledDatepicker(target[0])) {
  4121. return;
  4122. }
  4123. this._adjustInstDate(inst, offset +
  4124. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  4125. period);
  4126. this._updateDatepicker(inst);
  4127. },
  4128. /* Action for current link. */
  4129. _gotoToday: function(id) {
  4130. var date,
  4131. target = $(id),
  4132. inst = this._getInst(target[0]);
  4133. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  4134. inst.selectedDay = inst.currentDay;
  4135. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  4136. inst.drawYear = inst.selectedYear = inst.currentYear;
  4137. } else {
  4138. date = new Date();
  4139. inst.selectedDay = date.getDate();
  4140. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4141. inst.drawYear = inst.selectedYear = date.getFullYear();
  4142. }
  4143. this._notifyChange(inst);
  4144. this._adjustDate(target);
  4145. },
  4146. /* Action for selecting a new month/year. */
  4147. _selectMonthYear: function(id, select, period) {
  4148. var target = $(id),
  4149. inst = this._getInst(target[0]);
  4150. inst["selected" + (period === "M" ? "Month" : "Year")] =
  4151. inst["draw" + (period === "M" ? "Month" : "Year")] =
  4152. parseInt(select.options[select.selectedIndex].value,10);
  4153. this._notifyChange(inst);
  4154. this._adjustDate(target);
  4155. },
  4156. /* Action for selecting a day. */
  4157. _selectDay: function(id, month, year, td) {
  4158. var inst,
  4159. target = $(id);
  4160. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  4161. return;
  4162. }
  4163. inst = this._getInst(target[0]);
  4164. inst.selectedDay = inst.currentDay = $("a", td).html();
  4165. inst.selectedMonth = inst.currentMonth = month;
  4166. inst.selectedYear = inst.currentYear = year;
  4167. this._selectDate(id, this._formatDate(inst,
  4168. inst.currentDay, inst.currentMonth, inst.currentYear));
  4169. },
  4170. /* Erase the input field and hide the date picker. */
  4171. _clearDate: function(id) {
  4172. var target = $(id);
  4173. this._selectDate(target, "");
  4174. },
  4175. /* Update the input field with the selected date. */
  4176. _selectDate: function(id, dateStr) {
  4177. var onSelect,
  4178. target = $(id),
  4179. inst = this._getInst(target[0]);
  4180. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  4181. if (inst.input) {
  4182. inst.input.val(dateStr);
  4183. }
  4184. this._updateAlternate(inst);
  4185. onSelect = this._get(inst, "onSelect");
  4186. if (onSelect) {
  4187. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  4188. } else if (inst.input) {
  4189. inst.input.trigger("change"); // fire the change event
  4190. }
  4191. if (inst.inline){
  4192. this._updateDatepicker(inst);
  4193. } else {
  4194. this._hideDatepicker();
  4195. this._lastInput = inst.input[0];
  4196. if (typeof(inst.input[0]) !== "object") {
  4197. inst.input.focus(); // restore focus
  4198. }
  4199. this._lastInput = null;
  4200. }
  4201. },
  4202. /* Update any alternate field to synchronise with the main field. */
  4203. _updateAlternate: function(inst) {
  4204. var altFormat, date, dateStr,
  4205. altField = this._get(inst, "altField");
  4206. if (altField) { // update alternate field too
  4207. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  4208. date = this._getDate(inst);
  4209. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  4210. $(altField).each(function() { $(this).val(dateStr); });
  4211. }
  4212. },
  4213. /* Set as beforeShowDay function to prevent selection of weekends.
  4214. * @param date Date - the date to customise
  4215. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  4216. */
  4217. noWeekends: function(date) {
  4218. var day = date.getDay();
  4219. return [(day > 0 && day < 6), ""];
  4220. },
  4221. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  4222. * @param date Date - the date to get the week for
  4223. * @return number - the number of the week within the year that contains this date
  4224. */
  4225. iso8601Week: function(date) {
  4226. var time,
  4227. checkDate = new Date(date.getTime());
  4228. // Find Thursday of this week starting on Monday
  4229. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  4230. time = checkDate.getTime();
  4231. checkDate.setMonth(0); // Compare with Jan 1
  4232. checkDate.setDate(1);
  4233. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  4234. },
  4235. /* Parse a string value into a date object.
  4236. * See formatDate below for the possible formats.
  4237. *
  4238. * @param format string - the expected format of the date
  4239. * @param value string - the date in the above format
  4240. * @param settings Object - attributes include:
  4241. * shortYearCutoff number - the cutoff year for determining the century (optional)
  4242. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  4243. * dayNames string[7] - names of the days from Sunday (optional)
  4244. * monthNamesShort string[12] - abbreviated names of the months (optional)
  4245. * monthNames string[12] - names of the months (optional)
  4246. * @return Date - the extracted date value or null if value is blank
  4247. */
  4248. parseDate: function (format, value, settings) {
  4249. if (format == null || value == null) {
  4250. throw "Invalid arguments";
  4251. }
  4252. value = (typeof value === "object" ? value.toString() : value + "");
  4253. if (value === "") {
  4254. return null;
  4255. }
  4256. var iFormat, dim, extra,
  4257. iValue = 0,
  4258. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  4259. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  4260. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  4261. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  4262. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  4263. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  4264. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  4265. year = -1,
  4266. month = -1,
  4267. day = -1,
  4268. doy = -1,
  4269. literal = false,
  4270. date,
  4271. // Check whether a format character is doubled
  4272. lookAhead = function(match) {
  4273. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  4274. if (matches) {
  4275. iFormat++;
  4276. }
  4277. return matches;
  4278. },
  4279. // Extract a number from the string value
  4280. getNumber = function(match) {
  4281. var isDoubled = lookAhead(match),
  4282. size = (match === "@" ? 14 : (match === "!" ? 20 :
  4283. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  4284. minSize = (match === "y" ? size : 1),
  4285. digits = new RegExp("^\\d{" + minSize + "," + size + "}"),
  4286. num = value.substring(iValue).match(digits);
  4287. if (!num) {
  4288. throw "Missing number at position " + iValue;
  4289. }
  4290. iValue += num[0].length;
  4291. return parseInt(num[0], 10);
  4292. },
  4293. // Extract a name from the string value and convert to an index
  4294. getName = function(match, shortNames, longNames) {
  4295. var index = -1,
  4296. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  4297. return [ [k, v] ];
  4298. }).sort(function (a, b) {
  4299. return -(a[1].length - b[1].length);
  4300. });
  4301. $.each(names, function (i, pair) {
  4302. var name = pair[1];
  4303. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  4304. index = pair[0];
  4305. iValue += name.length;
  4306. return false;
  4307. }
  4308. });
  4309. if (index !== -1) {
  4310. return index + 1;
  4311. } else {
  4312. throw "Unknown name at position " + iValue;
  4313. }
  4314. },
  4315. // Confirm that a literal character matches the string value
  4316. checkLiteral = function() {
  4317. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  4318. throw "Unexpected literal at position " + iValue;
  4319. }
  4320. iValue++;
  4321. };
  4322. for (iFormat = 0; iFormat < format.length; iFormat++) {
  4323. if (literal) {
  4324. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  4325. literal = false;
  4326. } else {
  4327. checkLiteral();
  4328. }
  4329. } else {
  4330. switch (format.charAt(iFormat)) {
  4331. case "d":
  4332. day = getNumber("d");
  4333. break;
  4334. case "D":
  4335. getName("D", dayNamesShort, dayNames);
  4336. break;
  4337. case "o":
  4338. doy = getNumber("o");
  4339. break;
  4340. case "m":
  4341. month = getNumber("m");
  4342. break;
  4343. case "M":
  4344. month = getName("M", monthNamesShort, monthNames);
  4345. break;
  4346. case "y":
  4347. year = getNumber("y");
  4348. break;
  4349. case "@":
  4350. date = new Date(getNumber("@"));
  4351. year = date.getFullYear();
  4352. month = date.getMonth() + 1;
  4353. day = date.getDate();
  4354. break;
  4355. case "!":
  4356. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  4357. year = date.getFullYear();
  4358. month = date.getMonth() + 1;
  4359. day = date.getDate();
  4360. break;
  4361. case "'":
  4362. if (lookAhead("'")){
  4363. checkLiteral();
  4364. } else {
  4365. literal = true;
  4366. }
  4367. break;
  4368. default:
  4369. checkLiteral();
  4370. }
  4371. }
  4372. }
  4373. if (iValue < value.length){
  4374. extra = value.substr(iValue);
  4375. if (!/^\s+/.test(extra)) {
  4376. throw "Extra/unparsed characters found in date: " + extra;
  4377. }
  4378. }
  4379. if (year === -1) {
  4380. year = new Date().getFullYear();
  4381. } else if (year < 100) {
  4382. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  4383. (year <= shortYearCutoff ? 0 : -100);
  4384. }
  4385. if (doy > -1) {
  4386. month = 1;
  4387. day = doy;
  4388. do {
  4389. dim = this._getDaysInMonth(year, month - 1);
  4390. if (day <= dim) {
  4391. break;
  4392. }
  4393. month++;
  4394. day -= dim;
  4395. } while (true);
  4396. }
  4397. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  4398. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  4399. throw "Invalid date"; // E.g. 31/02/00
  4400. }
  4401. return date;
  4402. },
  4403. /* Standard date formats. */
  4404. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  4405. COOKIE: "D, dd M yy",
  4406. ISO_8601: "yy-mm-dd",
  4407. RFC_822: "D, d M y",
  4408. RFC_850: "DD, dd-M-y",
  4409. RFC_1036: "D, d M y",
  4410. RFC_1123: "D, d M yy",
  4411. RFC_2822: "D, d M yy",
  4412. RSS: "D, d M y", // RFC 822
  4413. TICKS: "!",
  4414. TIMESTAMP: "@",
  4415. W3C: "yy-mm-dd", // ISO 8601
  4416. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  4417. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  4418. /* Format a date object into a string value.
  4419. * The format can be combinations of the following:
  4420. * d - day of month (no leading zero)
  4421. * dd - day of month (two digit)
  4422. * o - day of year (no leading zeros)
  4423. * oo - day of year (three digit)
  4424. * D - day name short
  4425. * DD - day name long
  4426. * m - month of year (no leading zero)
  4427. * mm - month of year (two digit)
  4428. * M - month name short
  4429. * MM - month name long
  4430. * y - year (two digit)
  4431. * yy - year (four digit)
  4432. * @ - Unix timestamp (ms since 01/01/1970)
  4433. * ! - Windows ticks (100ns since 01/01/0001)
  4434. * "..." - literal text
  4435. * '' - single quote
  4436. *
  4437. * @param format string - the desired format of the date
  4438. * @param date Date - the date value to format
  4439. * @param settings Object - attributes include:
  4440. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  4441. * dayNames string[7] - names of the days from Sunday (optional)
  4442. * monthNamesShort string[12] - abbreviated names of the months (optional)
  4443. * monthNames string[12] - names of the months (optional)
  4444. * @return string - the date in the above format
  4445. */
  4446. formatDate: function (format, date, settings) {
  4447. if (!date) {
  4448. return "";
  4449. }
  4450. var iFormat,
  4451. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  4452. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  4453. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  4454. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  4455. // Check whether a format character is doubled
  4456. lookAhead = function(match) {
  4457. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  4458. if (matches) {
  4459. iFormat++;
  4460. }
  4461. return matches;
  4462. },
  4463. // Format a number, with leading zero if necessary
  4464. formatNumber = function(match, value, len) {
  4465. var num = "" + value;
  4466. if (lookAhead(match)) {
  4467. while (num.length < len) {
  4468. num = "0" + num;
  4469. }
  4470. }
  4471. return num;
  4472. },
  4473. // Format a name, short or long as requested
  4474. formatName = function(match, value, shortNames, longNames) {
  4475. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  4476. },
  4477. output = "",
  4478. literal = false;
  4479. if (date) {
  4480. for (iFormat = 0; iFormat < format.length; iFormat++) {
  4481. if (literal) {
  4482. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  4483. literal = false;
  4484. } else {
  4485. output += format.charAt(iFormat);
  4486. }
  4487. } else {
  4488. switch (format.charAt(iFormat)) {
  4489. case "d":
  4490. output += formatNumber("d", date.getDate(), 2);
  4491. break;
  4492. case "D":
  4493. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  4494. break;
  4495. case "o":
  4496. output += formatNumber("o",
  4497. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  4498. break;
  4499. case "m":
  4500. output += formatNumber("m", date.getMonth() + 1, 2);
  4501. break;
  4502. case "M":
  4503. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  4504. break;
  4505. case "y":
  4506. output += (lookAhead("y") ? date.getFullYear() :
  4507. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  4508. break;
  4509. case "@":
  4510. output += date.getTime();
  4511. break;
  4512. case "!":
  4513. output += date.getTime() * 10000 + this._ticksTo1970;
  4514. break;
  4515. case "'":
  4516. if (lookAhead("'")) {
  4517. output += "'";
  4518. } else {
  4519. literal = true;
  4520. }
  4521. break;
  4522. default:
  4523. output += format.charAt(iFormat);
  4524. }
  4525. }
  4526. }
  4527. }
  4528. return output;
  4529. },
  4530. /* Extract all possible characters from the date format. */
  4531. _possibleChars: function (format) {
  4532. var iFormat,
  4533. chars = "",
  4534. literal = false,
  4535. // Check whether a format character is doubled
  4536. lookAhead = function(match) {
  4537. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  4538. if (matches) {
  4539. iFormat++;
  4540. }
  4541. return matches;
  4542. };
  4543. for (iFormat = 0; iFormat < format.length; iFormat++) {
  4544. if (literal) {
  4545. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  4546. literal = false;
  4547. } else {
  4548. chars += format.charAt(iFormat);
  4549. }
  4550. } else {
  4551. switch (format.charAt(iFormat)) {
  4552. case "d": case "m": case "y": case "@":
  4553. chars += "0123456789";
  4554. break;
  4555. case "D": case "M":
  4556. return null; // Accept anything
  4557. case "'":
  4558. if (lookAhead("'")) {
  4559. chars += "'";
  4560. } else {
  4561. literal = true;
  4562. }
  4563. break;
  4564. default:
  4565. chars += format.charAt(iFormat);
  4566. }
  4567. }
  4568. }
  4569. return chars;
  4570. },
  4571. /* Get a setting value, defaulting if necessary. */
  4572. _get: function(inst, name) {
  4573. return inst.settings[name] !== undefined ?
  4574. inst.settings[name] : this._defaults[name];
  4575. },
  4576. /* Parse existing date and initialise date picker. */
  4577. _setDateFromField: function(inst, noDefault) {
  4578. if (inst.input.val() === inst.lastVal) {
  4579. return;
  4580. }
  4581. var dateFormat = this._get(inst, "dateFormat"),
  4582. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  4583. defaultDate = this._getDefaultDate(inst),
  4584. date = defaultDate,
  4585. settings = this._getFormatConfig(inst);
  4586. try {
  4587. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  4588. } catch (event) {
  4589. dates = (noDefault ? "" : dates);
  4590. }
  4591. inst.selectedDay = date.getDate();
  4592. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4593. inst.drawYear = inst.selectedYear = date.getFullYear();
  4594. inst.currentDay = (dates ? date.getDate() : 0);
  4595. inst.currentMonth = (dates ? date.getMonth() : 0);
  4596. inst.currentYear = (dates ? date.getFullYear() : 0);
  4597. this._adjustInstDate(inst);
  4598. },
  4599. /* Retrieve the default date shown on opening. */
  4600. _getDefaultDate: function(inst) {
  4601. return this._restrictMinMax(inst,
  4602. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  4603. },
  4604. /* A date may be specified as an exact value or a relative one. */
  4605. _determineDate: function(inst, date, defaultDate) {
  4606. var offsetNumeric = function(offset) {
  4607. var date = new Date();
  4608. date.setDate(date.getDate() + offset);
  4609. return date;
  4610. },
  4611. offsetString = function(offset) {
  4612. try {
  4613. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  4614. offset, $.datepicker._getFormatConfig(inst));
  4615. }
  4616. catch (e) {
  4617. // Ignore
  4618. }
  4619. var date = (offset.toLowerCase().match(/^c/) ?
  4620. $.datepicker._getDate(inst) : null) || new Date(),
  4621. year = date.getFullYear(),
  4622. month = date.getMonth(),
  4623. day = date.getDate(),
  4624. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  4625. matches = pattern.exec(offset);
  4626. while (matches) {
  4627. switch (matches[2] || "d") {
  4628. case "d" : case "D" :
  4629. day += parseInt(matches[1],10); break;
  4630. case "w" : case "W" :
  4631. day += parseInt(matches[1],10) * 7; break;
  4632. case "m" : case "M" :
  4633. month += parseInt(matches[1],10);
  4634. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  4635. break;
  4636. case "y": case "Y" :
  4637. year += parseInt(matches[1],10);
  4638. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  4639. break;
  4640. }
  4641. matches = pattern.exec(offset);
  4642. }
  4643. return new Date(year, month, day);
  4644. },
  4645. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  4646. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  4647. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  4648. if (newDate) {
  4649. newDate.setHours(0);
  4650. newDate.setMinutes(0);
  4651. newDate.setSeconds(0);
  4652. newDate.setMilliseconds(0);
  4653. }
  4654. return this._daylightSavingAdjust(newDate);
  4655. },
  4656. /* Handle switch to/from daylight saving.
  4657. * Hours may be non-zero on daylight saving cut-over:
  4658. * > 12 when midnight changeover, but then cannot generate
  4659. * midnight datetime, so jump to 1AM, otherwise reset.
  4660. * @param date (Date) the date to check
  4661. * @return (Date) the corrected date
  4662. */
  4663. _daylightSavingAdjust: function(date) {
  4664. if (!date) {
  4665. return null;
  4666. }
  4667. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  4668. return date;
  4669. },
  4670. /* Set the date(s) directly. */
  4671. _setDate: function(inst, date, noChange) {
  4672. var clear = !date,
  4673. origMonth = inst.selectedMonth,
  4674. origYear = inst.selectedYear,
  4675. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  4676. inst.selectedDay = inst.currentDay = newDate.getDate();
  4677. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  4678. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  4679. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  4680. this._notifyChange(inst);
  4681. }
  4682. this._adjustInstDate(inst);
  4683. if (inst.input) {
  4684. inst.input.val(clear ? "" : this._formatDate(inst));
  4685. }
  4686. },
  4687. /* Retrieve the date(s) directly. */
  4688. _getDate: function(inst) {
  4689. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  4690. this._daylightSavingAdjust(new Date(
  4691. inst.currentYear, inst.currentMonth, inst.currentDay)));
  4692. return startDate;
  4693. },
  4694. /* Attach the onxxx handlers. These are declared statically so
  4695. * they work with static code transformers like Caja.
  4696. */
  4697. _attachHandlers: function(inst) {
  4698. var stepMonths = this._get(inst, "stepMonths"),
  4699. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  4700. inst.dpDiv.find("[data-handler]").map(function () {
  4701. var handler = {
  4702. prev: function () {
  4703. $.datepicker._adjustDate(id, -stepMonths, "M");
  4704. },
  4705. next: function () {
  4706. $.datepicker._adjustDate(id, +stepMonths, "M");
  4707. },
  4708. hide: function () {
  4709. $.datepicker._hideDatepicker();
  4710. },
  4711. today: function () {
  4712. $.datepicker._gotoToday(id);
  4713. },
  4714. selectDay: function () {
  4715. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  4716. return false;
  4717. },
  4718. selectMonth: function () {
  4719. $.datepicker._selectMonthYear(id, this, "M");
  4720. return false;
  4721. },
  4722. selectYear: function () {
  4723. $.datepicker._selectMonthYear(id, this, "Y");
  4724. return false;
  4725. }
  4726. };
  4727. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  4728. });
  4729. },
  4730. /* Generate the HTML for the current state of the date picker. */
  4731. _generateHTML: function(inst) {
  4732. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  4733. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  4734. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  4735. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  4736. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  4737. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  4738. tempDate = new Date(),
  4739. today = this._daylightSavingAdjust(
  4740. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  4741. isRTL = this._get(inst, "isRTL"),
  4742. showButtonPanel = this._get(inst, "showButtonPanel"),
  4743. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  4744. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  4745. numMonths = this._getNumberOfMonths(inst),
  4746. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  4747. stepMonths = this._get(inst, "stepMonths"),
  4748. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  4749. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  4750. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  4751. minDate = this._getMinMaxDate(inst, "min"),
  4752. maxDate = this._getMinMaxDate(inst, "max"),
  4753. drawMonth = inst.drawMonth - showCurrentAtPos,
  4754. drawYear = inst.drawYear;
  4755. if (drawMonth < 0) {
  4756. drawMonth += 12;
  4757. drawYear--;
  4758. }
  4759. if (maxDate) {
  4760. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  4761. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  4762. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  4763. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  4764. drawMonth--;
  4765. if (drawMonth < 0) {
  4766. drawMonth = 11;
  4767. drawYear--;
  4768. }
  4769. }
  4770. }
  4771. inst.drawMonth = drawMonth;
  4772. inst.drawYear = drawYear;
  4773. prevText = this._get(inst, "prevText");
  4774. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  4775. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  4776. this._getFormatConfig(inst)));
  4777. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  4778. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  4779. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  4780. (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>"));
  4781. nextText = this._get(inst, "nextText");
  4782. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  4783. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  4784. this._getFormatConfig(inst)));
  4785. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  4786. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  4787. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  4788. (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>"));
  4789. currentText = this._get(inst, "currentText");
  4790. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  4791. currentText = (!navigationAsDateFormat ? currentText :
  4792. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  4793. 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'>" +
  4794. this._get(inst, "closeText") + "</button>" : "");
  4795. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  4796. (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'" +
  4797. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  4798. firstDay = parseInt(this._get(inst, "firstDay"),10);
  4799. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  4800. showWeek = this._get(inst, "showWeek");
  4801. dayNames = this._get(inst, "dayNames");
  4802. dayNamesMin = this._get(inst, "dayNamesMin");
  4803. monthNames = this._get(inst, "monthNames");
  4804. monthNamesShort = this._get(inst, "monthNamesShort");
  4805. beforeShowDay = this._get(inst, "beforeShowDay");
  4806. showOtherMonths = this._get(inst, "showOtherMonths");
  4807. selectOtherMonths = this._get(inst, "selectOtherMonths");
  4808. defaultDate = this._getDefaultDate(inst);
  4809. html = "";
  4810. dow;
  4811. for (row = 0; row < numMonths[0]; row++) {
  4812. group = "";
  4813. this.maxRows = 4;
  4814. for (col = 0; col < numMonths[1]; col++) {
  4815. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  4816. cornerClass = " ui-corner-all";
  4817. calender = "";
  4818. if (isMultiMonth) {
  4819. calender += "<div class='ui-datepicker-group";
  4820. if (numMonths[1] > 1) {
  4821. switch (col) {
  4822. case 0: calender += " ui-datepicker-group-first";
  4823. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  4824. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  4825. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  4826. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  4827. }
  4828. }
  4829. calender += "'>";
  4830. }
  4831. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  4832. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  4833. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  4834. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  4835. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  4836. "</div><table class='ui-datepicker-calendar'><thead>" +
  4837. "<tr>";
  4838. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  4839. for (dow = 0; dow < 7; dow++) { // days of the week
  4840. day = (dow + firstDay) % 7;
  4841. thead += "<th scope='col'" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  4842. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  4843. }
  4844. calender += thead + "</tr></thead><tbody>";
  4845. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  4846. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  4847. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  4848. }
  4849. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  4850. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  4851. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  4852. this.maxRows = numRows;
  4853. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  4854. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  4855. calender += "<tr>";
  4856. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  4857. this._get(inst, "calculateWeek")(printDate) + "</td>");
  4858. for (dow = 0; dow < 7; dow++) { // create date picker days
  4859. daySettings = (beforeShowDay ?
  4860. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  4861. otherMonth = (printDate.getMonth() !== drawMonth);
  4862. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  4863. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  4864. tbody += "<td class='" +
  4865. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  4866. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  4867. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  4868. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  4869. // or defaultDate is current printedDate and defaultDate is selectedDate
  4870. " " + this._dayOverClass : "") + // highlight selected day
  4871. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  4872. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  4873. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  4874. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  4875. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  4876. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  4877. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  4878. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  4879. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  4880. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  4881. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  4882. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  4883. printDate.setDate(printDate.getDate() + 1);
  4884. printDate = this._daylightSavingAdjust(printDate);
  4885. }
  4886. calender += tbody + "</tr>";
  4887. }
  4888. drawMonth++;
  4889. if (drawMonth > 11) {
  4890. drawMonth = 0;
  4891. drawYear++;
  4892. }
  4893. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  4894. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  4895. group += calender;
  4896. }
  4897. html += group;
  4898. }
  4899. html += buttonPanel;
  4900. inst._keyEvent = false;
  4901. return html;
  4902. },
  4903. /* Generate the month and year header. */
  4904. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  4905. secondary, monthNames, monthNamesShort) {
  4906. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  4907. changeMonth = this._get(inst, "changeMonth"),
  4908. changeYear = this._get(inst, "changeYear"),
  4909. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  4910. html = "<div class='ui-datepicker-title'>",
  4911. monthHtml = "";
  4912. // month selection
  4913. if (secondary || !changeMonth) {
  4914. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  4915. } else {
  4916. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  4917. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  4918. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  4919. for ( month = 0; month < 12; month++) {
  4920. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  4921. monthHtml += "<option value='" + month + "'" +
  4922. (month === drawMonth ? " selected='selected'" : "") +
  4923. ">" + monthNamesShort[month] + "</option>";
  4924. }
  4925. }
  4926. monthHtml += "</select>";
  4927. }
  4928. if (!showMonthAfterYear) {
  4929. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  4930. }
  4931. // year selection
  4932. if ( !inst.yearshtml ) {
  4933. inst.yearshtml = "";
  4934. if (secondary || !changeYear) {
  4935. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  4936. } else {
  4937. // determine range of years to display
  4938. years = this._get(inst, "yearRange").split(":");
  4939. thisYear = new Date().getFullYear();
  4940. determineYear = function(value) {
  4941. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  4942. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  4943. parseInt(value, 10)));
  4944. return (isNaN(year) ? thisYear : year);
  4945. };
  4946. year = determineYear(years[0]);
  4947. endYear = Math.max(year, determineYear(years[1] || ""));
  4948. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  4949. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  4950. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  4951. for (; year <= endYear; year++) {
  4952. inst.yearshtml += "<option value='" + year + "'" +
  4953. (year === drawYear ? " selected='selected'" : "") +
  4954. ">" + year + "</option>";
  4955. }
  4956. inst.yearshtml += "</select>";
  4957. html += inst.yearshtml;
  4958. inst.yearshtml = null;
  4959. }
  4960. }
  4961. html += this._get(inst, "yearSuffix");
  4962. if (showMonthAfterYear) {
  4963. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  4964. }
  4965. html += "</div>"; // Close datepicker_header
  4966. return html;
  4967. },
  4968. /* Adjust one of the date sub-fields. */
  4969. _adjustInstDate: function(inst, offset, period) {
  4970. var year = inst.drawYear + (period === "Y" ? offset : 0),
  4971. month = inst.drawMonth + (period === "M" ? offset : 0),
  4972. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  4973. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  4974. inst.selectedDay = date.getDate();
  4975. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4976. inst.drawYear = inst.selectedYear = date.getFullYear();
  4977. if (period === "M" || period === "Y") {
  4978. this._notifyChange(inst);
  4979. }
  4980. },
  4981. /* Ensure a date is within any min/max bounds. */
  4982. _restrictMinMax: function(inst, date) {
  4983. var minDate = this._getMinMaxDate(inst, "min"),
  4984. maxDate = this._getMinMaxDate(inst, "max"),
  4985. newDate = (minDate && date < minDate ? minDate : date);
  4986. return (maxDate && newDate > maxDate ? maxDate : newDate);
  4987. },
  4988. /* Notify change of month/year. */
  4989. _notifyChange: function(inst) {
  4990. var onChange = this._get(inst, "onChangeMonthYear");
  4991. if (onChange) {
  4992. onChange.apply((inst.input ? inst.input[0] : null),
  4993. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  4994. }
  4995. },
  4996. /* Determine the number of months to show. */
  4997. _getNumberOfMonths: function(inst) {
  4998. var numMonths = this._get(inst, "numberOfMonths");
  4999. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  5000. },
  5001. /* Determine the current maximum date - ensure no time components are set. */
  5002. _getMinMaxDate: function(inst, minMax) {
  5003. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  5004. },
  5005. /* Find the number of days in a given month. */
  5006. _getDaysInMonth: function(year, month) {
  5007. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  5008. },
  5009. /* Find the day of the week of the first of a month. */
  5010. _getFirstDayOfMonth: function(year, month) {
  5011. return new Date(year, month, 1).getDay();
  5012. },
  5013. /* Determines if we should allow a "next/prev" month display change. */
  5014. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  5015. var numMonths = this._getNumberOfMonths(inst),
  5016. date = this._daylightSavingAdjust(new Date(curYear,
  5017. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  5018. if (offset < 0) {
  5019. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  5020. }
  5021. return this._isInRange(inst, date);
  5022. },
  5023. /* Is the given date in the accepted range? */
  5024. _isInRange: function(inst, date) {
  5025. var yearSplit, currentYear,
  5026. minDate = this._getMinMaxDate(inst, "min"),
  5027. maxDate = this._getMinMaxDate(inst, "max"),
  5028. minYear = null,
  5029. maxYear = null,
  5030. years = this._get(inst, "yearRange");
  5031. if (years){
  5032. yearSplit = years.split(":");
  5033. currentYear = new Date().getFullYear();
  5034. minYear = parseInt(yearSplit[0], 10);
  5035. maxYear = parseInt(yearSplit[1], 10);
  5036. if ( yearSplit[0].match(/[+\-].*/) ) {
  5037. minYear += currentYear;
  5038. }
  5039. if ( yearSplit[1].match(/[+\-].*/) ) {
  5040. maxYear += currentYear;
  5041. }
  5042. }
  5043. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  5044. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  5045. (!minYear || date.getFullYear() >= minYear) &&
  5046. (!maxYear || date.getFullYear() <= maxYear));
  5047. },
  5048. /* Provide the configuration settings for formatting/parsing. */
  5049. _getFormatConfig: function(inst) {
  5050. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  5051. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  5052. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  5053. return {shortYearCutoff: shortYearCutoff,
  5054. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  5055. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  5056. },
  5057. /* Format the given date for display. */
  5058. _formatDate: function(inst, day, month, year) {
  5059. if (!day) {
  5060. inst.currentDay = inst.selectedDay;
  5061. inst.currentMonth = inst.selectedMonth;
  5062. inst.currentYear = inst.selectedYear;
  5063. }
  5064. var date = (day ? (typeof day === "object" ? day :
  5065. this._daylightSavingAdjust(new Date(year, month, day))) :
  5066. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  5067. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  5068. }
  5069. });
  5070. /*
  5071. * Bind hover events for datepicker elements.
  5072. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  5073. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  5074. */
  5075. function datepicker_bindHover(dpDiv) {
  5076. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  5077. return dpDiv.delegate(selector, "mouseout", function() {
  5078. $(this).removeClass("ui-state-hover");
  5079. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  5080. $(this).removeClass("ui-datepicker-prev-hover");
  5081. }
  5082. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  5083. $(this).removeClass("ui-datepicker-next-hover");
  5084. }
  5085. })
  5086. .delegate( selector, "mouseover", datepicker_handleMouseover );
  5087. }
  5088. function datepicker_handleMouseover() {
  5089. if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) {
  5090. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  5091. $(this).addClass("ui-state-hover");
  5092. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  5093. $(this).addClass("ui-datepicker-prev-hover");
  5094. }
  5095. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  5096. $(this).addClass("ui-datepicker-next-hover");
  5097. }
  5098. }
  5099. }
  5100. /* jQuery extend now ignores nulls! */
  5101. function datepicker_extendRemove(target, props) {
  5102. $.extend(target, props);
  5103. for (var name in props) {
  5104. if (props[name] == null) {
  5105. target[name] = props[name];
  5106. }
  5107. }
  5108. return target;
  5109. }
  5110. /* Invoke the datepicker functionality.
  5111. @param options string - a command, optionally followed by additional parameters or
  5112. Object - settings for attaching new datepicker functionality
  5113. @return jQuery object */
  5114. $.fn.datepicker = function(options){
  5115. /* Verify an empty collection wasn't passed - Fixes #6976 */
  5116. if ( !this.length ) {
  5117. return this;
  5118. }
  5119. /* Initialise the date picker. */
  5120. if (!$.datepicker.initialized) {
  5121. $(document).mousedown($.datepicker._checkExternalClick);
  5122. $.datepicker.initialized = true;
  5123. }
  5124. /* Append datepicker main container to body if not exist. */
  5125. if ($("#"+$.datepicker._mainDivId).length === 0) {
  5126. $("body").append($.datepicker.dpDiv);
  5127. }
  5128. var otherArgs = Array.prototype.slice.call(arguments, 1);
  5129. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  5130. return $.datepicker["_" + options + "Datepicker"].
  5131. apply($.datepicker, [this[0]].concat(otherArgs));
  5132. }
  5133. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  5134. return $.datepicker["_" + options + "Datepicker"].
  5135. apply($.datepicker, [this[0]].concat(otherArgs));
  5136. }
  5137. return this.each(function() {
  5138. typeof options === "string" ?
  5139. $.datepicker["_" + options + "Datepicker"].
  5140. apply($.datepicker, [this].concat(otherArgs)) :
  5141. $.datepicker._attachDatepicker(this, options);
  5142. });
  5143. };
  5144. $.datepicker = new Datepicker(); // singleton instance
  5145. $.datepicker.initialized = false;
  5146. $.datepicker.uuid = new Date().getTime();
  5147. $.datepicker.version = "1.11.1";
  5148. var datepicker = $.datepicker;
  5149. /*!
  5150. * jQuery UI Draggable 1.11.1
  5151. * http://jqueryui.com
  5152. *
  5153. * Copyright 2014 jQuery Foundation and other contributors
  5154. * Released under the MIT license.
  5155. * http://jquery.org/license
  5156. *
  5157. * http://api.jqueryui.com/draggable/
  5158. */
  5159. $.widget("ui.draggable", $.ui.mouse, {
  5160. version: "1.11.1",
  5161. widgetEventPrefix: "drag",
  5162. options: {
  5163. addClasses: true,
  5164. appendTo: "parent",
  5165. axis: false,
  5166. connectToSortable: false,
  5167. containment: false,
  5168. cursor: "auto",
  5169. cursorAt: false,
  5170. grid: false,
  5171. handle: false,
  5172. helper: "original",
  5173. iframeFix: false,
  5174. opacity: false,
  5175. refreshPositions: false,
  5176. revert: false,
  5177. revertDuration: 500,
  5178. scope: "default",
  5179. scroll: true,
  5180. scrollSensitivity: 20,
  5181. scrollSpeed: 20,
  5182. snap: false,
  5183. snapMode: "both",
  5184. snapTolerance: 20,
  5185. stack: false,
  5186. zIndex: false,
  5187. // callbacks
  5188. drag: null,
  5189. start: null,
  5190. stop: null
  5191. },
  5192. _create: function() {
  5193. if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
  5194. this.element[0].style.position = "relative";
  5195. }
  5196. if (this.options.addClasses){
  5197. this.element.addClass("ui-draggable");
  5198. }
  5199. if (this.options.disabled){
  5200. this.element.addClass("ui-draggable-disabled");
  5201. }
  5202. this._setHandleClassName();
  5203. this._mouseInit();
  5204. },
  5205. _setOption: function( key, value ) {
  5206. this._super( key, value );
  5207. if ( key === "handle" ) {
  5208. this._removeHandleClassName();
  5209. this._setHandleClassName();
  5210. }
  5211. },
  5212. _destroy: function() {
  5213. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  5214. this.destroyOnClear = true;
  5215. return;
  5216. }
  5217. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  5218. this._removeHandleClassName();
  5219. this._mouseDestroy();
  5220. },
  5221. _mouseCapture: function(event) {
  5222. var document = this.document[ 0 ],
  5223. o = this.options;
  5224. // support: IE9
  5225. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  5226. try {
  5227. // Support: IE9+
  5228. // If the <body> is blurred, IE will switch windows, see #9520
  5229. if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
  5230. // Blur any element that currently has focus, see #4261
  5231. $( document.activeElement ).blur();
  5232. }
  5233. } catch ( error ) {}
  5234. // among others, prevent a drag on a resizable-handle
  5235. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  5236. return false;
  5237. }
  5238. //Quit if we're not on a valid handle
  5239. this.handle = this._getHandle(event);
  5240. if (!this.handle) {
  5241. return false;
  5242. }
  5243. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  5244. $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
  5245. .css({
  5246. width: this.offsetWidth + "px", height: this.offsetHeight + "px",
  5247. position: "absolute", opacity: "0.001", zIndex: 1000
  5248. })
  5249. .css($(this).offset())
  5250. .appendTo("body");
  5251. });
  5252. return true;
  5253. },
  5254. _mouseStart: function(event) {
  5255. var o = this.options;
  5256. //Create and append the visible helper
  5257. this.helper = this._createHelper(event);
  5258. this.helper.addClass("ui-draggable-dragging");
  5259. //Cache the helper size
  5260. this._cacheHelperProportions();
  5261. //If ddmanager is used for droppables, set the global draggable
  5262. if ($.ui.ddmanager) {
  5263. $.ui.ddmanager.current = this;
  5264. }
  5265. /*
  5266. * - Position generation -
  5267. * This block generates everything position related - it's the core of draggables.
  5268. */
  5269. //Cache the margins of the original element
  5270. this._cacheMargins();
  5271. //Store the helper's css position
  5272. this.cssPosition = this.helper.css( "position" );
  5273. this.scrollParent = this.helper.scrollParent( true );
  5274. this.offsetParent = this.helper.offsetParent();
  5275. this.offsetParentCssPosition = this.offsetParent.css( "position" );
  5276. //The element's absolute position on the page minus margins
  5277. this.offset = this.positionAbs = this.element.offset();
  5278. this.offset = {
  5279. top: this.offset.top - this.margins.top,
  5280. left: this.offset.left - this.margins.left
  5281. };
  5282. //Reset scroll cache
  5283. this.offset.scroll = false;
  5284. $.extend(this.offset, {
  5285. click: { //Where the click happened, relative to the element
  5286. left: event.pageX - this.offset.left,
  5287. top: event.pageY - this.offset.top
  5288. },
  5289. parent: this._getParentOffset(),
  5290. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  5291. });
  5292. //Generate the original position
  5293. this.originalPosition = this.position = this._generatePosition( event, false );
  5294. this.originalPageX = event.pageX;
  5295. this.originalPageY = event.pageY;
  5296. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  5297. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  5298. //Set a containment if given in the options
  5299. this._setContainment();
  5300. //Trigger event + callbacks
  5301. if (this._trigger("start", event) === false) {
  5302. this._clear();
  5303. return false;
  5304. }
  5305. //Recache the helper size
  5306. this._cacheHelperProportions();
  5307. //Prepare the droppable offsets
  5308. if ($.ui.ddmanager && !o.dropBehaviour) {
  5309. $.ui.ddmanager.prepareOffsets(this, event);
  5310. }
  5311. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  5312. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  5313. if ( $.ui.ddmanager ) {
  5314. $.ui.ddmanager.dragStart(this, event);
  5315. }
  5316. return true;
  5317. },
  5318. _mouseDrag: function(event, noPropagation) {
  5319. // reset any necessary cached properties (see #5009)
  5320. if ( this.offsetParentCssPosition === "fixed" ) {
  5321. this.offset.parent = this._getParentOffset();
  5322. }
  5323. //Compute the helpers position
  5324. this.position = this._generatePosition( event, true );
  5325. this.positionAbs = this._convertPositionTo("absolute");
  5326. //Call plugins and callbacks and use the resulting position if something is returned
  5327. if (!noPropagation) {
  5328. var ui = this._uiHash();
  5329. if (this._trigger("drag", event, ui) === false) {
  5330. this._mouseUp({});
  5331. return false;
  5332. }
  5333. this.position = ui.position;
  5334. }
  5335. this.helper[ 0 ].style.left = this.position.left + "px";
  5336. this.helper[ 0 ].style.top = this.position.top + "px";
  5337. if ($.ui.ddmanager) {
  5338. $.ui.ddmanager.drag(this, event);
  5339. }
  5340. return false;
  5341. },
  5342. _mouseStop: function(event) {
  5343. //If we are using droppables, inform the manager about the drop
  5344. var that = this,
  5345. dropped = false;
  5346. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  5347. dropped = $.ui.ddmanager.drop(this, event);
  5348. }
  5349. //if a drop comes from outside (a sortable)
  5350. if (this.dropped) {
  5351. dropped = this.dropped;
  5352. this.dropped = false;
  5353. }
  5354. 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))) {
  5355. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  5356. if (that._trigger("stop", event) !== false) {
  5357. that._clear();
  5358. }
  5359. });
  5360. } else {
  5361. if (this._trigger("stop", event) !== false) {
  5362. this._clear();
  5363. }
  5364. }
  5365. return false;
  5366. },
  5367. _mouseUp: function(event) {
  5368. //Remove frame helpers
  5369. $("div.ui-draggable-iframeFix").each(function() {
  5370. this.parentNode.removeChild(this);
  5371. });
  5372. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  5373. if ( $.ui.ddmanager ) {
  5374. $.ui.ddmanager.dragStop(this, event);
  5375. }
  5376. // The interaction is over; whether or not the click resulted in a drag, focus the element
  5377. this.element.focus();
  5378. return $.ui.mouse.prototype._mouseUp.call(this, event);
  5379. },
  5380. cancel: function() {
  5381. if (this.helper.is(".ui-draggable-dragging")) {
  5382. this._mouseUp({});
  5383. } else {
  5384. this._clear();
  5385. }
  5386. return this;
  5387. },
  5388. _getHandle: function(event) {
  5389. return this.options.handle ?
  5390. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  5391. true;
  5392. },
  5393. _setHandleClassName: function() {
  5394. this.handleElement = this.options.handle ?
  5395. this.element.find( this.options.handle ) : this.element;
  5396. this.handleElement.addClass( "ui-draggable-handle" );
  5397. },
  5398. _removeHandleClassName: function() {
  5399. this.handleElement.removeClass( "ui-draggable-handle" );
  5400. },
  5401. _createHelper: function(event) {
  5402. var o = this.options,
  5403. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[ 0 ], [ event ])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
  5404. if (!helper.parents("body").length) {
  5405. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  5406. }
  5407. if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  5408. helper.css("position", "absolute");
  5409. }
  5410. return helper;
  5411. },
  5412. _adjustOffsetFromHelper: function(obj) {
  5413. if (typeof obj === "string") {
  5414. obj = obj.split(" ");
  5415. }
  5416. if ($.isArray(obj)) {
  5417. obj = { left: +obj[0], top: +obj[1] || 0 };
  5418. }
  5419. if ("left" in obj) {
  5420. this.offset.click.left = obj.left + this.margins.left;
  5421. }
  5422. if ("right" in obj) {
  5423. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  5424. }
  5425. if ("top" in obj) {
  5426. this.offset.click.top = obj.top + this.margins.top;
  5427. }
  5428. if ("bottom" in obj) {
  5429. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  5430. }
  5431. },
  5432. _isRootNode: function( element ) {
  5433. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  5434. },
  5435. _getParentOffset: function() {
  5436. //Get the offsetParent and cache its position
  5437. var po = this.offsetParent.offset(),
  5438. document = this.document[ 0 ];
  5439. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  5440. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  5441. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  5442. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  5443. if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  5444. po.left += this.scrollParent.scrollLeft();
  5445. po.top += this.scrollParent.scrollTop();
  5446. }
  5447. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  5448. po = { top: 0, left: 0 };
  5449. }
  5450. return {
  5451. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
  5452. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
  5453. };
  5454. },
  5455. _getRelativeOffset: function() {
  5456. if ( this.cssPosition !== "relative" ) {
  5457. return { top: 0, left: 0 };
  5458. }
  5459. var p = this.element.position(),
  5460. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  5461. return {
  5462. top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  5463. left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  5464. };
  5465. },
  5466. _cacheMargins: function() {
  5467. this.margins = {
  5468. left: (parseInt(this.element.css("marginLeft"), 10) || 0),
  5469. top: (parseInt(this.element.css("marginTop"), 10) || 0),
  5470. right: (parseInt(this.element.css("marginRight"), 10) || 0),
  5471. bottom: (parseInt(this.element.css("marginBottom"), 10) || 0)
  5472. };
  5473. },
  5474. _cacheHelperProportions: function() {
  5475. this.helperProportions = {
  5476. width: this.helper.outerWidth(),
  5477. height: this.helper.outerHeight()
  5478. };
  5479. },
  5480. _setContainment: function() {
  5481. var over, c, ce,
  5482. o = this.options,
  5483. document = this.document[ 0 ];
  5484. this.relativeContainer = null;
  5485. if ( !o.containment ) {
  5486. this.containment = null;
  5487. return;
  5488. }
  5489. if ( o.containment === "window" ) {
  5490. this.containment = [
  5491. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  5492. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  5493. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  5494. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  5495. ];
  5496. return;
  5497. }
  5498. if ( o.containment === "document") {
  5499. this.containment = [
  5500. 0,
  5501. 0,
  5502. $( document ).width() - this.helperProportions.width - this.margins.left,
  5503. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  5504. ];
  5505. return;
  5506. }
  5507. if ( o.containment.constructor === Array ) {
  5508. this.containment = o.containment;
  5509. return;
  5510. }
  5511. if ( o.containment === "parent" ) {
  5512. o.containment = this.helper[ 0 ].parentNode;
  5513. }
  5514. c = $( o.containment );
  5515. ce = c[ 0 ];
  5516. if ( !ce ) {
  5517. return;
  5518. }
  5519. over = c.css( "overflow" ) !== "hidden";
  5520. this.containment = [
  5521. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  5522. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  5523. ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right,
  5524. ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top - this.margins.bottom
  5525. ];
  5526. this.relativeContainer = c;
  5527. },
  5528. _convertPositionTo: function(d, pos) {
  5529. if (!pos) {
  5530. pos = this.position;
  5531. }
  5532. var mod = d === "absolute" ? 1 : -1,
  5533. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  5534. return {
  5535. top: (
  5536. pos.top + // The absolute mouse position
  5537. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  5538. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  5539. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
  5540. ),
  5541. left: (
  5542. pos.left + // The absolute mouse position
  5543. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  5544. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  5545. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod)
  5546. )
  5547. };
  5548. },
  5549. _generatePosition: function( event, constrainPosition ) {
  5550. var containment, co, top, left,
  5551. o = this.options,
  5552. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  5553. pageX = event.pageX,
  5554. pageY = event.pageY;
  5555. // Cache the scroll
  5556. if ( !scrollIsRootNode || !this.offset.scroll ) {
  5557. this.offset.scroll = {
  5558. top: this.scrollParent.scrollTop(),
  5559. left: this.scrollParent.scrollLeft()
  5560. };
  5561. }
  5562. /*
  5563. * - Position constraining -
  5564. * Constrain the position to a mix of grid, containment.
  5565. */
  5566. // If we are not dragging yet, we won't check for options
  5567. if ( constrainPosition ) {
  5568. if ( this.containment ) {
  5569. if ( this.relativeContainer ){
  5570. co = this.relativeContainer.offset();
  5571. containment = [
  5572. this.containment[ 0 ] + co.left,
  5573. this.containment[ 1 ] + co.top,
  5574. this.containment[ 2 ] + co.left,
  5575. this.containment[ 3 ] + co.top
  5576. ];
  5577. } else {
  5578. containment = this.containment;
  5579. }
  5580. if (event.pageX - this.offset.click.left < containment[0]) {
  5581. pageX = containment[0] + this.offset.click.left;
  5582. }
  5583. if (event.pageY - this.offset.click.top < containment[1]) {
  5584. pageY = containment[1] + this.offset.click.top;
  5585. }
  5586. if (event.pageX - this.offset.click.left > containment[2]) {
  5587. pageX = containment[2] + this.offset.click.left;
  5588. }
  5589. if (event.pageY - this.offset.click.top > containment[3]) {
  5590. pageY = containment[3] + this.offset.click.top;
  5591. }
  5592. }
  5593. if (o.grid) {
  5594. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  5595. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  5596. 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;
  5597. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  5598. 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;
  5599. }
  5600. if ( o.axis === "y" ) {
  5601. pageX = this.originalPageX;
  5602. }
  5603. if ( o.axis === "x" ) {
  5604. pageY = this.originalPageY;
  5605. }
  5606. }
  5607. return {
  5608. top: (
  5609. pageY - // The absolute mouse position
  5610. this.offset.click.top - // Click offset (relative to the element)
  5611. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  5612. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  5613. ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  5614. ),
  5615. left: (
  5616. pageX - // The absolute mouse position
  5617. this.offset.click.left - // Click offset (relative to the element)
  5618. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  5619. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  5620. ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  5621. )
  5622. };
  5623. },
  5624. _clear: function() {
  5625. this.helper.removeClass("ui-draggable-dragging");
  5626. if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  5627. this.helper.remove();
  5628. }
  5629. this.helper = null;
  5630. this.cancelHelperRemoval = false;
  5631. if ( this.destroyOnClear ) {
  5632. this.destroy();
  5633. }
  5634. },
  5635. // From now on bulk stuff - mainly helpers
  5636. _trigger: function(type, event, ui) {
  5637. ui = ui || this._uiHash();
  5638. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  5639. //The absolute position has to be recalculated after plugins
  5640. if (type === "drag") {
  5641. this.positionAbs = this._convertPositionTo("absolute");
  5642. }
  5643. return $.Widget.prototype._trigger.call(this, type, event, ui);
  5644. },
  5645. plugins: {},
  5646. _uiHash: function() {
  5647. return {
  5648. helper: this.helper,
  5649. position: this.position,
  5650. originalPosition: this.originalPosition,
  5651. offset: this.positionAbs
  5652. };
  5653. }
  5654. });
  5655. $.ui.plugin.add("draggable", "connectToSortable", {
  5656. start: function( event, ui, inst ) {
  5657. var o = inst.options,
  5658. uiSortable = $.extend({}, ui, { item: inst.element });
  5659. inst.sortables = [];
  5660. $(o.connectToSortable).each(function() {
  5661. var sortable = $( this ).sortable( "instance" );
  5662. if (sortable && !sortable.options.disabled) {
  5663. inst.sortables.push({
  5664. instance: sortable,
  5665. shouldRevert: sortable.options.revert
  5666. });
  5667. sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
  5668. sortable._trigger("activate", event, uiSortable);
  5669. }
  5670. });
  5671. },
  5672. stop: function( event, ui, inst ) {
  5673. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  5674. var uiSortable = $.extend( {}, ui, {
  5675. item: inst.element
  5676. });
  5677. $.each(inst.sortables, function() {
  5678. if (this.instance.isOver) {
  5679. this.instance.isOver = 0;
  5680. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  5681. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  5682. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
  5683. if (this.shouldRevert) {
  5684. this.instance.options.revert = this.shouldRevert;
  5685. }
  5686. //Trigger the stop of the sortable
  5687. this.instance._mouseStop(event);
  5688. this.instance.options.helper = this.instance.options._helper;
  5689. //If the helper has been the original item, restore properties in the sortable
  5690. if (inst.options.helper === "original") {
  5691. this.instance.currentItem.css({ top: "auto", left: "auto" });
  5692. }
  5693. } else {
  5694. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  5695. this.instance._trigger("deactivate", event, uiSortable);
  5696. }
  5697. });
  5698. },
  5699. drag: function( event, ui, inst ) {
  5700. var that = this;
  5701. $.each(inst.sortables, function() {
  5702. var innermostIntersecting = false,
  5703. thisSortable = this;
  5704. //Copy over some variables to allow calling the sortable's native _intersectsWith
  5705. this.instance.positionAbs = inst.positionAbs;
  5706. this.instance.helperProportions = inst.helperProportions;
  5707. this.instance.offset.click = inst.offset.click;
  5708. if (this.instance._intersectsWith(this.instance.containerCache)) {
  5709. innermostIntersecting = true;
  5710. $.each(inst.sortables, function() {
  5711. this.instance.positionAbs = inst.positionAbs;
  5712. this.instance.helperProportions = inst.helperProportions;
  5713. this.instance.offset.click = inst.offset.click;
  5714. if (this !== thisSortable &&
  5715. this.instance._intersectsWith(this.instance.containerCache) &&
  5716. $.contains(thisSortable.instance.element[0], this.instance.element[0])
  5717. ) {
  5718. innermostIntersecting = false;
  5719. }
  5720. return innermostIntersecting;
  5721. });
  5722. }
  5723. if (innermostIntersecting) {
  5724. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  5725. if (!this.instance.isOver) {
  5726. this.instance.isOver = 1;
  5727. //Now we fake the start of dragging for the sortable instance,
  5728. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  5729. //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
  5730. this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
  5731. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  5732. this.instance.options.helper = function() { return ui.helper[0]; };
  5733. event.target = this.instance.currentItem[0];
  5734. this.instance._mouseCapture(event, true);
  5735. this.instance._mouseStart(event, true, true);
  5736. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  5737. this.instance.offset.click.top = inst.offset.click.top;
  5738. this.instance.offset.click.left = inst.offset.click.left;
  5739. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  5740. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  5741. inst._trigger("toSortable", event);
  5742. inst.dropped = this.instance.element; //draggable revert needs that
  5743. //hack so receive/update callbacks work (mostly)
  5744. inst.currentItem = inst.element;
  5745. this.instance.fromOutside = inst;
  5746. }
  5747. //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
  5748. if (this.instance.currentItem) {
  5749. this.instance._mouseDrag(event);
  5750. }
  5751. } else {
  5752. //If it doesn't intersect with the sortable, and it intersected before,
  5753. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  5754. if (this.instance.isOver) {
  5755. this.instance.isOver = 0;
  5756. this.instance.cancelHelperRemoval = true;
  5757. //Prevent reverting on this forced stop
  5758. this.instance.options.revert = false;
  5759. // The out event needs to be triggered independently
  5760. this.instance._trigger("out", event, this.instance._uiHash(this.instance));
  5761. this.instance._mouseStop(event, true);
  5762. this.instance.options.helper = this.instance.options._helper;
  5763. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  5764. this.instance.currentItem.remove();
  5765. if (this.instance.placeholder) {
  5766. this.instance.placeholder.remove();
  5767. }
  5768. inst._trigger("fromSortable", event);
  5769. inst.dropped = false; //draggable revert needs that
  5770. }
  5771. }
  5772. });
  5773. }
  5774. });
  5775. $.ui.plugin.add("draggable", "cursor", {
  5776. start: function( event, ui, instance ) {
  5777. var t = $( "body" ),
  5778. o = instance.options;
  5779. if (t.css("cursor")) {
  5780. o._cursor = t.css("cursor");
  5781. }
  5782. t.css("cursor", o.cursor);
  5783. },
  5784. stop: function( event, ui, instance ) {
  5785. var o = instance.options;
  5786. if (o._cursor) {
  5787. $("body").css("cursor", o._cursor);
  5788. }
  5789. }
  5790. });
  5791. $.ui.plugin.add("draggable", "opacity", {
  5792. start: function( event, ui, instance ) {
  5793. var t = $( ui.helper ),
  5794. o = instance.options;
  5795. if (t.css("opacity")) {
  5796. o._opacity = t.css("opacity");
  5797. }
  5798. t.css("opacity", o.opacity);
  5799. },
  5800. stop: function( event, ui, instance ) {
  5801. var o = instance.options;
  5802. if (o._opacity) {
  5803. $(ui.helper).css("opacity", o._opacity);
  5804. }
  5805. }
  5806. });
  5807. $.ui.plugin.add("draggable", "scroll", {
  5808. start: function( event, ui, i ) {
  5809. if ( !i.scrollParentNotHidden ) {
  5810. i.scrollParentNotHidden = i.helper.scrollParent( false );
  5811. }
  5812. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  5813. i.overflowOffset = i.scrollParentNotHidden.offset();
  5814. }
  5815. },
  5816. drag: function( event, ui, i ) {
  5817. var o = i.options,
  5818. scrolled = false,
  5819. scrollParent = i.scrollParentNotHidden[ 0 ],
  5820. document = i.document[ 0 ];
  5821. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  5822. if ( !o.axis || o.axis !== "x" ) {
  5823. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) {
  5824. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  5825. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  5826. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  5827. }
  5828. }
  5829. if ( !o.axis || o.axis !== "y" ) {
  5830. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) {
  5831. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  5832. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  5833. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  5834. }
  5835. }
  5836. } else {
  5837. if (!o.axis || o.axis !== "x") {
  5838. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  5839. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  5840. } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  5841. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  5842. }
  5843. }
  5844. if (!o.axis || o.axis !== "y") {
  5845. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  5846. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  5847. } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  5848. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  5849. }
  5850. }
  5851. }
  5852. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  5853. $.ui.ddmanager.prepareOffsets(i, event);
  5854. }
  5855. }
  5856. });
  5857. $.ui.plugin.add("draggable", "snap", {
  5858. start: function( event, ui, i ) {
  5859. var o = i.options;
  5860. i.snapElements = [];
  5861. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  5862. var $t = $(this),
  5863. $o = $t.offset();
  5864. if (this !== i.element[0]) {
  5865. i.snapElements.push({
  5866. item: this,
  5867. width: $t.outerWidth(), height: $t.outerHeight(),
  5868. top: $o.top, left: $o.left
  5869. });
  5870. }
  5871. });
  5872. },
  5873. drag: function( event, ui, inst ) {
  5874. var ts, bs, ls, rs, l, r, t, b, i, first,
  5875. o = inst.options,
  5876. d = o.snapTolerance,
  5877. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  5878. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  5879. for (i = inst.snapElements.length - 1; i >= 0; i--){
  5880. l = inst.snapElements[i].left;
  5881. r = l + inst.snapElements[i].width;
  5882. t = inst.snapElements[i].top;
  5883. b = t + inst.snapElements[i].height;
  5884. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  5885. if (inst.snapElements[i].snapping) {
  5886. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  5887. }
  5888. inst.snapElements[i].snapping = false;
  5889. continue;
  5890. }
  5891. if (o.snapMode !== "inner") {
  5892. ts = Math.abs(t - y2) <= d;
  5893. bs = Math.abs(b - y1) <= d;
  5894. ls = Math.abs(l - x2) <= d;
  5895. rs = Math.abs(r - x1) <= d;
  5896. if (ts) {
  5897. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  5898. }
  5899. if (bs) {
  5900. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  5901. }
  5902. if (ls) {
  5903. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  5904. }
  5905. if (rs) {
  5906. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  5907. }
  5908. }
  5909. first = (ts || bs || ls || rs);
  5910. if (o.snapMode !== "outer") {
  5911. ts = Math.abs(t - y1) <= d;
  5912. bs = Math.abs(b - y2) <= d;
  5913. ls = Math.abs(l - x1) <= d;
  5914. rs = Math.abs(r - x2) <= d;
  5915. if (ts) {
  5916. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  5917. }
  5918. if (bs) {
  5919. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  5920. }
  5921. if (ls) {
  5922. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  5923. }
  5924. if (rs) {
  5925. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  5926. }
  5927. }
  5928. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  5929. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  5930. }
  5931. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  5932. }
  5933. }
  5934. });
  5935. $.ui.plugin.add("draggable", "stack", {
  5936. start: function( event, ui, instance ) {
  5937. var min,
  5938. o = instance.options,
  5939. group = $.makeArray($(o.stack)).sort(function(a, b) {
  5940. return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
  5941. });
  5942. if (!group.length) { return; }
  5943. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  5944. $(group).each(function(i) {
  5945. $(this).css("zIndex", min + i);
  5946. });
  5947. this.css("zIndex", (min + group.length));
  5948. }
  5949. });
  5950. $.ui.plugin.add("draggable", "zIndex", {
  5951. start: function( event, ui, instance ) {
  5952. var t = $( ui.helper ),
  5953. o = instance.options;
  5954. if (t.css("zIndex")) {
  5955. o._zIndex = t.css("zIndex");
  5956. }
  5957. t.css("zIndex", o.zIndex);
  5958. },
  5959. stop: function( event, ui, instance ) {
  5960. var o = instance.options;
  5961. if (o._zIndex) {
  5962. $(ui.helper).css("zIndex", o._zIndex);
  5963. }
  5964. }
  5965. });
  5966. var draggable = $.ui.draggable;
  5967. /*!
  5968. * jQuery UI Resizable 1.11.1
  5969. * http://jqueryui.com
  5970. *
  5971. * Copyright 2014 jQuery Foundation and other contributors
  5972. * Released under the MIT license.
  5973. * http://jquery.org/license
  5974. *
  5975. * http://api.jqueryui.com/resizable/
  5976. */
  5977. $.widget("ui.resizable", $.ui.mouse, {
  5978. version: "1.11.1",
  5979. widgetEventPrefix: "resize",
  5980. options: {
  5981. alsoResize: false,
  5982. animate: false,
  5983. animateDuration: "slow",
  5984. animateEasing: "swing",
  5985. aspectRatio: false,
  5986. autoHide: false,
  5987. containment: false,
  5988. ghost: false,
  5989. grid: false,
  5990. handles: "e,s,se",
  5991. helper: false,
  5992. maxHeight: null,
  5993. maxWidth: null,
  5994. minHeight: 10,
  5995. minWidth: 10,
  5996. // See #7960
  5997. zIndex: 90,
  5998. // callbacks
  5999. resize: null,
  6000. start: null,
  6001. stop: null
  6002. },
  6003. _num: function( value ) {
  6004. return parseInt( value, 10 ) || 0;
  6005. },
  6006. _isNumber: function( value ) {
  6007. return !isNaN( parseInt( value, 10 ) );
  6008. },
  6009. _hasScroll: function( el, a ) {
  6010. if ( $( el ).css( "overflow" ) === "hidden") {
  6011. return false;
  6012. }
  6013. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  6014. has = false;
  6015. if ( el[ scroll ] > 0 ) {
  6016. return true;
  6017. }
  6018. // TODO: determine which cases actually cause this to happen
  6019. // if the element doesn't have the scroll set, see if it's possible to
  6020. // set the scroll
  6021. el[ scroll ] = 1;
  6022. has = ( el[ scroll ] > 0 );
  6023. el[ scroll ] = 0;
  6024. return has;
  6025. },
  6026. _create: function() {
  6027. var n, i, handle, axis, hname,
  6028. that = this,
  6029. o = this.options;
  6030. this.element.addClass("ui-resizable");
  6031. $.extend(this, {
  6032. _aspectRatio: !!(o.aspectRatio),
  6033. aspectRatio: o.aspectRatio,
  6034. originalElement: this.element,
  6035. _proportionallyResizeElements: [],
  6036. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  6037. });
  6038. // Wrap the element if it cannot hold child nodes
  6039. if (this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  6040. this.element.wrap(
  6041. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  6042. position: this.element.css("position"),
  6043. width: this.element.outerWidth(),
  6044. height: this.element.outerHeight(),
  6045. top: this.element.css("top"),
  6046. left: this.element.css("left")
  6047. })
  6048. );
  6049. this.element = this.element.parent().data(
  6050. "ui-resizable", this.element.resizable( "instance" )
  6051. );
  6052. this.elementIsWrapper = true;
  6053. this.element.css({
  6054. marginLeft: this.originalElement.css("marginLeft"),
  6055. marginTop: this.originalElement.css("marginTop"),
  6056. marginRight: this.originalElement.css("marginRight"),
  6057. marginBottom: this.originalElement.css("marginBottom")
  6058. });
  6059. this.originalElement.css({
  6060. marginLeft: 0,
  6061. marginTop: 0,
  6062. marginRight: 0,
  6063. marginBottom: 0
  6064. });
  6065. // support: Safari
  6066. // Prevent Safari textarea resize
  6067. this.originalResizeStyle = this.originalElement.css("resize");
  6068. this.originalElement.css("resize", "none");
  6069. this._proportionallyResizeElements.push( this.originalElement.css({
  6070. position: "static",
  6071. zoom: 1,
  6072. display: "block"
  6073. }) );
  6074. // support: IE9
  6075. // avoid IE jump (hard set the margin)
  6076. this.originalElement.css({ margin: this.originalElement.css("margin") });
  6077. this._proportionallyResize();
  6078. }
  6079. this.handles = o.handles ||
  6080. ( !$(".ui-resizable-handle", this.element).length ?
  6081. "e,s,se" : {
  6082. n: ".ui-resizable-n",
  6083. e: ".ui-resizable-e",
  6084. s: ".ui-resizable-s",
  6085. w: ".ui-resizable-w",
  6086. se: ".ui-resizable-se",
  6087. sw: ".ui-resizable-sw",
  6088. ne: ".ui-resizable-ne",
  6089. nw: ".ui-resizable-nw"
  6090. } );
  6091. if (this.handles.constructor === String) {
  6092. if ( this.handles === "all") {
  6093. this.handles = "n,e,s,w,se,sw,ne,nw";
  6094. }
  6095. n = this.handles.split(",");
  6096. this.handles = {};
  6097. for (i = 0; i < n.length; i++) {
  6098. handle = $.trim(n[i]);
  6099. hname = "ui-resizable-" + handle;
  6100. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  6101. axis.css({ zIndex: o.zIndex });
  6102. // TODO : What's going on here?
  6103. if ("se" === handle) {
  6104. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  6105. }
  6106. this.handles[handle] = ".ui-resizable-" + handle;
  6107. this.element.append(axis);
  6108. }
  6109. }
  6110. this._renderAxis = function(target) {
  6111. var i, axis, padPos, padWrapper;
  6112. target = target || this.element;
  6113. for (i in this.handles) {
  6114. if (this.handles[i].constructor === String) {
  6115. this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
  6116. }
  6117. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  6118. axis = $(this.handles[i], this.element);
  6119. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  6120. padPos = [ "padding",
  6121. /ne|nw|n/.test(i) ? "Top" :
  6122. /se|sw|s/.test(i) ? "Bottom" :
  6123. /^e$/.test(i) ? "Right" : "Left" ].join("");
  6124. target.css(padPos, padWrapper);
  6125. this._proportionallyResize();
  6126. }
  6127. // TODO: What's that good for? There's not anything to be executed left
  6128. if (!$(this.handles[i]).length) {
  6129. continue;
  6130. }
  6131. }
  6132. };
  6133. // TODO: make renderAxis a prototype function
  6134. this._renderAxis(this.element);
  6135. this._handles = $(".ui-resizable-handle", this.element)
  6136. .disableSelection();
  6137. this._handles.mouseover(function() {
  6138. if (!that.resizing) {
  6139. if (this.className) {
  6140. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  6141. }
  6142. that.axis = axis && axis[1] ? axis[1] : "se";
  6143. }
  6144. });
  6145. if (o.autoHide) {
  6146. this._handles.hide();
  6147. $(this.element)
  6148. .addClass("ui-resizable-autohide")
  6149. .mouseenter(function() {
  6150. if (o.disabled) {
  6151. return;
  6152. }
  6153. $(this).removeClass("ui-resizable-autohide");
  6154. that._handles.show();
  6155. })
  6156. .mouseleave(function() {
  6157. if (o.disabled) {
  6158. return;
  6159. }
  6160. if (!that.resizing) {
  6161. $(this).addClass("ui-resizable-autohide");
  6162. that._handles.hide();
  6163. }
  6164. });
  6165. }
  6166. this._mouseInit();
  6167. },
  6168. _destroy: function() {
  6169. this._mouseDestroy();
  6170. var wrapper,
  6171. _destroy = function(exp) {
  6172. $(exp)
  6173. .removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  6174. .removeData("resizable")
  6175. .removeData("ui-resizable")
  6176. .unbind(".resizable")
  6177. .find(".ui-resizable-handle")
  6178. .remove();
  6179. };
  6180. // TODO: Unwrap at same DOM position
  6181. if (this.elementIsWrapper) {
  6182. _destroy(this.element);
  6183. wrapper = this.element;
  6184. this.originalElement.css({
  6185. position: wrapper.css("position"),
  6186. width: wrapper.outerWidth(),
  6187. height: wrapper.outerHeight(),
  6188. top: wrapper.css("top"),
  6189. left: wrapper.css("left")
  6190. }).insertAfter( wrapper );
  6191. wrapper.remove();
  6192. }
  6193. this.originalElement.css("resize", this.originalResizeStyle);
  6194. _destroy(this.originalElement);
  6195. return this;
  6196. },
  6197. _mouseCapture: function(event) {
  6198. var i, handle,
  6199. capture = false;
  6200. for (i in this.handles) {
  6201. handle = $(this.handles[i])[0];
  6202. if (handle === event.target || $.contains(handle, event.target)) {
  6203. capture = true;
  6204. }
  6205. }
  6206. return !this.options.disabled && capture;
  6207. },
  6208. _mouseStart: function(event) {
  6209. var curleft, curtop, cursor,
  6210. o = this.options,
  6211. el = this.element;
  6212. this.resizing = true;
  6213. this._renderProxy();
  6214. curleft = this._num(this.helper.css("left"));
  6215. curtop = this._num(this.helper.css("top"));
  6216. if (o.containment) {
  6217. curleft += $(o.containment).scrollLeft() || 0;
  6218. curtop += $(o.containment).scrollTop() || 0;
  6219. }
  6220. this.offset = this.helper.offset();
  6221. this.position = { left: curleft, top: curtop };
  6222. this.size = this._helper ? {
  6223. width: this.helper.width(),
  6224. height: this.helper.height()
  6225. } : {
  6226. width: el.width(),
  6227. height: el.height()
  6228. };
  6229. this.originalSize = this._helper ? {
  6230. width: el.outerWidth(),
  6231. height: el.outerHeight()
  6232. } : {
  6233. width: el.width(),
  6234. height: el.height()
  6235. };
  6236. this.sizeDiff = {
  6237. width: el.outerWidth() - el.width(),
  6238. height: el.outerHeight() - el.height()
  6239. };
  6240. this.originalPosition = { left: curleft, top: curtop };
  6241. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  6242. this.aspectRatio = (typeof o.aspectRatio === "number") ?
  6243. o.aspectRatio :
  6244. ((this.originalSize.width / this.originalSize.height) || 1);
  6245. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  6246. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  6247. el.addClass("ui-resizable-resizing");
  6248. this._propagate("start", event);
  6249. return true;
  6250. },
  6251. _mouseDrag: function(event) {
  6252. var data, props,
  6253. smp = this.originalMousePosition,
  6254. a = this.axis,
  6255. dx = (event.pageX - smp.left) || 0,
  6256. dy = (event.pageY - smp.top) || 0,
  6257. trigger = this._change[a];
  6258. this._updatePrevProperties();
  6259. if (!trigger) {
  6260. return false;
  6261. }
  6262. data = trigger.apply(this, [ event, dx, dy ]);
  6263. this._updateVirtualBoundaries(event.shiftKey);
  6264. if (this._aspectRatio || event.shiftKey) {
  6265. data = this._updateRatio(data, event);
  6266. }
  6267. data = this._respectSize(data, event);
  6268. this._updateCache(data);
  6269. this._propagate("resize", event);
  6270. props = this._applyChanges();
  6271. if ( !this._helper && this._proportionallyResizeElements.length ) {
  6272. this._proportionallyResize();
  6273. }
  6274. if ( !$.isEmptyObject( props ) ) {
  6275. this._updatePrevProperties();
  6276. this._trigger( "resize", event, this.ui() );
  6277. this._applyChanges();
  6278. }
  6279. return false;
  6280. },
  6281. _mouseStop: function(event) {
  6282. this.resizing = false;
  6283. var pr, ista, soffseth, soffsetw, s, left, top,
  6284. o = this.options, that = this;
  6285. if (this._helper) {
  6286. pr = this._proportionallyResizeElements;
  6287. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  6288. soffseth = ista && this._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height;
  6289. soffsetw = ista ? 0 : that.sizeDiff.width;
  6290. s = {
  6291. width: (that.helper.width() - soffsetw),
  6292. height: (that.helper.height() - soffseth)
  6293. };
  6294. left = (parseInt(that.element.css("left"), 10) +
  6295. (that.position.left - that.originalPosition.left)) || null;
  6296. top = (parseInt(that.element.css("top"), 10) +
  6297. (that.position.top - that.originalPosition.top)) || null;
  6298. if (!o.animate) {
  6299. this.element.css($.extend(s, { top: top, left: left }));
  6300. }
  6301. that.helper.height(that.size.height);
  6302. that.helper.width(that.size.width);
  6303. if (this._helper && !o.animate) {
  6304. this._proportionallyResize();
  6305. }
  6306. }
  6307. $("body").css("cursor", "auto");
  6308. this.element.removeClass("ui-resizable-resizing");
  6309. this._propagate("stop", event);
  6310. if (this._helper) {
  6311. this.helper.remove();
  6312. }
  6313. return false;
  6314. },
  6315. _updatePrevProperties: function() {
  6316. this.prevPosition = {
  6317. top: this.position.top,
  6318. left: this.position.left
  6319. };
  6320. this.prevSize = {
  6321. width: this.size.width,
  6322. height: this.size.height
  6323. };
  6324. },
  6325. _applyChanges: function() {
  6326. var props = {};
  6327. if ( this.position.top !== this.prevPosition.top ) {
  6328. props.top = this.position.top + "px";
  6329. }
  6330. if ( this.position.left !== this.prevPosition.left ) {
  6331. props.left = this.position.left + "px";
  6332. }
  6333. if ( this.size.width !== this.prevSize.width ) {
  6334. props.width = this.size.width + "px";
  6335. }
  6336. if ( this.size.height !== this.prevSize.height ) {
  6337. props.height = this.size.height + "px";
  6338. }
  6339. this.helper.css( props );
  6340. return props;
  6341. },
  6342. _updateVirtualBoundaries: function(forceAspectRatio) {
  6343. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  6344. o = this.options;
  6345. b = {
  6346. minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
  6347. maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  6348. minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
  6349. maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
  6350. };
  6351. if (this._aspectRatio || forceAspectRatio) {
  6352. pMinWidth = b.minHeight * this.aspectRatio;
  6353. pMinHeight = b.minWidth / this.aspectRatio;
  6354. pMaxWidth = b.maxHeight * this.aspectRatio;
  6355. pMaxHeight = b.maxWidth / this.aspectRatio;
  6356. if (pMinWidth > b.minWidth) {
  6357. b.minWidth = pMinWidth;
  6358. }
  6359. if (pMinHeight > b.minHeight) {
  6360. b.minHeight = pMinHeight;
  6361. }
  6362. if (pMaxWidth < b.maxWidth) {
  6363. b.maxWidth = pMaxWidth;
  6364. }
  6365. if (pMaxHeight < b.maxHeight) {
  6366. b.maxHeight = pMaxHeight;
  6367. }
  6368. }
  6369. this._vBoundaries = b;
  6370. },
  6371. _updateCache: function(data) {
  6372. this.offset = this.helper.offset();
  6373. if (this._isNumber(data.left)) {
  6374. this.position.left = data.left;
  6375. }
  6376. if (this._isNumber(data.top)) {
  6377. this.position.top = data.top;
  6378. }
  6379. if (this._isNumber(data.height)) {
  6380. this.size.height = data.height;
  6381. }
  6382. if (this._isNumber(data.width)) {
  6383. this.size.width = data.width;
  6384. }
  6385. },
  6386. _updateRatio: function( data ) {
  6387. var cpos = this.position,
  6388. csize = this.size,
  6389. a = this.axis;
  6390. if (this._isNumber(data.height)) {
  6391. data.width = (data.height * this.aspectRatio);
  6392. } else if (this._isNumber(data.width)) {
  6393. data.height = (data.width / this.aspectRatio);
  6394. }
  6395. if (a === "sw") {
  6396. data.left = cpos.left + (csize.width - data.width);
  6397. data.top = null;
  6398. }
  6399. if (a === "nw") {
  6400. data.top = cpos.top + (csize.height - data.height);
  6401. data.left = cpos.left + (csize.width - data.width);
  6402. }
  6403. return data;
  6404. },
  6405. _respectSize: function( data ) {
  6406. var o = this._vBoundaries,
  6407. a = this.axis,
  6408. ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width),
  6409. ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  6410. isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width),
  6411. isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  6412. dw = this.originalPosition.left + this.originalSize.width,
  6413. dh = this.position.top + this.size.height,
  6414. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  6415. if (isminw) {
  6416. data.width = o.minWidth;
  6417. }
  6418. if (isminh) {
  6419. data.height = o.minHeight;
  6420. }
  6421. if (ismaxw) {
  6422. data.width = o.maxWidth;
  6423. }
  6424. if (ismaxh) {
  6425. data.height = o.maxHeight;
  6426. }
  6427. if (isminw && cw) {
  6428. data.left = dw - o.minWidth;
  6429. }
  6430. if (ismaxw && cw) {
  6431. data.left = dw - o.maxWidth;
  6432. }
  6433. if (isminh && ch) {
  6434. data.top = dh - o.minHeight;
  6435. }
  6436. if (ismaxh && ch) {
  6437. data.top = dh - o.maxHeight;
  6438. }
  6439. // Fixing jump error on top/left - bug #2330
  6440. if (!data.width && !data.height && !data.left && data.top) {
  6441. data.top = null;
  6442. } else if (!data.width && !data.height && !data.top && data.left) {
  6443. data.left = null;
  6444. }
  6445. return data;
  6446. },
  6447. _getPaddingPlusBorderDimensions: function( element ) {
  6448. var i = 0,
  6449. widths = [],
  6450. borders = [
  6451. element.css( "borderTopWidth" ),
  6452. element.css( "borderRightWidth" ),
  6453. element.css( "borderBottomWidth" ),
  6454. element.css( "borderLeftWidth" )
  6455. ],
  6456. paddings = [
  6457. element.css( "paddingTop" ),
  6458. element.css( "paddingRight" ),
  6459. element.css( "paddingBottom" ),
  6460. element.css( "paddingLeft" )
  6461. ];
  6462. for ( ; i < 4; i++ ) {
  6463. widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 );
  6464. widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 );
  6465. }
  6466. return {
  6467. height: widths[ 0 ] + widths[ 2 ],
  6468. width: widths[ 1 ] + widths[ 3 ]
  6469. };
  6470. },
  6471. _proportionallyResize: function() {
  6472. if (!this._proportionallyResizeElements.length) {
  6473. return;
  6474. }
  6475. var prel,
  6476. i = 0,
  6477. element = this.helper || this.element;
  6478. for ( ; i < this._proportionallyResizeElements.length; i++) {
  6479. prel = this._proportionallyResizeElements[i];
  6480. // TODO: Seems like a bug to cache this.outerDimensions
  6481. // considering that we are in a loop.
  6482. if (!this.outerDimensions) {
  6483. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  6484. }
  6485. prel.css({
  6486. height: (element.height() - this.outerDimensions.height) || 0,
  6487. width: (element.width() - this.outerDimensions.width) || 0
  6488. });
  6489. }
  6490. },
  6491. _renderProxy: function() {
  6492. var el = this.element, o = this.options;
  6493. this.elementOffset = el.offset();
  6494. if (this._helper) {
  6495. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  6496. this.helper.addClass(this._helper).css({
  6497. width: this.element.outerWidth() - 1,
  6498. height: this.element.outerHeight() - 1,
  6499. position: "absolute",
  6500. left: this.elementOffset.left + "px",
  6501. top: this.elementOffset.top + "px",
  6502. zIndex: ++o.zIndex //TODO: Don't modify option
  6503. });
  6504. this.helper
  6505. .appendTo("body")
  6506. .disableSelection();
  6507. } else {
  6508. this.helper = this.element;
  6509. }
  6510. },
  6511. _change: {
  6512. e: function(event, dx) {
  6513. return { width: this.originalSize.width + dx };
  6514. },
  6515. w: function(event, dx) {
  6516. var cs = this.originalSize, sp = this.originalPosition;
  6517. return { left: sp.left + dx, width: cs.width - dx };
  6518. },
  6519. n: function(event, dx, dy) {
  6520. var cs = this.originalSize, sp = this.originalPosition;
  6521. return { top: sp.top + dy, height: cs.height - dy };
  6522. },
  6523. s: function(event, dx, dy) {
  6524. return { height: this.originalSize.height + dy };
  6525. },
  6526. se: function(event, dx, dy) {
  6527. return $.extend(this._change.s.apply(this, arguments),
  6528. this._change.e.apply(this, [ event, dx, dy ]));
  6529. },
  6530. sw: function(event, dx, dy) {
  6531. return $.extend(this._change.s.apply(this, arguments),
  6532. this._change.w.apply(this, [ event, dx, dy ]));
  6533. },
  6534. ne: function(event, dx, dy) {
  6535. return $.extend(this._change.n.apply(this, arguments),
  6536. this._change.e.apply(this, [ event, dx, dy ]));
  6537. },
  6538. nw: function(event, dx, dy) {
  6539. return $.extend(this._change.n.apply(this, arguments),
  6540. this._change.w.apply(this, [ event, dx, dy ]));
  6541. }
  6542. },
  6543. _propagate: function(n, event) {
  6544. $.ui.plugin.call(this, n, [ event, this.ui() ]);
  6545. (n !== "resize" && this._trigger(n, event, this.ui()));
  6546. },
  6547. plugins: {},
  6548. ui: function() {
  6549. return {
  6550. originalElement: this.originalElement,
  6551. element: this.element,
  6552. helper: this.helper,
  6553. position: this.position,
  6554. size: this.size,
  6555. originalSize: this.originalSize,
  6556. originalPosition: this.originalPosition
  6557. };
  6558. }
  6559. });
  6560. /*
  6561. * Resizable Extensions
  6562. */
  6563. $.ui.plugin.add("resizable", "animate", {
  6564. stop: function( event ) {
  6565. var that = $(this).resizable( "instance" ),
  6566. o = that.options,
  6567. pr = that._proportionallyResizeElements,
  6568. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  6569. soffseth = ista && that._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height,
  6570. soffsetw = ista ? 0 : that.sizeDiff.width,
  6571. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  6572. left = (parseInt(that.element.css("left"), 10) +
  6573. (that.position.left - that.originalPosition.left)) || null,
  6574. top = (parseInt(that.element.css("top"), 10) +
  6575. (that.position.top - that.originalPosition.top)) || null;
  6576. that.element.animate(
  6577. $.extend(style, top && left ? { top: top, left: left } : {}), {
  6578. duration: o.animateDuration,
  6579. easing: o.animateEasing,
  6580. step: function() {
  6581. var data = {
  6582. width: parseInt(that.element.css("width"), 10),
  6583. height: parseInt(that.element.css("height"), 10),
  6584. top: parseInt(that.element.css("top"), 10),
  6585. left: parseInt(that.element.css("left"), 10)
  6586. };
  6587. if (pr && pr.length) {
  6588. $(pr[0]).css({ width: data.width, height: data.height });
  6589. }
  6590. // propagating resize, and updating values for each animation step
  6591. that._updateCache(data);
  6592. that._propagate("resize", event);
  6593. }
  6594. }
  6595. );
  6596. }
  6597. });
  6598. $.ui.plugin.add( "resizable", "containment", {
  6599. start: function() {
  6600. var element, p, co, ch, cw, width, height,
  6601. that = $( this ).resizable( "instance" ),
  6602. o = that.options,
  6603. el = that.element,
  6604. oc = o.containment,
  6605. ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  6606. if ( !ce ) {
  6607. return;
  6608. }
  6609. that.containerElement = $( ce );
  6610. if ( /document/.test( oc ) || oc === document ) {
  6611. that.containerOffset = {
  6612. left: 0,
  6613. top: 0
  6614. };
  6615. that.containerPosition = {
  6616. left: 0,
  6617. top: 0
  6618. };
  6619. that.parentData = {
  6620. element: $( document ),
  6621. left: 0,
  6622. top: 0,
  6623. width: $( document ).width(),
  6624. height: $( document ).height() || document.body.parentNode.scrollHeight
  6625. };
  6626. } else {
  6627. element = $( ce );
  6628. p = [];
  6629. $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {
  6630. p[ i ] = that._num( element.css( "padding" + name ) );
  6631. });
  6632. that.containerOffset = element.offset();
  6633. that.containerPosition = element.position();
  6634. that.containerSize = {
  6635. height: ( element.innerHeight() - p[ 3 ] ),
  6636. width: ( element.innerWidth() - p[ 1 ] )
  6637. };
  6638. co = that.containerOffset;
  6639. ch = that.containerSize.height;
  6640. cw = that.containerSize.width;
  6641. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  6642. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  6643. that.parentData = {
  6644. element: ce,
  6645. left: co.left,
  6646. top: co.top,
  6647. width: width,
  6648. height: height
  6649. };
  6650. }
  6651. },
  6652. resize: function( event ) {
  6653. var woset, hoset, isParent, isOffsetRelative,
  6654. that = $( this ).resizable( "instance" ),
  6655. o = that.options,
  6656. co = that.containerOffset,
  6657. cp = that.position,
  6658. pRatio = that._aspectRatio || event.shiftKey,
  6659. cop = {
  6660. top: 0,
  6661. left: 0
  6662. },
  6663. ce = that.containerElement,
  6664. continueResize = true;
  6665. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  6666. cop = co;
  6667. }
  6668. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  6669. that.size.width = that.size.width +
  6670. ( that._helper ?
  6671. ( that.position.left - co.left ) :
  6672. ( that.position.left - cop.left ) );
  6673. if ( pRatio ) {
  6674. that.size.height = that.size.width / that.aspectRatio;
  6675. continueResize = false;
  6676. }
  6677. that.position.left = o.helper ? co.left : 0;
  6678. }
  6679. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  6680. that.size.height = that.size.height +
  6681. ( that._helper ?
  6682. ( that.position.top - co.top ) :
  6683. that.position.top );
  6684. if ( pRatio ) {
  6685. that.size.width = that.size.height * that.aspectRatio;
  6686. continueResize = false;
  6687. }
  6688. that.position.top = that._helper ? co.top : 0;
  6689. }
  6690. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  6691. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  6692. if ( isParent && isOffsetRelative ) {
  6693. that.offset.left = that.parentData.left + that.position.left;
  6694. that.offset.top = that.parentData.top + that.position.top;
  6695. } else {
  6696. that.offset.left = that.element.offset().left;
  6697. that.offset.top = that.element.offset().top;
  6698. }
  6699. woset = Math.abs( that.sizeDiff.width +
  6700. (that._helper ?
  6701. that.offset.left - cop.left :
  6702. (that.offset.left - co.left)) );
  6703. hoset = Math.abs( that.sizeDiff.height +
  6704. (that._helper ?
  6705. that.offset.top - cop.top :
  6706. (that.offset.top - co.top)) );
  6707. if ( woset + that.size.width >= that.parentData.width ) {
  6708. that.size.width = that.parentData.width - woset;
  6709. if ( pRatio ) {
  6710. that.size.height = that.size.width / that.aspectRatio;
  6711. continueResize = false;
  6712. }
  6713. }
  6714. if ( hoset + that.size.height >= that.parentData.height ) {
  6715. that.size.height = that.parentData.height - hoset;
  6716. if ( pRatio ) {
  6717. that.size.width = that.size.height * that.aspectRatio;
  6718. continueResize = false;
  6719. }
  6720. }
  6721. if ( !continueResize ){
  6722. that.position.left = that.prevPosition.left;
  6723. that.position.top = that.prevPosition.top;
  6724. that.size.width = that.prevSize.width;
  6725. that.size.height = that.prevSize.height;
  6726. }
  6727. },
  6728. stop: function() {
  6729. var that = $( this ).resizable( "instance" ),
  6730. o = that.options,
  6731. co = that.containerOffset,
  6732. cop = that.containerPosition,
  6733. ce = that.containerElement,
  6734. helper = $( that.helper ),
  6735. ho = helper.offset(),
  6736. w = helper.outerWidth() - that.sizeDiff.width,
  6737. h = helper.outerHeight() - that.sizeDiff.height;
  6738. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  6739. $( this ).css({
  6740. left: ho.left - cop.left - co.left,
  6741. width: w,
  6742. height: h
  6743. });
  6744. }
  6745. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  6746. $( this ).css({
  6747. left: ho.left - cop.left - co.left,
  6748. width: w,
  6749. height: h
  6750. });
  6751. }
  6752. }
  6753. });
  6754. $.ui.plugin.add("resizable", "alsoResize", {
  6755. start: function() {
  6756. var that = $(this).resizable( "instance" ),
  6757. o = that.options,
  6758. _store = function(exp) {
  6759. $(exp).each(function() {
  6760. var el = $(this);
  6761. el.data("ui-resizable-alsoresize", {
  6762. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  6763. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  6764. });
  6765. });
  6766. };
  6767. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  6768. if (o.alsoResize.length) {
  6769. o.alsoResize = o.alsoResize[0];
  6770. _store(o.alsoResize);
  6771. } else {
  6772. $.each(o.alsoResize, function(exp) {
  6773. _store(exp);
  6774. });
  6775. }
  6776. } else {
  6777. _store(o.alsoResize);
  6778. }
  6779. },
  6780. resize: function(event, ui) {
  6781. var that = $(this).resizable( "instance" ),
  6782. o = that.options,
  6783. os = that.originalSize,
  6784. op = that.originalPosition,
  6785. delta = {
  6786. height: (that.size.height - os.height) || 0,
  6787. width: (that.size.width - os.width) || 0,
  6788. top: (that.position.top - op.top) || 0,
  6789. left: (that.position.left - op.left) || 0
  6790. },
  6791. _alsoResize = function(exp, c) {
  6792. $(exp).each(function() {
  6793. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  6794. css = c && c.length ?
  6795. c :
  6796. el.parents(ui.originalElement[0]).length ?
  6797. [ "width", "height" ] :
  6798. [ "width", "height", "top", "left" ];
  6799. $.each(css, function(i, prop) {
  6800. var sum = (start[prop] || 0) + (delta[prop] || 0);
  6801. if (sum && sum >= 0) {
  6802. style[prop] = sum || null;
  6803. }
  6804. });
  6805. el.css(style);
  6806. });
  6807. };
  6808. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  6809. $.each(o.alsoResize, function(exp, c) {
  6810. _alsoResize(exp, c);
  6811. });
  6812. } else {
  6813. _alsoResize(o.alsoResize);
  6814. }
  6815. },
  6816. stop: function() {
  6817. $(this).removeData("resizable-alsoresize");
  6818. }
  6819. });
  6820. $.ui.plugin.add("resizable", "ghost", {
  6821. start: function() {
  6822. var that = $(this).resizable( "instance" ), o = that.options, cs = that.size;
  6823. that.ghost = that.originalElement.clone();
  6824. that.ghost
  6825. .css({
  6826. opacity: 0.25,
  6827. display: "block",
  6828. position: "relative",
  6829. height: cs.height,
  6830. width: cs.width,
  6831. margin: 0,
  6832. left: 0,
  6833. top: 0
  6834. })
  6835. .addClass("ui-resizable-ghost")
  6836. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  6837. that.ghost.appendTo(that.helper);
  6838. },
  6839. resize: function() {
  6840. var that = $(this).resizable( "instance" );
  6841. if (that.ghost) {
  6842. that.ghost.css({
  6843. position: "relative",
  6844. height: that.size.height,
  6845. width: that.size.width
  6846. });
  6847. }
  6848. },
  6849. stop: function() {
  6850. var that = $(this).resizable( "instance" );
  6851. if (that.ghost && that.helper) {
  6852. that.helper.get(0).removeChild(that.ghost.get(0));
  6853. }
  6854. }
  6855. });
  6856. $.ui.plugin.add("resizable", "grid", {
  6857. resize: function() {
  6858. var outerDimensions,
  6859. that = $(this).resizable( "instance" ),
  6860. o = that.options,
  6861. cs = that.size,
  6862. os = that.originalSize,
  6863. op = that.originalPosition,
  6864. a = that.axis,
  6865. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  6866. gridX = (grid[0] || 1),
  6867. gridY = (grid[1] || 1),
  6868. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  6869. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  6870. newWidth = os.width + ox,
  6871. newHeight = os.height + oy,
  6872. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  6873. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  6874. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  6875. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  6876. o.grid = grid;
  6877. if (isMinWidth) {
  6878. newWidth += gridX;
  6879. }
  6880. if (isMinHeight) {
  6881. newHeight += gridY;
  6882. }
  6883. if (isMaxWidth) {
  6884. newWidth -= gridX;
  6885. }
  6886. if (isMaxHeight) {
  6887. newHeight -= gridY;
  6888. }
  6889. if (/^(se|s|e)$/.test(a)) {
  6890. that.size.width = newWidth;
  6891. that.size.height = newHeight;
  6892. } else if (/^(ne)$/.test(a)) {
  6893. that.size.width = newWidth;
  6894. that.size.height = newHeight;
  6895. that.position.top = op.top - oy;
  6896. } else if (/^(sw)$/.test(a)) {
  6897. that.size.width = newWidth;
  6898. that.size.height = newHeight;
  6899. that.position.left = op.left - ox;
  6900. } else {
  6901. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) {
  6902. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  6903. }
  6904. if ( newHeight - gridY > 0 ) {
  6905. that.size.height = newHeight;
  6906. that.position.top = op.top - oy;
  6907. } else {
  6908. newHeight = gridY - outerDimensions.height;
  6909. that.size.height = newHeight;
  6910. that.position.top = op.top + os.height - newHeight;
  6911. }
  6912. if ( newWidth - gridX > 0 ) {
  6913. that.size.width = newWidth;
  6914. that.position.left = op.left - ox;
  6915. } else {
  6916. newWidth = gridY - outerDimensions.height;
  6917. that.size.width = newWidth;
  6918. that.position.left = op.left + os.width - newWidth;
  6919. }
  6920. }
  6921. }
  6922. });
  6923. var resizable = $.ui.resizable;
  6924. /*!
  6925. * jQuery UI Dialog 1.11.1
  6926. * http://jqueryui.com
  6927. *
  6928. * Copyright 2014 jQuery Foundation and other contributors
  6929. * Released under the MIT license.
  6930. * http://jquery.org/license
  6931. *
  6932. * http://api.jqueryui.com/dialog/
  6933. */
  6934. var dialog = $.widget( "ui.dialog", {
  6935. version: "1.11.1",
  6936. options: {
  6937. appendTo: "body",
  6938. autoOpen: true,
  6939. buttons: [],
  6940. closeOnEscape: true,
  6941. closeText: "Close",
  6942. dialogClass: "",
  6943. draggable: true,
  6944. hide: null,
  6945. height: "auto",
  6946. maxHeight: null,
  6947. maxWidth: null,
  6948. minHeight: 150,
  6949. minWidth: 150,
  6950. modal: false,
  6951. position: {
  6952. my: "center",
  6953. at: "center",
  6954. of: window,
  6955. collision: "fit",
  6956. // Ensure the titlebar is always visible
  6957. using: function( pos ) {
  6958. var topOffset = $( this ).css( pos ).offset().top;
  6959. if ( topOffset < 0 ) {
  6960. $( this ).css( "top", pos.top - topOffset );
  6961. }
  6962. }
  6963. },
  6964. resizable: true,
  6965. show: null,
  6966. title: null,
  6967. width: 300,
  6968. // callbacks
  6969. beforeClose: null,
  6970. close: null,
  6971. drag: null,
  6972. dragStart: null,
  6973. dragStop: null,
  6974. focus: null,
  6975. open: null,
  6976. resize: null,
  6977. resizeStart: null,
  6978. resizeStop: null
  6979. },
  6980. sizeRelatedOptions: {
  6981. buttons: true,
  6982. height: true,
  6983. maxHeight: true,
  6984. maxWidth: true,
  6985. minHeight: true,
  6986. minWidth: true,
  6987. width: true
  6988. },
  6989. resizableRelatedOptions: {
  6990. maxHeight: true,
  6991. maxWidth: true,
  6992. minHeight: true,
  6993. minWidth: true
  6994. },
  6995. _create: function() {
  6996. this.originalCss = {
  6997. display: this.element[ 0 ].style.display,
  6998. width: this.element[ 0 ].style.width,
  6999. minHeight: this.element[ 0 ].style.minHeight,
  7000. maxHeight: this.element[ 0 ].style.maxHeight,
  7001. height: this.element[ 0 ].style.height
  7002. };
  7003. this.originalPosition = {
  7004. parent: this.element.parent(),
  7005. index: this.element.parent().children().index( this.element )
  7006. };
  7007. this.originalTitle = this.element.attr( "title" );
  7008. this.options.title = this.options.title || this.originalTitle;
  7009. this._createWrapper();
  7010. this.element
  7011. .show()
  7012. .removeAttr( "title" )
  7013. .addClass( "ui-dialog-content ui-widget-content" )
  7014. .appendTo( this.uiDialog );
  7015. this._createTitlebar();
  7016. this._createButtonPane();
  7017. if ( this.options.draggable && $.fn.draggable ) {
  7018. this._makeDraggable();
  7019. }
  7020. if ( this.options.resizable && $.fn.resizable ) {
  7021. this._makeResizable();
  7022. }
  7023. this._isOpen = false;
  7024. this._trackFocus();
  7025. },
  7026. _init: function() {
  7027. if ( this.options.autoOpen ) {
  7028. this.open();
  7029. }
  7030. },
  7031. _appendTo: function() {
  7032. var element = this.options.appendTo;
  7033. if ( element && (element.jquery || element.nodeType) ) {
  7034. return $( element );
  7035. }
  7036. return this.document.find( element || "body" ).eq( 0 );
  7037. },
  7038. _destroy: function() {
  7039. var next,
  7040. originalPosition = this.originalPosition;
  7041. this._destroyOverlay();
  7042. this.element
  7043. .removeUniqueId()
  7044. .removeClass( "ui-dialog-content ui-widget-content" )
  7045. .css( this.originalCss )
  7046. // Without detaching first, the following becomes really slow
  7047. .detach();
  7048. this.uiDialog.stop( true, true ).remove();
  7049. if ( this.originalTitle ) {
  7050. this.element.attr( "title", this.originalTitle );
  7051. }
  7052. next = originalPosition.parent.children().eq( originalPosition.index );
  7053. // Don't try to place the dialog next to itself (#8613)
  7054. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  7055. next.before( this.element );
  7056. } else {
  7057. originalPosition.parent.append( this.element );
  7058. }
  7059. },
  7060. widget: function() {
  7061. return this.uiDialog;
  7062. },
  7063. disable: $.noop,
  7064. enable: $.noop,
  7065. close: function( event ) {
  7066. var activeElement,
  7067. that = this;
  7068. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  7069. return;
  7070. }
  7071. this._isOpen = false;
  7072. this._focusedElement = null;
  7073. this._destroyOverlay();
  7074. this._untrackInstance();
  7075. if ( !this.opener.filter( ":focusable" ).focus().length ) {
  7076. // support: IE9
  7077. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  7078. try {
  7079. activeElement = this.document[ 0 ].activeElement;
  7080. // Support: IE9, IE10
  7081. // If the <body> is blurred, IE will switch windows, see #4520
  7082. if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {
  7083. // Hiding a focused element doesn't trigger blur in WebKit
  7084. // so in case we have nothing to focus on, explicitly blur the active element
  7085. // https://bugs.webkit.org/show_bug.cgi?id=47182
  7086. $( activeElement ).blur();
  7087. }
  7088. } catch ( error ) {}
  7089. }
  7090. this._hide( this.uiDialog, this.options.hide, function() {
  7091. that._trigger( "close", event );
  7092. });
  7093. },
  7094. isOpen: function() {
  7095. return this._isOpen;
  7096. },
  7097. moveToTop: function() {
  7098. this._moveToTop();
  7099. },
  7100. _moveToTop: function( event, silent ) {
  7101. var moved = false,
  7102. zIndicies = this.uiDialog.siblings( ".ui-front:visible" ).map(function() {
  7103. return +$( this ).css( "z-index" );
  7104. }).get(),
  7105. zIndexMax = Math.max.apply( null, zIndicies );
  7106. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  7107. this.uiDialog.css( "z-index", zIndexMax + 1 );
  7108. moved = true;
  7109. }
  7110. if ( moved && !silent ) {
  7111. this._trigger( "focus", event );
  7112. }
  7113. return moved;
  7114. },
  7115. open: function() {
  7116. var that = this;
  7117. if ( this._isOpen ) {
  7118. if ( this._moveToTop() ) {
  7119. this._focusTabbable();
  7120. }
  7121. return;
  7122. }
  7123. this._isOpen = true;
  7124. this.opener = $( this.document[ 0 ].activeElement );
  7125. this._size();
  7126. this._position();
  7127. this._createOverlay();
  7128. this._moveToTop( null, true );
  7129. // Ensure the overlay is moved to the top with the dialog, but only when
  7130. // opening. The overlay shouldn't move after the dialog is open so that
  7131. // modeless dialogs opened after the modal dialog stack properly.
  7132. if ( this.overlay ) {
  7133. this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
  7134. }
  7135. this._show( this.uiDialog, this.options.show, function() {
  7136. that._focusTabbable();
  7137. that._trigger( "focus" );
  7138. });
  7139. // Track the dialog immediately upon openening in case a focus event
  7140. // somehow occurs outside of the dialog before an element inside the
  7141. // dialog is focused (#10152)
  7142. this._makeFocusTarget();
  7143. this._trigger( "open" );
  7144. },
  7145. _focusTabbable: function() {
  7146. // Set focus to the first match:
  7147. // 1. An element that was focused previously
  7148. // 2. First element inside the dialog matching [autofocus]
  7149. // 3. Tabbable element inside the content element
  7150. // 4. Tabbable element inside the buttonpane
  7151. // 5. The close button
  7152. // 6. The dialog itself
  7153. var hasFocus = this._focusedElement;
  7154. if ( !hasFocus ) {
  7155. hasFocus = this.element.find( "[autofocus]" );
  7156. }
  7157. if ( !hasFocus.length ) {
  7158. hasFocus = this.element.find( ":tabbable" );
  7159. }
  7160. if ( !hasFocus.length ) {
  7161. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  7162. }
  7163. if ( !hasFocus.length ) {
  7164. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  7165. }
  7166. if ( !hasFocus.length ) {
  7167. hasFocus = this.uiDialog;
  7168. }
  7169. hasFocus.eq( 0 ).focus();
  7170. },
  7171. _keepFocus: function( event ) {
  7172. function checkFocus() {
  7173. var activeElement = this.document[0].activeElement,
  7174. isActive = this.uiDialog[0] === activeElement ||
  7175. $.contains( this.uiDialog[0], activeElement );
  7176. if ( !isActive ) {
  7177. this._focusTabbable();
  7178. }
  7179. }
  7180. event.preventDefault();
  7181. checkFocus.call( this );
  7182. // support: IE
  7183. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  7184. // so we check again later
  7185. this._delay( checkFocus );
  7186. },
  7187. _createWrapper: function() {
  7188. this.uiDialog = $("<div>")
  7189. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  7190. this.options.dialogClass )
  7191. .hide()
  7192. .attr({
  7193. // Setting tabIndex makes the div focusable
  7194. tabIndex: -1,
  7195. role: "dialog"
  7196. })
  7197. .appendTo( this._appendTo() );
  7198. this._on( this.uiDialog, {
  7199. keydown: function( event ) {
  7200. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  7201. event.keyCode === $.ui.keyCode.ESCAPE ) {
  7202. event.preventDefault();
  7203. this.close( event );
  7204. return;
  7205. }
  7206. // prevent tabbing out of dialogs
  7207. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  7208. return;
  7209. }
  7210. var tabbables = this.uiDialog.find( ":tabbable" ),
  7211. first = tabbables.filter( ":first" ),
  7212. last = tabbables.filter( ":last" );
  7213. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  7214. this._delay(function() {
  7215. first.focus();
  7216. });
  7217. event.preventDefault();
  7218. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  7219. this._delay(function() {
  7220. last.focus();
  7221. });
  7222. event.preventDefault();
  7223. }
  7224. },
  7225. mousedown: function( event ) {
  7226. if ( this._moveToTop( event ) ) {
  7227. this._focusTabbable();
  7228. }
  7229. }
  7230. });
  7231. // We assume that any existing aria-describedby attribute means
  7232. // that the dialog content is marked up properly
  7233. // otherwise we brute force the content as the description
  7234. if ( !this.element.find( "[aria-describedby]" ).length ) {
  7235. this.uiDialog.attr({
  7236. "aria-describedby": this.element.uniqueId().attr( "id" )
  7237. });
  7238. }
  7239. },
  7240. _createTitlebar: function() {
  7241. var uiDialogTitle;
  7242. this.uiDialogTitlebar = $( "<div>" )
  7243. .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" )
  7244. .prependTo( this.uiDialog );
  7245. this._on( this.uiDialogTitlebar, {
  7246. mousedown: function( event ) {
  7247. // Don't prevent click on close button (#8838)
  7248. // Focusing a dialog that is partially scrolled out of view
  7249. // causes the browser to scroll it into view, preventing the click event
  7250. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  7251. // Dialog isn't getting focus when dragging (#8063)
  7252. this.uiDialog.focus();
  7253. }
  7254. }
  7255. });
  7256. // support: IE
  7257. // Use type="button" to prevent enter keypresses in textboxes from closing the
  7258. // dialog in IE (#9312)
  7259. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  7260. .button({
  7261. label: this.options.closeText,
  7262. icons: {
  7263. primary: "ui-icon-closethick"
  7264. },
  7265. text: false
  7266. })
  7267. .addClass( "ui-dialog-titlebar-close" )
  7268. .appendTo( this.uiDialogTitlebar );
  7269. this._on( this.uiDialogTitlebarClose, {
  7270. click: function( event ) {
  7271. event.preventDefault();
  7272. this.close( event );
  7273. }
  7274. });
  7275. uiDialogTitle = $( "<span>" )
  7276. .uniqueId()
  7277. .addClass( "ui-dialog-title" )
  7278. .prependTo( this.uiDialogTitlebar );
  7279. this._title( uiDialogTitle );
  7280. this.uiDialog.attr({
  7281. "aria-labelledby": uiDialogTitle.attr( "id" )
  7282. });
  7283. },
  7284. _title: function( title ) {
  7285. if ( !this.options.title ) {
  7286. title.html( "&#160;" );
  7287. }
  7288. title.text( this.options.title );
  7289. },
  7290. _createButtonPane: function() {
  7291. this.uiDialogButtonPane = $( "<div>" )
  7292. .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
  7293. this.uiButtonSet = $( "<div>" )
  7294. .addClass( "ui-dialog-buttonset" )
  7295. .appendTo( this.uiDialogButtonPane );
  7296. this._createButtons();
  7297. },
  7298. _createButtons: function() {
  7299. var that = this,
  7300. buttons = this.options.buttons;
  7301. // if we already have a button pane, remove it
  7302. this.uiDialogButtonPane.remove();
  7303. this.uiButtonSet.empty();
  7304. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  7305. this.uiDialog.removeClass( "ui-dialog-buttons" );
  7306. return;
  7307. }
  7308. $.each( buttons, function( name, props ) {
  7309. var click, buttonOptions;
  7310. props = $.isFunction( props ) ?
  7311. { click: props, text: name } :
  7312. props;
  7313. // Default to a non-submitting button
  7314. props = $.extend( { type: "button" }, props );
  7315. // Change the context for the click callback to be the main element
  7316. click = props.click;
  7317. props.click = function() {
  7318. click.apply( that.element[ 0 ], arguments );
  7319. };
  7320. buttonOptions = {
  7321. icons: props.icons,
  7322. text: props.showText
  7323. };
  7324. delete props.icons;
  7325. delete props.showText;
  7326. $( "<button></button>", props )
  7327. .button( buttonOptions )
  7328. .appendTo( that.uiButtonSet );
  7329. });
  7330. this.uiDialog.addClass( "ui-dialog-buttons" );
  7331. this.uiDialogButtonPane.appendTo( this.uiDialog );
  7332. },
  7333. _makeDraggable: function() {
  7334. var that = this,
  7335. options = this.options;
  7336. function filteredUi( ui ) {
  7337. return {
  7338. position: ui.position,
  7339. offset: ui.offset
  7340. };
  7341. }
  7342. this.uiDialog.draggable({
  7343. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  7344. handle: ".ui-dialog-titlebar",
  7345. containment: "document",
  7346. start: function( event, ui ) {
  7347. $( this ).addClass( "ui-dialog-dragging" );
  7348. that._blockFrames();
  7349. that._trigger( "dragStart", event, filteredUi( ui ) );
  7350. },
  7351. drag: function( event, ui ) {
  7352. that._trigger( "drag", event, filteredUi( ui ) );
  7353. },
  7354. stop: function( event, ui ) {
  7355. var left = ui.offset.left - that.document.scrollLeft(),
  7356. top = ui.offset.top - that.document.scrollTop();
  7357. options.position = {
  7358. my: "left top",
  7359. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  7360. "top" + (top >= 0 ? "+" : "") + top,
  7361. of: that.window
  7362. };
  7363. $( this ).removeClass( "ui-dialog-dragging" );
  7364. that._unblockFrames();
  7365. that._trigger( "dragStop", event, filteredUi( ui ) );
  7366. }
  7367. });
  7368. },
  7369. _makeResizable: function() {
  7370. var that = this,
  7371. options = this.options,
  7372. handles = options.resizable,
  7373. // .ui-resizable has position: relative defined in the stylesheet
  7374. // but dialogs have to use absolute or fixed positioning
  7375. position = this.uiDialog.css("position"),
  7376. resizeHandles = typeof handles === "string" ?
  7377. handles :
  7378. "n,e,s,w,se,sw,ne,nw";
  7379. function filteredUi( ui ) {
  7380. return {
  7381. originalPosition: ui.originalPosition,
  7382. originalSize: ui.originalSize,
  7383. position: ui.position,
  7384. size: ui.size
  7385. };
  7386. }
  7387. this.uiDialog.resizable({
  7388. cancel: ".ui-dialog-content",
  7389. containment: "document",
  7390. alsoResize: this.element,
  7391. maxWidth: options.maxWidth,
  7392. maxHeight: options.maxHeight,
  7393. minWidth: options.minWidth,
  7394. minHeight: this._minHeight(),
  7395. handles: resizeHandles,
  7396. start: function( event, ui ) {
  7397. $( this ).addClass( "ui-dialog-resizing" );
  7398. that._blockFrames();
  7399. that._trigger( "resizeStart", event, filteredUi( ui ) );
  7400. },
  7401. resize: function( event, ui ) {
  7402. that._trigger( "resize", event, filteredUi( ui ) );
  7403. },
  7404. stop: function( event, ui ) {
  7405. var offset = that.uiDialog.offset(),
  7406. left = offset.left - that.document.scrollLeft(),
  7407. top = offset.top - that.document.scrollTop();
  7408. options.height = that.uiDialog.height();
  7409. options.width = that.uiDialog.width();
  7410. options.position = {
  7411. my: "left top",
  7412. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  7413. "top" + (top >= 0 ? "+" : "") + top,
  7414. of: that.window
  7415. };
  7416. $( this ).removeClass( "ui-dialog-resizing" );
  7417. that._unblockFrames();
  7418. that._trigger( "resizeStop", event, filteredUi( ui ) );
  7419. }
  7420. })
  7421. .css( "position", position );
  7422. },
  7423. _trackFocus: function() {
  7424. this._on( this.widget(), {
  7425. focusin: function( event ) {
  7426. this._makeFocusTarget();
  7427. this._focusedElement = $( event.target );
  7428. }
  7429. });
  7430. },
  7431. _makeFocusTarget: function() {
  7432. this._untrackInstance();
  7433. this._trackingInstances().unshift( this );
  7434. },
  7435. _untrackInstance: function() {
  7436. var instances = this._trackingInstances(),
  7437. exists = $.inArray( this, instances );
  7438. if ( exists !== -1 ) {
  7439. instances.splice( exists, 1 );
  7440. }
  7441. },
  7442. _trackingInstances: function() {
  7443. var instances = this.document.data( "ui-dialog-instances" );
  7444. if ( !instances ) {
  7445. instances = [];
  7446. this.document.data( "ui-dialog-instances", instances );
  7447. }
  7448. return instances;
  7449. },
  7450. _minHeight: function() {
  7451. var options = this.options;
  7452. return options.height === "auto" ?
  7453. options.minHeight :
  7454. Math.min( options.minHeight, options.height );
  7455. },
  7456. _position: function() {
  7457. // Need to show the dialog to get the actual offset in the position plugin
  7458. var isVisible = this.uiDialog.is( ":visible" );
  7459. if ( !isVisible ) {
  7460. this.uiDialog.show();
  7461. }
  7462. this.uiDialog.position( this.options.position );
  7463. if ( !isVisible ) {
  7464. this.uiDialog.hide();
  7465. }
  7466. },
  7467. _setOptions: function( options ) {
  7468. var that = this,
  7469. resize = false,
  7470. resizableOptions = {};
  7471. $.each( options, function( key, value ) {
  7472. that._setOption( key, value );
  7473. if ( key in that.sizeRelatedOptions ) {
  7474. resize = true;
  7475. }
  7476. if ( key in that.resizableRelatedOptions ) {
  7477. resizableOptions[ key ] = value;
  7478. }
  7479. });
  7480. if ( resize ) {
  7481. this._size();
  7482. this._position();
  7483. }
  7484. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  7485. this.uiDialog.resizable( "option", resizableOptions );
  7486. }
  7487. },
  7488. _setOption: function( key, value ) {
  7489. var isDraggable, isResizable,
  7490. uiDialog = this.uiDialog;
  7491. if ( key === "dialogClass" ) {
  7492. uiDialog
  7493. .removeClass( this.options.dialogClass )
  7494. .addClass( value );
  7495. }
  7496. if ( key === "disabled" ) {
  7497. return;
  7498. }
  7499. this._super( key, value );
  7500. if ( key === "appendTo" ) {
  7501. this.uiDialog.appendTo( this._appendTo() );
  7502. }
  7503. if ( key === "buttons" ) {
  7504. this._createButtons();
  7505. }
  7506. if ( key === "closeText" ) {
  7507. this.uiDialogTitlebarClose.button({
  7508. // Ensure that we always pass a string
  7509. label: "" + value
  7510. });
  7511. }
  7512. if ( key === "draggable" ) {
  7513. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  7514. if ( isDraggable && !value ) {
  7515. uiDialog.draggable( "destroy" );
  7516. }
  7517. if ( !isDraggable && value ) {
  7518. this._makeDraggable();
  7519. }
  7520. }
  7521. if ( key === "position" ) {
  7522. this._position();
  7523. }
  7524. if ( key === "resizable" ) {
  7525. // currently resizable, becoming non-resizable
  7526. isResizable = uiDialog.is( ":data(ui-resizable)" );
  7527. if ( isResizable && !value ) {
  7528. uiDialog.resizable( "destroy" );
  7529. }
  7530. // currently resizable, changing handles
  7531. if ( isResizable && typeof value === "string" ) {
  7532. uiDialog.resizable( "option", "handles", value );
  7533. }
  7534. // currently non-resizable, becoming resizable
  7535. if ( !isResizable && value !== false ) {
  7536. this._makeResizable();
  7537. }
  7538. }
  7539. if ( key === "title" ) {
  7540. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  7541. }
  7542. },
  7543. _size: function() {
  7544. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  7545. // divs will both have width and height set, so we need to reset them
  7546. var nonContentHeight, minContentHeight, maxContentHeight,
  7547. options = this.options;
  7548. // Reset content sizing
  7549. this.element.show().css({
  7550. width: "auto",
  7551. minHeight: 0,
  7552. maxHeight: "none",
  7553. height: 0
  7554. });
  7555. if ( options.minWidth > options.width ) {
  7556. options.width = options.minWidth;
  7557. }
  7558. // reset wrapper sizing
  7559. // determine the height of all the non-content elements
  7560. nonContentHeight = this.uiDialog.css({
  7561. height: "auto",
  7562. width: options.width
  7563. })
  7564. .outerHeight();
  7565. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  7566. maxContentHeight = typeof options.maxHeight === "number" ?
  7567. Math.max( 0, options.maxHeight - nonContentHeight ) :
  7568. "none";
  7569. if ( options.height === "auto" ) {
  7570. this.element.css({
  7571. minHeight: minContentHeight,
  7572. maxHeight: maxContentHeight,
  7573. height: "auto"
  7574. });
  7575. } else {
  7576. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  7577. }
  7578. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  7579. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  7580. }
  7581. },
  7582. _blockFrames: function() {
  7583. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  7584. var iframe = $( this );
  7585. return $( "<div>" )
  7586. .css({
  7587. position: "absolute",
  7588. width: iframe.outerWidth(),
  7589. height: iframe.outerHeight()
  7590. })
  7591. .appendTo( iframe.parent() )
  7592. .offset( iframe.offset() )[0];
  7593. });
  7594. },
  7595. _unblockFrames: function() {
  7596. if ( this.iframeBlocks ) {
  7597. this.iframeBlocks.remove();
  7598. delete this.iframeBlocks;
  7599. }
  7600. },
  7601. _allowInteraction: function( event ) {
  7602. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  7603. return true;
  7604. }
  7605. // TODO: Remove hack when datepicker implements
  7606. // the .ui-front logic (#8989)
  7607. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  7608. },
  7609. _createOverlay: function() {
  7610. if ( !this.options.modal ) {
  7611. return;
  7612. }
  7613. // We use a delay in case the overlay is created from an
  7614. // event that we're going to be cancelling (#2804)
  7615. var isOpening = true;
  7616. this._delay(function() {
  7617. isOpening = false;
  7618. });
  7619. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  7620. // Prevent use of anchors and inputs
  7621. // Using _on() for an event handler shared across many instances is
  7622. // safe because the dialogs stack and must be closed in reverse order
  7623. this._on( this.document, {
  7624. focusin: function( event ) {
  7625. if ( isOpening ) {
  7626. return;
  7627. }
  7628. if ( !this._allowInteraction( event ) ) {
  7629. event.preventDefault();
  7630. this._trackingInstances()[ 0 ]._focusTabbable();
  7631. }
  7632. }
  7633. });
  7634. }
  7635. this.overlay = $( "<div>" )
  7636. .addClass( "ui-widget-overlay ui-front" )
  7637. .appendTo( this._appendTo() );
  7638. this._on( this.overlay, {
  7639. mousedown: "_keepFocus"
  7640. });
  7641. this.document.data( "ui-dialog-overlays",
  7642. (this.document.data( "ui-dialog-overlays" ) || 0) + 1 );
  7643. },
  7644. _destroyOverlay: function() {
  7645. if ( !this.options.modal ) {
  7646. return;
  7647. }
  7648. if ( this.overlay ) {
  7649. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  7650. if ( !overlays ) {
  7651. this.document
  7652. .unbind( "focusin" )
  7653. .removeData( "ui-dialog-overlays" );
  7654. } else {
  7655. this.document.data( "ui-dialog-overlays", overlays );
  7656. }
  7657. this.overlay.remove();
  7658. this.overlay = null;
  7659. }
  7660. }
  7661. });
  7662. /*!
  7663. * jQuery UI Droppable 1.11.1
  7664. * http://jqueryui.com
  7665. *
  7666. * Copyright 2014 jQuery Foundation and other contributors
  7667. * Released under the MIT license.
  7668. * http://jquery.org/license
  7669. *
  7670. * http://api.jqueryui.com/droppable/
  7671. */
  7672. $.widget( "ui.droppable", {
  7673. version: "1.11.1",
  7674. widgetEventPrefix: "drop",
  7675. options: {
  7676. accept: "*",
  7677. activeClass: false,
  7678. addClasses: true,
  7679. greedy: false,
  7680. hoverClass: false,
  7681. scope: "default",
  7682. tolerance: "intersect",
  7683. // callbacks
  7684. activate: null,
  7685. deactivate: null,
  7686. drop: null,
  7687. out: null,
  7688. over: null
  7689. },
  7690. _create: function() {
  7691. var proportions,
  7692. o = this.options,
  7693. accept = o.accept;
  7694. this.isover = false;
  7695. this.isout = true;
  7696. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  7697. return d.is( accept );
  7698. };
  7699. this.proportions = function( /* valueToWrite */ ) {
  7700. if ( arguments.length ) {
  7701. // Store the droppable's proportions
  7702. proportions = arguments[ 0 ];
  7703. } else {
  7704. // Retrieve or derive the droppable's proportions
  7705. return proportions ?
  7706. proportions :
  7707. proportions = {
  7708. width: this.element[ 0 ].offsetWidth,
  7709. height: this.element[ 0 ].offsetHeight
  7710. };
  7711. }
  7712. };
  7713. this._addToManager( o.scope );
  7714. o.addClasses && this.element.addClass( "ui-droppable" );
  7715. },
  7716. _addToManager: function( scope ) {
  7717. // Add the reference and positions to the manager
  7718. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  7719. $.ui.ddmanager.droppables[ scope ].push( this );
  7720. },
  7721. _splice: function( drop ) {
  7722. var i = 0;
  7723. for ( ; i < drop.length; i++ ) {
  7724. if ( drop[ i ] === this ) {
  7725. drop.splice( i, 1 );
  7726. }
  7727. }
  7728. },
  7729. _destroy: function() {
  7730. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  7731. this._splice( drop );
  7732. this.element.removeClass( "ui-droppable ui-droppable-disabled" );
  7733. },
  7734. _setOption: function( key, value ) {
  7735. if ( key === "accept" ) {
  7736. this.accept = $.isFunction( value ) ? value : function( d ) {
  7737. return d.is( value );
  7738. };
  7739. } else if ( key === "scope" ) {
  7740. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  7741. this._splice( drop );
  7742. this._addToManager( value );
  7743. }
  7744. this._super( key, value );
  7745. },
  7746. _activate: function( event ) {
  7747. var draggable = $.ui.ddmanager.current;
  7748. if ( this.options.activeClass ) {
  7749. this.element.addClass( this.options.activeClass );
  7750. }
  7751. if ( draggable ){
  7752. this._trigger( "activate", event, this.ui( draggable ) );
  7753. }
  7754. },
  7755. _deactivate: function( event ) {
  7756. var draggable = $.ui.ddmanager.current;
  7757. if ( this.options.activeClass ) {
  7758. this.element.removeClass( this.options.activeClass );
  7759. }
  7760. if ( draggable ){
  7761. this._trigger( "deactivate", event, this.ui( draggable ) );
  7762. }
  7763. },
  7764. _over: function( event ) {
  7765. var draggable = $.ui.ddmanager.current;
  7766. // Bail if draggable and droppable are same element
  7767. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  7768. return;
  7769. }
  7770. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7771. if ( this.options.hoverClass ) {
  7772. this.element.addClass( this.options.hoverClass );
  7773. }
  7774. this._trigger( "over", event, this.ui( draggable ) );
  7775. }
  7776. },
  7777. _out: function( event ) {
  7778. var draggable = $.ui.ddmanager.current;
  7779. // Bail if draggable and droppable are same element
  7780. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  7781. return;
  7782. }
  7783. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7784. if ( this.options.hoverClass ) {
  7785. this.element.removeClass( this.options.hoverClass );
  7786. }
  7787. this._trigger( "out", event, this.ui( draggable ) );
  7788. }
  7789. },
  7790. _drop: function( event, custom ) {
  7791. var draggable = custom || $.ui.ddmanager.current,
  7792. childrenIntersection = false;
  7793. // Bail if draggable and droppable are same element
  7794. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  7795. return false;
  7796. }
  7797. this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
  7798. var inst = $( this ).droppable( "instance" );
  7799. if (
  7800. inst.options.greedy &&
  7801. !inst.options.disabled &&
  7802. inst.options.scope === draggable.options.scope &&
  7803. inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
  7804. $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
  7805. ) { childrenIntersection = true; return false; }
  7806. });
  7807. if ( childrenIntersection ) {
  7808. return false;
  7809. }
  7810. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7811. if ( this.options.activeClass ) {
  7812. this.element.removeClass( this.options.activeClass );
  7813. }
  7814. if ( this.options.hoverClass ) {
  7815. this.element.removeClass( this.options.hoverClass );
  7816. }
  7817. this._trigger( "drop", event, this.ui( draggable ) );
  7818. return this.element;
  7819. }
  7820. return false;
  7821. },
  7822. ui: function( c ) {
  7823. return {
  7824. draggable: ( c.currentItem || c.element ),
  7825. helper: c.helper,
  7826. position: c.position,
  7827. offset: c.positionAbs
  7828. };
  7829. }
  7830. });
  7831. $.ui.intersect = (function() {
  7832. function isOverAxis( x, reference, size ) {
  7833. return ( x >= reference ) && ( x < ( reference + size ) );
  7834. }
  7835. return function( draggable, droppable, toleranceMode, event ) {
  7836. if ( !droppable.offset ) {
  7837. return false;
  7838. }
  7839. var x1 = ( draggable.positionAbs || draggable.position.absolute ).left,
  7840. y1 = ( draggable.positionAbs || draggable.position.absolute ).top,
  7841. x2 = x1 + draggable.helperProportions.width,
  7842. y2 = y1 + draggable.helperProportions.height,
  7843. l = droppable.offset.left,
  7844. t = droppable.offset.top,
  7845. r = l + droppable.proportions().width,
  7846. b = t + droppable.proportions().height;
  7847. switch ( toleranceMode ) {
  7848. case "fit":
  7849. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  7850. case "intersect":
  7851. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  7852. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  7853. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  7854. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  7855. case "pointer":
  7856. return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
  7857. case "touch":
  7858. return (
  7859. ( y1 >= t && y1 <= b ) || // Top edge touching
  7860. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  7861. ( y1 < t && y2 > b ) // Surrounded vertically
  7862. ) && (
  7863. ( x1 >= l && x1 <= r ) || // Left edge touching
  7864. ( x2 >= l && x2 <= r ) || // Right edge touching
  7865. ( x1 < l && x2 > r ) // Surrounded horizontally
  7866. );
  7867. default:
  7868. return false;
  7869. }
  7870. };
  7871. })();
  7872. /*
  7873. This manager tracks offsets of draggables and droppables
  7874. */
  7875. $.ui.ddmanager = {
  7876. current: null,
  7877. droppables: { "default": [] },
  7878. prepareOffsets: function( t, event ) {
  7879. var i, j,
  7880. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  7881. type = event ? event.type : null, // workaround for #2317
  7882. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  7883. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  7884. // No disabled and non-accepted
  7885. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
  7886. continue;
  7887. }
  7888. // Filter out elements in the current dragged item
  7889. for ( j = 0; j < list.length; j++ ) {
  7890. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  7891. m[ i ].proportions().height = 0;
  7892. continue droppablesLoop;
  7893. }
  7894. }
  7895. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  7896. if ( !m[ i ].visible ) {
  7897. continue;
  7898. }
  7899. // Activate the droppable if used directly from draggables
  7900. if ( type === "mousedown" ) {
  7901. m[ i ]._activate.call( m[ i ], event );
  7902. }
  7903. m[ i ].offset = m[ i ].element.offset();
  7904. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  7905. }
  7906. },
  7907. drop: function( draggable, event ) {
  7908. var dropped = false;
  7909. // Create a copy of the droppables in case the list changes during the drop (#9116)
  7910. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  7911. if ( !this.options ) {
  7912. return;
  7913. }
  7914. if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
  7915. dropped = this._drop.call( this, event ) || dropped;
  7916. }
  7917. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7918. this.isout = true;
  7919. this.isover = false;
  7920. this._deactivate.call( this, event );
  7921. }
  7922. });
  7923. return dropped;
  7924. },
  7925. dragStart: function( draggable, event ) {
  7926. // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  7927. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  7928. if ( !draggable.options.refreshPositions ) {
  7929. $.ui.ddmanager.prepareOffsets( draggable, event );
  7930. }
  7931. });
  7932. },
  7933. drag: function( draggable, event ) {
  7934. // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  7935. if ( draggable.options.refreshPositions ) {
  7936. $.ui.ddmanager.prepareOffsets( draggable, event );
  7937. }
  7938. // Run through all droppables and check their positions based on specific tolerance options
  7939. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  7940. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  7941. return;
  7942. }
  7943. var parentInstance, scope, parent,
  7944. intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
  7945. c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
  7946. if ( !c ) {
  7947. return;
  7948. }
  7949. if ( this.options.greedy ) {
  7950. // find droppable parents with same scope
  7951. scope = this.options.scope;
  7952. parent = this.element.parents( ":data(ui-droppable)" ).filter(function() {
  7953. return $( this ).droppable( "instance" ).options.scope === scope;
  7954. });
  7955. if ( parent.length ) {
  7956. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  7957. parentInstance.greedyChild = ( c === "isover" );
  7958. }
  7959. }
  7960. // we just moved into a greedy child
  7961. if ( parentInstance && c === "isover" ) {
  7962. parentInstance.isover = false;
  7963. parentInstance.isout = true;
  7964. parentInstance._out.call( parentInstance, event );
  7965. }
  7966. this[ c ] = true;
  7967. this[c === "isout" ? "isover" : "isout"] = false;
  7968. this[c === "isover" ? "_over" : "_out"].call( this, event );
  7969. // we just moved out of a greedy child
  7970. if ( parentInstance && c === "isout" ) {
  7971. parentInstance.isout = false;
  7972. parentInstance.isover = true;
  7973. parentInstance._over.call( parentInstance, event );
  7974. }
  7975. });
  7976. },
  7977. dragStop: function( draggable, event ) {
  7978. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  7979. // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  7980. if ( !draggable.options.refreshPositions ) {
  7981. $.ui.ddmanager.prepareOffsets( draggable, event );
  7982. }
  7983. }
  7984. };
  7985. var droppable = $.ui.droppable;
  7986. /*!
  7987. * jQuery UI Effects 1.11.1
  7988. * http://jqueryui.com
  7989. *
  7990. * Copyright 2014 jQuery Foundation and other contributors
  7991. * Released under the MIT license.
  7992. * http://jquery.org/license
  7993. *
  7994. * http://api.jqueryui.com/category/effects-core/
  7995. */
  7996. var dataSpace = "ui-effects-",
  7997. // Create a local jQuery because jQuery Color relies on it and the
  7998. // global may not exist with AMD and a custom build (#10199)
  7999. jQuery = $;
  8000. $.effects = {
  8001. effect: {}
  8002. };
  8003. /*!
  8004. * jQuery Color Animations v2.1.2
  8005. * https://github.com/jquery/jquery-color
  8006. *
  8007. * Copyright 2014 jQuery Foundation and other contributors
  8008. * Released under the MIT license.
  8009. * http://jquery.org/license
  8010. *
  8011. * Date: Wed Jan 16 08:47:09 2013 -0600
  8012. */
  8013. (function( jQuery, undefined ) {
  8014. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  8015. // plusequals test for += 100 -= 100
  8016. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  8017. // a set of RE's that can match strings and generate color tuples.
  8018. stringParsers = [ {
  8019. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  8020. parse: function( execResult ) {
  8021. return [
  8022. execResult[ 1 ],
  8023. execResult[ 2 ],
  8024. execResult[ 3 ],
  8025. execResult[ 4 ]
  8026. ];
  8027. }
  8028. }, {
  8029. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  8030. parse: function( execResult ) {
  8031. return [
  8032. execResult[ 1 ] * 2.55,
  8033. execResult[ 2 ] * 2.55,
  8034. execResult[ 3 ] * 2.55,
  8035. execResult[ 4 ]
  8036. ];
  8037. }
  8038. }, {
  8039. // this regex ignores A-F because it's compared against an already lowercased string
  8040. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  8041. parse: function( execResult ) {
  8042. return [
  8043. parseInt( execResult[ 1 ], 16 ),
  8044. parseInt( execResult[ 2 ], 16 ),
  8045. parseInt( execResult[ 3 ], 16 )
  8046. ];
  8047. }
  8048. }, {
  8049. // this regex ignores A-F because it's compared against an already lowercased string
  8050. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  8051. parse: function( execResult ) {
  8052. return [
  8053. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  8054. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  8055. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  8056. ];
  8057. }
  8058. }, {
  8059. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  8060. space: "hsla",
  8061. parse: function( execResult ) {
  8062. return [
  8063. execResult[ 1 ],
  8064. execResult[ 2 ] / 100,
  8065. execResult[ 3 ] / 100,
  8066. execResult[ 4 ]
  8067. ];
  8068. }
  8069. } ],
  8070. // jQuery.Color( )
  8071. color = jQuery.Color = function( color, green, blue, alpha ) {
  8072. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  8073. },
  8074. spaces = {
  8075. rgba: {
  8076. props: {
  8077. red: {
  8078. idx: 0,
  8079. type: "byte"
  8080. },
  8081. green: {
  8082. idx: 1,
  8083. type: "byte"
  8084. },
  8085. blue: {
  8086. idx: 2,
  8087. type: "byte"
  8088. }
  8089. }
  8090. },
  8091. hsla: {
  8092. props: {
  8093. hue: {
  8094. idx: 0,
  8095. type: "degrees"
  8096. },
  8097. saturation: {
  8098. idx: 1,
  8099. type: "percent"
  8100. },
  8101. lightness: {
  8102. idx: 2,
  8103. type: "percent"
  8104. }
  8105. }
  8106. }
  8107. },
  8108. propTypes = {
  8109. "byte": {
  8110. floor: true,
  8111. max: 255
  8112. },
  8113. "percent": {
  8114. max: 1
  8115. },
  8116. "degrees": {
  8117. mod: 360,
  8118. floor: true
  8119. }
  8120. },
  8121. support = color.support = {},
  8122. // element for support tests
  8123. supportElem = jQuery( "<p>" )[ 0 ],
  8124. // colors = jQuery.Color.names
  8125. colors,
  8126. // local aliases of functions called often
  8127. each = jQuery.each;
  8128. // determine rgba support immediately
  8129. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  8130. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  8131. // define cache name and alpha properties
  8132. // for rgba and hsla spaces
  8133. each( spaces, function( spaceName, space ) {
  8134. space.cache = "_" + spaceName;
  8135. space.props.alpha = {
  8136. idx: 3,
  8137. type: "percent",
  8138. def: 1
  8139. };
  8140. });
  8141. function clamp( value, prop, allowEmpty ) {
  8142. var type = propTypes[ prop.type ] || {};
  8143. if ( value == null ) {
  8144. return (allowEmpty || !prop.def) ? null : prop.def;
  8145. }
  8146. // ~~ is an short way of doing floor for positive numbers
  8147. value = type.floor ? ~~value : parseFloat( value );
  8148. // IE will pass in empty strings as value for alpha,
  8149. // which will hit this case
  8150. if ( isNaN( value ) ) {
  8151. return prop.def;
  8152. }
  8153. if ( type.mod ) {
  8154. // we add mod before modding to make sure that negatives values
  8155. // get converted properly: -10 -> 350
  8156. return (value + type.mod) % type.mod;
  8157. }
  8158. // for now all property types without mod have min and max
  8159. return 0 > value ? 0 : type.max < value ? type.max : value;
  8160. }
  8161. function stringParse( string ) {
  8162. var inst = color(),
  8163. rgba = inst._rgba = [];
  8164. string = string.toLowerCase();
  8165. each( stringParsers, function( i, parser ) {
  8166. var parsed,
  8167. match = parser.re.exec( string ),
  8168. values = match && parser.parse( match ),
  8169. spaceName = parser.space || "rgba";
  8170. if ( values ) {
  8171. parsed = inst[ spaceName ]( values );
  8172. // if this was an rgba parse the assignment might happen twice
  8173. // oh well....
  8174. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  8175. rgba = inst._rgba = parsed._rgba;
  8176. // exit each( stringParsers ) here because we matched
  8177. return false;
  8178. }
  8179. });
  8180. // Found a stringParser that handled it
  8181. if ( rgba.length ) {
  8182. // if this came from a parsed string, force "transparent" when alpha is 0
  8183. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  8184. if ( rgba.join() === "0,0,0,0" ) {
  8185. jQuery.extend( rgba, colors.transparent );
  8186. }
  8187. return inst;
  8188. }
  8189. // named colors
  8190. return colors[ string ];
  8191. }
  8192. color.fn = jQuery.extend( color.prototype, {
  8193. parse: function( red, green, blue, alpha ) {
  8194. if ( red === undefined ) {
  8195. this._rgba = [ null, null, null, null ];
  8196. return this;
  8197. }
  8198. if ( red.jquery || red.nodeType ) {
  8199. red = jQuery( red ).css( green );
  8200. green = undefined;
  8201. }
  8202. var inst = this,
  8203. type = jQuery.type( red ),
  8204. rgba = this._rgba = [];
  8205. // more than 1 argument specified - assume ( red, green, blue, alpha )
  8206. if ( green !== undefined ) {
  8207. red = [ red, green, blue, alpha ];
  8208. type = "array";
  8209. }
  8210. if ( type === "string" ) {
  8211. return this.parse( stringParse( red ) || colors._default );
  8212. }
  8213. if ( type === "array" ) {
  8214. each( spaces.rgba.props, function( key, prop ) {
  8215. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  8216. });
  8217. return this;
  8218. }
  8219. if ( type === "object" ) {
  8220. if ( red instanceof color ) {
  8221. each( spaces, function( spaceName, space ) {
  8222. if ( red[ space.cache ] ) {
  8223. inst[ space.cache ] = red[ space.cache ].slice();
  8224. }
  8225. });
  8226. } else {
  8227. each( spaces, function( spaceName, space ) {
  8228. var cache = space.cache;
  8229. each( space.props, function( key, prop ) {
  8230. // if the cache doesn't exist, and we know how to convert
  8231. if ( !inst[ cache ] && space.to ) {
  8232. // if the value was null, we don't need to copy it
  8233. // if the key was alpha, we don't need to copy it either
  8234. if ( key === "alpha" || red[ key ] == null ) {
  8235. return;
  8236. }
  8237. inst[ cache ] = space.to( inst._rgba );
  8238. }
  8239. // this is the only case where we allow nulls for ALL properties.
  8240. // call clamp with alwaysAllowEmpty
  8241. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  8242. });
  8243. // everything defined but alpha?
  8244. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  8245. // use the default of 1
  8246. inst[ cache ][ 3 ] = 1;
  8247. if ( space.from ) {
  8248. inst._rgba = space.from( inst[ cache ] );
  8249. }
  8250. }
  8251. });
  8252. }
  8253. return this;
  8254. }
  8255. },
  8256. is: function( compare ) {
  8257. var is = color( compare ),
  8258. same = true,
  8259. inst = this;
  8260. each( spaces, function( _, space ) {
  8261. var localCache,
  8262. isCache = is[ space.cache ];
  8263. if (isCache) {
  8264. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  8265. each( space.props, function( _, prop ) {
  8266. if ( isCache[ prop.idx ] != null ) {
  8267. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  8268. return same;
  8269. }
  8270. });
  8271. }
  8272. return same;
  8273. });
  8274. return same;
  8275. },
  8276. _space: function() {
  8277. var used = [],
  8278. inst = this;
  8279. each( spaces, function( spaceName, space ) {
  8280. if ( inst[ space.cache ] ) {
  8281. used.push( spaceName );
  8282. }
  8283. });
  8284. return used.pop();
  8285. },
  8286. transition: function( other, distance ) {
  8287. var end = color( other ),
  8288. spaceName = end._space(),
  8289. space = spaces[ spaceName ],
  8290. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  8291. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  8292. result = start.slice();
  8293. end = end[ space.cache ];
  8294. each( space.props, function( key, prop ) {
  8295. var index = prop.idx,
  8296. startValue = start[ index ],
  8297. endValue = end[ index ],
  8298. type = propTypes[ prop.type ] || {};
  8299. // if null, don't override start value
  8300. if ( endValue === null ) {
  8301. return;
  8302. }
  8303. // if null - use end
  8304. if ( startValue === null ) {
  8305. result[ index ] = endValue;
  8306. } else {
  8307. if ( type.mod ) {
  8308. if ( endValue - startValue > type.mod / 2 ) {
  8309. startValue += type.mod;
  8310. } else if ( startValue - endValue > type.mod / 2 ) {
  8311. startValue -= type.mod;
  8312. }
  8313. }
  8314. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  8315. }
  8316. });
  8317. return this[ spaceName ]( result );
  8318. },
  8319. blend: function( opaque ) {
  8320. // if we are already opaque - return ourself
  8321. if ( this._rgba[ 3 ] === 1 ) {
  8322. return this;
  8323. }
  8324. var rgb = this._rgba.slice(),
  8325. a = rgb.pop(),
  8326. blend = color( opaque )._rgba;
  8327. return color( jQuery.map( rgb, function( v, i ) {
  8328. return ( 1 - a ) * blend[ i ] + a * v;
  8329. }));
  8330. },
  8331. toRgbaString: function() {
  8332. var prefix = "rgba(",
  8333. rgba = jQuery.map( this._rgba, function( v, i ) {
  8334. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  8335. });
  8336. if ( rgba[ 3 ] === 1 ) {
  8337. rgba.pop();
  8338. prefix = "rgb(";
  8339. }
  8340. return prefix + rgba.join() + ")";
  8341. },
  8342. toHslaString: function() {
  8343. var prefix = "hsla(",
  8344. hsla = jQuery.map( this.hsla(), function( v, i ) {
  8345. if ( v == null ) {
  8346. v = i > 2 ? 1 : 0;
  8347. }
  8348. // catch 1 and 2
  8349. if ( i && i < 3 ) {
  8350. v = Math.round( v * 100 ) + "%";
  8351. }
  8352. return v;
  8353. });
  8354. if ( hsla[ 3 ] === 1 ) {
  8355. hsla.pop();
  8356. prefix = "hsl(";
  8357. }
  8358. return prefix + hsla.join() + ")";
  8359. },
  8360. toHexString: function( includeAlpha ) {
  8361. var rgba = this._rgba.slice(),
  8362. alpha = rgba.pop();
  8363. if ( includeAlpha ) {
  8364. rgba.push( ~~( alpha * 255 ) );
  8365. }
  8366. return "#" + jQuery.map( rgba, function( v ) {
  8367. // default to 0 when nulls exist
  8368. v = ( v || 0 ).toString( 16 );
  8369. return v.length === 1 ? "0" + v : v;
  8370. }).join("");
  8371. },
  8372. toString: function() {
  8373. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  8374. }
  8375. });
  8376. color.fn.parse.prototype = color.fn;
  8377. // hsla conversions adapted from:
  8378. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  8379. function hue2rgb( p, q, h ) {
  8380. h = ( h + 1 ) % 1;
  8381. if ( h * 6 < 1 ) {
  8382. return p + ( q - p ) * h * 6;
  8383. }
  8384. if ( h * 2 < 1) {
  8385. return q;
  8386. }
  8387. if ( h * 3 < 2 ) {
  8388. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  8389. }
  8390. return p;
  8391. }
  8392. spaces.hsla.to = function( rgba ) {
  8393. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  8394. return [ null, null, null, rgba[ 3 ] ];
  8395. }
  8396. var r = rgba[ 0 ] / 255,
  8397. g = rgba[ 1 ] / 255,
  8398. b = rgba[ 2 ] / 255,
  8399. a = rgba[ 3 ],
  8400. max = Math.max( r, g, b ),
  8401. min = Math.min( r, g, b ),
  8402. diff = max - min,
  8403. add = max + min,
  8404. l = add * 0.5,
  8405. h, s;
  8406. if ( min === max ) {
  8407. h = 0;
  8408. } else if ( r === max ) {
  8409. h = ( 60 * ( g - b ) / diff ) + 360;
  8410. } else if ( g === max ) {
  8411. h = ( 60 * ( b - r ) / diff ) + 120;
  8412. } else {
  8413. h = ( 60 * ( r - g ) / diff ) + 240;
  8414. }
  8415. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  8416. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  8417. if ( diff === 0 ) {
  8418. s = 0;
  8419. } else if ( l <= 0.5 ) {
  8420. s = diff / add;
  8421. } else {
  8422. s = diff / ( 2 - add );
  8423. }
  8424. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  8425. };
  8426. spaces.hsla.from = function( hsla ) {
  8427. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  8428. return [ null, null, null, hsla[ 3 ] ];
  8429. }
  8430. var h = hsla[ 0 ] / 360,
  8431. s = hsla[ 1 ],
  8432. l = hsla[ 2 ],
  8433. a = hsla[ 3 ],
  8434. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  8435. p = 2 * l - q;
  8436. return [
  8437. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  8438. Math.round( hue2rgb( p, q, h ) * 255 ),
  8439. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  8440. a
  8441. ];
  8442. };
  8443. each( spaces, function( spaceName, space ) {
  8444. var props = space.props,
  8445. cache = space.cache,
  8446. to = space.to,
  8447. from = space.from;
  8448. // makes rgba() and hsla()
  8449. color.fn[ spaceName ] = function( value ) {
  8450. // generate a cache for this space if it doesn't exist
  8451. if ( to && !this[ cache ] ) {
  8452. this[ cache ] = to( this._rgba );
  8453. }
  8454. if ( value === undefined ) {
  8455. return this[ cache ].slice();
  8456. }
  8457. var ret,
  8458. type = jQuery.type( value ),
  8459. arr = ( type === "array" || type === "object" ) ? value : arguments,
  8460. local = this[ cache ].slice();
  8461. each( props, function( key, prop ) {
  8462. var val = arr[ type === "object" ? key : prop.idx ];
  8463. if ( val == null ) {
  8464. val = local[ prop.idx ];
  8465. }
  8466. local[ prop.idx ] = clamp( val, prop );
  8467. });
  8468. if ( from ) {
  8469. ret = color( from( local ) );
  8470. ret[ cache ] = local;
  8471. return ret;
  8472. } else {
  8473. return color( local );
  8474. }
  8475. };
  8476. // makes red() green() blue() alpha() hue() saturation() lightness()
  8477. each( props, function( key, prop ) {
  8478. // alpha is included in more than one space
  8479. if ( color.fn[ key ] ) {
  8480. return;
  8481. }
  8482. color.fn[ key ] = function( value ) {
  8483. var vtype = jQuery.type( value ),
  8484. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  8485. local = this[ fn ](),
  8486. cur = local[ prop.idx ],
  8487. match;
  8488. if ( vtype === "undefined" ) {
  8489. return cur;
  8490. }
  8491. if ( vtype === "function" ) {
  8492. value = value.call( this, cur );
  8493. vtype = jQuery.type( value );
  8494. }
  8495. if ( value == null && prop.empty ) {
  8496. return this;
  8497. }
  8498. if ( vtype === "string" ) {
  8499. match = rplusequals.exec( value );
  8500. if ( match ) {
  8501. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  8502. }
  8503. }
  8504. local[ prop.idx ] = value;
  8505. return this[ fn ]( local );
  8506. };
  8507. });
  8508. });
  8509. // add cssHook and .fx.step function for each named hook.
  8510. // accept a space separated string of properties
  8511. color.hook = function( hook ) {
  8512. var hooks = hook.split( " " );
  8513. each( hooks, function( i, hook ) {
  8514. jQuery.cssHooks[ hook ] = {
  8515. set: function( elem, value ) {
  8516. var parsed, curElem,
  8517. backgroundColor = "";
  8518. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  8519. value = color( parsed || value );
  8520. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  8521. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  8522. while (
  8523. (backgroundColor === "" || backgroundColor === "transparent") &&
  8524. curElem && curElem.style
  8525. ) {
  8526. try {
  8527. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  8528. curElem = curElem.parentNode;
  8529. } catch ( e ) {
  8530. }
  8531. }
  8532. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  8533. backgroundColor :
  8534. "_default" );
  8535. }
  8536. value = value.toRgbaString();
  8537. }
  8538. try {
  8539. elem.style[ hook ] = value;
  8540. } catch( e ) {
  8541. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  8542. }
  8543. }
  8544. };
  8545. jQuery.fx.step[ hook ] = function( fx ) {
  8546. if ( !fx.colorInit ) {
  8547. fx.start = color( fx.elem, hook );
  8548. fx.end = color( fx.end );
  8549. fx.colorInit = true;
  8550. }
  8551. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  8552. };
  8553. });
  8554. };
  8555. color.hook( stepHooks );
  8556. jQuery.cssHooks.borderColor = {
  8557. expand: function( value ) {
  8558. var expanded = {};
  8559. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  8560. expanded[ "border" + part + "Color" ] = value;
  8561. });
  8562. return expanded;
  8563. }
  8564. };
  8565. // Basic color names only.
  8566. // Usage of any of the other color names requires adding yourself or including
  8567. // jquery.color.svg-names.js.
  8568. colors = jQuery.Color.names = {
  8569. // 4.1. Basic color keywords
  8570. aqua: "#00ffff",
  8571. black: "#000000",
  8572. blue: "#0000ff",
  8573. fuchsia: "#ff00ff",
  8574. gray: "#808080",
  8575. green: "#008000",
  8576. lime: "#00ff00",
  8577. maroon: "#800000",
  8578. navy: "#000080",
  8579. olive: "#808000",
  8580. purple: "#800080",
  8581. red: "#ff0000",
  8582. silver: "#c0c0c0",
  8583. teal: "#008080",
  8584. white: "#ffffff",
  8585. yellow: "#ffff00",
  8586. // 4.2.3. "transparent" color keyword
  8587. transparent: [ null, null, null, 0 ],
  8588. _default: "#ffffff"
  8589. };
  8590. })( jQuery );
  8591. /******************************************************************************/
  8592. /****************************** CLASS ANIMATIONS ******************************/
  8593. /******************************************************************************/
  8594. (function() {
  8595. var classAnimationActions = [ "add", "remove", "toggle" ],
  8596. shorthandStyles = {
  8597. border: 1,
  8598. borderBottom: 1,
  8599. borderColor: 1,
  8600. borderLeft: 1,
  8601. borderRight: 1,
  8602. borderTop: 1,
  8603. borderWidth: 1,
  8604. margin: 1,
  8605. padding: 1
  8606. };
  8607. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  8608. $.fx.step[ prop ] = function( fx ) {
  8609. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  8610. jQuery.style( fx.elem, prop, fx.end );
  8611. fx.setAttr = true;
  8612. }
  8613. };
  8614. });
  8615. function getElementStyles( elem ) {
  8616. var key, len,
  8617. style = elem.ownerDocument.defaultView ?
  8618. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  8619. elem.currentStyle,
  8620. styles = {};
  8621. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  8622. len = style.length;
  8623. while ( len-- ) {
  8624. key = style[ len ];
  8625. if ( typeof style[ key ] === "string" ) {
  8626. styles[ $.camelCase( key ) ] = style[ key ];
  8627. }
  8628. }
  8629. // support: Opera, IE <9
  8630. } else {
  8631. for ( key in style ) {
  8632. if ( typeof style[ key ] === "string" ) {
  8633. styles[ key ] = style[ key ];
  8634. }
  8635. }
  8636. }
  8637. return styles;
  8638. }
  8639. function styleDifference( oldStyle, newStyle ) {
  8640. var diff = {},
  8641. name, value;
  8642. for ( name in newStyle ) {
  8643. value = newStyle[ name ];
  8644. if ( oldStyle[ name ] !== value ) {
  8645. if ( !shorthandStyles[ name ] ) {
  8646. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  8647. diff[ name ] = value;
  8648. }
  8649. }
  8650. }
  8651. }
  8652. return diff;
  8653. }
  8654. // support: jQuery <1.8
  8655. if ( !$.fn.addBack ) {
  8656. $.fn.addBack = function( selector ) {
  8657. return this.add( selector == null ?
  8658. this.prevObject : this.prevObject.filter( selector )
  8659. );
  8660. };
  8661. }
  8662. $.effects.animateClass = function( value, duration, easing, callback ) {
  8663. var o = $.speed( duration, easing, callback );
  8664. return this.queue( function() {
  8665. var animated = $( this ),
  8666. baseClass = animated.attr( "class" ) || "",
  8667. applyClassChange,
  8668. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  8669. // map the animated objects to store the original styles.
  8670. allAnimations = allAnimations.map(function() {
  8671. var el = $( this );
  8672. return {
  8673. el: el,
  8674. start: getElementStyles( this )
  8675. };
  8676. });
  8677. // apply class change
  8678. applyClassChange = function() {
  8679. $.each( classAnimationActions, function(i, action) {
  8680. if ( value[ action ] ) {
  8681. animated[ action + "Class" ]( value[ action ] );
  8682. }
  8683. });
  8684. };
  8685. applyClassChange();
  8686. // map all animated objects again - calculate new styles and diff
  8687. allAnimations = allAnimations.map(function() {
  8688. this.end = getElementStyles( this.el[ 0 ] );
  8689. this.diff = styleDifference( this.start, this.end );
  8690. return this;
  8691. });
  8692. // apply original class
  8693. animated.attr( "class", baseClass );
  8694. // map all animated objects again - this time collecting a promise
  8695. allAnimations = allAnimations.map(function() {
  8696. var styleInfo = this,
  8697. dfd = $.Deferred(),
  8698. opts = $.extend({}, o, {
  8699. queue: false,
  8700. complete: function() {
  8701. dfd.resolve( styleInfo );
  8702. }
  8703. });
  8704. this.el.animate( this.diff, opts );
  8705. return dfd.promise();
  8706. });
  8707. // once all animations have completed:
  8708. $.when.apply( $, allAnimations.get() ).done(function() {
  8709. // set the final class
  8710. applyClassChange();
  8711. // for each animated element,
  8712. // clear all css properties that were animated
  8713. $.each( arguments, function() {
  8714. var el = this.el;
  8715. $.each( this.diff, function(key) {
  8716. el.css( key, "" );
  8717. });
  8718. });
  8719. // this is guarnteed to be there if you use jQuery.speed()
  8720. // it also handles dequeuing the next anim...
  8721. o.complete.call( animated[ 0 ] );
  8722. });
  8723. });
  8724. };
  8725. $.fn.extend({
  8726. addClass: (function( orig ) {
  8727. return function( classNames, speed, easing, callback ) {
  8728. return speed ?
  8729. $.effects.animateClass.call( this,
  8730. { add: classNames }, speed, easing, callback ) :
  8731. orig.apply( this, arguments );
  8732. };
  8733. })( $.fn.addClass ),
  8734. removeClass: (function( orig ) {
  8735. return function( classNames, speed, easing, callback ) {
  8736. return arguments.length > 1 ?
  8737. $.effects.animateClass.call( this,
  8738. { remove: classNames }, speed, easing, callback ) :
  8739. orig.apply( this, arguments );
  8740. };
  8741. })( $.fn.removeClass ),
  8742. toggleClass: (function( orig ) {
  8743. return function( classNames, force, speed, easing, callback ) {
  8744. if ( typeof force === "boolean" || force === undefined ) {
  8745. if ( !speed ) {
  8746. // without speed parameter
  8747. return orig.apply( this, arguments );
  8748. } else {
  8749. return $.effects.animateClass.call( this,
  8750. (force ? { add: classNames } : { remove: classNames }),
  8751. speed, easing, callback );
  8752. }
  8753. } else {
  8754. // without force parameter
  8755. return $.effects.animateClass.call( this,
  8756. { toggle: classNames }, force, speed, easing );
  8757. }
  8758. };
  8759. })( $.fn.toggleClass ),
  8760. switchClass: function( remove, add, speed, easing, callback) {
  8761. return $.effects.animateClass.call( this, {
  8762. add: add,
  8763. remove: remove
  8764. }, speed, easing, callback );
  8765. }
  8766. });
  8767. })();
  8768. /******************************************************************************/
  8769. /*********************************** EFFECTS **********************************/
  8770. /******************************************************************************/
  8771. (function() {
  8772. $.extend( $.effects, {
  8773. version: "1.11.1",
  8774. // Saves a set of properties in a data storage
  8775. save: function( element, set ) {
  8776. for ( var i = 0; i < set.length; i++ ) {
  8777. if ( set[ i ] !== null ) {
  8778. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  8779. }
  8780. }
  8781. },
  8782. // Restores a set of previously saved properties from a data storage
  8783. restore: function( element, set ) {
  8784. var val, i;
  8785. for ( i = 0; i < set.length; i++ ) {
  8786. if ( set[ i ] !== null ) {
  8787. val = element.data( dataSpace + set[ i ] );
  8788. // support: jQuery 1.6.2
  8789. // http://bugs.jquery.com/ticket/9917
  8790. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  8791. // We can't differentiate between "" and 0 here, so we just assume
  8792. // empty string since it's likely to be a more common value...
  8793. if ( val === undefined ) {
  8794. val = "";
  8795. }
  8796. element.css( set[ i ], val );
  8797. }
  8798. }
  8799. },
  8800. setMode: function( el, mode ) {
  8801. if (mode === "toggle") {
  8802. mode = el.is( ":hidden" ) ? "show" : "hide";
  8803. }
  8804. return mode;
  8805. },
  8806. // Translates a [top,left] array into a baseline value
  8807. // this should be a little more flexible in the future to handle a string & hash
  8808. getBaseline: function( origin, original ) {
  8809. var y, x;
  8810. switch ( origin[ 0 ] ) {
  8811. case "top": y = 0; break;
  8812. case "middle": y = 0.5; break;
  8813. case "bottom": y = 1; break;
  8814. default: y = origin[ 0 ] / original.height;
  8815. }
  8816. switch ( origin[ 1 ] ) {
  8817. case "left": x = 0; break;
  8818. case "center": x = 0.5; break;
  8819. case "right": x = 1; break;
  8820. default: x = origin[ 1 ] / original.width;
  8821. }
  8822. return {
  8823. x: x,
  8824. y: y
  8825. };
  8826. },
  8827. // Wraps the element around a wrapper that copies position properties
  8828. createWrapper: function( element ) {
  8829. // if the element is already wrapped, return it
  8830. if ( element.parent().is( ".ui-effects-wrapper" )) {
  8831. return element.parent();
  8832. }
  8833. // wrap the element
  8834. var props = {
  8835. width: element.outerWidth(true),
  8836. height: element.outerHeight(true),
  8837. "float": element.css( "float" )
  8838. },
  8839. wrapper = $( "<div></div>" )
  8840. .addClass( "ui-effects-wrapper" )
  8841. .css({
  8842. fontSize: "100%",
  8843. background: "transparent",
  8844. border: "none",
  8845. margin: 0,
  8846. padding: 0
  8847. }),
  8848. // Store the size in case width/height are defined in % - Fixes #5245
  8849. size = {
  8850. width: element.width(),
  8851. height: element.height()
  8852. },
  8853. active = document.activeElement;
  8854. // support: Firefox
  8855. // Firefox incorrectly exposes anonymous content
  8856. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  8857. try {
  8858. active.id;
  8859. } catch( e ) {
  8860. active = document.body;
  8861. }
  8862. element.wrap( wrapper );
  8863. // Fixes #7595 - Elements lose focus when wrapped.
  8864. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  8865. $( active ).focus();
  8866. }
  8867. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  8868. // transfer positioning properties to the wrapper
  8869. if ( element.css( "position" ) === "static" ) {
  8870. wrapper.css({ position: "relative" });
  8871. element.css({ position: "relative" });
  8872. } else {
  8873. $.extend( props, {
  8874. position: element.css( "position" ),
  8875. zIndex: element.css( "z-index" )
  8876. });
  8877. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  8878. props[ pos ] = element.css( pos );
  8879. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  8880. props[ pos ] = "auto";
  8881. }
  8882. });
  8883. element.css({
  8884. position: "relative",
  8885. top: 0,
  8886. left: 0,
  8887. right: "auto",
  8888. bottom: "auto"
  8889. });
  8890. }
  8891. element.css(size);
  8892. return wrapper.css( props ).show();
  8893. },
  8894. removeWrapper: function( element ) {
  8895. var active = document.activeElement;
  8896. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  8897. element.parent().replaceWith( element );
  8898. // Fixes #7595 - Elements lose focus when wrapped.
  8899. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  8900. $( active ).focus();
  8901. }
  8902. }
  8903. return element;
  8904. },
  8905. setTransition: function( element, list, factor, value ) {
  8906. value = value || {};
  8907. $.each( list, function( i, x ) {
  8908. var unit = element.cssUnit( x );
  8909. if ( unit[ 0 ] > 0 ) {
  8910. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  8911. }
  8912. });
  8913. return value;
  8914. }
  8915. });
  8916. // return an effect options object for the given parameters:
  8917. function _normalizeArguments( effect, options, speed, callback ) {
  8918. // allow passing all options as the first parameter
  8919. if ( $.isPlainObject( effect ) ) {
  8920. options = effect;
  8921. effect = effect.effect;
  8922. }
  8923. // convert to an object
  8924. effect = { effect: effect };
  8925. // catch (effect, null, ...)
  8926. if ( options == null ) {
  8927. options = {};
  8928. }
  8929. // catch (effect, callback)
  8930. if ( $.isFunction( options ) ) {
  8931. callback = options;
  8932. speed = null;
  8933. options = {};
  8934. }
  8935. // catch (effect, speed, ?)
  8936. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  8937. callback = speed;
  8938. speed = options;
  8939. options = {};
  8940. }
  8941. // catch (effect, options, callback)
  8942. if ( $.isFunction( speed ) ) {
  8943. callback = speed;
  8944. speed = null;
  8945. }
  8946. // add options to effect
  8947. if ( options ) {
  8948. $.extend( effect, options );
  8949. }
  8950. speed = speed || options.duration;
  8951. effect.duration = $.fx.off ? 0 :
  8952. typeof speed === "number" ? speed :
  8953. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  8954. $.fx.speeds._default;
  8955. effect.complete = callback || options.complete;
  8956. return effect;
  8957. }
  8958. function standardAnimationOption( option ) {
  8959. // Valid standard speeds (nothing, number, named speed)
  8960. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  8961. return true;
  8962. }
  8963. // Invalid strings - treat as "normal" speed
  8964. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  8965. return true;
  8966. }
  8967. // Complete callback
  8968. if ( $.isFunction( option ) ) {
  8969. return true;
  8970. }
  8971. // Options hash (but not naming an effect)
  8972. if ( typeof option === "object" && !option.effect ) {
  8973. return true;
  8974. }
  8975. // Didn't match any standard API
  8976. return false;
  8977. }
  8978. $.fn.extend({
  8979. effect: function( /* effect, options, speed, callback */ ) {
  8980. var args = _normalizeArguments.apply( this, arguments ),
  8981. mode = args.mode,
  8982. queue = args.queue,
  8983. effectMethod = $.effects.effect[ args.effect ];
  8984. if ( $.fx.off || !effectMethod ) {
  8985. // delegate to the original method (e.g., .show()) if possible
  8986. if ( mode ) {
  8987. return this[ mode ]( args.duration, args.complete );
  8988. } else {
  8989. return this.each( function() {
  8990. if ( args.complete ) {
  8991. args.complete.call( this );
  8992. }
  8993. });
  8994. }
  8995. }
  8996. function run( next ) {
  8997. var elem = $( this ),
  8998. complete = args.complete,
  8999. mode = args.mode;
  9000. function done() {
  9001. if ( $.isFunction( complete ) ) {
  9002. complete.call( elem[0] );
  9003. }
  9004. if ( $.isFunction( next ) ) {
  9005. next();
  9006. }
  9007. }
  9008. // If the element already has the correct final state, delegate to
  9009. // the core methods so the internal tracking of "olddisplay" works.
  9010. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  9011. elem[ mode ]();
  9012. done();
  9013. } else {
  9014. effectMethod.call( elem[0], args, done );
  9015. }
  9016. }
  9017. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  9018. },
  9019. show: (function( orig ) {
  9020. return function( option ) {
  9021. if ( standardAnimationOption( option ) ) {
  9022. return orig.apply( this, arguments );
  9023. } else {
  9024. var args = _normalizeArguments.apply( this, arguments );
  9025. args.mode = "show";
  9026. return this.effect.call( this, args );
  9027. }
  9028. };
  9029. })( $.fn.show ),
  9030. hide: (function( orig ) {
  9031. return function( option ) {
  9032. if ( standardAnimationOption( option ) ) {
  9033. return orig.apply( this, arguments );
  9034. } else {
  9035. var args = _normalizeArguments.apply( this, arguments );
  9036. args.mode = "hide";
  9037. return this.effect.call( this, args );
  9038. }
  9039. };
  9040. })( $.fn.hide ),
  9041. toggle: (function( orig ) {
  9042. return function( option ) {
  9043. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  9044. return orig.apply( this, arguments );
  9045. } else {
  9046. var args = _normalizeArguments.apply( this, arguments );
  9047. args.mode = "toggle";
  9048. return this.effect.call( this, args );
  9049. }
  9050. };
  9051. })( $.fn.toggle ),
  9052. // helper functions
  9053. cssUnit: function(key) {
  9054. var style = this.css( key ),
  9055. val = [];
  9056. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  9057. if ( style.indexOf( unit ) > 0 ) {
  9058. val = [ parseFloat( style ), unit ];
  9059. }
  9060. });
  9061. return val;
  9062. }
  9063. });
  9064. })();
  9065. /******************************************************************************/
  9066. /*********************************** EASING ***********************************/
  9067. /******************************************************************************/
  9068. (function() {
  9069. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  9070. var baseEasings = {};
  9071. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  9072. baseEasings[ name ] = function( p ) {
  9073. return Math.pow( p, i + 2 );
  9074. };
  9075. });
  9076. $.extend( baseEasings, {
  9077. Sine: function( p ) {
  9078. return 1 - Math.cos( p * Math.PI / 2 );
  9079. },
  9080. Circ: function( p ) {
  9081. return 1 - Math.sqrt( 1 - p * p );
  9082. },
  9083. Elastic: function( p ) {
  9084. return p === 0 || p === 1 ? p :
  9085. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  9086. },
  9087. Back: function( p ) {
  9088. return p * p * ( 3 * p - 2 );
  9089. },
  9090. Bounce: function( p ) {
  9091. var pow2,
  9092. bounce = 4;
  9093. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  9094. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  9095. }
  9096. });
  9097. $.each( baseEasings, function( name, easeIn ) {
  9098. $.easing[ "easeIn" + name ] = easeIn;
  9099. $.easing[ "easeOut" + name ] = function( p ) {
  9100. return 1 - easeIn( 1 - p );
  9101. };
  9102. $.easing[ "easeInOut" + name ] = function( p ) {
  9103. return p < 0.5 ?
  9104. easeIn( p * 2 ) / 2 :
  9105. 1 - easeIn( p * -2 + 2 ) / 2;
  9106. };
  9107. });
  9108. })();
  9109. var effect = $.effects;
  9110. /*!
  9111. * jQuery UI Effects Blind 1.11.1
  9112. * http://jqueryui.com
  9113. *
  9114. * Copyright 2014 jQuery Foundation and other contributors
  9115. * Released under the MIT license.
  9116. * http://jquery.org/license
  9117. *
  9118. * http://api.jqueryui.com/blind-effect/
  9119. */
  9120. var effectBlind = $.effects.effect.blind = function( o, done ) {
  9121. // Create element
  9122. var el = $( this ),
  9123. rvertical = /up|down|vertical/,
  9124. rpositivemotion = /up|left|vertical|horizontal/,
  9125. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9126. mode = $.effects.setMode( el, o.mode || "hide" ),
  9127. direction = o.direction || "up",
  9128. vertical = rvertical.test( direction ),
  9129. ref = vertical ? "height" : "width",
  9130. ref2 = vertical ? "top" : "left",
  9131. motion = rpositivemotion.test( direction ),
  9132. animation = {},
  9133. show = mode === "show",
  9134. wrapper, distance, margin;
  9135. // if already wrapped, the wrapper's properties are my property. #6245
  9136. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  9137. $.effects.save( el.parent(), props );
  9138. } else {
  9139. $.effects.save( el, props );
  9140. }
  9141. el.show();
  9142. wrapper = $.effects.createWrapper( el ).css({
  9143. overflow: "hidden"
  9144. });
  9145. distance = wrapper[ ref ]();
  9146. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  9147. animation[ ref ] = show ? distance : 0;
  9148. if ( !motion ) {
  9149. el
  9150. .css( vertical ? "bottom" : "right", 0 )
  9151. .css( vertical ? "top" : "left", "auto" )
  9152. .css({ position: "absolute" });
  9153. animation[ ref2 ] = show ? margin : distance + margin;
  9154. }
  9155. // start at 0 if we are showing
  9156. if ( show ) {
  9157. wrapper.css( ref, 0 );
  9158. if ( !motion ) {
  9159. wrapper.css( ref2, margin + distance );
  9160. }
  9161. }
  9162. // Animate
  9163. wrapper.animate( animation, {
  9164. duration: o.duration,
  9165. easing: o.easing,
  9166. queue: false,
  9167. complete: function() {
  9168. if ( mode === "hide" ) {
  9169. el.hide();
  9170. }
  9171. $.effects.restore( el, props );
  9172. $.effects.removeWrapper( el );
  9173. done();
  9174. }
  9175. });
  9176. };
  9177. /*!
  9178. * jQuery UI Effects Bounce 1.11.1
  9179. * http://jqueryui.com
  9180. *
  9181. * Copyright 2014 jQuery Foundation and other contributors
  9182. * Released under the MIT license.
  9183. * http://jquery.org/license
  9184. *
  9185. * http://api.jqueryui.com/bounce-effect/
  9186. */
  9187. var effectBounce = $.effects.effect.bounce = function( o, done ) {
  9188. var el = $( this ),
  9189. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9190. // defaults:
  9191. mode = $.effects.setMode( el, o.mode || "effect" ),
  9192. hide = mode === "hide",
  9193. show = mode === "show",
  9194. direction = o.direction || "up",
  9195. distance = o.distance,
  9196. times = o.times || 5,
  9197. // number of internal animations
  9198. anims = times * 2 + ( show || hide ? 1 : 0 ),
  9199. speed = o.duration / anims,
  9200. easing = o.easing,
  9201. // utility:
  9202. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9203. motion = ( direction === "up" || direction === "left" ),
  9204. i,
  9205. upAnim,
  9206. downAnim,
  9207. // we will need to re-assemble the queue to stack our animations in place
  9208. queue = el.queue(),
  9209. queuelen = queue.length;
  9210. // Avoid touching opacity to prevent clearType and PNG issues in IE
  9211. if ( show || hide ) {
  9212. props.push( "opacity" );
  9213. }
  9214. $.effects.save( el, props );
  9215. el.show();
  9216. $.effects.createWrapper( el ); // Create Wrapper
  9217. // default distance for the BIGGEST bounce is the outer Distance / 3
  9218. if ( !distance ) {
  9219. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  9220. }
  9221. if ( show ) {
  9222. downAnim = { opacity: 1 };
  9223. downAnim[ ref ] = 0;
  9224. // if we are showing, force opacity 0 and set the initial position
  9225. // then do the "first" animation
  9226. el.css( "opacity", 0 )
  9227. .css( ref, motion ? -distance * 2 : distance * 2 )
  9228. .animate( downAnim, speed, easing );
  9229. }
  9230. // start at the smallest distance if we are hiding
  9231. if ( hide ) {
  9232. distance = distance / Math.pow( 2, times - 1 );
  9233. }
  9234. downAnim = {};
  9235. downAnim[ ref ] = 0;
  9236. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  9237. for ( i = 0; i < times; i++ ) {
  9238. upAnim = {};
  9239. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9240. el.animate( upAnim, speed, easing )
  9241. .animate( downAnim, speed, easing );
  9242. distance = hide ? distance * 2 : distance / 2;
  9243. }
  9244. // Last Bounce when Hiding
  9245. if ( hide ) {
  9246. upAnim = { opacity: 0 };
  9247. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9248. el.animate( upAnim, speed, easing );
  9249. }
  9250. el.queue(function() {
  9251. if ( hide ) {
  9252. el.hide();
  9253. }
  9254. $.effects.restore( el, props );
  9255. $.effects.removeWrapper( el );
  9256. done();
  9257. });
  9258. // inject all the animations we just queued to be first in line (after "inprogress")
  9259. if ( queuelen > 1) {
  9260. queue.splice.apply( queue,
  9261. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9262. }
  9263. el.dequeue();
  9264. };
  9265. /*!
  9266. * jQuery UI Effects Clip 1.11.1
  9267. * http://jqueryui.com
  9268. *
  9269. * Copyright 2014 jQuery Foundation and other contributors
  9270. * Released under the MIT license.
  9271. * http://jquery.org/license
  9272. *
  9273. * http://api.jqueryui.com/clip-effect/
  9274. */
  9275. var effectClip = $.effects.effect.clip = function( o, done ) {
  9276. // Create element
  9277. var el = $( this ),
  9278. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9279. mode = $.effects.setMode( el, o.mode || "hide" ),
  9280. show = mode === "show",
  9281. direction = o.direction || "vertical",
  9282. vert = direction === "vertical",
  9283. size = vert ? "height" : "width",
  9284. position = vert ? "top" : "left",
  9285. animation = {},
  9286. wrapper, animate, distance;
  9287. // Save & Show
  9288. $.effects.save( el, props );
  9289. el.show();
  9290. // Create Wrapper
  9291. wrapper = $.effects.createWrapper( el ).css({
  9292. overflow: "hidden"
  9293. });
  9294. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  9295. distance = animate[ size ]();
  9296. // Shift
  9297. if ( show ) {
  9298. animate.css( size, 0 );
  9299. animate.css( position, distance / 2 );
  9300. }
  9301. // Create Animation Object:
  9302. animation[ size ] = show ? distance : 0;
  9303. animation[ position ] = show ? 0 : distance / 2;
  9304. // Animate
  9305. animate.animate( animation, {
  9306. queue: false,
  9307. duration: o.duration,
  9308. easing: o.easing,
  9309. complete: function() {
  9310. if ( !show ) {
  9311. el.hide();
  9312. }
  9313. $.effects.restore( el, props );
  9314. $.effects.removeWrapper( el );
  9315. done();
  9316. }
  9317. });
  9318. };
  9319. /*!
  9320. * jQuery UI Effects Drop 1.11.1
  9321. * http://jqueryui.com
  9322. *
  9323. * Copyright 2014 jQuery Foundation and other contributors
  9324. * Released under the MIT license.
  9325. * http://jquery.org/license
  9326. *
  9327. * http://api.jqueryui.com/drop-effect/
  9328. */
  9329. var effectDrop = $.effects.effect.drop = function( o, done ) {
  9330. var el = $( this ),
  9331. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  9332. mode = $.effects.setMode( el, o.mode || "hide" ),
  9333. show = mode === "show",
  9334. direction = o.direction || "left",
  9335. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9336. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  9337. animation = {
  9338. opacity: show ? 1 : 0
  9339. },
  9340. distance;
  9341. // Adjust
  9342. $.effects.save( el, props );
  9343. el.show();
  9344. $.effects.createWrapper( el );
  9345. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  9346. if ( show ) {
  9347. el
  9348. .css( "opacity", 0 )
  9349. .css( ref, motion === "pos" ? -distance : distance );
  9350. }
  9351. // Animation
  9352. animation[ ref ] = ( show ?
  9353. ( motion === "pos" ? "+=" : "-=" ) :
  9354. ( motion === "pos" ? "-=" : "+=" ) ) +
  9355. distance;
  9356. // Animate
  9357. el.animate( animation, {
  9358. queue: false,
  9359. duration: o.duration,
  9360. easing: o.easing,
  9361. complete: function() {
  9362. if ( mode === "hide" ) {
  9363. el.hide();
  9364. }
  9365. $.effects.restore( el, props );
  9366. $.effects.removeWrapper( el );
  9367. done();
  9368. }
  9369. });
  9370. };
  9371. /*!
  9372. * jQuery UI Effects Explode 1.11.1
  9373. * http://jqueryui.com
  9374. *
  9375. * Copyright 2014 jQuery Foundation and other contributors
  9376. * Released under the MIT license.
  9377. * http://jquery.org/license
  9378. *
  9379. * http://api.jqueryui.com/explode-effect/
  9380. */
  9381. var effectExplode = $.effects.effect.explode = function( o, done ) {
  9382. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  9383. cells = rows,
  9384. el = $( this ),
  9385. mode = $.effects.setMode( el, o.mode || "hide" ),
  9386. show = mode === "show",
  9387. // show and then visibility:hidden the element before calculating offset
  9388. offset = el.show().css( "visibility", "hidden" ).offset(),
  9389. // width and height of a piece
  9390. width = Math.ceil( el.outerWidth() / cells ),
  9391. height = Math.ceil( el.outerHeight() / rows ),
  9392. pieces = [],
  9393. // loop
  9394. i, j, left, top, mx, my;
  9395. // children animate complete:
  9396. function childComplete() {
  9397. pieces.push( this );
  9398. if ( pieces.length === rows * cells ) {
  9399. animComplete();
  9400. }
  9401. }
  9402. // clone the element for each row and cell.
  9403. for ( i = 0; i < rows ; i++ ) { // ===>
  9404. top = offset.top + i * height;
  9405. my = i - ( rows - 1 ) / 2 ;
  9406. for ( j = 0; j < cells ; j++ ) { // |||
  9407. left = offset.left + j * width;
  9408. mx = j - ( cells - 1 ) / 2 ;
  9409. // Create a clone of the now hidden main element that will be absolute positioned
  9410. // within a wrapper div off the -left and -top equal to size of our pieces
  9411. el
  9412. .clone()
  9413. .appendTo( "body" )
  9414. .wrap( "<div></div>" )
  9415. .css({
  9416. position: "absolute",
  9417. visibility: "visible",
  9418. left: -j * width,
  9419. top: -i * height
  9420. })
  9421. // select the wrapper - make it overflow: hidden and absolute positioned based on
  9422. // where the original was located +left and +top equal to the size of pieces
  9423. .parent()
  9424. .addClass( "ui-effects-explode" )
  9425. .css({
  9426. position: "absolute",
  9427. overflow: "hidden",
  9428. width: width,
  9429. height: height,
  9430. left: left + ( show ? mx * width : 0 ),
  9431. top: top + ( show ? my * height : 0 ),
  9432. opacity: show ? 0 : 1
  9433. }).animate({
  9434. left: left + ( show ? 0 : mx * width ),
  9435. top: top + ( show ? 0 : my * height ),
  9436. opacity: show ? 1 : 0
  9437. }, o.duration || 500, o.easing, childComplete );
  9438. }
  9439. }
  9440. function animComplete() {
  9441. el.css({
  9442. visibility: "visible"
  9443. });
  9444. $( pieces ).remove();
  9445. if ( !show ) {
  9446. el.hide();
  9447. }
  9448. done();
  9449. }
  9450. };
  9451. /*!
  9452. * jQuery UI Effects Fade 1.11.1
  9453. * http://jqueryui.com
  9454. *
  9455. * Copyright 2014 jQuery Foundation and other contributors
  9456. * Released under the MIT license.
  9457. * http://jquery.org/license
  9458. *
  9459. * http://api.jqueryui.com/fade-effect/
  9460. */
  9461. var effectFade = $.effects.effect.fade = function( o, done ) {
  9462. var el = $( this ),
  9463. mode = $.effects.setMode( el, o.mode || "toggle" );
  9464. el.animate({
  9465. opacity: mode
  9466. }, {
  9467. queue: false,
  9468. duration: o.duration,
  9469. easing: o.easing,
  9470. complete: done
  9471. });
  9472. };
  9473. /*!
  9474. * jQuery UI Effects Fold 1.11.1
  9475. * http://jqueryui.com
  9476. *
  9477. * Copyright 2014 jQuery Foundation and other contributors
  9478. * Released under the MIT license.
  9479. * http://jquery.org/license
  9480. *
  9481. * http://api.jqueryui.com/fold-effect/
  9482. */
  9483. var effectFold = $.effects.effect.fold = function( o, done ) {
  9484. // Create element
  9485. var el = $( this ),
  9486. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9487. mode = $.effects.setMode( el, o.mode || "hide" ),
  9488. show = mode === "show",
  9489. hide = mode === "hide",
  9490. size = o.size || 15,
  9491. percent = /([0-9]+)%/.exec( size ),
  9492. horizFirst = !!o.horizFirst,
  9493. widthFirst = show !== horizFirst,
  9494. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  9495. duration = o.duration / 2,
  9496. wrapper, distance,
  9497. animation1 = {},
  9498. animation2 = {};
  9499. $.effects.save( el, props );
  9500. el.show();
  9501. // Create Wrapper
  9502. wrapper = $.effects.createWrapper( el ).css({
  9503. overflow: "hidden"
  9504. });
  9505. distance = widthFirst ?
  9506. [ wrapper.width(), wrapper.height() ] :
  9507. [ wrapper.height(), wrapper.width() ];
  9508. if ( percent ) {
  9509. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  9510. }
  9511. if ( show ) {
  9512. wrapper.css( horizFirst ? {
  9513. height: 0,
  9514. width: size
  9515. } : {
  9516. height: size,
  9517. width: 0
  9518. });
  9519. }
  9520. // Animation
  9521. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  9522. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  9523. // Animate
  9524. wrapper
  9525. .animate( animation1, duration, o.easing )
  9526. .animate( animation2, duration, o.easing, function() {
  9527. if ( hide ) {
  9528. el.hide();
  9529. }
  9530. $.effects.restore( el, props );
  9531. $.effects.removeWrapper( el );
  9532. done();
  9533. });
  9534. };
  9535. /*!
  9536. * jQuery UI Effects Highlight 1.11.1
  9537. * http://jqueryui.com
  9538. *
  9539. * Copyright 2014 jQuery Foundation and other contributors
  9540. * Released under the MIT license.
  9541. * http://jquery.org/license
  9542. *
  9543. * http://api.jqueryui.com/highlight-effect/
  9544. */
  9545. var effectHighlight = $.effects.effect.highlight = function( o, done ) {
  9546. var elem = $( this ),
  9547. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  9548. mode = $.effects.setMode( elem, o.mode || "show" ),
  9549. animation = {
  9550. backgroundColor: elem.css( "backgroundColor" )
  9551. };
  9552. if (mode === "hide") {
  9553. animation.opacity = 0;
  9554. }
  9555. $.effects.save( elem, props );
  9556. elem
  9557. .show()
  9558. .css({
  9559. backgroundImage: "none",
  9560. backgroundColor: o.color || "#ffff99"
  9561. })
  9562. .animate( animation, {
  9563. queue: false,
  9564. duration: o.duration,
  9565. easing: o.easing,
  9566. complete: function() {
  9567. if ( mode === "hide" ) {
  9568. elem.hide();
  9569. }
  9570. $.effects.restore( elem, props );
  9571. done();
  9572. }
  9573. });
  9574. };
  9575. /*!
  9576. * jQuery UI Effects Size 1.11.1
  9577. * http://jqueryui.com
  9578. *
  9579. * Copyright 2014 jQuery Foundation and other contributors
  9580. * Released under the MIT license.
  9581. * http://jquery.org/license
  9582. *
  9583. * http://api.jqueryui.com/size-effect/
  9584. */
  9585. var effectSize = $.effects.effect.size = function( o, done ) {
  9586. // Create element
  9587. var original, baseline, factor,
  9588. el = $( this ),
  9589. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  9590. // Always restore
  9591. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  9592. // Copy for children
  9593. props2 = [ "width", "height", "overflow" ],
  9594. cProps = [ "fontSize" ],
  9595. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  9596. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  9597. // Set options
  9598. mode = $.effects.setMode( el, o.mode || "effect" ),
  9599. restore = o.restore || mode !== "effect",
  9600. scale = o.scale || "both",
  9601. origin = o.origin || [ "middle", "center" ],
  9602. position = el.css( "position" ),
  9603. props = restore ? props0 : props1,
  9604. zero = {
  9605. height: 0,
  9606. width: 0,
  9607. outerHeight: 0,
  9608. outerWidth: 0
  9609. };
  9610. if ( mode === "show" ) {
  9611. el.show();
  9612. }
  9613. original = {
  9614. height: el.height(),
  9615. width: el.width(),
  9616. outerHeight: el.outerHeight(),
  9617. outerWidth: el.outerWidth()
  9618. };
  9619. if ( o.mode === "toggle" && mode === "show" ) {
  9620. el.from = o.to || zero;
  9621. el.to = o.from || original;
  9622. } else {
  9623. el.from = o.from || ( mode === "show" ? zero : original );
  9624. el.to = o.to || ( mode === "hide" ? zero : original );
  9625. }
  9626. // Set scaling factor
  9627. factor = {
  9628. from: {
  9629. y: el.from.height / original.height,
  9630. x: el.from.width / original.width
  9631. },
  9632. to: {
  9633. y: el.to.height / original.height,
  9634. x: el.to.width / original.width
  9635. }
  9636. };
  9637. // Scale the css box
  9638. if ( scale === "box" || scale === "both" ) {
  9639. // Vertical props scaling
  9640. if ( factor.from.y !== factor.to.y ) {
  9641. props = props.concat( vProps );
  9642. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  9643. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  9644. }
  9645. // Horizontal props scaling
  9646. if ( factor.from.x !== factor.to.x ) {
  9647. props = props.concat( hProps );
  9648. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  9649. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  9650. }
  9651. }
  9652. // Scale the content
  9653. if ( scale === "content" || scale === "both" ) {
  9654. // Vertical props scaling
  9655. if ( factor.from.y !== factor.to.y ) {
  9656. props = props.concat( cProps ).concat( props2 );
  9657. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  9658. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  9659. }
  9660. }
  9661. $.effects.save( el, props );
  9662. el.show();
  9663. $.effects.createWrapper( el );
  9664. el.css( "overflow", "hidden" ).css( el.from );
  9665. // Adjust
  9666. if (origin) { // Calculate baseline shifts
  9667. baseline = $.effects.getBaseline( origin, original );
  9668. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  9669. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  9670. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  9671. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  9672. }
  9673. el.css( el.from ); // set top & left
  9674. // Animate
  9675. if ( scale === "content" || scale === "both" ) { // Scale the children
  9676. // Add margins/font-size
  9677. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  9678. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  9679. props2 = props0.concat(vProps).concat(hProps);
  9680. el.find( "*[width]" ).each( function() {
  9681. var child = $( this ),
  9682. c_original = {
  9683. height: child.height(),
  9684. width: child.width(),
  9685. outerHeight: child.outerHeight(),
  9686. outerWidth: child.outerWidth()
  9687. };
  9688. if (restore) {
  9689. $.effects.save(child, props2);
  9690. }
  9691. child.from = {
  9692. height: c_original.height * factor.from.y,
  9693. width: c_original.width * factor.from.x,
  9694. outerHeight: c_original.outerHeight * factor.from.y,
  9695. outerWidth: c_original.outerWidth * factor.from.x
  9696. };
  9697. child.to = {
  9698. height: c_original.height * factor.to.y,
  9699. width: c_original.width * factor.to.x,
  9700. outerHeight: c_original.height * factor.to.y,
  9701. outerWidth: c_original.width * factor.to.x
  9702. };
  9703. // Vertical props scaling
  9704. if ( factor.from.y !== factor.to.y ) {
  9705. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  9706. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  9707. }
  9708. // Horizontal props scaling
  9709. if ( factor.from.x !== factor.to.x ) {
  9710. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  9711. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  9712. }
  9713. // Animate children
  9714. child.css( child.from );
  9715. child.animate( child.to, o.duration, o.easing, function() {
  9716. // Restore children
  9717. if ( restore ) {
  9718. $.effects.restore( child, props2 );
  9719. }
  9720. });
  9721. });
  9722. }
  9723. // Animate
  9724. el.animate( el.to, {
  9725. queue: false,
  9726. duration: o.duration,
  9727. easing: o.easing,
  9728. complete: function() {
  9729. if ( el.to.opacity === 0 ) {
  9730. el.css( "opacity", el.from.opacity );
  9731. }
  9732. if ( mode === "hide" ) {
  9733. el.hide();
  9734. }
  9735. $.effects.restore( el, props );
  9736. if ( !restore ) {
  9737. // we need to calculate our new positioning based on the scaling
  9738. if ( position === "static" ) {
  9739. el.css({
  9740. position: "relative",
  9741. top: el.to.top,
  9742. left: el.to.left
  9743. });
  9744. } else {
  9745. $.each([ "top", "left" ], function( idx, pos ) {
  9746. el.css( pos, function( _, str ) {
  9747. var val = parseInt( str, 10 ),
  9748. toRef = idx ? el.to.left : el.to.top;
  9749. // if original was "auto", recalculate the new value from wrapper
  9750. if ( str === "auto" ) {
  9751. return toRef + "px";
  9752. }
  9753. return val + toRef + "px";
  9754. });
  9755. });
  9756. }
  9757. }
  9758. $.effects.removeWrapper( el );
  9759. done();
  9760. }
  9761. });
  9762. };
  9763. /*!
  9764. * jQuery UI Effects Scale 1.11.1
  9765. * http://jqueryui.com
  9766. *
  9767. * Copyright 2014 jQuery Foundation and other contributors
  9768. * Released under the MIT license.
  9769. * http://jquery.org/license
  9770. *
  9771. * http://api.jqueryui.com/scale-effect/
  9772. */
  9773. var effectScale = $.effects.effect.scale = function( o, done ) {
  9774. // Create element
  9775. var el = $( this ),
  9776. options = $.extend( true, {}, o ),
  9777. mode = $.effects.setMode( el, o.mode || "effect" ),
  9778. percent = parseInt( o.percent, 10 ) ||
  9779. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  9780. direction = o.direction || "both",
  9781. origin = o.origin,
  9782. original = {
  9783. height: el.height(),
  9784. width: el.width(),
  9785. outerHeight: el.outerHeight(),
  9786. outerWidth: el.outerWidth()
  9787. },
  9788. factor = {
  9789. y: direction !== "horizontal" ? (percent / 100) : 1,
  9790. x: direction !== "vertical" ? (percent / 100) : 1
  9791. };
  9792. // We are going to pass this effect to the size effect:
  9793. options.effect = "size";
  9794. options.queue = false;
  9795. options.complete = done;
  9796. // Set default origin and restore for show/hide
  9797. if ( mode !== "effect" ) {
  9798. options.origin = origin || [ "middle", "center" ];
  9799. options.restore = true;
  9800. }
  9801. options.from = o.from || ( mode === "show" ? {
  9802. height: 0,
  9803. width: 0,
  9804. outerHeight: 0,
  9805. outerWidth: 0
  9806. } : original );
  9807. options.to = {
  9808. height: original.height * factor.y,
  9809. width: original.width * factor.x,
  9810. outerHeight: original.outerHeight * factor.y,
  9811. outerWidth: original.outerWidth * factor.x
  9812. };
  9813. // Fade option to support puff
  9814. if ( options.fade ) {
  9815. if ( mode === "show" ) {
  9816. options.from.opacity = 0;
  9817. options.to.opacity = 1;
  9818. }
  9819. if ( mode === "hide" ) {
  9820. options.from.opacity = 1;
  9821. options.to.opacity = 0;
  9822. }
  9823. }
  9824. // Animate
  9825. el.effect( options );
  9826. };
  9827. /*!
  9828. * jQuery UI Effects Puff 1.11.1
  9829. * http://jqueryui.com
  9830. *
  9831. * Copyright 2014 jQuery Foundation and other contributors
  9832. * Released under the MIT license.
  9833. * http://jquery.org/license
  9834. *
  9835. * http://api.jqueryui.com/puff-effect/
  9836. */
  9837. var effectPuff = $.effects.effect.puff = function( o, done ) {
  9838. var elem = $( this ),
  9839. mode = $.effects.setMode( elem, o.mode || "hide" ),
  9840. hide = mode === "hide",
  9841. percent = parseInt( o.percent, 10 ) || 150,
  9842. factor = percent / 100,
  9843. original = {
  9844. height: elem.height(),
  9845. width: elem.width(),
  9846. outerHeight: elem.outerHeight(),
  9847. outerWidth: elem.outerWidth()
  9848. };
  9849. $.extend( o, {
  9850. effect: "scale",
  9851. queue: false,
  9852. fade: true,
  9853. mode: mode,
  9854. complete: done,
  9855. percent: hide ? percent : 100,
  9856. from: hide ?
  9857. original :
  9858. {
  9859. height: original.height * factor,
  9860. width: original.width * factor,
  9861. outerHeight: original.outerHeight * factor,
  9862. outerWidth: original.outerWidth * factor
  9863. }
  9864. });
  9865. elem.effect( o );
  9866. };
  9867. /*!
  9868. * jQuery UI Effects Pulsate 1.11.1
  9869. * http://jqueryui.com
  9870. *
  9871. * Copyright 2014 jQuery Foundation and other contributors
  9872. * Released under the MIT license.
  9873. * http://jquery.org/license
  9874. *
  9875. * http://api.jqueryui.com/pulsate-effect/
  9876. */
  9877. var effectPulsate = $.effects.effect.pulsate = function( o, done ) {
  9878. var elem = $( this ),
  9879. mode = $.effects.setMode( elem, o.mode || "show" ),
  9880. show = mode === "show",
  9881. hide = mode === "hide",
  9882. showhide = ( show || mode === "hide" ),
  9883. // showing or hiding leaves of the "last" animation
  9884. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  9885. duration = o.duration / anims,
  9886. animateTo = 0,
  9887. queue = elem.queue(),
  9888. queuelen = queue.length,
  9889. i;
  9890. if ( show || !elem.is(":visible")) {
  9891. elem.css( "opacity", 0 ).show();
  9892. animateTo = 1;
  9893. }
  9894. // anims - 1 opacity "toggles"
  9895. for ( i = 1; i < anims; i++ ) {
  9896. elem.animate({
  9897. opacity: animateTo
  9898. }, duration, o.easing );
  9899. animateTo = 1 - animateTo;
  9900. }
  9901. elem.animate({
  9902. opacity: animateTo
  9903. }, duration, o.easing);
  9904. elem.queue(function() {
  9905. if ( hide ) {
  9906. elem.hide();
  9907. }
  9908. done();
  9909. });
  9910. // We just queued up "anims" animations, we need to put them next in the queue
  9911. if ( queuelen > 1 ) {
  9912. queue.splice.apply( queue,
  9913. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9914. }
  9915. elem.dequeue();
  9916. };
  9917. /*!
  9918. * jQuery UI Effects Shake 1.11.1
  9919. * http://jqueryui.com
  9920. *
  9921. * Copyright 2014 jQuery Foundation and other contributors
  9922. * Released under the MIT license.
  9923. * http://jquery.org/license
  9924. *
  9925. * http://api.jqueryui.com/shake-effect/
  9926. */
  9927. var effectShake = $.effects.effect.shake = function( o, done ) {
  9928. var el = $( this ),
  9929. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9930. mode = $.effects.setMode( el, o.mode || "effect" ),
  9931. direction = o.direction || "left",
  9932. distance = o.distance || 20,
  9933. times = o.times || 3,
  9934. anims = times * 2 + 1,
  9935. speed = Math.round( o.duration / anims ),
  9936. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9937. positiveMotion = (direction === "up" || direction === "left"),
  9938. animation = {},
  9939. animation1 = {},
  9940. animation2 = {},
  9941. i,
  9942. // we will need to re-assemble the queue to stack our animations in place
  9943. queue = el.queue(),
  9944. queuelen = queue.length;
  9945. $.effects.save( el, props );
  9946. el.show();
  9947. $.effects.createWrapper( el );
  9948. // Animation
  9949. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  9950. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  9951. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  9952. // Animate
  9953. el.animate( animation, speed, o.easing );
  9954. // Shakes
  9955. for ( i = 1; i < times; i++ ) {
  9956. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  9957. }
  9958. el
  9959. .animate( animation1, speed, o.easing )
  9960. .animate( animation, speed / 2, o.easing )
  9961. .queue(function() {
  9962. if ( mode === "hide" ) {
  9963. el.hide();
  9964. }
  9965. $.effects.restore( el, props );
  9966. $.effects.removeWrapper( el );
  9967. done();
  9968. });
  9969. // inject all the animations we just queued to be first in line (after "inprogress")
  9970. if ( queuelen > 1) {
  9971. queue.splice.apply( queue,
  9972. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9973. }
  9974. el.dequeue();
  9975. };
  9976. /*!
  9977. * jQuery UI Effects Slide 1.11.1
  9978. * http://jqueryui.com
  9979. *
  9980. * Copyright 2014 jQuery Foundation and other contributors
  9981. * Released under the MIT license.
  9982. * http://jquery.org/license
  9983. *
  9984. * http://api.jqueryui.com/slide-effect/
  9985. */
  9986. var effectSlide = $.effects.effect.slide = function( o, done ) {
  9987. // Create element
  9988. var el = $( this ),
  9989. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  9990. mode = $.effects.setMode( el, o.mode || "show" ),
  9991. show = mode === "show",
  9992. direction = o.direction || "left",
  9993. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9994. positiveMotion = (direction === "up" || direction === "left"),
  9995. distance,
  9996. animation = {};
  9997. // Adjust
  9998. $.effects.save( el, props );
  9999. el.show();
  10000. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  10001. $.effects.createWrapper( el ).css({
  10002. overflow: "hidden"
  10003. });
  10004. if ( show ) {
  10005. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  10006. }
  10007. // Animation
  10008. animation[ ref ] = ( show ?
  10009. ( positiveMotion ? "+=" : "-=") :
  10010. ( positiveMotion ? "-=" : "+=")) +
  10011. distance;
  10012. // Animate
  10013. el.animate( animation, {
  10014. queue: false,
  10015. duration: o.duration,
  10016. easing: o.easing,
  10017. complete: function() {
  10018. if ( mode === "hide" ) {
  10019. el.hide();
  10020. }
  10021. $.effects.restore( el, props );
  10022. $.effects.removeWrapper( el );
  10023. done();
  10024. }
  10025. });
  10026. };
  10027. /*!
  10028. * jQuery UI Effects Transfer 1.11.1
  10029. * http://jqueryui.com
  10030. *
  10031. * Copyright 2014 jQuery Foundation and other contributors
  10032. * Released under the MIT license.
  10033. * http://jquery.org/license
  10034. *
  10035. * http://api.jqueryui.com/transfer-effect/
  10036. */
  10037. var effectTransfer = $.effects.effect.transfer = function( o, done ) {
  10038. var elem = $( this ),
  10039. target = $( o.to ),
  10040. targetFixed = target.css( "position" ) === "fixed",
  10041. body = $("body"),
  10042. fixTop = targetFixed ? body.scrollTop() : 0,
  10043. fixLeft = targetFixed ? body.scrollLeft() : 0,
  10044. endPosition = target.offset(),
  10045. animation = {
  10046. top: endPosition.top - fixTop,
  10047. left: endPosition.left - fixLeft,
  10048. height: target.innerHeight(),
  10049. width: target.innerWidth()
  10050. },
  10051. startPosition = elem.offset(),
  10052. transfer = $( "<div class='ui-effects-transfer'></div>" )
  10053. .appendTo( document.body )
  10054. .addClass( o.className )
  10055. .css({
  10056. top: startPosition.top - fixTop,
  10057. left: startPosition.left - fixLeft,
  10058. height: elem.innerHeight(),
  10059. width: elem.innerWidth(),
  10060. position: targetFixed ? "fixed" : "absolute"
  10061. })
  10062. .animate( animation, o.duration, o.easing, function() {
  10063. transfer.remove();
  10064. done();
  10065. });
  10066. };
  10067. /*!
  10068. * jQuery UI Progressbar 1.11.1
  10069. * http://jqueryui.com
  10070. *
  10071. * Copyright 2014 jQuery Foundation and other contributors
  10072. * Released under the MIT license.
  10073. * http://jquery.org/license
  10074. *
  10075. * http://api.jqueryui.com/progressbar/
  10076. */
  10077. var progressbar = $.widget( "ui.progressbar", {
  10078. version: "1.11.1",
  10079. options: {
  10080. max: 100,
  10081. value: 0,
  10082. change: null,
  10083. complete: null
  10084. },
  10085. min: 0,
  10086. _create: function() {
  10087. // Constrain initial value
  10088. this.oldValue = this.options.value = this._constrainedValue();
  10089. this.element
  10090. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10091. .attr({
  10092. // Only set static values, aria-valuenow and aria-valuemax are
  10093. // set inside _refreshValue()
  10094. role: "progressbar",
  10095. "aria-valuemin": this.min
  10096. });
  10097. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  10098. .appendTo( this.element );
  10099. this._refreshValue();
  10100. },
  10101. _destroy: function() {
  10102. this.element
  10103. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10104. .removeAttr( "role" )
  10105. .removeAttr( "aria-valuemin" )
  10106. .removeAttr( "aria-valuemax" )
  10107. .removeAttr( "aria-valuenow" );
  10108. this.valueDiv.remove();
  10109. },
  10110. value: function( newValue ) {
  10111. if ( newValue === undefined ) {
  10112. return this.options.value;
  10113. }
  10114. this.options.value = this._constrainedValue( newValue );
  10115. this._refreshValue();
  10116. },
  10117. _constrainedValue: function( newValue ) {
  10118. if ( newValue === undefined ) {
  10119. newValue = this.options.value;
  10120. }
  10121. this.indeterminate = newValue === false;
  10122. // sanitize value
  10123. if ( typeof newValue !== "number" ) {
  10124. newValue = 0;
  10125. }
  10126. return this.indeterminate ? false :
  10127. Math.min( this.options.max, Math.max( this.min, newValue ) );
  10128. },
  10129. _setOptions: function( options ) {
  10130. // Ensure "value" option is set after other values (like max)
  10131. var value = options.value;
  10132. delete options.value;
  10133. this._super( options );
  10134. this.options.value = this._constrainedValue( value );
  10135. this._refreshValue();
  10136. },
  10137. _setOption: function( key, value ) {
  10138. if ( key === "max" ) {
  10139. // Don't allow a max less than min
  10140. value = Math.max( this.min, value );
  10141. }
  10142. if ( key === "disabled" ) {
  10143. this.element
  10144. .toggleClass( "ui-state-disabled", !!value )
  10145. .attr( "aria-disabled", value );
  10146. }
  10147. this._super( key, value );
  10148. },
  10149. _percentage: function() {
  10150. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  10151. },
  10152. _refreshValue: function() {
  10153. var value = this.options.value,
  10154. percentage = this._percentage();
  10155. this.valueDiv
  10156. .toggle( this.indeterminate || value > this.min )
  10157. .toggleClass( "ui-corner-right", value === this.options.max )
  10158. .width( percentage.toFixed(0) + "%" );
  10159. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  10160. if ( this.indeterminate ) {
  10161. this.element.removeAttr( "aria-valuenow" );
  10162. if ( !this.overlayDiv ) {
  10163. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  10164. }
  10165. } else {
  10166. this.element.attr({
  10167. "aria-valuemax": this.options.max,
  10168. "aria-valuenow": value
  10169. });
  10170. if ( this.overlayDiv ) {
  10171. this.overlayDiv.remove();
  10172. this.overlayDiv = null;
  10173. }
  10174. }
  10175. if ( this.oldValue !== value ) {
  10176. this.oldValue = value;
  10177. this._trigger( "change" );
  10178. }
  10179. if ( value === this.options.max ) {
  10180. this._trigger( "complete" );
  10181. }
  10182. }
  10183. });
  10184. /*!
  10185. * jQuery UI Selectable 1.11.1
  10186. * http://jqueryui.com
  10187. *
  10188. * Copyright 2014 jQuery Foundation and other contributors
  10189. * Released under the MIT license.
  10190. * http://jquery.org/license
  10191. *
  10192. * http://api.jqueryui.com/selectable/
  10193. */
  10194. var selectable = $.widget("ui.selectable", $.ui.mouse, {
  10195. version: "1.11.1",
  10196. options: {
  10197. appendTo: "body",
  10198. autoRefresh: true,
  10199. distance: 0,
  10200. filter: "*",
  10201. tolerance: "touch",
  10202. // callbacks
  10203. selected: null,
  10204. selecting: null,
  10205. start: null,
  10206. stop: null,
  10207. unselected: null,
  10208. unselecting: null
  10209. },
  10210. _create: function() {
  10211. var selectees,
  10212. that = this;
  10213. this.element.addClass("ui-selectable");
  10214. this.dragged = false;
  10215. // cache selectee children based on filter
  10216. this.refresh = function() {
  10217. selectees = $(that.options.filter, that.element[0]);
  10218. selectees.addClass("ui-selectee");
  10219. selectees.each(function() {
  10220. var $this = $(this),
  10221. pos = $this.offset();
  10222. $.data(this, "selectable-item", {
  10223. element: this,
  10224. $element: $this,
  10225. left: pos.left,
  10226. top: pos.top,
  10227. right: pos.left + $this.outerWidth(),
  10228. bottom: pos.top + $this.outerHeight(),
  10229. startselected: false,
  10230. selected: $this.hasClass("ui-selected"),
  10231. selecting: $this.hasClass("ui-selecting"),
  10232. unselecting: $this.hasClass("ui-unselecting")
  10233. });
  10234. });
  10235. };
  10236. this.refresh();
  10237. this.selectees = selectees.addClass("ui-selectee");
  10238. this._mouseInit();
  10239. this.helper = $("<div class='ui-selectable-helper'></div>");
  10240. },
  10241. _destroy: function() {
  10242. this.selectees
  10243. .removeClass("ui-selectee")
  10244. .removeData("selectable-item");
  10245. this.element
  10246. .removeClass("ui-selectable ui-selectable-disabled");
  10247. this._mouseDestroy();
  10248. },
  10249. _mouseStart: function(event) {
  10250. var that = this,
  10251. options = this.options;
  10252. this.opos = [ event.pageX, event.pageY ];
  10253. if (this.options.disabled) {
  10254. return;
  10255. }
  10256. this.selectees = $(options.filter, this.element[0]);
  10257. this._trigger("start", event);
  10258. $(options.appendTo).append(this.helper);
  10259. // position helper (lasso)
  10260. this.helper.css({
  10261. "left": event.pageX,
  10262. "top": event.pageY,
  10263. "width": 0,
  10264. "height": 0
  10265. });
  10266. if (options.autoRefresh) {
  10267. this.refresh();
  10268. }
  10269. this.selectees.filter(".ui-selected").each(function() {
  10270. var selectee = $.data(this, "selectable-item");
  10271. selectee.startselected = true;
  10272. if (!event.metaKey && !event.ctrlKey) {
  10273. selectee.$element.removeClass("ui-selected");
  10274. selectee.selected = false;
  10275. selectee.$element.addClass("ui-unselecting");
  10276. selectee.unselecting = true;
  10277. // selectable UNSELECTING callback
  10278. that._trigger("unselecting", event, {
  10279. unselecting: selectee.element
  10280. });
  10281. }
  10282. });
  10283. $(event.target).parents().addBack().each(function() {
  10284. var doSelect,
  10285. selectee = $.data(this, "selectable-item");
  10286. if (selectee) {
  10287. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  10288. selectee.$element
  10289. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  10290. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  10291. selectee.unselecting = !doSelect;
  10292. selectee.selecting = doSelect;
  10293. selectee.selected = doSelect;
  10294. // selectable (UN)SELECTING callback
  10295. if (doSelect) {
  10296. that._trigger("selecting", event, {
  10297. selecting: selectee.element
  10298. });
  10299. } else {
  10300. that._trigger("unselecting", event, {
  10301. unselecting: selectee.element
  10302. });
  10303. }
  10304. return false;
  10305. }
  10306. });
  10307. },
  10308. _mouseDrag: function(event) {
  10309. this.dragged = true;
  10310. if (this.options.disabled) {
  10311. return;
  10312. }
  10313. var tmp,
  10314. that = this,
  10315. options = this.options,
  10316. x1 = this.opos[0],
  10317. y1 = this.opos[1],
  10318. x2 = event.pageX,
  10319. y2 = event.pageY;
  10320. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  10321. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  10322. this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });
  10323. this.selectees.each(function() {
  10324. var selectee = $.data(this, "selectable-item"),
  10325. hit = false;
  10326. //prevent helper from being selected if appendTo: selectable
  10327. if (!selectee || selectee.element === that.element[0]) {
  10328. return;
  10329. }
  10330. if (options.tolerance === "touch") {
  10331. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  10332. } else if (options.tolerance === "fit") {
  10333. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  10334. }
  10335. if (hit) {
  10336. // SELECT
  10337. if (selectee.selected) {
  10338. selectee.$element.removeClass("ui-selected");
  10339. selectee.selected = false;
  10340. }
  10341. if (selectee.unselecting) {
  10342. selectee.$element.removeClass("ui-unselecting");
  10343. selectee.unselecting = false;
  10344. }
  10345. if (!selectee.selecting) {
  10346. selectee.$element.addClass("ui-selecting");
  10347. selectee.selecting = true;
  10348. // selectable SELECTING callback
  10349. that._trigger("selecting", event, {
  10350. selecting: selectee.element
  10351. });
  10352. }
  10353. } else {
  10354. // UNSELECT
  10355. if (selectee.selecting) {
  10356. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  10357. selectee.$element.removeClass("ui-selecting");
  10358. selectee.selecting = false;
  10359. selectee.$element.addClass("ui-selected");
  10360. selectee.selected = true;
  10361. } else {
  10362. selectee.$element.removeClass("ui-selecting");
  10363. selectee.selecting = false;
  10364. if (selectee.startselected) {
  10365. selectee.$element.addClass("ui-unselecting");
  10366. selectee.unselecting = true;
  10367. }
  10368. // selectable UNSELECTING callback
  10369. that._trigger("unselecting", event, {
  10370. unselecting: selectee.element
  10371. });
  10372. }
  10373. }
  10374. if (selectee.selected) {
  10375. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  10376. selectee.$element.removeClass("ui-selected");
  10377. selectee.selected = false;
  10378. selectee.$element.addClass("ui-unselecting");
  10379. selectee.unselecting = true;
  10380. // selectable UNSELECTING callback
  10381. that._trigger("unselecting", event, {
  10382. unselecting: selectee.element
  10383. });
  10384. }
  10385. }
  10386. }
  10387. });
  10388. return false;
  10389. },
  10390. _mouseStop: function(event) {
  10391. var that = this;
  10392. this.dragged = false;
  10393. $(".ui-unselecting", this.element[0]).each(function() {
  10394. var selectee = $.data(this, "selectable-item");
  10395. selectee.$element.removeClass("ui-unselecting");
  10396. selectee.unselecting = false;
  10397. selectee.startselected = false;
  10398. that._trigger("unselected", event, {
  10399. unselected: selectee.element
  10400. });
  10401. });
  10402. $(".ui-selecting", this.element[0]).each(function() {
  10403. var selectee = $.data(this, "selectable-item");
  10404. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  10405. selectee.selecting = false;
  10406. selectee.selected = true;
  10407. selectee.startselected = true;
  10408. that._trigger("selected", event, {
  10409. selected: selectee.element
  10410. });
  10411. });
  10412. this._trigger("stop", event);
  10413. this.helper.remove();
  10414. return false;
  10415. }
  10416. });
  10417. /*!
  10418. * jQuery UI Selectmenu 1.11.1
  10419. * http://jqueryui.com
  10420. *
  10421. * Copyright 2014 jQuery Foundation and other contributors
  10422. * Released under the MIT license.
  10423. * http://jquery.org/license
  10424. *
  10425. * http://api.jqueryui.com/selectmenu
  10426. */
  10427. var selectmenu = $.widget( "ui.selectmenu", {
  10428. version: "1.11.1",
  10429. defaultElement: "<select>",
  10430. options: {
  10431. appendTo: null,
  10432. disabled: null,
  10433. icons: {
  10434. button: "ui-icon-triangle-1-s"
  10435. },
  10436. position: {
  10437. my: "left top",
  10438. at: "left bottom",
  10439. collision: "none"
  10440. },
  10441. width: null,
  10442. // callbacks
  10443. change: null,
  10444. close: null,
  10445. focus: null,
  10446. open: null,
  10447. select: null
  10448. },
  10449. _create: function() {
  10450. var selectmenuId = this.element.uniqueId().attr( "id" );
  10451. this.ids = {
  10452. element: selectmenuId,
  10453. button: selectmenuId + "-button",
  10454. menu: selectmenuId + "-menu"
  10455. };
  10456. this._drawButton();
  10457. this._drawMenu();
  10458. if ( this.options.disabled ) {
  10459. this.disable();
  10460. }
  10461. },
  10462. _drawButton: function() {
  10463. var that = this,
  10464. tabindex = this.element.attr( "tabindex" );
  10465. // Associate existing label with the new button
  10466. this.label = $( "label[for='" + this.ids.element + "']" ).attr( "for", this.ids.button );
  10467. this._on( this.label, {
  10468. click: function( event ) {
  10469. this.button.focus();
  10470. event.preventDefault();
  10471. }
  10472. });
  10473. // Hide original select element
  10474. this.element.hide();
  10475. // Create button
  10476. this.button = $( "<span>", {
  10477. "class": "ui-selectmenu-button ui-widget ui-state-default ui-corner-all",
  10478. tabindex: tabindex || this.options.disabled ? -1 : 0,
  10479. id: this.ids.button,
  10480. role: "combobox",
  10481. "aria-expanded": "false",
  10482. "aria-autocomplete": "list",
  10483. "aria-owns": this.ids.menu,
  10484. "aria-haspopup": "true"
  10485. })
  10486. .insertAfter( this.element );
  10487. $( "<span>", {
  10488. "class": "ui-icon " + this.options.icons.button
  10489. })
  10490. .prependTo( this.button );
  10491. this.buttonText = $( "<span>", {
  10492. "class": "ui-selectmenu-text"
  10493. })
  10494. .appendTo( this.button );
  10495. this._setText( this.buttonText, this.element.find( "option:selected" ).text() );
  10496. this._resizeButton();
  10497. this._on( this.button, this._buttonEvents );
  10498. this.button.one( "focusin", function() {
  10499. // Delay rendering the menu items until the button receives focus.
  10500. // The menu may have already been rendered via a programmatic open.
  10501. if ( !that.menuItems ) {
  10502. that._refreshMenu();
  10503. }
  10504. });
  10505. this._hoverable( this.button );
  10506. this._focusable( this.button );
  10507. },
  10508. _drawMenu: function() {
  10509. var that = this;
  10510. // Create menu
  10511. this.menu = $( "<ul>", {
  10512. "aria-hidden": "true",
  10513. "aria-labelledby": this.ids.button,
  10514. id: this.ids.menu
  10515. });
  10516. // Wrap menu
  10517. this.menuWrap = $( "<div>", {
  10518. "class": "ui-selectmenu-menu ui-front"
  10519. })
  10520. .append( this.menu )
  10521. .appendTo( this._appendTo() );
  10522. // Initialize menu widget
  10523. this.menuInstance = this.menu
  10524. .menu({
  10525. role: "listbox",
  10526. select: function( event, ui ) {
  10527. event.preventDefault();
  10528. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  10529. },
  10530. focus: function( event, ui ) {
  10531. var item = ui.item.data( "ui-selectmenu-item" );
  10532. // Prevent inital focus from firing and check if its a newly focused item
  10533. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  10534. that._trigger( "focus", event, { item: item } );
  10535. if ( !that.isOpen ) {
  10536. that._select( item, event );
  10537. }
  10538. }
  10539. that.focusIndex = item.index;
  10540. that.button.attr( "aria-activedescendant",
  10541. that.menuItems.eq( item.index ).attr( "id" ) );
  10542. }
  10543. })
  10544. .menu( "instance" );
  10545. // Adjust menu styles to dropdown
  10546. this.menu
  10547. .addClass( "ui-corner-bottom" )
  10548. .removeClass( "ui-corner-all" );
  10549. // Don't close the menu on mouseleave
  10550. this.menuInstance._off( this.menu, "mouseleave" );
  10551. // Cancel the menu's collapseAll on document click
  10552. this.menuInstance._closeOnDocumentClick = function() {
  10553. return false;
  10554. };
  10555. // Selects often contain empty items, but never contain dividers
  10556. this.menuInstance._isDivider = function() {
  10557. return false;
  10558. };
  10559. },
  10560. refresh: function() {
  10561. this._refreshMenu();
  10562. this._setText( this.buttonText, this._getSelectedItem().text() );
  10563. if ( !this.options.width ) {
  10564. this._resizeButton();
  10565. }
  10566. },
  10567. _refreshMenu: function() {
  10568. this.menu.empty();
  10569. var item,
  10570. options = this.element.find( "option" );
  10571. if ( !options.length ) {
  10572. return;
  10573. }
  10574. this._parseOptions( options );
  10575. this._renderMenu( this.menu, this.items );
  10576. this.menuInstance.refresh();
  10577. this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" );
  10578. item = this._getSelectedItem();
  10579. // Update the menu to have the correct item focused
  10580. this.menuInstance.focus( null, item );
  10581. this._setAria( item.data( "ui-selectmenu-item" ) );
  10582. // Set disabled state
  10583. this._setOption( "disabled", this.element.prop( "disabled" ) );
  10584. },
  10585. open: function( event ) {
  10586. if ( this.options.disabled ) {
  10587. return;
  10588. }
  10589. // If this is the first time the menu is being opened, render the items
  10590. if ( !this.menuItems ) {
  10591. this._refreshMenu();
  10592. } else {
  10593. // Menu clears focus on close, reset focus to selected item
  10594. this.menu.find( ".ui-state-focus" ).removeClass( "ui-state-focus" );
  10595. this.menuInstance.focus( null, this._getSelectedItem() );
  10596. }
  10597. this.isOpen = true;
  10598. this._toggleAttr();
  10599. this._resizeMenu();
  10600. this._position();
  10601. this._on( this.document, this._documentClick );
  10602. this._trigger( "open", event );
  10603. },
  10604. _position: function() {
  10605. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  10606. },
  10607. close: function( event ) {
  10608. if ( !this.isOpen ) {
  10609. return;
  10610. }
  10611. this.isOpen = false;
  10612. this._toggleAttr();
  10613. this._off( this.document );
  10614. this._trigger( "close", event );
  10615. },
  10616. widget: function() {
  10617. return this.button;
  10618. },
  10619. menuWidget: function() {
  10620. return this.menu;
  10621. },
  10622. _renderMenu: function( ul, items ) {
  10623. var that = this,
  10624. currentOptgroup = "";
  10625. $.each( items, function( index, item ) {
  10626. if ( item.optgroup !== currentOptgroup ) {
  10627. $( "<li>", {
  10628. "class": "ui-selectmenu-optgroup ui-menu-divider" +
  10629. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  10630. " ui-state-disabled" :
  10631. "" ),
  10632. text: item.optgroup
  10633. })
  10634. .appendTo( ul );
  10635. currentOptgroup = item.optgroup;
  10636. }
  10637. that._renderItemData( ul, item );
  10638. });
  10639. },
  10640. _renderItemData: function( ul, item ) {
  10641. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  10642. },
  10643. _renderItem: function( ul, item ) {
  10644. var li = $( "<li>" );
  10645. if ( item.disabled ) {
  10646. li.addClass( "ui-state-disabled" );
  10647. }
  10648. this._setText( li, item.label );
  10649. return li.appendTo( ul );
  10650. },
  10651. _setText: function( element, value ) {
  10652. if ( value ) {
  10653. element.text( value );
  10654. } else {
  10655. element.html( "&#160;" );
  10656. }
  10657. },
  10658. _move: function( direction, event ) {
  10659. var item, next,
  10660. filter = ".ui-menu-item";
  10661. if ( this.isOpen ) {
  10662. item = this.menuItems.eq( this.focusIndex );
  10663. } else {
  10664. item = this.menuItems.eq( this.element[ 0 ].selectedIndex );
  10665. filter += ":not(.ui-state-disabled)";
  10666. }
  10667. if ( direction === "first" || direction === "last" ) {
  10668. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  10669. } else {
  10670. next = item[ direction + "All" ]( filter ).eq( 0 );
  10671. }
  10672. if ( next.length ) {
  10673. this.menuInstance.focus( event, next );
  10674. }
  10675. },
  10676. _getSelectedItem: function() {
  10677. return this.menuItems.eq( this.element[ 0 ].selectedIndex );
  10678. },
  10679. _toggle: function( event ) {
  10680. this[ this.isOpen ? "close" : "open" ]( event );
  10681. },
  10682. _documentClick: {
  10683. mousedown: function( event ) {
  10684. if ( !this.isOpen ) {
  10685. return;
  10686. }
  10687. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + this.ids.button ).length ) {
  10688. this.close( event );
  10689. }
  10690. }
  10691. },
  10692. _buttonEvents: {
  10693. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  10694. mousedown: function( event ) {
  10695. event.preventDefault();
  10696. },
  10697. click: "_toggle",
  10698. keydown: function( event ) {
  10699. var preventDefault = true;
  10700. switch ( event.keyCode ) {
  10701. case $.ui.keyCode.TAB:
  10702. case $.ui.keyCode.ESCAPE:
  10703. this.close( event );
  10704. preventDefault = false;
  10705. break;
  10706. case $.ui.keyCode.ENTER:
  10707. if ( this.isOpen ) {
  10708. this._selectFocusedItem( event );
  10709. }
  10710. break;
  10711. case $.ui.keyCode.UP:
  10712. if ( event.altKey ) {
  10713. this._toggle( event );
  10714. } else {
  10715. this._move( "prev", event );
  10716. }
  10717. break;
  10718. case $.ui.keyCode.DOWN:
  10719. if ( event.altKey ) {
  10720. this._toggle( event );
  10721. } else {
  10722. this._move( "next", event );
  10723. }
  10724. break;
  10725. case $.ui.keyCode.SPACE:
  10726. if ( this.isOpen ) {
  10727. this._selectFocusedItem( event );
  10728. } else {
  10729. this._toggle( event );
  10730. }
  10731. break;
  10732. case $.ui.keyCode.LEFT:
  10733. this._move( "prev", event );
  10734. break;
  10735. case $.ui.keyCode.RIGHT:
  10736. this._move( "next", event );
  10737. break;
  10738. case $.ui.keyCode.HOME:
  10739. case $.ui.keyCode.PAGE_UP:
  10740. this._move( "first", event );
  10741. break;
  10742. case $.ui.keyCode.END:
  10743. case $.ui.keyCode.PAGE_DOWN:
  10744. this._move( "last", event );
  10745. break;
  10746. default:
  10747. this.menu.trigger( event );
  10748. preventDefault = false;
  10749. }
  10750. if ( preventDefault ) {
  10751. event.preventDefault();
  10752. }
  10753. }
  10754. },
  10755. _selectFocusedItem: function( event ) {
  10756. var item = this.menuItems.eq( this.focusIndex );
  10757. if ( !item.hasClass( "ui-state-disabled" ) ) {
  10758. this._select( item.data( "ui-selectmenu-item" ), event );
  10759. }
  10760. },
  10761. _select: function( item, event ) {
  10762. var oldIndex = this.element[ 0 ].selectedIndex;
  10763. // Change native select element
  10764. this.element[ 0 ].selectedIndex = item.index;
  10765. this._setText( this.buttonText, item.label );
  10766. this._setAria( item );
  10767. this._trigger( "select", event, { item: item } );
  10768. if ( item.index !== oldIndex ) {
  10769. this._trigger( "change", event, { item: item } );
  10770. }
  10771. this.close( event );
  10772. },
  10773. _setAria: function( item ) {
  10774. var id = this.menuItems.eq( item.index ).attr( "id" );
  10775. this.button.attr({
  10776. "aria-labelledby": id,
  10777. "aria-activedescendant": id
  10778. });
  10779. this.menu.attr( "aria-activedescendant", id );
  10780. },
  10781. _setOption: function( key, value ) {
  10782. if ( key === "icons" ) {
  10783. this.button.find( "span.ui-icon" )
  10784. .removeClass( this.options.icons.button )
  10785. .addClass( value.button );
  10786. }
  10787. this._super( key, value );
  10788. if ( key === "appendTo" ) {
  10789. this.menuWrap.appendTo( this._appendTo() );
  10790. }
  10791. if ( key === "disabled" ) {
  10792. this.menuInstance.option( "disabled", value );
  10793. this.button
  10794. .toggleClass( "ui-state-disabled", value )
  10795. .attr( "aria-disabled", value );
  10796. this.element.prop( "disabled", value );
  10797. if ( value ) {
  10798. this.button.attr( "tabindex", -1 );
  10799. this.close();
  10800. } else {
  10801. this.button.attr( "tabindex", 0 );
  10802. }
  10803. }
  10804. if ( key === "width" ) {
  10805. this._resizeButton();
  10806. }
  10807. },
  10808. _appendTo: function() {
  10809. var element = this.options.appendTo;
  10810. if ( element ) {
  10811. element = element.jquery || element.nodeType ?
  10812. $( element ) :
  10813. this.document.find( element ).eq( 0 );
  10814. }
  10815. if ( !element || !element[ 0 ] ) {
  10816. element = this.element.closest( ".ui-front" );
  10817. }
  10818. if ( !element.length ) {
  10819. element = this.document[ 0 ].body;
  10820. }
  10821. return element;
  10822. },
  10823. _toggleAttr: function() {
  10824. this.button
  10825. .toggleClass( "ui-corner-top", this.isOpen )
  10826. .toggleClass( "ui-corner-all", !this.isOpen )
  10827. .attr( "aria-expanded", this.isOpen );
  10828. this.menuWrap.toggleClass( "ui-selectmenu-open", this.isOpen );
  10829. this.menu.attr( "aria-hidden", !this.isOpen );
  10830. },
  10831. _resizeButton: function() {
  10832. var width = this.options.width;
  10833. if ( !width ) {
  10834. width = this.element.show().outerWidth();
  10835. this.element.hide();
  10836. }
  10837. this.button.outerWidth( width );
  10838. },
  10839. _resizeMenu: function() {
  10840. this.menu.outerWidth( Math.max(
  10841. this.button.outerWidth(),
  10842. // support: IE10
  10843. // IE10 wraps long text (possibly a rounding bug)
  10844. // so we add 1px to avoid the wrapping
  10845. this.menu.width( "" ).outerWidth() + 1
  10846. ) );
  10847. },
  10848. _getCreateOptions: function() {
  10849. return { disabled: this.element.prop( "disabled" ) };
  10850. },
  10851. _parseOptions: function( options ) {
  10852. var data = [];
  10853. options.each(function( index, item ) {
  10854. var option = $( item ),
  10855. optgroup = option.parent( "optgroup" );
  10856. data.push({
  10857. element: option,
  10858. index: index,
  10859. value: option.attr( "value" ),
  10860. label: option.text(),
  10861. optgroup: optgroup.attr( "label" ) || "",
  10862. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  10863. });
  10864. });
  10865. this.items = data;
  10866. },
  10867. _destroy: function() {
  10868. this.menuWrap.remove();
  10869. this.button.remove();
  10870. this.element.show();
  10871. this.element.removeUniqueId();
  10872. this.label.attr( "for", this.ids.element );
  10873. }
  10874. });
  10875. /*!
  10876. * jQuery UI Slider 1.11.1
  10877. * http://jqueryui.com
  10878. *
  10879. * Copyright 2014 jQuery Foundation and other contributors
  10880. * Released under the MIT license.
  10881. * http://jquery.org/license
  10882. *
  10883. * http://api.jqueryui.com/slider/
  10884. */
  10885. var slider = $.widget( "ui.slider", $.ui.mouse, {
  10886. version: "1.11.1",
  10887. widgetEventPrefix: "slide",
  10888. options: {
  10889. animate: false,
  10890. distance: 0,
  10891. max: 100,
  10892. min: 0,
  10893. orientation: "horizontal",
  10894. range: false,
  10895. step: 1,
  10896. value: 0,
  10897. values: null,
  10898. // callbacks
  10899. change: null,
  10900. slide: null,
  10901. start: null,
  10902. stop: null
  10903. },
  10904. // number of pages in a slider
  10905. // (how many times can you page up/down to go through the whole range)
  10906. numPages: 5,
  10907. _create: function() {
  10908. this._keySliding = false;
  10909. this._mouseSliding = false;
  10910. this._animateOff = true;
  10911. this._handleIndex = null;
  10912. this._detectOrientation();
  10913. this._mouseInit();
  10914. this.element
  10915. .addClass( "ui-slider" +
  10916. " ui-slider-" + this.orientation +
  10917. " ui-widget" +
  10918. " ui-widget-content" +
  10919. " ui-corner-all");
  10920. this._refresh();
  10921. this._setOption( "disabled", this.options.disabled );
  10922. this._animateOff = false;
  10923. },
  10924. _refresh: function() {
  10925. this._createRange();
  10926. this._createHandles();
  10927. this._setupEvents();
  10928. this._refreshValue();
  10929. },
  10930. _createHandles: function() {
  10931. var i, handleCount,
  10932. options = this.options,
  10933. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  10934. handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",
  10935. handles = [];
  10936. handleCount = ( options.values && options.values.length ) || 1;
  10937. if ( existingHandles.length > handleCount ) {
  10938. existingHandles.slice( handleCount ).remove();
  10939. existingHandles = existingHandles.slice( 0, handleCount );
  10940. }
  10941. for ( i = existingHandles.length; i < handleCount; i++ ) {
  10942. handles.push( handle );
  10943. }
  10944. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  10945. this.handle = this.handles.eq( 0 );
  10946. this.handles.each(function( i ) {
  10947. $( this ).data( "ui-slider-handle-index", i );
  10948. });
  10949. },
  10950. _createRange: function() {
  10951. var options = this.options,
  10952. classes = "";
  10953. if ( options.range ) {
  10954. if ( options.range === true ) {
  10955. if ( !options.values ) {
  10956. options.values = [ this._valueMin(), this._valueMin() ];
  10957. } else if ( options.values.length && options.values.length !== 2 ) {
  10958. options.values = [ options.values[0], options.values[0] ];
  10959. } else if ( $.isArray( options.values ) ) {
  10960. options.values = options.values.slice(0);
  10961. }
  10962. }
  10963. if ( !this.range || !this.range.length ) {
  10964. this.range = $( "<div></div>" )
  10965. .appendTo( this.element );
  10966. classes = "ui-slider-range" +
  10967. // note: this isn't the most fittingly semantic framework class for this element,
  10968. // but worked best visually with a variety of themes
  10969. " ui-widget-header ui-corner-all";
  10970. } else {
  10971. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  10972. // Handle range switching from true to min/max
  10973. .css({
  10974. "left": "",
  10975. "bottom": ""
  10976. });
  10977. }
  10978. this.range.addClass( classes +
  10979. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  10980. } else {
  10981. if ( this.range ) {
  10982. this.range.remove();
  10983. }
  10984. this.range = null;
  10985. }
  10986. },
  10987. _setupEvents: function() {
  10988. this._off( this.handles );
  10989. this._on( this.handles, this._handleEvents );
  10990. this._hoverable( this.handles );
  10991. this._focusable( this.handles );
  10992. },
  10993. _destroy: function() {
  10994. this.handles.remove();
  10995. if ( this.range ) {
  10996. this.range.remove();
  10997. }
  10998. this.element
  10999. .removeClass( "ui-slider" +
  11000. " ui-slider-horizontal" +
  11001. " ui-slider-vertical" +
  11002. " ui-widget" +
  11003. " ui-widget-content" +
  11004. " ui-corner-all" );
  11005. this._mouseDestroy();
  11006. },
  11007. _mouseCapture: function( event ) {
  11008. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  11009. that = this,
  11010. o = this.options;
  11011. if ( o.disabled ) {
  11012. return false;
  11013. }
  11014. this.elementSize = {
  11015. width: this.element.outerWidth(),
  11016. height: this.element.outerHeight()
  11017. };
  11018. this.elementOffset = this.element.offset();
  11019. position = { x: event.pageX, y: event.pageY };
  11020. normValue = this._normValueFromMouse( position );
  11021. distance = this._valueMax() - this._valueMin() + 1;
  11022. this.handles.each(function( i ) {
  11023. var thisDistance = Math.abs( normValue - that.values(i) );
  11024. if (( distance > thisDistance ) ||
  11025. ( distance === thisDistance &&
  11026. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  11027. distance = thisDistance;
  11028. closestHandle = $( this );
  11029. index = i;
  11030. }
  11031. });
  11032. allowed = this._start( event, index );
  11033. if ( allowed === false ) {
  11034. return false;
  11035. }
  11036. this._mouseSliding = true;
  11037. this._handleIndex = index;
  11038. closestHandle
  11039. .addClass( "ui-state-active" )
  11040. .focus();
  11041. offset = closestHandle.offset();
  11042. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  11043. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  11044. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  11045. top: event.pageY - offset.top -
  11046. ( closestHandle.height() / 2 ) -
  11047. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  11048. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  11049. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  11050. };
  11051. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  11052. this._slide( event, index, normValue );
  11053. }
  11054. this._animateOff = true;
  11055. return true;
  11056. },
  11057. _mouseStart: function() {
  11058. return true;
  11059. },
  11060. _mouseDrag: function( event ) {
  11061. var position = { x: event.pageX, y: event.pageY },
  11062. normValue = this._normValueFromMouse( position );
  11063. this._slide( event, this._handleIndex, normValue );
  11064. return false;
  11065. },
  11066. _mouseStop: function( event ) {
  11067. this.handles.removeClass( "ui-state-active" );
  11068. this._mouseSliding = false;
  11069. this._stop( event, this._handleIndex );
  11070. this._change( event, this._handleIndex );
  11071. this._handleIndex = null;
  11072. this._clickOffset = null;
  11073. this._animateOff = false;
  11074. return false;
  11075. },
  11076. _detectOrientation: function() {
  11077. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  11078. },
  11079. _normValueFromMouse: function( position ) {
  11080. var pixelTotal,
  11081. pixelMouse,
  11082. percentMouse,
  11083. valueTotal,
  11084. valueMouse;
  11085. if ( this.orientation === "horizontal" ) {
  11086. pixelTotal = this.elementSize.width;
  11087. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  11088. } else {
  11089. pixelTotal = this.elementSize.height;
  11090. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  11091. }
  11092. percentMouse = ( pixelMouse / pixelTotal );
  11093. if ( percentMouse > 1 ) {
  11094. percentMouse = 1;
  11095. }
  11096. if ( percentMouse < 0 ) {
  11097. percentMouse = 0;
  11098. }
  11099. if ( this.orientation === "vertical" ) {
  11100. percentMouse = 1 - percentMouse;
  11101. }
  11102. valueTotal = this._valueMax() - this._valueMin();
  11103. valueMouse = this._valueMin() + percentMouse * valueTotal;
  11104. return this._trimAlignValue( valueMouse );
  11105. },
  11106. _start: function( event, index ) {
  11107. var uiHash = {
  11108. handle: this.handles[ index ],
  11109. value: this.value()
  11110. };
  11111. if ( this.options.values && this.options.values.length ) {
  11112. uiHash.value = this.values( index );
  11113. uiHash.values = this.values();
  11114. }
  11115. return this._trigger( "start", event, uiHash );
  11116. },
  11117. _slide: function( event, index, newVal ) {
  11118. var otherVal,
  11119. newValues,
  11120. allowed;
  11121. if ( this.options.values && this.options.values.length ) {
  11122. otherVal = this.values( index ? 0 : 1 );
  11123. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  11124. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  11125. ) {
  11126. newVal = otherVal;
  11127. }
  11128. if ( newVal !== this.values( index ) ) {
  11129. newValues = this.values();
  11130. newValues[ index ] = newVal;
  11131. // A slide can be canceled by returning false from the slide callback
  11132. allowed = this._trigger( "slide", event, {
  11133. handle: this.handles[ index ],
  11134. value: newVal,
  11135. values: newValues
  11136. } );
  11137. otherVal = this.values( index ? 0 : 1 );
  11138. if ( allowed !== false ) {
  11139. this.values( index, newVal );
  11140. }
  11141. }
  11142. } else {
  11143. if ( newVal !== this.value() ) {
  11144. // A slide can be canceled by returning false from the slide callback
  11145. allowed = this._trigger( "slide", event, {
  11146. handle: this.handles[ index ],
  11147. value: newVal
  11148. } );
  11149. if ( allowed !== false ) {
  11150. this.value( newVal );
  11151. }
  11152. }
  11153. }
  11154. },
  11155. _stop: function( event, index ) {
  11156. var uiHash = {
  11157. handle: this.handles[ index ],
  11158. value: this.value()
  11159. };
  11160. if ( this.options.values && this.options.values.length ) {
  11161. uiHash.value = this.values( index );
  11162. uiHash.values = this.values();
  11163. }
  11164. this._trigger( "stop", event, uiHash );
  11165. },
  11166. _change: function( event, index ) {
  11167. if ( !this._keySliding && !this._mouseSliding ) {
  11168. var uiHash = {
  11169. handle: this.handles[ index ],
  11170. value: this.value()
  11171. };
  11172. if ( this.options.values && this.options.values.length ) {
  11173. uiHash.value = this.values( index );
  11174. uiHash.values = this.values();
  11175. }
  11176. //store the last changed value index for reference when handles overlap
  11177. this._lastChangedValue = index;
  11178. this._trigger( "change", event, uiHash );
  11179. }
  11180. },
  11181. value: function( newValue ) {
  11182. if ( arguments.length ) {
  11183. this.options.value = this._trimAlignValue( newValue );
  11184. this._refreshValue();
  11185. this._change( null, 0 );
  11186. return;
  11187. }
  11188. return this._value();
  11189. },
  11190. values: function( index, newValue ) {
  11191. var vals,
  11192. newValues,
  11193. i;
  11194. if ( arguments.length > 1 ) {
  11195. this.options.values[ index ] = this._trimAlignValue( newValue );
  11196. this._refreshValue();
  11197. this._change( null, index );
  11198. return;
  11199. }
  11200. if ( arguments.length ) {
  11201. if ( $.isArray( arguments[ 0 ] ) ) {
  11202. vals = this.options.values;
  11203. newValues = arguments[ 0 ];
  11204. for ( i = 0; i < vals.length; i += 1 ) {
  11205. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  11206. this._change( null, i );
  11207. }
  11208. this._refreshValue();
  11209. } else {
  11210. if ( this.options.values && this.options.values.length ) {
  11211. return this._values( index );
  11212. } else {
  11213. return this.value();
  11214. }
  11215. }
  11216. } else {
  11217. return this._values();
  11218. }
  11219. },
  11220. _setOption: function( key, value ) {
  11221. var i,
  11222. valsLength = 0;
  11223. if ( key === "range" && this.options.range === true ) {
  11224. if ( value === "min" ) {
  11225. this.options.value = this._values( 0 );
  11226. this.options.values = null;
  11227. } else if ( value === "max" ) {
  11228. this.options.value = this._values( this.options.values.length - 1 );
  11229. this.options.values = null;
  11230. }
  11231. }
  11232. if ( $.isArray( this.options.values ) ) {
  11233. valsLength = this.options.values.length;
  11234. }
  11235. if ( key === "disabled" ) {
  11236. this.element.toggleClass( "ui-state-disabled", !!value );
  11237. }
  11238. this._super( key, value );
  11239. switch ( key ) {
  11240. case "orientation":
  11241. this._detectOrientation();
  11242. this.element
  11243. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  11244. .addClass( "ui-slider-" + this.orientation );
  11245. this._refreshValue();
  11246. // Reset positioning from previous orientation
  11247. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  11248. break;
  11249. case "value":
  11250. this._animateOff = true;
  11251. this._refreshValue();
  11252. this._change( null, 0 );
  11253. this._animateOff = false;
  11254. break;
  11255. case "values":
  11256. this._animateOff = true;
  11257. this._refreshValue();
  11258. for ( i = 0; i < valsLength; i += 1 ) {
  11259. this._change( null, i );
  11260. }
  11261. this._animateOff = false;
  11262. break;
  11263. case "min":
  11264. case "max":
  11265. this._animateOff = true;
  11266. this._refreshValue();
  11267. this._animateOff = false;
  11268. break;
  11269. case "range":
  11270. this._animateOff = true;
  11271. this._refresh();
  11272. this._animateOff = false;
  11273. break;
  11274. }
  11275. },
  11276. //internal value getter
  11277. // _value() returns value trimmed by min and max, aligned by step
  11278. _value: function() {
  11279. var val = this.options.value;
  11280. val = this._trimAlignValue( val );
  11281. return val;
  11282. },
  11283. //internal values getter
  11284. // _values() returns array of values trimmed by min and max, aligned by step
  11285. // _values( index ) returns single value trimmed by min and max, aligned by step
  11286. _values: function( index ) {
  11287. var val,
  11288. vals,
  11289. i;
  11290. if ( arguments.length ) {
  11291. val = this.options.values[ index ];
  11292. val = this._trimAlignValue( val );
  11293. return val;
  11294. } else if ( this.options.values && this.options.values.length ) {
  11295. // .slice() creates a copy of the array
  11296. // this copy gets trimmed by min and max and then returned
  11297. vals = this.options.values.slice();
  11298. for ( i = 0; i < vals.length; i+= 1) {
  11299. vals[ i ] = this._trimAlignValue( vals[ i ] );
  11300. }
  11301. return vals;
  11302. } else {
  11303. return [];
  11304. }
  11305. },
  11306. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  11307. _trimAlignValue: function( val ) {
  11308. if ( val <= this._valueMin() ) {
  11309. return this._valueMin();
  11310. }
  11311. if ( val >= this._valueMax() ) {
  11312. return this._valueMax();
  11313. }
  11314. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  11315. valModStep = (val - this._valueMin()) % step,
  11316. alignValue = val - valModStep;
  11317. if ( Math.abs(valModStep) * 2 >= step ) {
  11318. alignValue += ( valModStep > 0 ) ? step : ( -step );
  11319. }
  11320. // Since JavaScript has problems with large floats, round
  11321. // the final value to 5 digits after the decimal point (see #4124)
  11322. return parseFloat( alignValue.toFixed(5) );
  11323. },
  11324. _valueMin: function() {
  11325. return this.options.min;
  11326. },
  11327. _valueMax: function() {
  11328. return this.options.max;
  11329. },
  11330. _refreshValue: function() {
  11331. var lastValPercent, valPercent, value, valueMin, valueMax,
  11332. oRange = this.options.range,
  11333. o = this.options,
  11334. that = this,
  11335. animate = ( !this._animateOff ) ? o.animate : false,
  11336. _set = {};
  11337. if ( this.options.values && this.options.values.length ) {
  11338. this.handles.each(function( i ) {
  11339. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  11340. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11341. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11342. if ( that.options.range === true ) {
  11343. if ( that.orientation === "horizontal" ) {
  11344. if ( i === 0 ) {
  11345. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  11346. }
  11347. if ( i === 1 ) {
  11348. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11349. }
  11350. } else {
  11351. if ( i === 0 ) {
  11352. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  11353. }
  11354. if ( i === 1 ) {
  11355. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11356. }
  11357. }
  11358. }
  11359. lastValPercent = valPercent;
  11360. });
  11361. } else {
  11362. value = this.value();
  11363. valueMin = this._valueMin();
  11364. valueMax = this._valueMax();
  11365. valPercent = ( valueMax !== valueMin ) ?
  11366. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  11367. 0;
  11368. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11369. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11370. if ( oRange === "min" && this.orientation === "horizontal" ) {
  11371. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  11372. }
  11373. if ( oRange === "max" && this.orientation === "horizontal" ) {
  11374. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11375. }
  11376. if ( oRange === "min" && this.orientation === "vertical" ) {
  11377. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  11378. }
  11379. if ( oRange === "max" && this.orientation === "vertical" ) {
  11380. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11381. }
  11382. }
  11383. },
  11384. _handleEvents: {
  11385. keydown: function( event ) {
  11386. var allowed, curVal, newVal, step,
  11387. index = $( event.target ).data( "ui-slider-handle-index" );
  11388. switch ( event.keyCode ) {
  11389. case $.ui.keyCode.HOME:
  11390. case $.ui.keyCode.END:
  11391. case $.ui.keyCode.PAGE_UP:
  11392. case $.ui.keyCode.PAGE_DOWN:
  11393. case $.ui.keyCode.UP:
  11394. case $.ui.keyCode.RIGHT:
  11395. case $.ui.keyCode.DOWN:
  11396. case $.ui.keyCode.LEFT:
  11397. event.preventDefault();
  11398. if ( !this._keySliding ) {
  11399. this._keySliding = true;
  11400. $( event.target ).addClass( "ui-state-active" );
  11401. allowed = this._start( event, index );
  11402. if ( allowed === false ) {
  11403. return;
  11404. }
  11405. }
  11406. break;
  11407. }
  11408. step = this.options.step;
  11409. if ( this.options.values && this.options.values.length ) {
  11410. curVal = newVal = this.values( index );
  11411. } else {
  11412. curVal = newVal = this.value();
  11413. }
  11414. switch ( event.keyCode ) {
  11415. case $.ui.keyCode.HOME:
  11416. newVal = this._valueMin();
  11417. break;
  11418. case $.ui.keyCode.END:
  11419. newVal = this._valueMax();
  11420. break;
  11421. case $.ui.keyCode.PAGE_UP:
  11422. newVal = this._trimAlignValue(
  11423. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  11424. );
  11425. break;
  11426. case $.ui.keyCode.PAGE_DOWN:
  11427. newVal = this._trimAlignValue(
  11428. curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
  11429. break;
  11430. case $.ui.keyCode.UP:
  11431. case $.ui.keyCode.RIGHT:
  11432. if ( curVal === this._valueMax() ) {
  11433. return;
  11434. }
  11435. newVal = this._trimAlignValue( curVal + step );
  11436. break;
  11437. case $.ui.keyCode.DOWN:
  11438. case $.ui.keyCode.LEFT:
  11439. if ( curVal === this._valueMin() ) {
  11440. return;
  11441. }
  11442. newVal = this._trimAlignValue( curVal - step );
  11443. break;
  11444. }
  11445. this._slide( event, index, newVal );
  11446. },
  11447. keyup: function( event ) {
  11448. var index = $( event.target ).data( "ui-slider-handle-index" );
  11449. if ( this._keySliding ) {
  11450. this._keySliding = false;
  11451. this._stop( event, index );
  11452. this._change( event, index );
  11453. $( event.target ).removeClass( "ui-state-active" );
  11454. }
  11455. }
  11456. }
  11457. });
  11458. /*!
  11459. * jQuery UI Sortable 1.11.1
  11460. * http://jqueryui.com
  11461. *
  11462. * Copyright 2014 jQuery Foundation and other contributors
  11463. * Released under the MIT license.
  11464. * http://jquery.org/license
  11465. *
  11466. * http://api.jqueryui.com/sortable/
  11467. */
  11468. var sortable = $.widget("ui.sortable", $.ui.mouse, {
  11469. version: "1.11.1",
  11470. widgetEventPrefix: "sort",
  11471. ready: false,
  11472. options: {
  11473. appendTo: "parent",
  11474. axis: false,
  11475. connectWith: false,
  11476. containment: false,
  11477. cursor: "auto",
  11478. cursorAt: false,
  11479. dropOnEmpty: true,
  11480. forcePlaceholderSize: false,
  11481. forceHelperSize: false,
  11482. grid: false,
  11483. handle: false,
  11484. helper: "original",
  11485. items: "> *",
  11486. opacity: false,
  11487. placeholder: false,
  11488. revert: false,
  11489. scroll: true,
  11490. scrollSensitivity: 20,
  11491. scrollSpeed: 20,
  11492. scope: "default",
  11493. tolerance: "intersect",
  11494. zIndex: 1000,
  11495. // callbacks
  11496. activate: null,
  11497. beforeStop: null,
  11498. change: null,
  11499. deactivate: null,
  11500. out: null,
  11501. over: null,
  11502. receive: null,
  11503. remove: null,
  11504. sort: null,
  11505. start: null,
  11506. stop: null,
  11507. update: null
  11508. },
  11509. _isOverAxis: function( x, reference, size ) {
  11510. return ( x >= reference ) && ( x < ( reference + size ) );
  11511. },
  11512. _isFloating: function( item ) {
  11513. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  11514. },
  11515. _create: function() {
  11516. var o = this.options;
  11517. this.containerCache = {};
  11518. this.element.addClass("ui-sortable");
  11519. //Get the items
  11520. this.refresh();
  11521. //Let's determine if the items are being displayed horizontally
  11522. this.floating = this.items.length ? o.axis === "x" || this._isFloating(this.items[0].item) : false;
  11523. //Let's determine the parent's offset
  11524. this.offset = this.element.offset();
  11525. //Initialize mouse events for interaction
  11526. this._mouseInit();
  11527. this._setHandleClassName();
  11528. //We're ready to go
  11529. this.ready = true;
  11530. },
  11531. _setOption: function( key, value ) {
  11532. this._super( key, value );
  11533. if ( key === "handle" ) {
  11534. this._setHandleClassName();
  11535. }
  11536. },
  11537. _setHandleClassName: function() {
  11538. this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" );
  11539. $.each( this.items, function() {
  11540. ( this.instance.options.handle ?
  11541. this.item.find( this.instance.options.handle ) : this.item )
  11542. .addClass( "ui-sortable-handle" );
  11543. });
  11544. },
  11545. _destroy: function() {
  11546. this.element
  11547. .removeClass( "ui-sortable ui-sortable-disabled" )
  11548. .find( ".ui-sortable-handle" )
  11549. .removeClass( "ui-sortable-handle" );
  11550. this._mouseDestroy();
  11551. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  11552. this.items[i].item.removeData(this.widgetName + "-item");
  11553. }
  11554. return this;
  11555. },
  11556. _mouseCapture: function(event, overrideHandle) {
  11557. var currentItem = null,
  11558. validHandle = false,
  11559. that = this;
  11560. if (this.reverting) {
  11561. return false;
  11562. }
  11563. if(this.options.disabled || this.options.type === "static") {
  11564. return false;
  11565. }
  11566. //We have to refresh the items data once first
  11567. this._refreshItems(event);
  11568. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  11569. $(event.target).parents().each(function() {
  11570. if($.data(this, that.widgetName + "-item") === that) {
  11571. currentItem = $(this);
  11572. return false;
  11573. }
  11574. });
  11575. if($.data(event.target, that.widgetName + "-item") === that) {
  11576. currentItem = $(event.target);
  11577. }
  11578. if(!currentItem) {
  11579. return false;
  11580. }
  11581. if(this.options.handle && !overrideHandle) {
  11582. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  11583. if(this === event.target) {
  11584. validHandle = true;
  11585. }
  11586. });
  11587. if(!validHandle) {
  11588. return false;
  11589. }
  11590. }
  11591. this.currentItem = currentItem;
  11592. this._removeCurrentsFromItems();
  11593. return true;
  11594. },
  11595. _mouseStart: function(event, overrideHandle, noActivation) {
  11596. var i, body,
  11597. o = this.options;
  11598. this.currentContainer = this;
  11599. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  11600. this.refreshPositions();
  11601. //Create and append the visible helper
  11602. this.helper = this._createHelper(event);
  11603. //Cache the helper size
  11604. this._cacheHelperProportions();
  11605. /*
  11606. * - Position generation -
  11607. * This block generates everything position related - it's the core of draggables.
  11608. */
  11609. //Cache the margins of the original element
  11610. this._cacheMargins();
  11611. //Get the next scrolling parent
  11612. this.scrollParent = this.helper.scrollParent();
  11613. //The element's absolute position on the page minus margins
  11614. this.offset = this.currentItem.offset();
  11615. this.offset = {
  11616. top: this.offset.top - this.margins.top,
  11617. left: this.offset.left - this.margins.left
  11618. };
  11619. $.extend(this.offset, {
  11620. click: { //Where the click happened, relative to the element
  11621. left: event.pageX - this.offset.left,
  11622. top: event.pageY - this.offset.top
  11623. },
  11624. parent: this._getParentOffset(),
  11625. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  11626. });
  11627. // Only after we got the offset, we can change the helper's position to absolute
  11628. // TODO: Still need to figure out a way to make relative sorting possible
  11629. this.helper.css("position", "absolute");
  11630. this.cssPosition = this.helper.css("position");
  11631. //Generate the original position
  11632. this.originalPosition = this._generatePosition(event);
  11633. this.originalPageX = event.pageX;
  11634. this.originalPageY = event.pageY;
  11635. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  11636. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  11637. //Cache the former DOM position
  11638. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  11639. //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
  11640. if(this.helper[0] !== this.currentItem[0]) {
  11641. this.currentItem.hide();
  11642. }
  11643. //Create the placeholder
  11644. this._createPlaceholder();
  11645. //Set a containment if given in the options
  11646. if(o.containment) {
  11647. this._setContainment();
  11648. }
  11649. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  11650. body = this.document.find( "body" );
  11651. // support: IE
  11652. this.storedCursor = body.css( "cursor" );
  11653. body.css( "cursor", o.cursor );
  11654. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  11655. }
  11656. if(o.opacity) { // opacity option
  11657. if (this.helper.css("opacity")) {
  11658. this._storedOpacity = this.helper.css("opacity");
  11659. }
  11660. this.helper.css("opacity", o.opacity);
  11661. }
  11662. if(o.zIndex) { // zIndex option
  11663. if (this.helper.css("zIndex")) {
  11664. this._storedZIndex = this.helper.css("zIndex");
  11665. }
  11666. this.helper.css("zIndex", o.zIndex);
  11667. }
  11668. //Prepare scrolling
  11669. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  11670. this.overflowOffset = this.scrollParent.offset();
  11671. }
  11672. //Call callbacks
  11673. this._trigger("start", event, this._uiHash());
  11674. //Recache the helper size
  11675. if(!this._preserveHelperProportions) {
  11676. this._cacheHelperProportions();
  11677. }
  11678. //Post "activate" events to possible containers
  11679. if( !noActivation ) {
  11680. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  11681. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  11682. }
  11683. }
  11684. //Prepare possible droppables
  11685. if($.ui.ddmanager) {
  11686. $.ui.ddmanager.current = this;
  11687. }
  11688. if ($.ui.ddmanager && !o.dropBehaviour) {
  11689. $.ui.ddmanager.prepareOffsets(this, event);
  11690. }
  11691. this.dragging = true;
  11692. this.helper.addClass("ui-sortable-helper");
  11693. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  11694. return true;
  11695. },
  11696. _mouseDrag: function(event) {
  11697. var i, item, itemElement, intersection,
  11698. o = this.options,
  11699. scrolled = false;
  11700. //Compute the helpers position
  11701. this.position = this._generatePosition(event);
  11702. this.positionAbs = this._convertPositionTo("absolute");
  11703. if (!this.lastPositionAbs) {
  11704. this.lastPositionAbs = this.positionAbs;
  11705. }
  11706. //Do scrolling
  11707. if(this.options.scroll) {
  11708. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  11709. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  11710. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  11711. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  11712. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  11713. }
  11714. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  11715. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  11716. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  11717. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  11718. }
  11719. } else {
  11720. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  11721. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  11722. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  11723. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  11724. }
  11725. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  11726. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  11727. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  11728. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  11729. }
  11730. }
  11731. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  11732. $.ui.ddmanager.prepareOffsets(this, event);
  11733. }
  11734. }
  11735. //Regenerate the absolute position used for position checks
  11736. this.positionAbs = this._convertPositionTo("absolute");
  11737. //Set the helper position
  11738. if(!this.options.axis || this.options.axis !== "y") {
  11739. this.helper[0].style.left = this.position.left+"px";
  11740. }
  11741. if(!this.options.axis || this.options.axis !== "x") {
  11742. this.helper[0].style.top = this.position.top+"px";
  11743. }
  11744. //Rearrange
  11745. for (i = this.items.length - 1; i >= 0; i--) {
  11746. //Cache variables and intersection, continue if no intersection
  11747. item = this.items[i];
  11748. itemElement = item.item[0];
  11749. intersection = this._intersectsWithPointer(item);
  11750. if (!intersection) {
  11751. continue;
  11752. }
  11753. // Only put the placeholder inside the current Container, skip all
  11754. // items from other containers. This works because when moving
  11755. // an item from one container to another the
  11756. // currentContainer is switched before the placeholder is moved.
  11757. //
  11758. // Without this, moving items in "sub-sortables" can cause
  11759. // the placeholder to jitter between the outer and inner container.
  11760. if (item.instance !== this.currentContainer) {
  11761. continue;
  11762. }
  11763. // cannot intersect with itself
  11764. // no useless actions that have been done before
  11765. // no action if the item moved is the parent of the item checked
  11766. if (itemElement !== this.currentItem[0] &&
  11767. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  11768. !$.contains(this.placeholder[0], itemElement) &&
  11769. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  11770. ) {
  11771. this.direction = intersection === 1 ? "down" : "up";
  11772. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  11773. this._rearrange(event, item);
  11774. } else {
  11775. break;
  11776. }
  11777. this._trigger("change", event, this._uiHash());
  11778. break;
  11779. }
  11780. }
  11781. //Post events to containers
  11782. this._contactContainers(event);
  11783. //Interconnect with droppables
  11784. if($.ui.ddmanager) {
  11785. $.ui.ddmanager.drag(this, event);
  11786. }
  11787. //Call callbacks
  11788. this._trigger("sort", event, this._uiHash());
  11789. this.lastPositionAbs = this.positionAbs;
  11790. return false;
  11791. },
  11792. _mouseStop: function(event, noPropagation) {
  11793. if(!event) {
  11794. return;
  11795. }
  11796. //If we are using droppables, inform the manager about the drop
  11797. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  11798. $.ui.ddmanager.drop(this, event);
  11799. }
  11800. if(this.options.revert) {
  11801. var that = this,
  11802. cur = this.placeholder.offset(),
  11803. axis = this.options.axis,
  11804. animation = {};
  11805. if ( !axis || axis === "x" ) {
  11806. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  11807. }
  11808. if ( !axis || axis === "y" ) {
  11809. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  11810. }
  11811. this.reverting = true;
  11812. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  11813. that._clear(event);
  11814. });
  11815. } else {
  11816. this._clear(event, noPropagation);
  11817. }
  11818. return false;
  11819. },
  11820. cancel: function() {
  11821. if(this.dragging) {
  11822. this._mouseUp({ target: null });
  11823. if(this.options.helper === "original") {
  11824. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  11825. } else {
  11826. this.currentItem.show();
  11827. }
  11828. //Post deactivating events to containers
  11829. for (var i = this.containers.length - 1; i >= 0; i--){
  11830. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  11831. if(this.containers[i].containerCache.over) {
  11832. this.containers[i]._trigger("out", null, this._uiHash(this));
  11833. this.containers[i].containerCache.over = 0;
  11834. }
  11835. }
  11836. }
  11837. if (this.placeholder) {
  11838. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  11839. if(this.placeholder[0].parentNode) {
  11840. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  11841. }
  11842. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  11843. this.helper.remove();
  11844. }
  11845. $.extend(this, {
  11846. helper: null,
  11847. dragging: false,
  11848. reverting: false,
  11849. _noFinalSort: null
  11850. });
  11851. if(this.domPosition.prev) {
  11852. $(this.domPosition.prev).after(this.currentItem);
  11853. } else {
  11854. $(this.domPosition.parent).prepend(this.currentItem);
  11855. }
  11856. }
  11857. return this;
  11858. },
  11859. serialize: function(o) {
  11860. var items = this._getItemsAsjQuery(o && o.connected),
  11861. str = [];
  11862. o = o || {};
  11863. $(items).each(function() {
  11864. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  11865. if (res) {
  11866. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  11867. }
  11868. });
  11869. if(!str.length && o.key) {
  11870. str.push(o.key + "=");
  11871. }
  11872. return str.join("&");
  11873. },
  11874. toArray: function(o) {
  11875. var items = this._getItemsAsjQuery(o && o.connected),
  11876. ret = [];
  11877. o = o || {};
  11878. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  11879. return ret;
  11880. },
  11881. /* Be careful with the following core functions */
  11882. _intersectsWith: function(item) {
  11883. var x1 = this.positionAbs.left,
  11884. x2 = x1 + this.helperProportions.width,
  11885. y1 = this.positionAbs.top,
  11886. y2 = y1 + this.helperProportions.height,
  11887. l = item.left,
  11888. r = l + item.width,
  11889. t = item.top,
  11890. b = t + item.height,
  11891. dyClick = this.offset.click.top,
  11892. dxClick = this.offset.click.left,
  11893. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  11894. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  11895. isOverElement = isOverElementHeight && isOverElementWidth;
  11896. if ( this.options.tolerance === "pointer" ||
  11897. this.options.forcePointerForContainers ||
  11898. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  11899. ) {
  11900. return isOverElement;
  11901. } else {
  11902. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  11903. x2 - (this.helperProportions.width / 2) < r && // Left Half
  11904. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  11905. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  11906. }
  11907. },
  11908. _intersectsWithPointer: function(item) {
  11909. var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  11910. isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  11911. isOverElement = isOverElementHeight && isOverElementWidth,
  11912. verticalDirection = this._getDragVerticalDirection(),
  11913. horizontalDirection = this._getDragHorizontalDirection();
  11914. if (!isOverElement) {
  11915. return false;
  11916. }
  11917. return this.floating ?
  11918. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  11919. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  11920. },
  11921. _intersectsWithSides: function(item) {
  11922. var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  11923. isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  11924. verticalDirection = this._getDragVerticalDirection(),
  11925. horizontalDirection = this._getDragHorizontalDirection();
  11926. if (this.floating && horizontalDirection) {
  11927. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  11928. } else {
  11929. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  11930. }
  11931. },
  11932. _getDragVerticalDirection: function() {
  11933. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  11934. return delta !== 0 && (delta > 0 ? "down" : "up");
  11935. },
  11936. _getDragHorizontalDirection: function() {
  11937. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  11938. return delta !== 0 && (delta > 0 ? "right" : "left");
  11939. },
  11940. refresh: function(event) {
  11941. this._refreshItems(event);
  11942. this._setHandleClassName();
  11943. this.refreshPositions();
  11944. return this;
  11945. },
  11946. _connectWith: function() {
  11947. var options = this.options;
  11948. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  11949. },
  11950. _getItemsAsjQuery: function(connected) {
  11951. var i, j, cur, inst,
  11952. items = [],
  11953. queries = [],
  11954. connectWith = this._connectWith();
  11955. if(connectWith && connected) {
  11956. for (i = connectWith.length - 1; i >= 0; i--){
  11957. cur = $(connectWith[i]);
  11958. for ( j = cur.length - 1; j >= 0; j--){
  11959. inst = $.data(cur[j], this.widgetFullName);
  11960. if(inst && inst !== this && !inst.options.disabled) {
  11961. 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]);
  11962. }
  11963. }
  11964. }
  11965. }
  11966. 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]);
  11967. function addItems() {
  11968. items.push( this );
  11969. }
  11970. for (i = queries.length - 1; i >= 0; i--){
  11971. queries[i][0].each( addItems );
  11972. }
  11973. return $(items);
  11974. },
  11975. _removeCurrentsFromItems: function() {
  11976. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  11977. this.items = $.grep(this.items, function (item) {
  11978. for (var j=0; j < list.length; j++) {
  11979. if(list[j] === item.item[0]) {
  11980. return false;
  11981. }
  11982. }
  11983. return true;
  11984. });
  11985. },
  11986. _refreshItems: function(event) {
  11987. this.items = [];
  11988. this.containers = [this];
  11989. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  11990. items = this.items,
  11991. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  11992. connectWith = this._connectWith();
  11993. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  11994. for (i = connectWith.length - 1; i >= 0; i--){
  11995. cur = $(connectWith[i]);
  11996. for (j = cur.length - 1; j >= 0; j--){
  11997. inst = $.data(cur[j], this.widgetFullName);
  11998. if(inst && inst !== this && !inst.options.disabled) {
  11999. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  12000. this.containers.push(inst);
  12001. }
  12002. }
  12003. }
  12004. }
  12005. for (i = queries.length - 1; i >= 0; i--) {
  12006. targetData = queries[i][1];
  12007. _queries = queries[i][0];
  12008. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  12009. item = $(_queries[j]);
  12010. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  12011. items.push({
  12012. item: item,
  12013. instance: targetData,
  12014. width: 0, height: 0,
  12015. left: 0, top: 0
  12016. });
  12017. }
  12018. }
  12019. },
  12020. refreshPositions: function(fast) {
  12021. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  12022. if(this.offsetParent && this.helper) {
  12023. this.offset.parent = this._getParentOffset();
  12024. }
  12025. var i, item, t, p;
  12026. for (i = this.items.length - 1; i >= 0; i--){
  12027. item = this.items[i];
  12028. //We ignore calculating positions of all connected containers when we're not over them
  12029. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  12030. continue;
  12031. }
  12032. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  12033. if (!fast) {
  12034. item.width = t.outerWidth();
  12035. item.height = t.outerHeight();
  12036. }
  12037. p = t.offset();
  12038. item.left = p.left;
  12039. item.top = p.top;
  12040. }
  12041. if(this.options.custom && this.options.custom.refreshContainers) {
  12042. this.options.custom.refreshContainers.call(this);
  12043. } else {
  12044. for (i = this.containers.length - 1; i >= 0; i--){
  12045. p = this.containers[i].element.offset();
  12046. this.containers[i].containerCache.left = p.left;
  12047. this.containers[i].containerCache.top = p.top;
  12048. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  12049. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  12050. }
  12051. }
  12052. return this;
  12053. },
  12054. _createPlaceholder: function(that) {
  12055. that = that || this;
  12056. var className,
  12057. o = that.options;
  12058. if(!o.placeholder || o.placeholder.constructor === String) {
  12059. className = o.placeholder;
  12060. o.placeholder = {
  12061. element: function() {
  12062. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  12063. element = $( "<" + nodeName + ">", that.document[0] )
  12064. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  12065. .removeClass("ui-sortable-helper");
  12066. if ( nodeName === "tr" ) {
  12067. that.currentItem.children().each(function() {
  12068. $( "<td>&#160;</td>", that.document[0] )
  12069. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  12070. .appendTo( element );
  12071. });
  12072. } else if ( nodeName === "img" ) {
  12073. element.attr( "src", that.currentItem.attr( "src" ) );
  12074. }
  12075. if ( !className ) {
  12076. element.css( "visibility", "hidden" );
  12077. }
  12078. return element;
  12079. },
  12080. update: function(container, p) {
  12081. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  12082. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  12083. if(className && !o.forcePlaceholderSize) {
  12084. return;
  12085. }
  12086. //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
  12087. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  12088. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  12089. }
  12090. };
  12091. }
  12092. //Create the placeholder
  12093. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  12094. //Append it after the actual current item
  12095. that.currentItem.after(that.placeholder);
  12096. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  12097. o.placeholder.update(that, that.placeholder);
  12098. },
  12099. _contactContainers: function(event) {
  12100. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
  12101. innermostContainer = null,
  12102. innermostIndex = null;
  12103. // get innermost container that intersects with item
  12104. for (i = this.containers.length - 1; i >= 0; i--) {
  12105. // never consider a container that's located within the item itself
  12106. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  12107. continue;
  12108. }
  12109. if(this._intersectsWith(this.containers[i].containerCache)) {
  12110. // if we've already found a container and it's more "inner" than this, then continue
  12111. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  12112. continue;
  12113. }
  12114. innermostContainer = this.containers[i];
  12115. innermostIndex = i;
  12116. } else {
  12117. // container doesn't intersect. trigger "out" event if necessary
  12118. if(this.containers[i].containerCache.over) {
  12119. this.containers[i]._trigger("out", event, this._uiHash(this));
  12120. this.containers[i].containerCache.over = 0;
  12121. }
  12122. }
  12123. }
  12124. // if no intersecting containers found, return
  12125. if(!innermostContainer) {
  12126. return;
  12127. }
  12128. // move the item into the container if it's not there already
  12129. if(this.containers.length === 1) {
  12130. if (!this.containers[innermostIndex].containerCache.over) {
  12131. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  12132. this.containers[innermostIndex].containerCache.over = 1;
  12133. }
  12134. } else {
  12135. //When entering a new container, we will find the item with the least distance and append our item near it
  12136. dist = 10000;
  12137. itemWithLeastDistance = null;
  12138. floating = innermostContainer.floating || this._isFloating(this.currentItem);
  12139. posProperty = floating ? "left" : "top";
  12140. sizeProperty = floating ? "width" : "height";
  12141. axis = floating ? "clientX" : "clientY";
  12142. for (j = this.items.length - 1; j >= 0; j--) {
  12143. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  12144. continue;
  12145. }
  12146. if(this.items[j].item[0] === this.currentItem[0]) {
  12147. continue;
  12148. }
  12149. cur = this.items[j].item.offset()[posProperty];
  12150. nearBottom = false;
  12151. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  12152. nearBottom = true;
  12153. }
  12154. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  12155. dist = Math.abs( event[ axis ] - cur );
  12156. itemWithLeastDistance = this.items[ j ];
  12157. this.direction = nearBottom ? "up": "down";
  12158. }
  12159. }
  12160. //Check if dropOnEmpty is enabled
  12161. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  12162. return;
  12163. }
  12164. if(this.currentContainer === this.containers[innermostIndex]) {
  12165. return;
  12166. }
  12167. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  12168. this._trigger("change", event, this._uiHash());
  12169. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  12170. this.currentContainer = this.containers[innermostIndex];
  12171. //Update the placeholder
  12172. this.options.placeholder.update(this.currentContainer, this.placeholder);
  12173. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  12174. this.containers[innermostIndex].containerCache.over = 1;
  12175. }
  12176. },
  12177. _createHelper: function(event) {
  12178. var o = this.options,
  12179. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  12180. //Add the helper to the DOM if that didn't happen already
  12181. if(!helper.parents("body").length) {
  12182. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  12183. }
  12184. if(helper[0] === this.currentItem[0]) {
  12185. 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") };
  12186. }
  12187. if(!helper[0].style.width || o.forceHelperSize) {
  12188. helper.width(this.currentItem.width());
  12189. }
  12190. if(!helper[0].style.height || o.forceHelperSize) {
  12191. helper.height(this.currentItem.height());
  12192. }
  12193. return helper;
  12194. },
  12195. _adjustOffsetFromHelper: function(obj) {
  12196. if (typeof obj === "string") {
  12197. obj = obj.split(" ");
  12198. }
  12199. if ($.isArray(obj)) {
  12200. obj = {left: +obj[0], top: +obj[1] || 0};
  12201. }
  12202. if ("left" in obj) {
  12203. this.offset.click.left = obj.left + this.margins.left;
  12204. }
  12205. if ("right" in obj) {
  12206. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  12207. }
  12208. if ("top" in obj) {
  12209. this.offset.click.top = obj.top + this.margins.top;
  12210. }
  12211. if ("bottom" in obj) {
  12212. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  12213. }
  12214. },
  12215. _getParentOffset: function() {
  12216. //Get the offsetParent and cache its position
  12217. this.offsetParent = this.helper.offsetParent();
  12218. var po = this.offsetParent.offset();
  12219. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  12220. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  12221. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  12222. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  12223. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  12224. po.left += this.scrollParent.scrollLeft();
  12225. po.top += this.scrollParent.scrollTop();
  12226. }
  12227. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  12228. // with an ugly IE fix
  12229. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  12230. po = { top: 0, left: 0 };
  12231. }
  12232. return {
  12233. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  12234. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  12235. };
  12236. },
  12237. _getRelativeOffset: function() {
  12238. if(this.cssPosition === "relative") {
  12239. var p = this.currentItem.position();
  12240. return {
  12241. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  12242. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  12243. };
  12244. } else {
  12245. return { top: 0, left: 0 };
  12246. }
  12247. },
  12248. _cacheMargins: function() {
  12249. this.margins = {
  12250. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  12251. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  12252. };
  12253. },
  12254. _cacheHelperProportions: function() {
  12255. this.helperProportions = {
  12256. width: this.helper.outerWidth(),
  12257. height: this.helper.outerHeight()
  12258. };
  12259. },
  12260. _setContainment: function() {
  12261. var ce, co, over,
  12262. o = this.options;
  12263. if(o.containment === "parent") {
  12264. o.containment = this.helper[0].parentNode;
  12265. }
  12266. if(o.containment === "document" || o.containment === "window") {
  12267. this.containment = [
  12268. 0 - this.offset.relative.left - this.offset.parent.left,
  12269. 0 - this.offset.relative.top - this.offset.parent.top,
  12270. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  12271. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  12272. ];
  12273. }
  12274. if(!(/^(document|window|parent)$/).test(o.containment)) {
  12275. ce = $(o.containment)[0];
  12276. co = $(o.containment).offset();
  12277. over = ($(ce).css("overflow") !== "hidden");
  12278. this.containment = [
  12279. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  12280. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  12281. 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,
  12282. 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
  12283. ];
  12284. }
  12285. },
  12286. _convertPositionTo: function(d, pos) {
  12287. if(!pos) {
  12288. pos = this.position;
  12289. }
  12290. var mod = d === "absolute" ? 1 : -1,
  12291. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  12292. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  12293. return {
  12294. top: (
  12295. pos.top + // The absolute mouse position
  12296. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  12297. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  12298. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  12299. ),
  12300. left: (
  12301. pos.left + // The absolute mouse position
  12302. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  12303. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  12304. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  12305. )
  12306. };
  12307. },
  12308. _generatePosition: function(event) {
  12309. var top, left,
  12310. o = this.options,
  12311. pageX = event.pageX,
  12312. pageY = event.pageY,
  12313. 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);
  12314. // This is another very weird special case that only happens for relative elements:
  12315. // 1. If the css position is relative
  12316. // 2. and the scroll parent is the document or similar to the offset parent
  12317. // we have to refresh the relative offset during the scroll so there are no jumps
  12318. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  12319. this.offset.relative = this._getRelativeOffset();
  12320. }
  12321. /*
  12322. * - Position constraining -
  12323. * Constrain the position to a mix of grid, containment.
  12324. */
  12325. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  12326. if(this.containment) {
  12327. if(event.pageX - this.offset.click.left < this.containment[0]) {
  12328. pageX = this.containment[0] + this.offset.click.left;
  12329. }
  12330. if(event.pageY - this.offset.click.top < this.containment[1]) {
  12331. pageY = this.containment[1] + this.offset.click.top;
  12332. }
  12333. if(event.pageX - this.offset.click.left > this.containment[2]) {
  12334. pageX = this.containment[2] + this.offset.click.left;
  12335. }
  12336. if(event.pageY - this.offset.click.top > this.containment[3]) {
  12337. pageY = this.containment[3] + this.offset.click.top;
  12338. }
  12339. }
  12340. if(o.grid) {
  12341. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  12342. 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;
  12343. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  12344. 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;
  12345. }
  12346. }
  12347. return {
  12348. top: (
  12349. pageY - // The absolute mouse position
  12350. this.offset.click.top - // Click offset (relative to the element)
  12351. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  12352. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  12353. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  12354. ),
  12355. left: (
  12356. pageX - // The absolute mouse position
  12357. this.offset.click.left - // Click offset (relative to the element)
  12358. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  12359. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  12360. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  12361. )
  12362. };
  12363. },
  12364. _rearrange: function(event, i, a, hardRefresh) {
  12365. 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));
  12366. //Various things done here to improve the performance:
  12367. // 1. we create a setTimeout, that calls refreshPositions
  12368. // 2. on the instance, we have a counter variable, that get's higher after every append
  12369. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  12370. // 4. this lets only the last addition to the timeout stack through
  12371. this.counter = this.counter ? ++this.counter : 1;
  12372. var counter = this.counter;
  12373. this._delay(function() {
  12374. if(counter === this.counter) {
  12375. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  12376. }
  12377. });
  12378. },
  12379. _clear: function(event, noPropagation) {
  12380. this.reverting = false;
  12381. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  12382. // everything else normalized again
  12383. var i,
  12384. delayedTriggers = [];
  12385. // We first have to update the dom position of the actual currentItem
  12386. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  12387. if(!this._noFinalSort && this.currentItem.parent().length) {
  12388. this.placeholder.before(this.currentItem);
  12389. }
  12390. this._noFinalSort = null;
  12391. if(this.helper[0] === this.currentItem[0]) {
  12392. for(i in this._storedCSS) {
  12393. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  12394. this._storedCSS[i] = "";
  12395. }
  12396. }
  12397. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  12398. } else {
  12399. this.currentItem.show();
  12400. }
  12401. if(this.fromOutside && !noPropagation) {
  12402. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  12403. }
  12404. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  12405. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  12406. }
  12407. // Check if the items Container has Changed and trigger appropriate
  12408. // events.
  12409. if (this !== this.currentContainer) {
  12410. if(!noPropagation) {
  12411. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  12412. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  12413. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  12414. }
  12415. }
  12416. //Post events to containers
  12417. function delayEvent( type, instance, container ) {
  12418. return function( event ) {
  12419. container._trigger( type, event, instance._uiHash( instance ) );
  12420. };
  12421. }
  12422. for (i = this.containers.length - 1; i >= 0; i--){
  12423. if (!noPropagation) {
  12424. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  12425. }
  12426. if(this.containers[i].containerCache.over) {
  12427. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  12428. this.containers[i].containerCache.over = 0;
  12429. }
  12430. }
  12431. //Do what was originally in plugins
  12432. if ( this.storedCursor ) {
  12433. this.document.find( "body" ).css( "cursor", this.storedCursor );
  12434. this.storedStylesheet.remove();
  12435. }
  12436. if(this._storedOpacity) {
  12437. this.helper.css("opacity", this._storedOpacity);
  12438. }
  12439. if(this._storedZIndex) {
  12440. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  12441. }
  12442. this.dragging = false;
  12443. if(this.cancelHelperRemoval) {
  12444. if(!noPropagation) {
  12445. this._trigger("beforeStop", event, this._uiHash());
  12446. for (i=0; i < delayedTriggers.length; i++) {
  12447. delayedTriggers[i].call(this, event);
  12448. } //Trigger all delayed events
  12449. this._trigger("stop", event, this._uiHash());
  12450. }
  12451. this.fromOutside = false;
  12452. return false;
  12453. }
  12454. if(!noPropagation) {
  12455. this._trigger("beforeStop", event, this._uiHash());
  12456. }
  12457. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  12458. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  12459. if(this.helper[0] !== this.currentItem[0]) {
  12460. this.helper.remove();
  12461. }
  12462. this.helper = null;
  12463. if(!noPropagation) {
  12464. for (i=0; i < delayedTriggers.length; i++) {
  12465. delayedTriggers[i].call(this, event);
  12466. } //Trigger all delayed events
  12467. this._trigger("stop", event, this._uiHash());
  12468. }
  12469. this.fromOutside = false;
  12470. return true;
  12471. },
  12472. _trigger: function() {
  12473. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  12474. this.cancel();
  12475. }
  12476. },
  12477. _uiHash: function(_inst) {
  12478. var inst = _inst || this;
  12479. return {
  12480. helper: inst.helper,
  12481. placeholder: inst.placeholder || $([]),
  12482. position: inst.position,
  12483. originalPosition: inst.originalPosition,
  12484. offset: inst.positionAbs,
  12485. item: inst.currentItem,
  12486. sender: _inst ? _inst.element : null
  12487. };
  12488. }
  12489. });
  12490. /*!
  12491. * jQuery UI Spinner 1.11.1
  12492. * http://jqueryui.com
  12493. *
  12494. * Copyright 2014 jQuery Foundation and other contributors
  12495. * Released under the MIT license.
  12496. * http://jquery.org/license
  12497. *
  12498. * http://api.jqueryui.com/spinner/
  12499. */
  12500. function spinner_modifier( fn ) {
  12501. return function() {
  12502. var previous = this.element.val();
  12503. fn.apply( this, arguments );
  12504. this._refresh();
  12505. if ( previous !== this.element.val() ) {
  12506. this._trigger( "change" );
  12507. }
  12508. };
  12509. }
  12510. var spinner = $.widget( "ui.spinner", {
  12511. version: "1.11.1",
  12512. defaultElement: "<input>",
  12513. widgetEventPrefix: "spin",
  12514. options: {
  12515. culture: null,
  12516. icons: {
  12517. down: "ui-icon-triangle-1-s",
  12518. up: "ui-icon-triangle-1-n"
  12519. },
  12520. incremental: true,
  12521. max: null,
  12522. min: null,
  12523. numberFormat: null,
  12524. page: 10,
  12525. step: 1,
  12526. change: null,
  12527. spin: null,
  12528. start: null,
  12529. stop: null
  12530. },
  12531. _create: function() {
  12532. // handle string values that need to be parsed
  12533. this._setOption( "max", this.options.max );
  12534. this._setOption( "min", this.options.min );
  12535. this._setOption( "step", this.options.step );
  12536. // Only format if there is a value, prevents the field from being marked
  12537. // as invalid in Firefox, see #9573.
  12538. if ( this.value() !== "" ) {
  12539. // Format the value, but don't constrain.
  12540. this._value( this.element.val(), true );
  12541. }
  12542. this._draw();
  12543. this._on( this._events );
  12544. this._refresh();
  12545. // turning off autocomplete prevents the browser from remembering the
  12546. // value when navigating through history, so we re-enable autocomplete
  12547. // if the page is unloaded before the widget is destroyed. #7790
  12548. this._on( this.window, {
  12549. beforeunload: function() {
  12550. this.element.removeAttr( "autocomplete" );
  12551. }
  12552. });
  12553. },
  12554. _getCreateOptions: function() {
  12555. var options = {},
  12556. element = this.element;
  12557. $.each( [ "min", "max", "step" ], function( i, option ) {
  12558. var value = element.attr( option );
  12559. if ( value !== undefined && value.length ) {
  12560. options[ option ] = value;
  12561. }
  12562. });
  12563. return options;
  12564. },
  12565. _events: {
  12566. keydown: function( event ) {
  12567. if ( this._start( event ) && this._keydown( event ) ) {
  12568. event.preventDefault();
  12569. }
  12570. },
  12571. keyup: "_stop",
  12572. focus: function() {
  12573. this.previous = this.element.val();
  12574. },
  12575. blur: function( event ) {
  12576. if ( this.cancelBlur ) {
  12577. delete this.cancelBlur;
  12578. return;
  12579. }
  12580. this._stop();
  12581. this._refresh();
  12582. if ( this.previous !== this.element.val() ) {
  12583. this._trigger( "change", event );
  12584. }
  12585. },
  12586. mousewheel: function( event, delta ) {
  12587. if ( !delta ) {
  12588. return;
  12589. }
  12590. if ( !this.spinning && !this._start( event ) ) {
  12591. return false;
  12592. }
  12593. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  12594. clearTimeout( this.mousewheelTimer );
  12595. this.mousewheelTimer = this._delay(function() {
  12596. if ( this.spinning ) {
  12597. this._stop( event );
  12598. }
  12599. }, 100 );
  12600. event.preventDefault();
  12601. },
  12602. "mousedown .ui-spinner-button": function( event ) {
  12603. var previous;
  12604. // We never want the buttons to have focus; whenever the user is
  12605. // interacting with the spinner, the focus should be on the input.
  12606. // If the input is focused then this.previous is properly set from
  12607. // when the input first received focus. If the input is not focused
  12608. // then we need to set this.previous based on the value before spinning.
  12609. previous = this.element[0] === this.document[0].activeElement ?
  12610. this.previous : this.element.val();
  12611. function checkFocus() {
  12612. var isActive = this.element[0] === this.document[0].activeElement;
  12613. if ( !isActive ) {
  12614. this.element.focus();
  12615. this.previous = previous;
  12616. // support: IE
  12617. // IE sets focus asynchronously, so we need to check if focus
  12618. // moved off of the input because the user clicked on the button.
  12619. this._delay(function() {
  12620. this.previous = previous;
  12621. });
  12622. }
  12623. }
  12624. // ensure focus is on (or stays on) the text field
  12625. event.preventDefault();
  12626. checkFocus.call( this );
  12627. // support: IE
  12628. // IE doesn't prevent moving focus even with event.preventDefault()
  12629. // so we set a flag to know when we should ignore the blur event
  12630. // and check (again) if focus moved off of the input.
  12631. this.cancelBlur = true;
  12632. this._delay(function() {
  12633. delete this.cancelBlur;
  12634. checkFocus.call( this );
  12635. });
  12636. if ( this._start( event ) === false ) {
  12637. return;
  12638. }
  12639. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  12640. },
  12641. "mouseup .ui-spinner-button": "_stop",
  12642. "mouseenter .ui-spinner-button": function( event ) {
  12643. // button will add ui-state-active if mouse was down while mouseleave and kept down
  12644. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  12645. return;
  12646. }
  12647. if ( this._start( event ) === false ) {
  12648. return false;
  12649. }
  12650. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  12651. },
  12652. // TODO: do we really want to consider this a stop?
  12653. // shouldn't we just stop the repeater and wait until mouseup before
  12654. // we trigger the stop event?
  12655. "mouseleave .ui-spinner-button": "_stop"
  12656. },
  12657. _draw: function() {
  12658. var uiSpinner = this.uiSpinner = this.element
  12659. .addClass( "ui-spinner-input" )
  12660. .attr( "autocomplete", "off" )
  12661. .wrap( this._uiSpinnerHtml() )
  12662. .parent()
  12663. // add buttons
  12664. .append( this._buttonHtml() );
  12665. this.element.attr( "role", "spinbutton" );
  12666. // button bindings
  12667. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  12668. .attr( "tabIndex", -1 )
  12669. .button()
  12670. .removeClass( "ui-corner-all" );
  12671. // IE 6 doesn't understand height: 50% for the buttons
  12672. // unless the wrapper has an explicit height
  12673. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  12674. uiSpinner.height() > 0 ) {
  12675. uiSpinner.height( uiSpinner.height() );
  12676. }
  12677. // disable spinner if element was already disabled
  12678. if ( this.options.disabled ) {
  12679. this.disable();
  12680. }
  12681. },
  12682. _keydown: function( event ) {
  12683. var options = this.options,
  12684. keyCode = $.ui.keyCode;
  12685. switch ( event.keyCode ) {
  12686. case keyCode.UP:
  12687. this._repeat( null, 1, event );
  12688. return true;
  12689. case keyCode.DOWN:
  12690. this._repeat( null, -1, event );
  12691. return true;
  12692. case keyCode.PAGE_UP:
  12693. this._repeat( null, options.page, event );
  12694. return true;
  12695. case keyCode.PAGE_DOWN:
  12696. this._repeat( null, -options.page, event );
  12697. return true;
  12698. }
  12699. return false;
  12700. },
  12701. _uiSpinnerHtml: function() {
  12702. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  12703. },
  12704. _buttonHtml: function() {
  12705. return "" +
  12706. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  12707. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  12708. "</a>" +
  12709. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  12710. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  12711. "</a>";
  12712. },
  12713. _start: function( event ) {
  12714. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  12715. return false;
  12716. }
  12717. if ( !this.counter ) {
  12718. this.counter = 1;
  12719. }
  12720. this.spinning = true;
  12721. return true;
  12722. },
  12723. _repeat: function( i, steps, event ) {
  12724. i = i || 500;
  12725. clearTimeout( this.timer );
  12726. this.timer = this._delay(function() {
  12727. this._repeat( 40, steps, event );
  12728. }, i );
  12729. this._spin( steps * this.options.step, event );
  12730. },
  12731. _spin: function( step, event ) {
  12732. var value = this.value() || 0;
  12733. if ( !this.counter ) {
  12734. this.counter = 1;
  12735. }
  12736. value = this._adjustValue( value + step * this._increment( this.counter ) );
  12737. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  12738. this._value( value );
  12739. this.counter++;
  12740. }
  12741. },
  12742. _increment: function( i ) {
  12743. var incremental = this.options.incremental;
  12744. if ( incremental ) {
  12745. return $.isFunction( incremental ) ?
  12746. incremental( i ) :
  12747. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  12748. }
  12749. return 1;
  12750. },
  12751. _precision: function() {
  12752. var precision = this._precisionOf( this.options.step );
  12753. if ( this.options.min !== null ) {
  12754. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  12755. }
  12756. return precision;
  12757. },
  12758. _precisionOf: function( num ) {
  12759. var str = num.toString(),
  12760. decimal = str.indexOf( "." );
  12761. return decimal === -1 ? 0 : str.length - decimal - 1;
  12762. },
  12763. _adjustValue: function( value ) {
  12764. var base, aboveMin,
  12765. options = this.options;
  12766. // make sure we're at a valid step
  12767. // - find out where we are relative to the base (min or 0)
  12768. base = options.min !== null ? options.min : 0;
  12769. aboveMin = value - base;
  12770. // - round to the nearest step
  12771. aboveMin = Math.round(aboveMin / options.step) * options.step;
  12772. // - rounding is based on 0, so adjust back to our base
  12773. value = base + aboveMin;
  12774. // fix precision from bad JS floating point math
  12775. value = parseFloat( value.toFixed( this._precision() ) );
  12776. // clamp the value
  12777. if ( options.max !== null && value > options.max) {
  12778. return options.max;
  12779. }
  12780. if ( options.min !== null && value < options.min ) {
  12781. return options.min;
  12782. }
  12783. return value;
  12784. },
  12785. _stop: function( event ) {
  12786. if ( !this.spinning ) {
  12787. return;
  12788. }
  12789. clearTimeout( this.timer );
  12790. clearTimeout( this.mousewheelTimer );
  12791. this.counter = 0;
  12792. this.spinning = false;
  12793. this._trigger( "stop", event );
  12794. },
  12795. _setOption: function( key, value ) {
  12796. if ( key === "culture" || key === "numberFormat" ) {
  12797. var prevValue = this._parse( this.element.val() );
  12798. this.options[ key ] = value;
  12799. this.element.val( this._format( prevValue ) );
  12800. return;
  12801. }
  12802. if ( key === "max" || key === "min" || key === "step" ) {
  12803. if ( typeof value === "string" ) {
  12804. value = this._parse( value );
  12805. }
  12806. }
  12807. if ( key === "icons" ) {
  12808. this.buttons.first().find( ".ui-icon" )
  12809. .removeClass( this.options.icons.up )
  12810. .addClass( value.up );
  12811. this.buttons.last().find( ".ui-icon" )
  12812. .removeClass( this.options.icons.down )
  12813. .addClass( value.down );
  12814. }
  12815. this._super( key, value );
  12816. if ( key === "disabled" ) {
  12817. this.widget().toggleClass( "ui-state-disabled", !!value );
  12818. this.element.prop( "disabled", !!value );
  12819. this.buttons.button( value ? "disable" : "enable" );
  12820. }
  12821. },
  12822. _setOptions: spinner_modifier(function( options ) {
  12823. this._super( options );
  12824. }),
  12825. _parse: function( val ) {
  12826. if ( typeof val === "string" && val !== "" ) {
  12827. val = window.Globalize && this.options.numberFormat ?
  12828. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  12829. }
  12830. return val === "" || isNaN( val ) ? null : val;
  12831. },
  12832. _format: function( value ) {
  12833. if ( value === "" ) {
  12834. return "";
  12835. }
  12836. return window.Globalize && this.options.numberFormat ?
  12837. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  12838. value;
  12839. },
  12840. _refresh: function() {
  12841. this.element.attr({
  12842. "aria-valuemin": this.options.min,
  12843. "aria-valuemax": this.options.max,
  12844. // TODO: what should we do with values that can't be parsed?
  12845. "aria-valuenow": this._parse( this.element.val() )
  12846. });
  12847. },
  12848. isValid: function() {
  12849. var value = this.value();
  12850. // null is invalid
  12851. if ( value === null ) {
  12852. return false;
  12853. }
  12854. // if value gets adjusted, it's invalid
  12855. return value === this._adjustValue( value );
  12856. },
  12857. // update the value without triggering change
  12858. _value: function( value, allowAny ) {
  12859. var parsed;
  12860. if ( value !== "" ) {
  12861. parsed = this._parse( value );
  12862. if ( parsed !== null ) {
  12863. if ( !allowAny ) {
  12864. parsed = this._adjustValue( parsed );
  12865. }
  12866. value = this._format( parsed );
  12867. }
  12868. }
  12869. this.element.val( value );
  12870. this._refresh();
  12871. },
  12872. _destroy: function() {
  12873. this.element
  12874. .removeClass( "ui-spinner-input" )
  12875. .prop( "disabled", false )
  12876. .removeAttr( "autocomplete" )
  12877. .removeAttr( "role" )
  12878. .removeAttr( "aria-valuemin" )
  12879. .removeAttr( "aria-valuemax" )
  12880. .removeAttr( "aria-valuenow" );
  12881. this.uiSpinner.replaceWith( this.element );
  12882. },
  12883. stepUp: spinner_modifier(function( steps ) {
  12884. this._stepUp( steps );
  12885. }),
  12886. _stepUp: function( steps ) {
  12887. if ( this._start() ) {
  12888. this._spin( (steps || 1) * this.options.step );
  12889. this._stop();
  12890. }
  12891. },
  12892. stepDown: spinner_modifier(function( steps ) {
  12893. this._stepDown( steps );
  12894. }),
  12895. _stepDown: function( steps ) {
  12896. if ( this._start() ) {
  12897. this._spin( (steps || 1) * -this.options.step );
  12898. this._stop();
  12899. }
  12900. },
  12901. pageUp: spinner_modifier(function( pages ) {
  12902. this._stepUp( (pages || 1) * this.options.page );
  12903. }),
  12904. pageDown: spinner_modifier(function( pages ) {
  12905. this._stepDown( (pages || 1) * this.options.page );
  12906. }),
  12907. value: function( newVal ) {
  12908. if ( !arguments.length ) {
  12909. return this._parse( this.element.val() );
  12910. }
  12911. spinner_modifier( this._value ).call( this, newVal );
  12912. },
  12913. widget: function() {
  12914. return this.uiSpinner;
  12915. }
  12916. });
  12917. /*!
  12918. * jQuery UI Tabs 1.11.1
  12919. * http://jqueryui.com
  12920. *
  12921. * Copyright 2014 jQuery Foundation and other contributors
  12922. * Released under the MIT license.
  12923. * http://jquery.org/license
  12924. *
  12925. * http://api.jqueryui.com/tabs/
  12926. */
  12927. var tabs = $.widget( "ui.tabs", {
  12928. version: "1.11.1",
  12929. delay: 300,
  12930. options: {
  12931. active: null,
  12932. collapsible: false,
  12933. event: "click",
  12934. heightStyle: "content",
  12935. hide: null,
  12936. show: null,
  12937. // callbacks
  12938. activate: null,
  12939. beforeActivate: null,
  12940. beforeLoad: null,
  12941. load: null
  12942. },
  12943. _isLocal: (function() {
  12944. var rhash = /#.*$/;
  12945. return function( anchor ) {
  12946. var anchorUrl, locationUrl;
  12947. // support: IE7
  12948. // IE7 doesn't normalize the href property when set via script (#9317)
  12949. anchor = anchor.cloneNode( false );
  12950. anchorUrl = anchor.href.replace( rhash, "" );
  12951. locationUrl = location.href.replace( rhash, "" );
  12952. // decoding may throw an error if the URL isn't UTF-8 (#9518)
  12953. try {
  12954. anchorUrl = decodeURIComponent( anchorUrl );
  12955. } catch ( error ) {}
  12956. try {
  12957. locationUrl = decodeURIComponent( locationUrl );
  12958. } catch ( error ) {}
  12959. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  12960. };
  12961. })(),
  12962. _create: function() {
  12963. var that = this,
  12964. options = this.options;
  12965. this.running = false;
  12966. this.element
  12967. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  12968. .toggleClass( "ui-tabs-collapsible", options.collapsible );
  12969. this._processTabs();
  12970. options.active = this._initialActive();
  12971. // Take disabling tabs via class attribute from HTML
  12972. // into account and update option properly.
  12973. if ( $.isArray( options.disabled ) ) {
  12974. options.disabled = $.unique( options.disabled.concat(
  12975. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  12976. return that.tabs.index( li );
  12977. })
  12978. ) ).sort();
  12979. }
  12980. // check for length avoids error when initializing empty list
  12981. if ( this.options.active !== false && this.anchors.length ) {
  12982. this.active = this._findActive( options.active );
  12983. } else {
  12984. this.active = $();
  12985. }
  12986. this._refresh();
  12987. if ( this.active.length ) {
  12988. this.load( options.active );
  12989. }
  12990. },
  12991. _initialActive: function() {
  12992. var active = this.options.active,
  12993. collapsible = this.options.collapsible,
  12994. locationHash = location.hash.substring( 1 );
  12995. if ( active === null ) {
  12996. // check the fragment identifier in the URL
  12997. if ( locationHash ) {
  12998. this.tabs.each(function( i, tab ) {
  12999. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  13000. active = i;
  13001. return false;
  13002. }
  13003. });
  13004. }
  13005. // check for a tab marked active via a class
  13006. if ( active === null ) {
  13007. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  13008. }
  13009. // no active tab, set to false
  13010. if ( active === null || active === -1 ) {
  13011. active = this.tabs.length ? 0 : false;
  13012. }
  13013. }
  13014. // handle numbers: negative, out of range
  13015. if ( active !== false ) {
  13016. active = this.tabs.index( this.tabs.eq( active ) );
  13017. if ( active === -1 ) {
  13018. active = collapsible ? false : 0;
  13019. }
  13020. }
  13021. // don't allow collapsible: false and active: false
  13022. if ( !collapsible && active === false && this.anchors.length ) {
  13023. active = 0;
  13024. }
  13025. return active;
  13026. },
  13027. _getCreateEventData: function() {
  13028. return {
  13029. tab: this.active,
  13030. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  13031. };
  13032. },
  13033. _tabKeydown: function( event ) {
  13034. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  13035. selectedIndex = this.tabs.index( focusedTab ),
  13036. goingForward = true;
  13037. if ( this._handlePageNav( event ) ) {
  13038. return;
  13039. }
  13040. switch ( event.keyCode ) {
  13041. case $.ui.keyCode.RIGHT:
  13042. case $.ui.keyCode.DOWN:
  13043. selectedIndex++;
  13044. break;
  13045. case $.ui.keyCode.UP:
  13046. case $.ui.keyCode.LEFT:
  13047. goingForward = false;
  13048. selectedIndex--;
  13049. break;
  13050. case $.ui.keyCode.END:
  13051. selectedIndex = this.anchors.length - 1;
  13052. break;
  13053. case $.ui.keyCode.HOME:
  13054. selectedIndex = 0;
  13055. break;
  13056. case $.ui.keyCode.SPACE:
  13057. // Activate only, no collapsing
  13058. event.preventDefault();
  13059. clearTimeout( this.activating );
  13060. this._activate( selectedIndex );
  13061. return;
  13062. case $.ui.keyCode.ENTER:
  13063. // Toggle (cancel delayed activation, allow collapsing)
  13064. event.preventDefault();
  13065. clearTimeout( this.activating );
  13066. // Determine if we should collapse or activate
  13067. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  13068. return;
  13069. default:
  13070. return;
  13071. }
  13072. // Focus the appropriate tab, based on which key was pressed
  13073. event.preventDefault();
  13074. clearTimeout( this.activating );
  13075. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  13076. // Navigating with control key will prevent automatic activation
  13077. if ( !event.ctrlKey ) {
  13078. // Update aria-selected immediately so that AT think the tab is already selected.
  13079. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  13080. // but the tab will already be activated by the time the announcement finishes.
  13081. focusedTab.attr( "aria-selected", "false" );
  13082. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  13083. this.activating = this._delay(function() {
  13084. this.option( "active", selectedIndex );
  13085. }, this.delay );
  13086. }
  13087. },
  13088. _panelKeydown: function( event ) {
  13089. if ( this._handlePageNav( event ) ) {
  13090. return;
  13091. }
  13092. // Ctrl+up moves focus to the current tab
  13093. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  13094. event.preventDefault();
  13095. this.active.focus();
  13096. }
  13097. },
  13098. // Alt+page up/down moves focus to the previous/next tab (and activates)
  13099. _handlePageNav: function( event ) {
  13100. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  13101. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  13102. return true;
  13103. }
  13104. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  13105. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  13106. return true;
  13107. }
  13108. },
  13109. _findNextTab: function( index, goingForward ) {
  13110. var lastTabIndex = this.tabs.length - 1;
  13111. function constrain() {
  13112. if ( index > lastTabIndex ) {
  13113. index = 0;
  13114. }
  13115. if ( index < 0 ) {
  13116. index = lastTabIndex;
  13117. }
  13118. return index;
  13119. }
  13120. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  13121. index = goingForward ? index + 1 : index - 1;
  13122. }
  13123. return index;
  13124. },
  13125. _focusNextTab: function( index, goingForward ) {
  13126. index = this._findNextTab( index, goingForward );
  13127. this.tabs.eq( index ).focus();
  13128. return index;
  13129. },
  13130. _setOption: function( key, value ) {
  13131. if ( key === "active" ) {
  13132. // _activate() will handle invalid values and update this.options
  13133. this._activate( value );
  13134. return;
  13135. }
  13136. if ( key === "disabled" ) {
  13137. // don't use the widget factory's disabled handling
  13138. this._setupDisabled( value );
  13139. return;
  13140. }
  13141. this._super( key, value);
  13142. if ( key === "collapsible" ) {
  13143. this.element.toggleClass( "ui-tabs-collapsible", value );
  13144. // Setting collapsible: false while collapsed; open first panel
  13145. if ( !value && this.options.active === false ) {
  13146. this._activate( 0 );
  13147. }
  13148. }
  13149. if ( key === "event" ) {
  13150. this._setupEvents( value );
  13151. }
  13152. if ( key === "heightStyle" ) {
  13153. this._setupHeightStyle( value );
  13154. }
  13155. },
  13156. _sanitizeSelector: function( hash ) {
  13157. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  13158. },
  13159. refresh: function() {
  13160. var options = this.options,
  13161. lis = this.tablist.children( ":has(a[href])" );
  13162. // get disabled tabs from class attribute from HTML
  13163. // this will get converted to a boolean if needed in _refresh()
  13164. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  13165. return lis.index( tab );
  13166. });
  13167. this._processTabs();
  13168. // was collapsed or no tabs
  13169. if ( options.active === false || !this.anchors.length ) {
  13170. options.active = false;
  13171. this.active = $();
  13172. // was active, but active tab is gone
  13173. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  13174. // all remaining tabs are disabled
  13175. if ( this.tabs.length === options.disabled.length ) {
  13176. options.active = false;
  13177. this.active = $();
  13178. // activate previous tab
  13179. } else {
  13180. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  13181. }
  13182. // was active, active tab still exists
  13183. } else {
  13184. // make sure active index is correct
  13185. options.active = this.tabs.index( this.active );
  13186. }
  13187. this._refresh();
  13188. },
  13189. _refresh: function() {
  13190. this._setupDisabled( this.options.disabled );
  13191. this._setupEvents( this.options.event );
  13192. this._setupHeightStyle( this.options.heightStyle );
  13193. this.tabs.not( this.active ).attr({
  13194. "aria-selected": "false",
  13195. "aria-expanded": "false",
  13196. tabIndex: -1
  13197. });
  13198. this.panels.not( this._getPanelForTab( this.active ) )
  13199. .hide()
  13200. .attr({
  13201. "aria-hidden": "true"
  13202. });
  13203. // Make sure one tab is in the tab order
  13204. if ( !this.active.length ) {
  13205. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  13206. } else {
  13207. this.active
  13208. .addClass( "ui-tabs-active ui-state-active" )
  13209. .attr({
  13210. "aria-selected": "true",
  13211. "aria-expanded": "true",
  13212. tabIndex: 0
  13213. });
  13214. this._getPanelForTab( this.active )
  13215. .show()
  13216. .attr({
  13217. "aria-hidden": "false"
  13218. });
  13219. }
  13220. },
  13221. _processTabs: function() {
  13222. var that = this;
  13223. this.tablist = this._getList()
  13224. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  13225. .attr( "role", "tablist" )
  13226. // Prevent users from focusing disabled tabs via click
  13227. .delegate( "> li", "mousedown" + this.eventNamespace, function( event ) {
  13228. if ( $( this ).is( ".ui-state-disabled" ) ) {
  13229. event.preventDefault();
  13230. }
  13231. })
  13232. // support: IE <9
  13233. // Preventing the default action in mousedown doesn't prevent IE
  13234. // from focusing the element, so if the anchor gets focused, blur.
  13235. // We don't have to worry about focusing the previously focused
  13236. // element since clicking on a non-focusable element should focus
  13237. // the body anyway.
  13238. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  13239. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  13240. this.blur();
  13241. }
  13242. });
  13243. this.tabs = this.tablist.find( "> li:has(a[href])" )
  13244. .addClass( "ui-state-default ui-corner-top" )
  13245. .attr({
  13246. role: "tab",
  13247. tabIndex: -1
  13248. });
  13249. this.anchors = this.tabs.map(function() {
  13250. return $( "a", this )[ 0 ];
  13251. })
  13252. .addClass( "ui-tabs-anchor" )
  13253. .attr({
  13254. role: "presentation",
  13255. tabIndex: -1
  13256. });
  13257. this.panels = $();
  13258. this.anchors.each(function( i, anchor ) {
  13259. var selector, panel, panelId,
  13260. anchorId = $( anchor ).uniqueId().attr( "id" ),
  13261. tab = $( anchor ).closest( "li" ),
  13262. originalAriaControls = tab.attr( "aria-controls" );
  13263. // inline tab
  13264. if ( that._isLocal( anchor ) ) {
  13265. selector = anchor.hash;
  13266. panelId = selector.substring( 1 );
  13267. panel = that.element.find( that._sanitizeSelector( selector ) );
  13268. // remote tab
  13269. } else {
  13270. // If the tab doesn't already have aria-controls,
  13271. // generate an id by using a throw-away element
  13272. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  13273. selector = "#" + panelId;
  13274. panel = that.element.find( selector );
  13275. if ( !panel.length ) {
  13276. panel = that._createPanel( panelId );
  13277. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  13278. }
  13279. panel.attr( "aria-live", "polite" );
  13280. }
  13281. if ( panel.length) {
  13282. that.panels = that.panels.add( panel );
  13283. }
  13284. if ( originalAriaControls ) {
  13285. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  13286. }
  13287. tab.attr({
  13288. "aria-controls": panelId,
  13289. "aria-labelledby": anchorId
  13290. });
  13291. panel.attr( "aria-labelledby", anchorId );
  13292. });
  13293. this.panels
  13294. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  13295. .attr( "role", "tabpanel" );
  13296. },
  13297. // allow overriding how to find the list for rare usage scenarios (#7715)
  13298. _getList: function() {
  13299. return this.tablist || this.element.find( "ol,ul" ).eq( 0 );
  13300. },
  13301. _createPanel: function( id ) {
  13302. return $( "<div>" )
  13303. .attr( "id", id )
  13304. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  13305. .data( "ui-tabs-destroy", true );
  13306. },
  13307. _setupDisabled: function( disabled ) {
  13308. if ( $.isArray( disabled ) ) {
  13309. if ( !disabled.length ) {
  13310. disabled = false;
  13311. } else if ( disabled.length === this.anchors.length ) {
  13312. disabled = true;
  13313. }
  13314. }
  13315. // disable tabs
  13316. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  13317. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  13318. $( li )
  13319. .addClass( "ui-state-disabled" )
  13320. .attr( "aria-disabled", "true" );
  13321. } else {
  13322. $( li )
  13323. .removeClass( "ui-state-disabled" )
  13324. .removeAttr( "aria-disabled" );
  13325. }
  13326. }
  13327. this.options.disabled = disabled;
  13328. },
  13329. _setupEvents: function( event ) {
  13330. var events = {};
  13331. if ( event ) {
  13332. $.each( event.split(" "), function( index, eventName ) {
  13333. events[ eventName ] = "_eventHandler";
  13334. });
  13335. }
  13336. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  13337. // Always prevent the default action, even when disabled
  13338. this._on( true, this.anchors, {
  13339. click: function( event ) {
  13340. event.preventDefault();
  13341. }
  13342. });
  13343. this._on( this.anchors, events );
  13344. this._on( this.tabs, { keydown: "_tabKeydown" } );
  13345. this._on( this.panels, { keydown: "_panelKeydown" } );
  13346. this._focusable( this.tabs );
  13347. this._hoverable( this.tabs );
  13348. },
  13349. _setupHeightStyle: function( heightStyle ) {
  13350. var maxHeight,
  13351. parent = this.element.parent();
  13352. if ( heightStyle === "fill" ) {
  13353. maxHeight = parent.height();
  13354. maxHeight -= this.element.outerHeight() - this.element.height();
  13355. this.element.siblings( ":visible" ).each(function() {
  13356. var elem = $( this ),
  13357. position = elem.css( "position" );
  13358. if ( position === "absolute" || position === "fixed" ) {
  13359. return;
  13360. }
  13361. maxHeight -= elem.outerHeight( true );
  13362. });
  13363. this.element.children().not( this.panels ).each(function() {
  13364. maxHeight -= $( this ).outerHeight( true );
  13365. });
  13366. this.panels.each(function() {
  13367. $( this ).height( Math.max( 0, maxHeight -
  13368. $( this ).innerHeight() + $( this ).height() ) );
  13369. })
  13370. .css( "overflow", "auto" );
  13371. } else if ( heightStyle === "auto" ) {
  13372. maxHeight = 0;
  13373. this.panels.each(function() {
  13374. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  13375. }).height( maxHeight );
  13376. }
  13377. },
  13378. _eventHandler: function( event ) {
  13379. var options = this.options,
  13380. active = this.active,
  13381. anchor = $( event.currentTarget ),
  13382. tab = anchor.closest( "li" ),
  13383. clickedIsActive = tab[ 0 ] === active[ 0 ],
  13384. collapsing = clickedIsActive && options.collapsible,
  13385. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  13386. toHide = !active.length ? $() : this._getPanelForTab( active ),
  13387. eventData = {
  13388. oldTab: active,
  13389. oldPanel: toHide,
  13390. newTab: collapsing ? $() : tab,
  13391. newPanel: toShow
  13392. };
  13393. event.preventDefault();
  13394. if ( tab.hasClass( "ui-state-disabled" ) ||
  13395. // tab is already loading
  13396. tab.hasClass( "ui-tabs-loading" ) ||
  13397. // can't switch durning an animation
  13398. this.running ||
  13399. // click on active header, but not collapsible
  13400. ( clickedIsActive && !options.collapsible ) ||
  13401. // allow canceling activation
  13402. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  13403. return;
  13404. }
  13405. options.active = collapsing ? false : this.tabs.index( tab );
  13406. this.active = clickedIsActive ? $() : tab;
  13407. if ( this.xhr ) {
  13408. this.xhr.abort();
  13409. }
  13410. if ( !toHide.length && !toShow.length ) {
  13411. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  13412. }
  13413. if ( toShow.length ) {
  13414. this.load( this.tabs.index( tab ), event );
  13415. }
  13416. this._toggle( event, eventData );
  13417. },
  13418. // handles show/hide for selecting tabs
  13419. _toggle: function( event, eventData ) {
  13420. var that = this,
  13421. toShow = eventData.newPanel,
  13422. toHide = eventData.oldPanel;
  13423. this.running = true;
  13424. function complete() {
  13425. that.running = false;
  13426. that._trigger( "activate", event, eventData );
  13427. }
  13428. function show() {
  13429. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  13430. if ( toShow.length && that.options.show ) {
  13431. that._show( toShow, that.options.show, complete );
  13432. } else {
  13433. toShow.show();
  13434. complete();
  13435. }
  13436. }
  13437. // start out by hiding, then showing, then completing
  13438. if ( toHide.length && this.options.hide ) {
  13439. this._hide( toHide, this.options.hide, function() {
  13440. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  13441. show();
  13442. });
  13443. } else {
  13444. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  13445. toHide.hide();
  13446. show();
  13447. }
  13448. toHide.attr( "aria-hidden", "true" );
  13449. eventData.oldTab.attr({
  13450. "aria-selected": "false",
  13451. "aria-expanded": "false"
  13452. });
  13453. // If we're switching tabs, remove the old tab from the tab order.
  13454. // If we're opening from collapsed state, remove the previous tab from the tab order.
  13455. // If we're collapsing, then keep the collapsing tab in the tab order.
  13456. if ( toShow.length && toHide.length ) {
  13457. eventData.oldTab.attr( "tabIndex", -1 );
  13458. } else if ( toShow.length ) {
  13459. this.tabs.filter(function() {
  13460. return $( this ).attr( "tabIndex" ) === 0;
  13461. })
  13462. .attr( "tabIndex", -1 );
  13463. }
  13464. toShow.attr( "aria-hidden", "false" );
  13465. eventData.newTab.attr({
  13466. "aria-selected": "true",
  13467. "aria-expanded": "true",
  13468. tabIndex: 0
  13469. });
  13470. },
  13471. _activate: function( index ) {
  13472. var anchor,
  13473. active = this._findActive( index );
  13474. // trying to activate the already active panel
  13475. if ( active[ 0 ] === this.active[ 0 ] ) {
  13476. return;
  13477. }
  13478. // trying to collapse, simulate a click on the current active header
  13479. if ( !active.length ) {
  13480. active = this.active;
  13481. }
  13482. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  13483. this._eventHandler({
  13484. target: anchor,
  13485. currentTarget: anchor,
  13486. preventDefault: $.noop
  13487. });
  13488. },
  13489. _findActive: function( index ) {
  13490. return index === false ? $() : this.tabs.eq( index );
  13491. },
  13492. _getIndex: function( index ) {
  13493. // meta-function to give users option to provide a href string instead of a numerical index.
  13494. if ( typeof index === "string" ) {
  13495. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  13496. }
  13497. return index;
  13498. },
  13499. _destroy: function() {
  13500. if ( this.xhr ) {
  13501. this.xhr.abort();
  13502. }
  13503. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  13504. this.tablist
  13505. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  13506. .removeAttr( "role" );
  13507. this.anchors
  13508. .removeClass( "ui-tabs-anchor" )
  13509. .removeAttr( "role" )
  13510. .removeAttr( "tabIndex" )
  13511. .removeUniqueId();
  13512. this.tablist.unbind( this.eventNamespace );
  13513. this.tabs.add( this.panels ).each(function() {
  13514. if ( $.data( this, "ui-tabs-destroy" ) ) {
  13515. $( this ).remove();
  13516. } else {
  13517. $( this )
  13518. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  13519. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  13520. .removeAttr( "tabIndex" )
  13521. .removeAttr( "aria-live" )
  13522. .removeAttr( "aria-busy" )
  13523. .removeAttr( "aria-selected" )
  13524. .removeAttr( "aria-labelledby" )
  13525. .removeAttr( "aria-hidden" )
  13526. .removeAttr( "aria-expanded" )
  13527. .removeAttr( "role" );
  13528. }
  13529. });
  13530. this.tabs.each(function() {
  13531. var li = $( this ),
  13532. prev = li.data( "ui-tabs-aria-controls" );
  13533. if ( prev ) {
  13534. li
  13535. .attr( "aria-controls", prev )
  13536. .removeData( "ui-tabs-aria-controls" );
  13537. } else {
  13538. li.removeAttr( "aria-controls" );
  13539. }
  13540. });
  13541. this.panels.show();
  13542. if ( this.options.heightStyle !== "content" ) {
  13543. this.panels.css( "height", "" );
  13544. }
  13545. },
  13546. enable: function( index ) {
  13547. var disabled = this.options.disabled;
  13548. if ( disabled === false ) {
  13549. return;
  13550. }
  13551. if ( index === undefined ) {
  13552. disabled = false;
  13553. } else {
  13554. index = this._getIndex( index );
  13555. if ( $.isArray( disabled ) ) {
  13556. disabled = $.map( disabled, function( num ) {
  13557. return num !== index ? num : null;
  13558. });
  13559. } else {
  13560. disabled = $.map( this.tabs, function( li, num ) {
  13561. return num !== index ? num : null;
  13562. });
  13563. }
  13564. }
  13565. this._setupDisabled( disabled );
  13566. },
  13567. disable: function( index ) {
  13568. var disabled = this.options.disabled;
  13569. if ( disabled === true ) {
  13570. return;
  13571. }
  13572. if ( index === undefined ) {
  13573. disabled = true;
  13574. } else {
  13575. index = this._getIndex( index );
  13576. if ( $.inArray( index, disabled ) !== -1 ) {
  13577. return;
  13578. }
  13579. if ( $.isArray( disabled ) ) {
  13580. disabled = $.merge( [ index ], disabled ).sort();
  13581. } else {
  13582. disabled = [ index ];
  13583. }
  13584. }
  13585. this._setupDisabled( disabled );
  13586. },
  13587. load: function( index, event ) {
  13588. index = this._getIndex( index );
  13589. var that = this,
  13590. tab = this.tabs.eq( index ),
  13591. anchor = tab.find( ".ui-tabs-anchor" ),
  13592. panel = this._getPanelForTab( tab ),
  13593. eventData = {
  13594. tab: tab,
  13595. panel: panel
  13596. };
  13597. // not remote
  13598. if ( this._isLocal( anchor[ 0 ] ) ) {
  13599. return;
  13600. }
  13601. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  13602. // support: jQuery <1.8
  13603. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  13604. // but as of 1.8, $.ajax() always returns a jqXHR object.
  13605. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  13606. tab.addClass( "ui-tabs-loading" );
  13607. panel.attr( "aria-busy", "true" );
  13608. this.xhr
  13609. .success(function( response ) {
  13610. // support: jQuery <1.8
  13611. // http://bugs.jquery.com/ticket/11778
  13612. setTimeout(function() {
  13613. panel.html( response );
  13614. that._trigger( "load", event, eventData );
  13615. }, 1 );
  13616. })
  13617. .complete(function( jqXHR, status ) {
  13618. // support: jQuery <1.8
  13619. // http://bugs.jquery.com/ticket/11778
  13620. setTimeout(function() {
  13621. if ( status === "abort" ) {
  13622. that.panels.stop( false, true );
  13623. }
  13624. tab.removeClass( "ui-tabs-loading" );
  13625. panel.removeAttr( "aria-busy" );
  13626. if ( jqXHR === that.xhr ) {
  13627. delete that.xhr;
  13628. }
  13629. }, 1 );
  13630. });
  13631. }
  13632. },
  13633. _ajaxSettings: function( anchor, event, eventData ) {
  13634. var that = this;
  13635. return {
  13636. url: anchor.attr( "href" ),
  13637. beforeSend: function( jqXHR, settings ) {
  13638. return that._trigger( "beforeLoad", event,
  13639. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  13640. }
  13641. };
  13642. },
  13643. _getPanelForTab: function( tab ) {
  13644. var id = $( tab ).attr( "aria-controls" );
  13645. return this.element.find( this._sanitizeSelector( "#" + id ) );
  13646. }
  13647. });
  13648. /*!
  13649. * jQuery UI Tooltip 1.11.1
  13650. * http://jqueryui.com
  13651. *
  13652. * Copyright 2014 jQuery Foundation and other contributors
  13653. * Released under the MIT license.
  13654. * http://jquery.org/license
  13655. *
  13656. * http://api.jqueryui.com/tooltip/
  13657. */
  13658. var tooltip = $.widget( "ui.tooltip", {
  13659. version: "1.11.1",
  13660. options: {
  13661. content: function() {
  13662. // support: IE<9, Opera in jQuery <1.7
  13663. // .text() can't accept undefined, so coerce to a string
  13664. var title = $( this ).attr( "title" ) || "";
  13665. // Escape title, since we're going from an attribute to raw HTML
  13666. return $( "<a>" ).text( title ).html();
  13667. },
  13668. hide: true,
  13669. // Disabled elements have inconsistent behavior across browsers (#8661)
  13670. items: "[title]:not([disabled])",
  13671. position: {
  13672. my: "left top+15",
  13673. at: "left bottom",
  13674. collision: "flipfit flip"
  13675. },
  13676. show: true,
  13677. tooltipClass: null,
  13678. track: false,
  13679. // callbacks
  13680. close: null,
  13681. open: null
  13682. },
  13683. _addDescribedBy: function( elem, id ) {
  13684. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  13685. describedby.push( id );
  13686. elem
  13687. .data( "ui-tooltip-id", id )
  13688. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  13689. },
  13690. _removeDescribedBy: function( elem ) {
  13691. var id = elem.data( "ui-tooltip-id" ),
  13692. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  13693. index = $.inArray( id, describedby );
  13694. if ( index !== -1 ) {
  13695. describedby.splice( index, 1 );
  13696. }
  13697. elem.removeData( "ui-tooltip-id" );
  13698. describedby = $.trim( describedby.join( " " ) );
  13699. if ( describedby ) {
  13700. elem.attr( "aria-describedby", describedby );
  13701. } else {
  13702. elem.removeAttr( "aria-describedby" );
  13703. }
  13704. },
  13705. _create: function() {
  13706. this._on({
  13707. mouseover: "open",
  13708. focusin: "open"
  13709. });
  13710. // IDs of generated tooltips, needed for destroy
  13711. this.tooltips = {};
  13712. // IDs of parent tooltips where we removed the title attribute
  13713. this.parents = {};
  13714. if ( this.options.disabled ) {
  13715. this._disable();
  13716. }
  13717. // Append the aria-live region so tooltips announce correctly
  13718. this.liveRegion = $( "<div>" )
  13719. .attr({
  13720. role: "log",
  13721. "aria-live": "assertive",
  13722. "aria-relevant": "additions"
  13723. })
  13724. .addClass( "ui-helper-hidden-accessible" )
  13725. .appendTo( this.document[ 0 ].body );
  13726. },
  13727. _setOption: function( key, value ) {
  13728. var that = this;
  13729. if ( key === "disabled" ) {
  13730. this[ value ? "_disable" : "_enable" ]();
  13731. this.options[ key ] = value;
  13732. // disable element style changes
  13733. return;
  13734. }
  13735. this._super( key, value );
  13736. if ( key === "content" ) {
  13737. $.each( this.tooltips, function( id, element ) {
  13738. that._updateContent( element );
  13739. });
  13740. }
  13741. },
  13742. _disable: function() {
  13743. var that = this;
  13744. // close open tooltips
  13745. $.each( this.tooltips, function( id, element ) {
  13746. var event = $.Event( "blur" );
  13747. event.target = event.currentTarget = element[0];
  13748. that.close( event, true );
  13749. });
  13750. // remove title attributes to prevent native tooltips
  13751. this.element.find( this.options.items ).addBack().each(function() {
  13752. var element = $( this );
  13753. if ( element.is( "[title]" ) ) {
  13754. element
  13755. .data( "ui-tooltip-title", element.attr( "title" ) )
  13756. .removeAttr( "title" );
  13757. }
  13758. });
  13759. },
  13760. _enable: function() {
  13761. // restore title attributes
  13762. this.element.find( this.options.items ).addBack().each(function() {
  13763. var element = $( this );
  13764. if ( element.data( "ui-tooltip-title" ) ) {
  13765. element.attr( "title", element.data( "ui-tooltip-title" ) );
  13766. }
  13767. });
  13768. },
  13769. open: function( event ) {
  13770. var that = this,
  13771. target = $( event ? event.target : this.element )
  13772. // we need closest here due to mouseover bubbling,
  13773. // but always pointing at the same event target
  13774. .closest( this.options.items );
  13775. // No element to show a tooltip for or the tooltip is already open
  13776. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  13777. return;
  13778. }
  13779. if ( target.attr( "title" ) ) {
  13780. target.data( "ui-tooltip-title", target.attr( "title" ) );
  13781. }
  13782. target.data( "ui-tooltip-open", true );
  13783. // kill parent tooltips, custom or native, for hover
  13784. if ( event && event.type === "mouseover" ) {
  13785. target.parents().each(function() {
  13786. var parent = $( this ),
  13787. blurEvent;
  13788. if ( parent.data( "ui-tooltip-open" ) ) {
  13789. blurEvent = $.Event( "blur" );
  13790. blurEvent.target = blurEvent.currentTarget = this;
  13791. that.close( blurEvent, true );
  13792. }
  13793. if ( parent.attr( "title" ) ) {
  13794. parent.uniqueId();
  13795. that.parents[ this.id ] = {
  13796. element: this,
  13797. title: parent.attr( "title" )
  13798. };
  13799. parent.attr( "title", "" );
  13800. }
  13801. });
  13802. }
  13803. this._updateContent( target, event );
  13804. },
  13805. _updateContent: function( target, event ) {
  13806. var content,
  13807. contentOption = this.options.content,
  13808. that = this,
  13809. eventType = event ? event.type : null;
  13810. if ( typeof contentOption === "string" ) {
  13811. return this._open( event, target, contentOption );
  13812. }
  13813. content = contentOption.call( target[0], function( response ) {
  13814. // ignore async response if tooltip was closed already
  13815. if ( !target.data( "ui-tooltip-open" ) ) {
  13816. return;
  13817. }
  13818. // IE may instantly serve a cached response for ajax requests
  13819. // delay this call to _open so the other call to _open runs first
  13820. that._delay(function() {
  13821. // jQuery creates a special event for focusin when it doesn't
  13822. // exist natively. To improve performance, the native event
  13823. // object is reused and the type is changed. Therefore, we can't
  13824. // rely on the type being correct after the event finished
  13825. // bubbling, so we set it back to the previous value. (#8740)
  13826. if ( event ) {
  13827. event.type = eventType;
  13828. }
  13829. this._open( event, target, response );
  13830. });
  13831. });
  13832. if ( content ) {
  13833. this._open( event, target, content );
  13834. }
  13835. },
  13836. _open: function( event, target, content ) {
  13837. var tooltip, events, delayedShow, a11yContent,
  13838. positionOption = $.extend( {}, this.options.position );
  13839. if ( !content ) {
  13840. return;
  13841. }
  13842. // Content can be updated multiple times. If the tooltip already
  13843. // exists, then just update the content and bail.
  13844. tooltip = this._find( target );
  13845. if ( tooltip.length ) {
  13846. tooltip.find( ".ui-tooltip-content" ).html( content );
  13847. return;
  13848. }
  13849. // if we have a title, clear it to prevent the native tooltip
  13850. // we have to check first to avoid defining a title if none exists
  13851. // (we don't want to cause an element to start matching [title])
  13852. //
  13853. // We use removeAttr only for key events, to allow IE to export the correct
  13854. // accessible attributes. For mouse events, set to empty string to avoid
  13855. // native tooltip showing up (happens only when removing inside mouseover).
  13856. if ( target.is( "[title]" ) ) {
  13857. if ( event && event.type === "mouseover" ) {
  13858. target.attr( "title", "" );
  13859. } else {
  13860. target.removeAttr( "title" );
  13861. }
  13862. }
  13863. tooltip = this._tooltip( target );
  13864. this._addDescribedBy( target, tooltip.attr( "id" ) );
  13865. tooltip.find( ".ui-tooltip-content" ).html( content );
  13866. // Support: Voiceover on OS X, JAWS on IE <= 9
  13867. // JAWS announces deletions even when aria-relevant="additions"
  13868. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  13869. this.liveRegion.children().hide();
  13870. if ( content.clone ) {
  13871. a11yContent = content.clone();
  13872. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  13873. } else {
  13874. a11yContent = content;
  13875. }
  13876. $( "<div>" ).html( a11yContent ).appendTo( this.liveRegion );
  13877. function position( event ) {
  13878. positionOption.of = event;
  13879. if ( tooltip.is( ":hidden" ) ) {
  13880. return;
  13881. }
  13882. tooltip.position( positionOption );
  13883. }
  13884. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  13885. this._on( this.document, {
  13886. mousemove: position
  13887. });
  13888. // trigger once to override element-relative positioning
  13889. position( event );
  13890. } else {
  13891. tooltip.position( $.extend({
  13892. of: target
  13893. }, this.options.position ) );
  13894. }
  13895. this.hiding = false;
  13896. this.closing = false;
  13897. tooltip.hide();
  13898. this._show( tooltip, this.options.show );
  13899. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  13900. // as the tooltip is visible, position the tooltip using the most recent
  13901. // event.
  13902. if ( this.options.show && this.options.show.delay ) {
  13903. delayedShow = this.delayedShow = setInterval(function() {
  13904. if ( tooltip.is( ":visible" ) ) {
  13905. position( positionOption.of );
  13906. clearInterval( delayedShow );
  13907. }
  13908. }, $.fx.interval );
  13909. }
  13910. this._trigger( "open", event, { tooltip: tooltip } );
  13911. events = {
  13912. keyup: function( event ) {
  13913. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  13914. var fakeEvent = $.Event(event);
  13915. fakeEvent.currentTarget = target[0];
  13916. this.close( fakeEvent, true );
  13917. }
  13918. }
  13919. };
  13920. // Only bind remove handler for delegated targets. Non-delegated
  13921. // tooltips will handle this in destroy.
  13922. if ( target[ 0 ] !== this.element[ 0 ] ) {
  13923. events.remove = function() {
  13924. this._removeTooltip( tooltip );
  13925. };
  13926. }
  13927. if ( !event || event.type === "mouseover" ) {
  13928. events.mouseleave = "close";
  13929. }
  13930. if ( !event || event.type === "focusin" ) {
  13931. events.focusout = "close";
  13932. }
  13933. this._on( true, target, events );
  13934. },
  13935. close: function( event ) {
  13936. var that = this,
  13937. target = $( event ? event.currentTarget : this.element ),
  13938. tooltip = this._find( target );
  13939. // disabling closes the tooltip, so we need to track when we're closing
  13940. // to avoid an infinite loop in case the tooltip becomes disabled on close
  13941. if ( this.closing ) {
  13942. return;
  13943. }
  13944. // Clear the interval for delayed tracking tooltips
  13945. clearInterval( this.delayedShow );
  13946. // only set title if we had one before (see comment in _open())
  13947. // If the title attribute has changed since open(), don't restore
  13948. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  13949. target.attr( "title", target.data( "ui-tooltip-title" ) );
  13950. }
  13951. this._removeDescribedBy( target );
  13952. this.hiding = true;
  13953. tooltip.stop( true );
  13954. this._hide( tooltip, this.options.hide, function() {
  13955. that._removeTooltip( $( this ) );
  13956. this.hiding = false;
  13957. this.closing = false;
  13958. });
  13959. target.removeData( "ui-tooltip-open" );
  13960. this._off( target, "mouseleave focusout keyup" );
  13961. // Remove 'remove' binding only on delegated targets
  13962. if ( target[ 0 ] !== this.element[ 0 ] ) {
  13963. this._off( target, "remove" );
  13964. }
  13965. this._off( this.document, "mousemove" );
  13966. if ( event && event.type === "mouseleave" ) {
  13967. $.each( this.parents, function( id, parent ) {
  13968. $( parent.element ).attr( "title", parent.title );
  13969. delete that.parents[ id ];
  13970. });
  13971. }
  13972. this.closing = true;
  13973. this._trigger( "close", event, { tooltip: tooltip } );
  13974. if ( !this.hiding ) {
  13975. this.closing = false;
  13976. }
  13977. },
  13978. _tooltip: function( element ) {
  13979. var tooltip = $( "<div>" )
  13980. .attr( "role", "tooltip" )
  13981. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  13982. ( this.options.tooltipClass || "" ) ),
  13983. id = tooltip.uniqueId().attr( "id" );
  13984. $( "<div>" )
  13985. .addClass( "ui-tooltip-content" )
  13986. .appendTo( tooltip );
  13987. tooltip.appendTo( this.document[0].body );
  13988. this.tooltips[ id ] = element;
  13989. return tooltip;
  13990. },
  13991. _find: function( target ) {
  13992. var id = target.data( "ui-tooltip-id" );
  13993. return id ? $( "#" + id ) : $();
  13994. },
  13995. _removeTooltip: function( tooltip ) {
  13996. tooltip.remove();
  13997. delete this.tooltips[ tooltip.attr( "id" ) ];
  13998. },
  13999. _destroy: function() {
  14000. var that = this;
  14001. // close open tooltips
  14002. $.each( this.tooltips, function( id, element ) {
  14003. // Delegate to close method to handle common cleanup
  14004. var event = $.Event( "blur" );
  14005. event.target = event.currentTarget = element[0];
  14006. that.close( event, true );
  14007. // Remove immediately; destroying an open tooltip doesn't use the
  14008. // hide animation
  14009. $( "#" + id ).remove();
  14010. // Restore the title
  14011. if ( element.data( "ui-tooltip-title" ) ) {
  14012. // If the title attribute has changed since open(), don't restore
  14013. if ( !element.attr( "title" ) ) {
  14014. element.attr( "title", element.data( "ui-tooltip-title" ) );
  14015. }
  14016. element.removeData( "ui-tooltip-title" );
  14017. }
  14018. });
  14019. this.liveRegion.remove();
  14020. }
  14021. });
  14022. }));