1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931 |
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- (function(core) {
- if (typeof define == "function" && define.amd) { // AMD
- define("uikit", function(){
- var uikit = window.UIkit || core(window, window.jQuery, window.document);
- uikit.load = function(res, req, onload, config) {
- var resources = res.split(','), load = [], i, base = (config.config && config.config.uikit && config.config.uikit.base ? config.config.uikit.base : "").replace(/\/+$/g, "");
- if (!base) {
- throw new Error( "Please define base path to UIkit in the requirejs config." );
- }
- for (i = 0; i < resources.length; i += 1) {
- var resource = resources[i].replace(/\./g, '/');
- load.push(base+'/components/'+resource);
- }
- req(load, function() {
- onload(uikit);
- });
- };
- return uikit;
- });
- }
- if (!window.jQuery) {
- throw new Error( "UIkit requires jQuery" );
- }
- if (window && window.jQuery) {
- core(window, window.jQuery, window.document);
- }
- })(function(global, $, doc) {
- "use strict";
- var UI = {}, _UI = global.UIkit ? Object.create(global.UIkit) : undefined;
- UI.version = '2.27.1';
- UI.noConflict = function() {
- // restore UIkit version
- if (_UI) {
- global.UIkit = _UI;
- $.UIkit = _UI;
- $.fn.uk = _UI.fn;
- }
- return UI;
- };
- UI.prefix = function(str) {
- return str;
- };
- // cache jQuery
- UI.$ = $;
- UI.$doc = UI.$(document);
- UI.$win = UI.$(window);
- UI.$html = UI.$('html');
- UI.support = {};
- UI.support.transition = (function() {
- var transitionEnd = (function() {
- var element = doc.body || doc.documentElement,
- transEndEventNames = {
- WebkitTransition : 'webkitTransitionEnd',
- MozTransition : 'transitionend',
- OTransition : 'oTransitionEnd otransitionend',
- transition : 'transitionend'
- }, name;
- for (name in transEndEventNames) {
- if (element.style[name] !== undefined) return transEndEventNames[name];
- }
- }());
- return transitionEnd && { end: transitionEnd };
- })();
- UI.support.animation = (function() {
- var animationEnd = (function() {
- var element = doc.body || doc.documentElement,
- animEndEventNames = {
- WebkitAnimation : 'webkitAnimationEnd',
- MozAnimation : 'animationend',
- OAnimation : 'oAnimationEnd oanimationend',
- animation : 'animationend'
- }, name;
- for (name in animEndEventNames) {
- if (element.style[name] !== undefined) return animEndEventNames[name];
- }
- }());
- return animationEnd && { end: animationEnd };
- })();
- // requestAnimationFrame polyfill
- //https://github.com/darius/requestAnimationFrame
- (function() {
- Date.now = Date.now || function() { return new Date().getTime(); };
- var vendors = ['webkit', 'moz'];
- for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) {
- var vp = vendors[i];
- window.requestAnimationFrame = window[vp+'RequestAnimationFrame'];
- window.cancelAnimationFrame = (window[vp+'CancelAnimationFrame']
- || window[vp+'CancelRequestAnimationFrame']);
- }
- if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) // iOS6 is buggy
- || !window.requestAnimationFrame || !window.cancelAnimationFrame) {
- var lastTime = 0;
- window.requestAnimationFrame = function(callback) {
- var now = Date.now();
- var nextTime = Math.max(lastTime + 16, now);
- return setTimeout(function() { callback(lastTime = nextTime); },
- nextTime - now);
- };
- window.cancelAnimationFrame = clearTimeout;
- }
- }());
- UI.support.touch = (
- ('ontouchstart' in document) ||
- (global.DocumentTouch && document instanceof global.DocumentTouch) ||
- (global.navigator.msPointerEnabled && global.navigator.msMaxTouchPoints > 0) || //IE 10
- (global.navigator.pointerEnabled && global.navigator.maxTouchPoints > 0) || //IE >=11
- false
- );
- UI.support.mutationobserver = (global.MutationObserver || global.WebKitMutationObserver || null);
- UI.Utils = {};
- UI.Utils.isFullscreen = function() {
- return document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement || document.fullscreenElement || false;
- };
- UI.Utils.str2json = function(str, notevil) {
- try {
- if (notevil) {
- return JSON.parse(str
- // wrap keys without quote with valid double quote
- .replace(/([\$\w]+)\s*:/g, function(_, $1){return '"'+$1+'":';})
- // replacing single quote wrapped ones to double quote
- .replace(/'([^']+)'/g, function(_, $1){return '"'+$1+'"';})
- );
- } else {
- return (new Function("", "var json = " + str + "; return JSON.parse(JSON.stringify(json));"))();
- }
- } catch(e) { return false; }
- };
- UI.Utils.debounce = function(func, wait, immediate) {
- var timeout;
- return function() {
- var context = this, args = arguments;
- var later = function() {
- timeout = null;
- if (!immediate) func.apply(context, args);
- };
- var callNow = immediate && !timeout;
- clearTimeout(timeout);
- timeout = setTimeout(later, wait);
- if (callNow) func.apply(context, args);
- };
- };
- UI.Utils.throttle = function (func, limit) {
- var wait = false;
- return function () {
- if (!wait) {
- func.call();
- wait = true;
- setTimeout(function () {
- wait = false;
- }, limit);
- }
- }
- };
- UI.Utils.removeCssRules = function(selectorRegEx) {
- var idx, idxs, stylesheet, _i, _j, _k, _len, _len1, _len2, _ref;
- if(!selectorRegEx) return;
- setTimeout(function(){
- try {
- _ref = document.styleSheets;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- stylesheet = _ref[_i];
- idxs = [];
- stylesheet.cssRules = stylesheet.cssRules;
- for (idx = _j = 0, _len1 = stylesheet.cssRules.length; _j < _len1; idx = ++_j) {
- if (stylesheet.cssRules[idx].type === CSSRule.STYLE_RULE && selectorRegEx.test(stylesheet.cssRules[idx].selectorText)) {
- idxs.unshift(idx);
- }
- }
- for (_k = 0, _len2 = idxs.length; _k < _len2; _k++) {
- stylesheet.deleteRule(idxs[_k]);
- }
- }
- } catch (_error) {}
- }, 0);
- };
- UI.Utils.isInView = function(element, options) {
- var $element = $(element);
- if (!$element.is(':visible')) {
- return false;
- }
- var window_left = UI.$win.scrollLeft(), window_top = UI.$win.scrollTop(), offset = $element.offset(), left = offset.left, top = offset.top;
- options = $.extend({topoffset:0, leftoffset:0}, options);
- if (top + $element.height() >= window_top && top - options.topoffset <= window_top + UI.$win.height() &&
- left + $element.width() >= window_left && left - options.leftoffset <= window_left + UI.$win.width()) {
- return true;
- } else {
- return false;
- }
- };
- UI.Utils.checkDisplay = function(context, initanimation) {
- var elements = UI.$('[data-uk-margin], [data-uk-grid-match], [data-uk-grid-margin], [data-uk-check-display]', context || document), animated;
- if (context && !elements.length) {
- elements = $(context);
- }
- elements.trigger('display.uk.check');
- // fix firefox / IE animations
- if (initanimation) {
- if (typeof(initanimation)!='string') {
- initanimation = '[class*="uk-animation-"]';
- }
- elements.find(initanimation).each(function(){
- var ele = UI.$(this),
- cls = ele.attr('class'),
- anim = cls.match(/uk-animation-(.+)/);
- ele.removeClass(anim[0]).width();
- ele.addClass(anim[0]);
- });
- }
- return elements;
- };
- UI.Utils.options = function(string) {
- if ($.type(string)!='string') return string;
- if (string.indexOf(':') != -1 && string.trim().substr(-1) != '}') {
- string = '{'+string+'}';
- }
- var start = (string ? string.indexOf("{") : -1), options = {};
- if (start != -1) {
- try {
- options = UI.Utils.str2json(string.substr(start));
- } catch (e) {}
- }
- return options;
- };
- UI.Utils.animate = function(element, cls) {
- var d = $.Deferred();
- element = UI.$(element);
- element.css('display', 'none').addClass(cls).one(UI.support.animation.end, function() {
- element.removeClass(cls);
- d.resolve();
- });
- element.css('display', '');
- return d.promise();
- };
- UI.Utils.uid = function(prefix) {
- return (prefix || 'id') + (new Date().getTime())+"RAND"+(Math.ceil(Math.random() * 100000));
- };
- UI.Utils.template = function(str, data) {
- var tokens = str.replace(/\n/g, '\\n').replace(/\{\{\{\s*(.+?)\s*\}\}\}/g, "{{!$1}}").split(/(\{\{\s*(.+?)\s*\}\})/g),
- i=0, toc, cmd, prop, val, fn, output = [], openblocks = 0;
- while(i < tokens.length) {
- toc = tokens[i];
- if(toc.match(/\{\{\s*(.+?)\s*\}\}/)) {
- i = i + 1;
- toc = tokens[i];
- cmd = toc[0];
- prop = toc.substring(toc.match(/^(\^|\#|\!|\~|\:)/) ? 1:0);
- switch(cmd) {
- case '~':
- output.push("for(var $i=0;$i<"+prop+".length;$i++) { var $item = "+prop+"[$i];");
- openblocks++;
- break;
- case ':':
- output.push("for(var $key in "+prop+") { var $val = "+prop+"[$key];");
- openblocks++;
- break;
- case '#':
- output.push("if("+prop+") {");
- openblocks++;
- break;
- case '^':
- output.push("if(!"+prop+") {");
- openblocks++;
- break;
- case '/':
- output.push("}");
- openblocks--;
- break;
- case '!':
- output.push("__ret.push("+prop+");");
- break;
- default:
- output.push("__ret.push(escape("+prop+"));");
- break;
- }
- } else {
- output.push("__ret.push('"+toc.replace(/\'/g, "\\'")+"');");
- }
- i = i + 1;
- }
- fn = new Function('$data', [
- 'var __ret = [];',
- 'try {',
- 'with($data){', (!openblocks ? output.join('') : '__ret = ["Not all blocks are closed correctly."]'), '};',
- '}catch(e){__ret = [e.message];}',
- 'return __ret.join("").replace(/\\n\\n/g, "\\n");',
- "function escape(html) { return String(html).replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>');}"
- ].join("\n"));
- return data ? fn(data) : fn;
- };
- UI.Utils.focus = function(element, extra) {
- element = $(element);
- var autofocus = element.find('[autofocus]:first'), tabidx;
- if (autofocus.length) {
- return autofocus.focus();
- }
- autofocus = element.find(':input'+(extra && (','+extra) || '')).first();
- if (autofocus.length) {
- return autofocus.focus();
- }
- if (!element.attr('tabindex')) {
- tabidx = 1000;
- element.attr('tabindex', tabidx);
- }
- element[0].focus();
- if (tabidx) {
- element.attr('tabindex', '');
- }
- return element;
- }
- UI.Utils.events = {};
- UI.Utils.events.click = UI.support.touch ? 'tap' : 'click';
- global.UIkit = UI;
- // deprecated
- UI.fn = function(command, options) {
- var args = arguments, cmd = command.match(/^([a-z\-]+)(?:\.([a-z]+))?/i), component = cmd[1], method = cmd[2];
- if (!UI[component]) {
- $.error("UIkit component [" + component + "] does not exist.");
- return this;
- }
- return this.each(function() {
- var $this = $(this), data = $this.data(component);
- if (!data) $this.data(component, (data = UI[component](this, method ? undefined : options)));
- if (method) data[method].apply(data, Array.prototype.slice.call(args, 1));
- });
- };
- $.UIkit = UI;
- $.fn.uk = UI.fn;
- UI.langdirection = UI.$html.attr("dir") == "rtl" ? "right" : "left";
- UI.components = {};
- UI.component = function(name, def) {
- var fn = function(element, options) {
- var $this = this;
- this.UIkit = UI;
- this.element = element ? UI.$(element) : null;
- this.options = $.extend(true, {}, this.defaults, options);
- this.plugins = {};
- if (this.element) {
- this.element.data(name, this);
- }
- this.init();
- (this.options.plugins.length ? this.options.plugins : Object.keys(fn.plugins)).forEach(function(plugin) {
- if (fn.plugins[plugin].init) {
- fn.plugins[plugin].init($this);
- $this.plugins[plugin] = true;
- }
- });
- this.trigger('init.uk.component', [name, this]);
- return this;
- };
- fn.plugins = {};
- $.extend(true, fn.prototype, {
- defaults : {plugins: []},
- boot: function(){},
- init: function(){},
- on: function(a1,a2,a3){
- return UI.$(this.element || this).on(a1,a2,a3);
- },
- one: function(a1,a2,a3){
- return UI.$(this.element || this).one(a1,a2,a3);
- },
- off: function(evt){
- return UI.$(this.element || this).off(evt);
- },
- trigger: function(evt, params) {
- return UI.$(this.element || this).trigger(evt, params);
- },
- find: function(selector) {
- return UI.$(this.element ? this.element: []).find(selector);
- },
- proxy: function(obj, methods) {
- var $this = this;
- methods.split(' ').forEach(function(method) {
- if (!$this[method]) $this[method] = function() { return obj[method].apply(obj, arguments); };
- });
- },
- mixin: function(obj, methods) {
- var $this = this;
- methods.split(' ').forEach(function(method) {
- if (!$this[method]) $this[method] = obj[method].bind($this);
- });
- },
- option: function() {
- if (arguments.length == 1) {
- return this.options[arguments[0]] || undefined;
- } else if (arguments.length == 2) {
- this.options[arguments[0]] = arguments[1];
- }
- }
- }, def);
- this.components[name] = fn;
- this[name] = function() {
- var element, options;
- if (arguments.length) {
- switch(arguments.length) {
- case 1:
- if (typeof arguments[0] === "string" || arguments[0].nodeType || arguments[0] instanceof jQuery) {
- element = $(arguments[0]);
- } else {
- options = arguments[0];
- }
- break;
- case 2:
- element = $(arguments[0]);
- options = arguments[1];
- break;
- }
- }
- if (element && element.data(name)) {
- return element.data(name);
- }
- return (new UI.components[name](element, options));
- };
- if (UI.domready) {
- UI.component.boot(name);
- }
- return fn;
- };
- UI.plugin = function(component, name, def) {
- this.components[component].plugins[name] = def;
- };
- UI.component.boot = function(name) {
- if (UI.components[name].prototype && UI.components[name].prototype.boot && !UI.components[name].booted) {
- UI.components[name].prototype.boot.apply(UI, []);
- UI.components[name].booted = true;
- }
- };
- UI.component.bootComponents = function() {
- for (var component in UI.components) {
- UI.component.boot(component);
- }
- };
- // DOM mutation save ready helper function
- UI.domObservers = [];
- UI.domready = false;
- UI.ready = function(fn) {
- UI.domObservers.push(fn);
- if (UI.domready) {
- fn(document);
- }
- };
- UI.on = function(a1,a2,a3){
- if (a1 && a1.indexOf('ready.uk.dom') > -1 && UI.domready) {
- a2.apply(UI.$doc);
- }
- return UI.$doc.on(a1,a2,a3);
- };
- UI.one = function(a1,a2,a3){
- if (a1 && a1.indexOf('ready.uk.dom') > -1 && UI.domready) {
- a2.apply(UI.$doc);
- return UI.$doc;
- }
- return UI.$doc.one(a1,a2,a3);
- };
- UI.trigger = function(evt, params) {
- return UI.$doc.trigger(evt, params);
- };
- UI.domObserve = function(selector, fn) {
- if(!UI.support.mutationobserver) return;
- fn = fn || function() {};
- UI.$(selector).each(function() {
- var element = this,
- $element = UI.$(element);
- if ($element.data('observer')) {
- return;
- }
- try {
- var observer = new UI.support.mutationobserver(UI.Utils.debounce(function(mutations) {
- fn.apply(element, [$element]);
- $element.trigger('changed.uk.dom');
- }, 50), {childList: true, subtree: true});
- // pass in the target node, as well as the observer options
- observer.observe(element, { childList: true, subtree: true });
- $element.data('observer', observer);
- } catch(e) {}
- });
- };
- UI.init = function(root) {
- root = root || document;
- UI.domObservers.forEach(function(fn){
- fn(root);
- });
- };
- UI.on('domready.uk.dom', function(){
- UI.init();
- if (UI.domready) UI.Utils.checkDisplay();
- });
- document.addEventListener('DOMContentLoaded', function(){
- var domReady = function() {
- UI.$body = UI.$('body');
- UI.trigger('beforeready.uk.dom');
- UI.component.bootComponents();
- // custom scroll observer
- var rafToken = requestAnimationFrame((function(){
- var memory = {dir: {x:0, y:0}, x: window.pageXOffset, y:window.pageYOffset};
- var fn = function(){
- // reading this (window.page[X|Y]Offset) causes a full page recalc of the layout in Chrome,
- // so we only want to do this once
- var wpxo = window.pageXOffset;
- var wpyo = window.pageYOffset;
- // Did the scroll position change since the last time we were here?
- if (memory.x != wpxo || memory.y != wpyo) {
- // Set the direction of the scroll and store the new position
- if (wpxo != memory.x) {memory.dir.x = wpxo > memory.x ? 1:-1; } else { memory.dir.x = 0; }
- if (wpyo != memory.y) {memory.dir.y = wpyo > memory.y ? 1:-1; } else { memory.dir.y = 0; }
- memory.x = wpxo;
- memory.y = wpyo;
- // Trigger the scroll event, this could probably be sent using memory.clone() but this is
- // more explicit and easier to see exactly what is being sent in the event.
- UI.$doc.trigger('scrolling.uk.document', [{
- dir: {x: memory.dir.x, y: memory.dir.y}, x: wpxo, y: wpyo
- }]);
- }
- cancelAnimationFrame(rafToken);
- rafToken = requestAnimationFrame(fn);
- };
- if (UI.support.touch) {
- UI.$html.on('touchmove touchend MSPointerMove MSPointerUp pointermove pointerup', fn);
- }
- if (memory.x || memory.y) fn();
- return fn;
- })());
- // run component init functions on dom
- UI.trigger('domready.uk.dom');
- if (UI.support.touch) {
- // remove css hover rules for touch devices
- // UI.Utils.removeCssRules(/\.uk-(?!navbar).*:hover/);
- // viewport unit fix for uk-height-viewport - should be fixed in iOS 8
- if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) {
- UI.$win.on('load orientationchange resize', UI.Utils.debounce((function(){
- var fn = function() {
- $('.uk-height-viewport').css('height', window.innerHeight);
- return fn;
- };
- return fn();
- })(), 100));
- }
- }
- UI.trigger('afterready.uk.dom');
- // mark that domready is left behind
- UI.domready = true;
- // auto init js components
- if (UI.support.mutationobserver) {
- var initFn = UI.Utils.debounce(function(){
- requestAnimationFrame(function(){ UI.init(document.body);});
- }, 10);
- (new UI.support.mutationobserver(function(mutations) {
- var init = false;
- mutations.every(function(mutation){
- if (mutation.type != 'childList') return true;
- for (var i = 0, node; i < mutation.addedNodes.length; ++i) {
- node = mutation.addedNodes[i];
- if (node.outerHTML && node.outerHTML.indexOf('data-uk-') !== -1) {
- return (init = true) && false;
- }
- }
- return true;
- });
- if (init) initFn();
- })).observe(document.body, {childList: true, subtree: true});
- }
- };
- if (document.readyState == 'complete' || document.readyState == 'interactive') {
- setTimeout(domReady);
- }
- return domReady;
- }());
- // add touch identifier class
- UI.$html.addClass(UI.support.touch ? "uk-touch" : "uk-notouch");
- // add uk-hover class on tap to support overlays on touch devices
- if (UI.support.touch) {
- var hoverset = false,
- exclude,
- hovercls = 'uk-hover',
- selector = '.uk-overlay, .uk-overlay-hover, .uk-overlay-toggle, .uk-animation-hover, .uk-has-hover';
- UI.$html.on('mouseenter touchstart MSPointerDown pointerdown', selector, function() {
- if (hoverset) $('.'+hovercls).removeClass(hovercls);
- hoverset = $(this).addClass(hovercls);
- }).on('mouseleave touchend MSPointerUp pointerup', function(e) {
- exclude = $(e.target).parents(selector);
- if (hoverset) {
- hoverset.not(exclude).removeClass(hovercls);
- }
- });
- }
- return UI;
- });
- // Based on Zeptos touch.js
- // https://raw.github.com/madrobby/zepto/master/src/touch.js
- // Zepto.js may be freely distributed under the MIT license.
- ;(function($){
- if ($.fn.swipeLeft) {
- return;
- }
- var touch = {}, touchTimeout, tapTimeout, swipeTimeout, longTapTimeout, longTapDelay = 750, gesture;
- function swipeDirection(x1, x2, y1, y2) {
- return Math.abs(x1 - x2) >= Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down');
- }
- function longTap() {
- longTapTimeout = null;
- if (touch.last) {
- if ( touch.el !== undefined ) touch.el.trigger('longTap');
- touch = {};
- }
- }
- function cancelLongTap() {
- if (longTapTimeout) clearTimeout(longTapTimeout);
- longTapTimeout = null;
- }
- function cancelAll() {
- if (touchTimeout) clearTimeout(touchTimeout);
- if (tapTimeout) clearTimeout(tapTimeout);
- if (swipeTimeout) clearTimeout(swipeTimeout);
- if (longTapTimeout) clearTimeout(longTapTimeout);
- touchTimeout = tapTimeout = swipeTimeout = longTapTimeout = null;
- touch = {};
- }
- function isPrimaryTouch(event){
- return event.pointerType == event.MSPOINTER_TYPE_TOUCH && event.isPrimary;
- }
- $(function(){
- var now, delta, deltaX = 0, deltaY = 0, firstTouch;
- if ('MSGesture' in window) {
- gesture = new MSGesture();
- gesture.target = document.body;
- }
- $(document)
- .on('MSGestureEnd gestureend', function(e){
- var swipeDirectionFromVelocity = e.originalEvent.velocityX > 1 ? 'Right' : e.originalEvent.velocityX < -1 ? 'Left' : e.originalEvent.velocityY > 1 ? 'Down' : e.originalEvent.velocityY < -1 ? 'Up' : null;
- if (swipeDirectionFromVelocity && touch.el !== undefined) {
- touch.el.trigger('swipe');
- touch.el.trigger('swipe'+ swipeDirectionFromVelocity);
- }
- })
- // MSPointerDown: for IE10
- // pointerdown: for IE11
- .on('touchstart MSPointerDown pointerdown', function(e){
- if(e.type == 'MSPointerDown' && !isPrimaryTouch(e.originalEvent)) return;
- firstTouch = (e.type == 'MSPointerDown' || e.type == 'pointerdown') ? e : e.originalEvent.touches[0];
- now = Date.now();
- delta = now - (touch.last || now);
- touch.el = $('tagName' in firstTouch.target ? firstTouch.target : firstTouch.target.parentNode);
- if(touchTimeout) clearTimeout(touchTimeout);
- touch.x1 = firstTouch.pageX;
- touch.y1 = firstTouch.pageY;
- if (delta > 0 && delta <= 250) touch.isDoubleTap = true;
- touch.last = now;
- longTapTimeout = setTimeout(longTap, longTapDelay);
- // adds the current touch contact for IE gesture recognition
- if (gesture && ( e.type == 'MSPointerDown' || e.type == 'pointerdown' || e.type == 'touchstart' ) ) {
- gesture.addPointer(e.originalEvent.pointerId);
- }
- })
- // MSPointerMove: for IE10
- // pointermove: for IE11
- .on('touchmove MSPointerMove pointermove', function(e){
- if (e.type == 'MSPointerMove' && !isPrimaryTouch(e.originalEvent)) return;
- firstTouch = (e.type == 'MSPointerMove' || e.type == 'pointermove') ? e : e.originalEvent.touches[0];
- cancelLongTap();
- touch.x2 = firstTouch.pageX;
- touch.y2 = firstTouch.pageY;
- deltaX += Math.abs(touch.x1 - touch.x2);
- deltaY += Math.abs(touch.y1 - touch.y2);
- })
- // MSPointerUp: for IE10
- // pointerup: for IE11
- .on('touchend MSPointerUp pointerup', function(e){
- if (e.type == 'MSPointerUp' && !isPrimaryTouch(e.originalEvent)) return;
- cancelLongTap();
- // swipe
- if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) || (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30)){
- swipeTimeout = setTimeout(function() {
- if ( touch.el !== undefined ) {
- touch.el.trigger('swipe');
- touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)));
- }
- touch = {};
- }, 0);
- // normal tap
- } else if ('last' in touch) {
- // don't fire tap when delta position changed by more than 30 pixels,
- // for instance when moving to a point and back to origin
- if (isNaN(deltaX) || (deltaX < 30 && deltaY < 30)) {
- // delay by one tick so we can cancel the 'tap' event if 'scroll' fires
- // ('tap' fires before 'scroll')
- tapTimeout = setTimeout(function() {
- // trigger universal 'tap' with the option to cancelTouch()
- // (cancelTouch cancels processing of single vs double taps for faster 'tap' response)
- var event = $.Event('tap');
- event.cancelTouch = cancelAll;
- if ( touch.el !== undefined ) touch.el.trigger(event);
- // trigger double tap immediately
- if (touch.isDoubleTap) {
- if ( touch.el !== undefined ) touch.el.trigger('doubleTap');
- touch = {};
- }
- // trigger single tap after 250ms of inactivity
- else {
- touchTimeout = setTimeout(function(){
- touchTimeout = null;
- if ( touch.el !== undefined ) touch.el.trigger('singleTap');
- touch = {};
- }, 250);
- }
- }, 0);
- } else {
- touch = {};
- }
- deltaX = deltaY = 0;
- }
- })
- // when the browser window loses focus,
- // for example when a modal dialog is shown,
- // cancel all ongoing events
- .on('touchcancel MSPointerCancel pointercancel', cancelAll);
- // scrolling the window indicates intention of the user
- // to scroll, not tap or swipe, so cancel all ongoing events
- $(window).on('scroll', cancelAll);
- });
- ['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(eventName){
- $.fn[eventName] = function(callback){ return $(this).on(eventName, callback); };
- });
- })(jQuery);
- (function(UI) {
- "use strict";
- var stacks = [];
- UI.component('stackMargin', {
- defaults: {
- cls: 'uk-margin-small-top',
- rowfirst: false,
- observe: false
- },
- boot: function() {
- // init code
- UI.ready(function(context) {
- UI.$("[data-uk-margin]", context).each(function() {
- var ele = UI.$(this);
- if (!ele.data("stackMargin")) {
- UI.stackMargin(ele, UI.Utils.options(ele.attr("data-uk-margin")));
- }
- });
- });
- },
- init: function() {
- var $this = this;
- UI.$win.on('resize orientationchange', (function() {
- var fn = function() {
- $this.process();
- };
- UI.$(function() {
- fn();
- UI.$win.on("load", fn);
- });
- return UI.Utils.debounce(fn, 20);
- })());
- this.on("display.uk.check", function(e) {
- if (this.element.is(":visible")) this.process();
- }.bind(this));
- if (this.options.observe) {
- UI.domObserve(this.element, function(e) {
- if ($this.element.is(":visible")) $this.process();
- });
- }
- stacks.push(this);
- },
- process: function() {
- var $this = this, columns = this.element.children();
- UI.Utils.stackMargin(columns, this.options);
- if (!this.options.rowfirst || !columns.length) {
- return this;
- }
- // Mark first column elements
- var group = {}, minleft = false;
- columns.removeClass(this.options.rowfirst).each(function(offset, $ele){
- $ele = UI.$(this);
- if (this.style.display != 'none') {
- offset = $ele.offset().left;
- ((group[offset] = group[offset] || []) && group[offset]).push(this);
- minleft = minleft === false ? offset : Math.min(minleft, offset);
- }
- });
- UI.$(group[minleft]).addClass(this.options.rowfirst);
- return this;
- }
- });
- // responsive element e.g. iframes
- (function(){
- var elements = [], check = function(ele) {
- if (!ele.is(':visible')) return;
- var width = ele.parent().width(),
- iwidth = ele.data('width'),
- ratio = (width / iwidth),
- height = Math.floor(ratio * ele.data('height'));
- ele.css({'height': (width < iwidth) ? height : ele.data('height')});
- };
- UI.component('responsiveElement', {
- defaults: {},
- boot: function() {
- // init code
- UI.ready(function(context) {
- UI.$("iframe.uk-responsive-width, [data-uk-responsive]", context).each(function() {
- var ele = UI.$(this), obj;
- if (!ele.data("responsiveElement")) {
- obj = UI.responsiveElement(ele, {});
- }
- });
- });
- },
- init: function() {
- var ele = this.element;
- if (ele.attr('width') && ele.attr('height')) {
- ele.data({
- 'width' : ele.attr('width'),
- 'height': ele.attr('height')
- }).on('display.uk.check', function(){
- check(ele);
- });
- check(ele);
- elements.push(ele);
- }
- }
- });
- UI.$win.on('resize load', UI.Utils.debounce(function(){
- elements.forEach(function(ele){
- check(ele);
- });
- }, 15));
- })();
- // helper
- UI.Utils.stackMargin = function(elements, options) {
- options = UI.$.extend({
- cls: 'uk-margin-small-top'
- }, options);
- elements = UI.$(elements).removeClass(options.cls);
- var min = false;
- elements.each(function(offset, height, pos, $ele){
- $ele = UI.$(this);
- if ($ele.css('display') != 'none') {
- offset = $ele.offset();
- height = $ele.outerHeight();
- pos = offset.top + height;
- $ele.data({
- 'ukMarginPos': pos,
- 'ukMarginTop': offset.top
- });
- if (min === false || (offset.top < min.top) ) {
- min = {
- top : offset.top,
- left : offset.left,
- pos : pos
- };
- }
- }
- }).each(function($ele) {
- $ele = UI.$(this);
- if ($ele.css('display') != 'none' && $ele.data('ukMarginTop') > min.top && $ele.data('ukMarginPos') > min.pos) {
- $ele.addClass(options.cls);
- }
- });
- };
- UI.Utils.matchHeights = function(elements, options) {
- elements = UI.$(elements).css('min-height', '');
- options = UI.$.extend({ row : true }, options);
- var matchHeights = function(group){
- if (group.length < 2) return;
- var max = 0;
- group.each(function() {
- max = Math.max(max, UI.$(this).outerHeight());
- }).each(function() {
- var element = UI.$(this),
- height = max - (element.css('box-sizing') == 'border-box' ? 0 : (element.outerHeight() - element.height()));
- element.css('min-height', height + 'px');
- });
- };
- if (options.row) {
- elements.first().width(); // force redraw
- setTimeout(function(){
- var lastoffset = false, group = [];
- elements.each(function() {
- var ele = UI.$(this), offset = ele.offset().top;
- if (offset != lastoffset && group.length) {
- matchHeights(UI.$(group));
- group = [];
- offset = ele.offset().top;
- }
- group.push(ele);
- lastoffset = offset;
- });
- if (group.length) {
- matchHeights(UI.$(group));
- }
- }, 0);
- } else {
- matchHeights(elements);
- }
- };
- (function(cacheSvgs){
- UI.Utils.inlineSvg = function(selector, root) {
- var images = UI.$(selector || 'img[src$=".svg"]', root || document).each(function(){
- var img = UI.$(this),
- src = img.attr('src');
- if (!cacheSvgs[src]) {
- var d = UI.$.Deferred();
- UI.$.get(src, {nc: Math.random()}, function(data){
- d.resolve(UI.$(data).find('svg'));
- });
- cacheSvgs[src] = d.promise();
- }
- cacheSvgs[src].then(function(svg) {
- var $svg = UI.$(svg).clone();
- if (img.attr('id')) $svg.attr('id', img.attr('id'));
- if (img.attr('class')) $svg.attr('class', img.attr('class'));
- if (img.attr('style')) $svg.attr('style', img.attr('style'));
- if (img.attr('width')) {
- $svg.attr('width', img.attr('width'));
- if (!img.attr('height')) $svg.removeAttr('height');
- }
- if (img.attr('height')){
- $svg.attr('height', img.attr('height'));
- if (!img.attr('width')) $svg.removeAttr('width');
- }
- img.replaceWith($svg);
- });
- });
- };
- // init code
- UI.ready(function(context) {
- UI.Utils.inlineSvg('[data-uk-svg]', context);
- });
- })({});
- UI.Utils.getCssVar = function(name) {
- /* usage in css: .var-name:before { content:"xyz" } */
- var val, doc = document.documentElement, element = doc.appendChild(document.createElement('div'));
- element.classList.add('var-'+name);
- try {
- val = JSON.parse(val = getComputedStyle(element, ':before').content.replace(/^["'](.*)["']$/, '$1'));
- } catch (e) {
- val = undefined;
- }
- doc.removeChild(element);
- return val;
- }
- })(UIkit);
- (function(UI) {
- "use strict";
- UI.component('smoothScroll', {
- boot: function() {
- // init code
- UI.$html.on("click.smooth-scroll.uikit", "[data-uk-smooth-scroll]", function(e) {
- var ele = UI.$(this);
- if (!ele.data("smoothScroll")) {
- var obj = UI.smoothScroll(ele, UI.Utils.options(ele.attr("data-uk-smooth-scroll")));
- ele.trigger("click");
- }
- return false;
- });
- },
- init: function() {
- var $this = this;
- this.on("click", function(e) {
- e.preventDefault();
- scrollToElement(UI.$(this.hash).length ? UI.$(this.hash) : UI.$("body"), $this.options);
- });
- }
- });
- function scrollToElement(ele, options) {
- options = UI.$.extend({
- duration: 1000,
- transition: 'easeOutExpo',
- offset: 0,
- complete: function(){}
- }, options);
- // get / set parameters
- var target = ele.offset().top - options.offset,
- docheight = UI.$doc.height(),
- winheight = window.innerHeight;
- if ((target + winheight) > docheight) {
- target = docheight - winheight;
- }
- // animate to target, fire callback when done
- UI.$("html,body").stop().animate({scrollTop: target}, options.duration, options.transition).promise().done(options.complete);
- }
- UI.Utils.scrollToElement = scrollToElement;
- if (!UI.$.easing.easeOutExpo) {
- UI.$.easing.easeOutExpo = function(x, t, b, c, d) { return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b; };
- }
- })(UIkit);
- (function(UI) {
- "use strict";
- var $win = UI.$win,
- $doc = UI.$doc,
- scrollspies = [],
- checkScrollSpy = function() {
- for(var i=0; i < scrollspies.length; i++) {
- window.requestAnimationFrame.apply(window, [scrollspies[i].check]);
- }
- };
- UI.component('scrollspy', {
- defaults: {
- target : false,
- cls : "uk-scrollspy-inview",
- initcls : "uk-scrollspy-init-inview",
- topoffset : 0,
- leftoffset : 0,
- repeat : false,
- delay : 0
- },
- boot: function() {
- // listen to scroll and resize
- $doc.on("scrolling.uk.document", checkScrollSpy);
- $win.on("load resize orientationchange", UI.Utils.debounce(checkScrollSpy, 50));
- // init code
- UI.ready(function(context) {
- UI.$("[data-uk-scrollspy]", context).each(function() {
- var element = UI.$(this);
- if (!element.data("scrollspy")) {
- var obj = UI.scrollspy(element, UI.Utils.options(element.attr("data-uk-scrollspy")));
- }
- });
- });
- },
- init: function() {
- var $this = this, inviewstate, initinview, togglecls = this.options.cls.split(/,/), fn = function(){
- var elements = $this.options.target ? $this.element.find($this.options.target) : $this.element,
- delayIdx = elements.length === 1 ? 1 : 0,
- toggleclsIdx = 0;
- elements.each(function(idx){
- var element = UI.$(this),
- inviewstate = element.data('inviewstate'),
- inview = UI.Utils.isInView(element, $this.options),
- toggle = element.data('ukScrollspyCls') || togglecls[toggleclsIdx].trim();
- if (inview && !inviewstate && !element.data('scrollspy-idle')) {
- if (!initinview) {
- element.addClass($this.options.initcls);
- $this.offset = element.offset();
- initinview = true;
- element.trigger("init.uk.scrollspy");
- }
- element.data('scrollspy-idle', setTimeout(function(){
- element.addClass("uk-scrollspy-inview").toggleClass(toggle).width();
- element.trigger("inview.uk.scrollspy");
- element.data('scrollspy-idle', false);
- element.data('inviewstate', true);
- }, $this.options.delay * delayIdx));
- delayIdx++;
- }
- if (!inview && inviewstate && $this.options.repeat) {
- if (element.data('scrollspy-idle')) {
- clearTimeout(element.data('scrollspy-idle'));
- element.data('scrollspy-idle', false);
- }
- element.removeClass("uk-scrollspy-inview").toggleClass(toggle);
- element.data('inviewstate', false);
- element.trigger("outview.uk.scrollspy");
- }
- toggleclsIdx = togglecls[toggleclsIdx + 1] ? (toggleclsIdx + 1) : 0;
- });
- };
- fn();
- this.check = fn;
- scrollspies.push(this);
- }
- });
- var scrollspynavs = [],
- checkScrollSpyNavs = function() {
- for(var i=0; i < scrollspynavs.length; i++) {
- window.requestAnimationFrame.apply(window, [scrollspynavs[i].check]);
- }
- };
- UI.component('scrollspynav', {
- defaults: {
- "cls" : 'uk-active',
- "closest" : false,
- "topoffset" : 0,
- "leftoffset" : 0,
- "smoothscroll" : false
- },
- boot: function() {
- // listen to scroll and resize
- $doc.on("scrolling.uk.document", checkScrollSpyNavs);
- $win.on("resize orientationchange", UI.Utils.debounce(checkScrollSpyNavs, 50));
- // init code
- UI.ready(function(context) {
- UI.$("[data-uk-scrollspy-nav]", context).each(function() {
- var element = UI.$(this);
- if (!element.data("scrollspynav")) {
- var obj = UI.scrollspynav(element, UI.Utils.options(element.attr("data-uk-scrollspy-nav")));
- }
- });
- });
- },
- init: function() {
- var ids = [],
- links = this.find("a[href^='#']").each(function(){ if(this.getAttribute("href").trim()!=='#') ids.push(this.getAttribute("href")); }),
- targets = UI.$(ids.join(",")),
- clsActive = this.options.cls,
- clsClosest = this.options.closest || this.options.closest;
- var $this = this, inviews, fn = function(){
- inviews = [];
- for (var i=0 ; i < targets.length ; i++) {
- if (UI.Utils.isInView(targets.eq(i), $this.options)) {
- inviews.push(targets.eq(i));
- }
- }
- if (inviews.length) {
- var navitems,
- scrollTop = $win.scrollTop(),
- target = (function(){
- for(var i=0; i< inviews.length;i++){
- if (inviews[i].offset().top - $this.options.topoffset >= scrollTop){
- return inviews[i];
- }
- }
- })();
- if (!target) return;
- if ($this.options.closest) {
- links.blur().closest(clsClosest).removeClass(clsActive);
- navitems = links.filter("a[href='#"+target.attr("id")+"']").closest(clsClosest).addClass(clsActive);
- } else {
- navitems = links.removeClass(clsActive).filter("a[href='#"+target.attr("id")+"']").addClass(clsActive);
- }
- $this.element.trigger("inview.uk.scrollspynav", [target, navitems]);
- }
- };
- if (this.options.smoothscroll && UI.smoothScroll) {
- links.each(function(){
- UI.smoothScroll(this, $this.options.smoothscroll);
- });
- }
- fn();
- this.element.data("scrollspynav", this);
- this.check = fn;
- scrollspynavs.push(this);
- }
- });
- })(UIkit);
- (function(UI){
- "use strict";
- var toggles = [];
- UI.component('toggle', {
- defaults: {
- target : false,
- cls : 'uk-hidden',
- animation : false,
- duration : 200
- },
- boot: function(){
- // init code
- UI.ready(function(context) {
- UI.$("[data-uk-toggle]", context).each(function() {
- var ele = UI.$(this);
- if (!ele.data("toggle")) {
- var obj = UI.toggle(ele, UI.Utils.options(ele.attr("data-uk-toggle")));
- }
- });
- setTimeout(function(){
- toggles.forEach(function(toggle){
- toggle.getToggles();
- });
- }, 0);
- });
- },
- init: function() {
- var $this = this;
- this.aria = (this.options.cls.indexOf('uk-hidden') !== -1);
- this.on("click", function(e) {
- if ($this.element.is('a[href="javascript:void(0);"]')) {
- e.preventDefault();
- }
- $this.toggle();
- });
- toggles.push(this);
- },
- toggle: function() {
- this.getToggles();
- if(!this.totoggle.length) return;
- if (this.options.animation && UI.support.animation) {
- var $this = this, animations = this.options.animation.split(',');
- if (animations.length == 1) {
- animations[1] = animations[0];
- }
- animations[0] = animations[0].trim();
- animations[1] = animations[1].trim();
- this.totoggle.css('animation-duration', this.options.duration+'ms');
- this.totoggle.each(function(){
- var ele = UI.$(this);
- if (ele.hasClass($this.options.cls)) {
- ele.toggleClass($this.options.cls);
- UI.Utils.animate(ele, animations[0]).then(function(){
- ele.css('animation-duration', '');
- UI.Utils.checkDisplay(ele);
- });
- } else {
- UI.Utils.animate(this, animations[1]+' uk-animation-reverse').then(function(){
- ele.toggleClass($this.options.cls).css('animation-duration', '');
- UI.Utils.checkDisplay(ele);
- });
- }
- });
- } else {
- this.totoggle.toggleClass(this.options.cls);
- UI.Utils.checkDisplay(this.totoggle);
- }
- this.updateAria();
- },
- getToggles: function() {
- this.totoggle = this.options.target ? UI.$(this.options.target):[];
- this.updateAria();
- },
- updateAria: function() {
- if (this.aria && this.totoggle.length) {
- this.totoggle.not('[aria-hidden]').each(function(){
- UI.$(this).attr('aria-hidden', UI.$(this).hasClass('uk-hidden'));
- });
- }
- }
- });
- })(UIkit);
- (function(UI) {
- "use strict";
- UI.component('alert', {
- defaults: {
- fade: true,
- duration: 200,
- trigger: '.uk-alert-close'
- },
- boot: function() {
- // init code
- UI.$html.on("click.alert.uikit", "[data-uk-alert]", function(e) {
- var ele = UI.$(this);
- if (!ele.data("alert")) {
- var alert = UI.alert(ele, UI.Utils.options(ele.attr("data-uk-alert")));
- if (UI.$(e.target).is(alert.options.trigger)) {
- e.preventDefault();
- alert.close();
- }
- }
- });
- },
- init: function() {
- var $this = this;
- this.on("click", this.options.trigger, function(e) {
- e.preventDefault();
- $this.close();
- });
- },
- close: function() {
- var element = this.trigger("close.uk.alert"),
- removeElement = function () {
- this.trigger("closed.uk.alert").remove();
- }.bind(this);
- if (this.options.fade) {
- element.css("overflow", "hidden").css("max-height", element.height()).animate({
- "height" : 0,
- "opacity" : 0,
- "padding-top" : 0,
- "padding-bottom" : 0,
- "margin-top" : 0,
- "margin-bottom" : 0
- }, this.options.duration, removeElement);
- } else {
- removeElement();
- }
- }
- });
- })(UIkit);
- (function(UI) {
- "use strict";
- UI.component('buttonRadio', {
- defaults: {
- activeClass: 'uk-active',
- target: '.uk-button'
- },
- boot: function() {
- // init code
- UI.$html.on("click.buttonradio.uikit", "[data-uk-button-radio]", function(e) {
- var ele = UI.$(this);
- if (!ele.data("buttonRadio")) {
- var obj = UI.buttonRadio(ele, UI.Utils.options(ele.attr("data-uk-button-radio"))),
- target = UI.$(e.target);
- if (target.is(obj.options.target)) {
- target.trigger("click");
- }
- }
- });
- },
- init: function() {
- var $this = this;
- // Init ARIA
- this.find($this.options.target).attr('aria-checked', 'false').filter('.' + $this.options.activeClass).attr('aria-checked', 'true');
- this.on("click", this.options.target, function(e) {
- var ele = UI.$(this);
- if (ele.is('a[href="javascript:void(0);"]')) e.preventDefault();
- $this.find($this.options.target).not(ele).removeClass($this.options.activeClass).blur();
- ele.addClass($this.options.activeClass);
- // Update ARIA
- $this.find($this.options.target).not(ele).attr('aria-checked', 'false');
- ele.attr('aria-checked', 'true');
- $this.trigger("change.uk.button", [ele]);
- });
- },
- getSelected: function() {
- return this.find('.' + this.options.activeClass);
- }
- });
- UI.component('buttonCheckbox', {
- defaults: {
- activeClass: 'uk-active',
- target: '.uk-button'
- },
- boot: function() {
- UI.$html.on("click.buttoncheckbox.uikit", "[data-uk-button-checkbox]", function(e) {
- var ele = UI.$(this);
- if (!ele.data("buttonCheckbox")) {
- var obj = UI.buttonCheckbox(ele, UI.Utils.options(ele.attr("data-uk-button-checkbox"))),
- target = UI.$(e.target);
- if (target.is(obj.options.target)) {
- target.trigger("click");
- }
- }
- });
- },
- init: function() {
- var $this = this;
- // Init ARIA
- this.find($this.options.target).attr('aria-checked', 'false').filter('.' + $this.options.activeClass).attr('aria-checked', 'true');
- this.on("click", this.options.target, function(e) {
- var ele = UI.$(this);
- if (ele.is('a[href="javascript:void(0);"]')) e.preventDefault();
- ele.toggleClass($this.options.activeClass).blur();
- // Update ARIA
- ele.attr('aria-checked', ele.hasClass($this.options.activeClass));
- $this.trigger("change.uk.button", [ele]);
- });
- },
- getSelected: function() {
- return this.find('.' + this.options.activeClass);
- }
- });
- UI.component('button', {
- defaults: {},
- boot: function() {
- UI.$html.on("click.button.uikit", "[data-uk-button]", function(e) {
- var ele = UI.$(this);
- if (!ele.data("button")) {
- var obj = UI.button(ele, UI.Utils.options(ele.attr("data-uk-button")));
- ele.trigger("click");
- }
- });
- },
- init: function() {
- var $this = this;
- // Init ARIA
- this.element.attr('aria-pressed', this.element.hasClass("uk-active"));
- this.on("click", function(e) {
- if ($this.element.is('a[href="javascript:void(0);"]')) e.preventDefault();
- $this.toggle();
- $this.trigger("change.uk.button", [$this.element.blur().hasClass("uk-active")]);
- });
- },
- toggle: function() {
- this.element.toggleClass("uk-active");
- // Update ARIA
- this.element.attr('aria-pressed', this.element.hasClass("uk-active"));
- }
- });
- })(UIkit);
- (function(UI) {
- "use strict";
- var active = false, hoverIdle, flips = {
- x: {
- "bottom-left" : 'bottom-right',
- "bottom-right" : 'bottom-left',
- "bottom-center" : 'bottom-center',
- "top-left" : 'top-right',
- "top-right" : 'top-left',
- "top-center" : 'top-center',
- "left-top" : 'right-top',
- "left-bottom" : 'right-bottom',
- "left-center" : 'right-center',
- "right-top" : 'left-top',
- "right-bottom" : 'left-bottom',
- "right-center" : 'left-center'
- },
- y: {
- "bottom-left" : 'top-left',
- "bottom-right" : 'top-right',
- "bottom-center" : 'top-center',
- "top-left" : 'bottom-left',
- "top-right" : 'bottom-right',
- "top-center" : 'bottom-center',
- "left-top" : 'left-bottom',
- "left-bottom" : 'left-top',
- "left-center" : 'left-center',
- "right-top" : 'right-bottom',
- "right-bottom" : 'right-top',
- "right-center" : 'right-center'
- },
- xy: {
- "bottom-left" : 'top-right',
- "bottom-right" : 'top-left',
- "bottom-center" : 'top-center',
- "top-left" : 'bottom-right',
- "top-right" : 'bottom-left',
- "top-center" : 'bottom-center',
- "left-top" : 'right-bottom',
- "left-bottom" : 'right-top',
- "left-center" : 'right-center',
- "right-top" : 'left-bottom',
- "right-bottom" : 'left-top',
- "right-center" : 'left-center'
- }
- };
- UI.component('dropdown', {
- defaults: {
- mode : 'hover',
- pos : 'bottom-left',
- offset : 0,
- remaintime : 800,
- justify : false,
- boundary : UI.$win,
- delay : 0,
- dropdownSelector: '.uk-dropdown,.uk-dropdown-blank',
- hoverDelayIdle : 250,
- preventflip : false
- },
- remainIdle: false,
- boot: function() {
- var triggerevent = UI.support.touch ? "click" : "mouseenter";
- // init code
- UI.$html.on(triggerevent+".dropdown.uikit focus", "[data-uk-dropdown]", function(e) {
- var ele = UI.$(this);
- if (!ele.data("dropdown")) {
- var dropdown = UI.dropdown(ele, UI.Utils.options(ele.attr("data-uk-dropdown")));
- if (triggerevent=="click" || (triggerevent=="mouseenter" && dropdown.options.mode=="hover")) {
- dropdown.element.trigger(triggerevent);
- }
- if (dropdown.element.find(dropdown.options.dropdownSelector).length) {
- e.preventDefault();
- }
- }
- });
- },
- init: function() {
- var $this = this;
- this.dropdown = this.find(this.options.dropdownSelector);
- this.offsetParent = this.dropdown.parents().filter(function() {
- return UI.$.inArray(UI.$(this).css('position'), ['relative', 'fixed', 'absolute']) !== -1;
- }).slice(0,1);
- this.centered = this.dropdown.hasClass('uk-dropdown-center');
- this.justified = this.options.justify ? UI.$(this.options.justify) : false;
- this.boundary = UI.$(this.options.boundary);
- if (!this.boundary.length) {
- this.boundary = UI.$win;
- }
- // legacy DEPRECATED!
- if (this.dropdown.hasClass('uk-dropdown-up')) {
- this.options.pos = 'top-left';
- }
- if (this.dropdown.hasClass('uk-dropdown-flip')) {
- this.options.pos = this.options.pos.replace('left','right');
- }
- if (this.dropdown.hasClass('uk-dropdown-center')) {
- this.options.pos = this.options.pos.replace(/(left|right)/,'center');
- }
- //-- end legacy
- // Init ARIA
- this.element.attr('aria-haspopup', 'true');
- this.element.attr('aria-expanded', this.element.hasClass('uk-open'));
- this.dropdown.attr('aria-hidden', 'true');
- if (this.options.mode == "click" || UI.support.touch) {
- this.on("click.uk.dropdown", function(e) {
- var $target = UI.$(e.target);
- if (!$target.parents($this.options.dropdownSelector).length) {
- if ($target.is("a[href='javascript:void(0);']") || $target.parent().is("a[href='javascript:void(0);']") || ($this.dropdown.length && !$this.dropdown.is(":visible")) ){
- e.preventDefault();
- }
- $target.blur();
- }
- if (!$this.element.hasClass('uk-open')) {
- $this.show();
- } else {
- if (!$this.dropdown.find(e.target).length || $target.is(".uk-dropdown-close") || $target.parents(".uk-dropdown-close").length) {
- $this.hide();
- }
- }
- });
- } else {
- this.on("mouseenter", function(e) {
- $this.trigger('pointerenter.uk.dropdown', [$this]);
- if ($this.remainIdle) {
- clearTimeout($this.remainIdle);
- }
- if (hoverIdle) {
- clearTimeout(hoverIdle);
- }
- if (active && active == $this) {
- return;
- }
- // pseudo manuAim
- if (active && active != $this) {
- hoverIdle = setTimeout(function() {
- hoverIdle = setTimeout($this.show.bind($this), $this.options.delay);
- }, $this.options.hoverDelayIdle);
- } else {
- hoverIdle = setTimeout($this.show.bind($this), $this.options.delay);
- }
- }).on("mouseleave", function() {
- if (hoverIdle) {
- clearTimeout(hoverIdle);
- }
- $this.remainIdle = setTimeout(function() {
- if (active && active == $this) $this.hide();
- }, $this.options.remaintime);
- $this.trigger('pointerleave.uk.dropdown', [$this]);
- }).on("click", function(e){
- var $target = UI.$(e.target);
- if ($this.remainIdle) {
- clearTimeout($this.remainIdle);
- }
- if (active && active == $this) {
- if (!$this.dropdown.find(e.target).length || $target.is(".uk-dropdown-close") || $target.parents(".uk-dropdown-close").length) {
- $this.hide();
- }
- return;
- }
- if ($target.is("a[href='javascript:void(0);']") || $target.parent().is("a[href='javascript:void(0);']")){
- e.preventDefault();
- }
- $this.show();
- });
- }
- },
- show: function(){
- UI.$html.off("click.outer.dropdown");
- if (active && active != this) {
- active.hide(true);
- }
- if (hoverIdle) {
- clearTimeout(hoverIdle);
- }
- this.trigger('beforeshow.uk.dropdown', [this]);
- this.checkDimensions();
- this.element.addClass('uk-open');
- // Update ARIA
- this.element.attr('aria-expanded', 'true');
- this.dropdown.attr('aria-hidden', 'false');
- this.trigger('show.uk.dropdown', [this]);
- UI.Utils.checkDisplay(this.dropdown, true);
- UI.Utils.focus(this.dropdown);
- active = this;
- this.registerOuterClick();
- },
- hide: function(force) {
- this.trigger('beforehide.uk.dropdown', [this, force]);
- this.element.removeClass('uk-open');
- if (this.remainIdle) {
- clearTimeout(this.remainIdle);
- }
- this.remainIdle = false;
- // Update ARIA
- this.element.attr('aria-expanded', 'false');
- this.dropdown.attr('aria-hidden', 'true');
- this.trigger('hide.uk.dropdown', [this, force]);
- if (active == this) active = false;
- },
- registerOuterClick: function(){
- var $this = this;
- UI.$html.off("click.outer.dropdown");
- setTimeout(function() {
- UI.$html.on("click.outer.dropdown", function(e) {
- if (hoverIdle) {
- clearTimeout(hoverIdle);
- }
- var $target = UI.$(e.target);
- if (active == $this && !$this.element.find(e.target).length) {
- $this.hide(true);
- UI.$html.off("click.outer.dropdown");
- }
- });
- }, 10);
- },
- checkDimensions: function() {
- if (!this.dropdown.length) return;
- // reset
- this.dropdown.removeClass('uk-dropdown-top uk-dropdown-bottom uk-dropdown-left uk-dropdown-right uk-dropdown-stack').css({
- 'top-left':'',
- 'left':'',
- 'margin-left' :'',
- 'margin-right':''
- });
- if (this.justified && this.justified.length) {
- this.dropdown.css("min-width", "");
- }
- var $this = this,
- pos = UI.$.extend({}, this.offsetParent.offset(), {width: this.offsetParent[0].offsetWidth, height: this.offsetParent[0].offsetHeight}),
- posoffset = this.options.offset,
- dropdown = this.dropdown,
- offset = dropdown.show().offset() || {left: 0, top: 0},
- width = dropdown.outerWidth(),
- height = dropdown.outerHeight(),
- boundarywidth = this.boundary.width(),
- boundaryoffset = this.boundary[0] !== window && this.boundary.offset() ? this.boundary.offset(): {top:0, left:0},
- dpos = this.options.pos;
- var variants = {
- "bottom-left" : {top: 0 + pos.height + posoffset, left: 0},
- "bottom-right" : {top: 0 + pos.height + posoffset, left: 0 + pos.width - width},
- "bottom-center" : {top: 0 + pos.height + posoffset, left: 0 + pos.width / 2 - width / 2},
- "top-left" : {top: 0 - height - posoffset, left: 0},
- "top-right" : {top: 0 - height - posoffset, left: 0 + pos.width - width},
- "top-center" : {top: 0 - height - posoffset, left: 0 + pos.width / 2 - width / 2},
- "left-top" : {top: 0, left: 0 - width - posoffset},
- "left-bottom" : {top: 0 + pos.height - height, left: 0 - width - posoffset},
- "left-center" : {top: 0 + pos.height / 2 - height / 2, left: 0 - width - posoffset},
- "right-top" : {top: 0, left: 0 + pos.width + posoffset},
- "right-bottom" : {top: 0 + pos.height - height, left: 0 + pos.width + posoffset},
- "right-center" : {top: 0 + pos.height / 2 - height / 2, left: 0 + pos.width + posoffset}
- },
- css = {},
- pp;
- pp = dpos.split('-');
- css = variants[dpos] ? variants[dpos] : variants['bottom-left'];
- // justify dropdown
- if (this.justified && this.justified.length) {
- justify(dropdown.css({left:0}), this.justified, boundarywidth);
- } else {
- if (this.options.preventflip !== true) {
- var fdpos;
- switch(this.checkBoundary(pos.left + css.left, pos.top + css.top, width, height, boundarywidth)) {
- case "x":
- if(this.options.preventflip !=='x') fdpos = flips['x'][dpos] || 'right-top';
- break;
- case "y":
- if(this.options.preventflip !=='y') fdpos = flips['y'][dpos] || 'top-left';
- break;
- case "xy":
- if(!this.options.preventflip) fdpos = flips['xy'][dpos] || 'right-bottom';
- break;
- }
- if (fdpos) {
- pp = fdpos.split('-');
- css = variants[fdpos] ? variants[fdpos] : variants['bottom-left'];
- // check flipped
- if (this.checkBoundary(pos.left + css.left, pos.top + css.top, width, height, boundarywidth)) {
- pp = dpos.split('-');
- css = variants[dpos] ? variants[dpos] : variants['bottom-left'];
- }
- }
- }
- }
- if (width > boundarywidth) {
- dropdown.addClass("uk-dropdown-stack");
- this.trigger('stack.uk.dropdown', [this]);
- }
- dropdown.css(css).css("display", "").addClass('uk-dropdown-'+pp[0]);
- },
- checkBoundary: function(left, top, width, height, boundarywidth) {
- var axis = "";
- if (left < 0 || ((left - UI.$win.scrollLeft())+width) > boundarywidth) {
- axis += "x";
- }
- if ((top - UI.$win.scrollTop()) < 0 || ((top - UI.$win.scrollTop())+height) > window.innerHeight) {
- axis += "y";
- }
- return axis;
- }
- });
- UI.component('dropdownOverlay', {
- defaults: {
- justify : false,
- cls : '',
- duration: 200
- },
- boot: function() {
- // init code
- UI.ready(function(context) {
- UI.$("[data-uk-dropdown-overlay]", context).each(function() {
- var ele = UI.$(this);
- if (!ele.data("dropdownOverlay")) {
- UI.dropdownOverlay(ele, UI.Utils.options(ele.attr("data-uk-dropdown-overlay")));
- }
- });
- });
- },
- init: function() {
- var $this = this;
- this.justified = this.options.justify ? UI.$(this.options.justify) : false;
- this.overlay = this.element.find('uk-dropdown-overlay');
- if (!this.overlay.length) {
- this.overlay = UI.$('<div class="uk-dropdown-overlay"></div>').appendTo(this.element);
- }
- this.overlay.addClass(this.options.cls);
- this.on({
- 'beforeshow.uk.dropdown': function(e, dropdown) {
- $this.dropdown = dropdown;
- if ($this.justified && $this.justified.length) {
- justify($this.overlay.css({'display':'block', 'margin-left':'','margin-right':''}), $this.justified, $this.justified.outerWidth());
- }
- },
- 'show.uk.dropdown': function(e, dropdown) {
- var h = $this.dropdown.dropdown.outerHeight(true);
- $this.dropdown.element.removeClass('uk-open');
- $this.overlay.stop().css('display', 'block').animate({height: h}, $this.options.duration, function() {
- $this.dropdown.dropdown.css('visibility', '');
- $this.dropdown.element.addClass('uk-open');
- UI.Utils.checkDisplay($this.dropdown.dropdown, true);
- });
- $this.pointerleave = false;
- },
- 'hide.uk.dropdown': function() {
- $this.overlay.stop().animate({height: 0}, $this.options.duration);
- },
- 'pointerenter.uk.dropdown': function(e, dropdown) {
- clearTimeout($this.remainIdle);
- },
- 'pointerleave.uk.dropdown': function(e, dropdown) {
- $this.pointerleave = true;
- }
- });
- this.overlay.on({
- 'mouseenter': function() {
- if ($this.remainIdle) {
- clearTimeout($this.dropdown.remainIdle);
- clearTimeout($this.remainIdle);
- }
- },
- 'mouseleave': function(){
- if ($this.pointerleave && active) {
- $this.remainIdle = setTimeout(function() {
- if(active) active.hide();
- }, active.options.remaintime);
- }
- }
- })
- }
- });
- function justify(ele, justifyTo, boundarywidth, offset) {
- ele = UI.$(ele);
- justifyTo = UI.$(justifyTo);
- boundarywidth = boundarywidth || window.innerWidth;
- offset = offset || ele.offset();
- if (justifyTo.length) {
- var jwidth = justifyTo.outerWidth();
- ele.css("min-width", jwidth);
- if (UI.langdirection == 'right') {
- var right1 = boundarywidth - (justifyTo.offset().left + jwidth),
- right2 = boundarywidth - (ele.offset().left + ele.outerWidth());
- ele.css("margin-right", right1 - right2);
- } else {
- ele.css("margin-left", justifyTo.offset().left - offset.left);
- }
- }
- }
- })(UIkit);
- (function(UI) {
- "use strict";
- var grids = [];
- UI.component('gridMatchHeight', {
- defaults: {
- target : false,
- row : true,
- ignorestacked : false,
- observe : false
- },
- boot: function() {
- // init code
- UI.ready(function(context) {
- UI.$("[data-uk-grid-match]", context).each(function() {
- var grid = UI.$(this), obj;
- if (!grid.data("gridMatchHeight")) {
- obj = UI.gridMatchHeight(grid, UI.Utils.options(grid.attr("data-uk-grid-match")));
- }
- });
- });
- },
- init: function() {
- var $this = this;
- this.columns = this.element.children();
- this.elements = this.options.target ? this.find(this.options.target) : this.columns;
- if (!this.columns.length) return;
- UI.$win.on('load resize orientationchange', (function() {
- var fn = function() {
- if ($this.element.is(":visible")) $this.match();
- };
- UI.$(function() { fn(); });
- return UI.Utils.debounce(fn, 50);
- })());
- if (this.options.observe) {
- UI.domObserve(this.element, function(e) {
- if ($this.element.is(":visible")) $this.match();
- });
- }
- this.on("display.uk.check", function(e) {
- if(this.element.is(":visible")) this.match();
- }.bind(this));
- grids.push(this);
- },
- match: function() {
- var firstvisible = this.columns.filter(":visible:first");
- if (!firstvisible.length) return;
- var stacked = Math.ceil(100 * parseFloat(firstvisible.css('width')) / parseFloat(firstvisible.parent().css('width'))) >= 100;
- if (stacked && !this.options.ignorestacked) {
- this.revert();
- } else {
- UI.Utils.matchHeights(this.elements, this.options);
- }
- return this;
- },
- revert: function() {
- this.elements.css('min-height', '');
- return this;
- }
- });
- UI.component('gridMargin', {
- defaults: {
- cls : 'uk-grid-margin',
- rowfirst : 'uk-row-first'
- },
- boot: function() {
- // init code
- UI.ready(function(context) {
- UI.$("[data-uk-grid-margin]", context).each(function() {
- var grid = UI.$(this), obj;
- if (!grid.data("gridMargin")) {
- obj = UI.gridMargin(grid, UI.Utils.options(grid.attr("data-uk-grid-margin")));
- }
- });
- });
- },
- init: function() {
- var stackMargin = UI.stackMargin(this.element, this.options);
- }
- });
- })(UIkit);
- (function(UI) {
- "use strict";
- var active = false, activeCount = 0, $html = UI.$html, body;
- UI.$win.on("resize orientationchange", UI.Utils.debounce(function(){
- UI.$('.uk-modal.uk-open').each(function(){
- return UI.$(this).data('modal') && UI.$(this).data('modal').resize();
- });
- }, 150));
- UI.component('modal', {
- defaults: {
- keyboard: true,
- bgclose: true,
- minScrollHeight: 150,
- center: false,
- modal: true
- },
- scrollable: false,
- transition: false,
- hasTransitioned: true,
- init: function() {
- if (!body) body = UI.$('body');
- if (!this.element.length) return;
- var $this = this;
- this.paddingdir = "padding-" + (UI.langdirection == 'left' ? "right":"left");
- this.dialog = this.find(".uk-modal-dialog");
- this.active = false;
- // Update ARIA
- this.element.attr('aria-hidden', this.element.hasClass("uk-open"));
- this.on("click", ".uk-modal-close", function(e) {
- e.preventDefault();
- $this.hide();
- }).on("click", function(e) {
- var target = UI.$(e.target);
- if (target[0] == $this.element[0] && $this.options.bgclose) {
- $this.hide();
- }
- });
- UI.domObserve(this.element, function(e) { $this.resize(); });
- },
- toggle: function() {
- return this[this.isActive() ? "hide" : "show"]();
- },
- show: function() {
- if (!this.element.length) return;
- var $this = this;
- if (this.isActive()) return;
- if (this.options.modal && active) {
- active.hide(true);
- }
- this.element.removeClass("uk-open").show();
- this.resize(true);
- if (this.options.modal) {
- active = this;
- }
- this.active = true;
- activeCount++;
- if (UI.support.transition) {
- this.hasTransitioned = false;
- this.element.one(UI.support.transition.end, function(){
- $this.hasTransitioned = true;
- UI.Utils.focus($this.dialog, 'a[href]');
- }).addClass("uk-open");
- } else {
- this.element.addClass("uk-open");
- UI.Utils.focus(this.dialog, 'a[href]');
- }
- $html.addClass("uk-modal-page").height(); // force browser engine redraw
- // Update ARIA
- this.element.attr('aria-hidden', 'false');
- this.element.trigger("show.uk.modal");
- UI.Utils.checkDisplay(this.dialog, true);
- return this;
- },
- hide: function(force) {
- if (!force && UI.support.transition && this.hasTransitioned) {
- var $this = this;
- this.one(UI.support.transition.end, function() {
- $this._hide();
- }).removeClass("uk-open");
- } else {
- this._hide();
- }
- return this;
- },
- resize: function(force) {
- if (!this.isActive() && !force) return;
- var bodywidth = body.width();
- this.scrollbarwidth = window.innerWidth - bodywidth;
- body.css(this.paddingdir, this.scrollbarwidth);
- this.element.css('overflow-y', this.scrollbarwidth ? 'scroll' : 'auto');
- if (!this.updateScrollable() && this.options.center) {
- var dh = this.dialog.outerHeight(),
- pad = parseInt(this.dialog.css('margin-top'), 10) + parseInt(this.dialog.css('margin-bottom'), 10);
- if ((dh + pad) < window.innerHeight) {
- this.dialog.css({'top': (window.innerHeight/2 - dh/2) - pad });
- } else {
- this.dialog.css({'top': ''});
- }
- }
- },
- updateScrollable: function() {
- // has scrollable?
- var scrollable = this.dialog.find('.uk-overflow-container:visible:first');
- if (scrollable.length) {
- scrollable.css('height', 0);
- var offset = Math.abs(parseInt(this.dialog.css('margin-top'), 10)),
- dh = this.dialog.outerHeight(),
- wh = window.innerHeight,
- h = wh - 2*(offset < 20 ? 20:offset) - dh;
- scrollable.css({
- 'max-height': (h < this.options.minScrollHeight ? '':h),
- 'height':''
- });
- return true;
- }
- return false;
- },
- _hide: function() {
- this.active = false;
- if (activeCount > 0) activeCount--;
- else activeCount = 0;
- this.element.hide().removeClass('uk-open');
- // Update ARIA
- this.element.attr('aria-hidden', 'true');
- if (!activeCount) {
- $html.removeClass('uk-modal-page');
- body.css(this.paddingdir, "");
- }
- if (active===this) active = false;
- this.trigger('hide.uk.modal');
- },
- isActive: function() {
- return this.element.hasClass('uk-open');
- }
- });
- UI.component('modalTrigger', {
- boot: function() {
- // init code
- UI.$html.on("click.modal.uikit", "[data-uk-modal]", function(e) {
- var ele = UI.$(this);
- if (ele.is("a")) {
- e.preventDefault();
- }
- if (!ele.data("modalTrigger")) {
- var modal = UI.modalTrigger(ele, UI.Utils.options(ele.attr("data-uk-modal")));
- modal.show();
- }
- });
- // close modal on esc button
- UI.$html.on('keydown.modal.uikit', function (e) {
- if (active && e.keyCode === 27 && active.options.keyboard) { // ESC
- e.preventDefault();
- active.hide();
- }
- });
- },
- init: function() {
- var $this = this;
- this.options = UI.$.extend({
- "target": $this.element.is("a") ? $this.element.attr("href") : false
- }, this.options);
- this.modal = UI.modal(this.options.target, this.options);
- this.on("click", function(e) {
- e.preventDefault();
- $this.show();
- });
- //methods
- this.proxy(this.modal, "show hide isActive");
- }
- });
- UI.modal.dialog = function(content, options) {
- var modal = UI.modal(UI.$(UI.modal.dialog.template).appendTo("body"), options);
- modal.on("hide.uk.modal", function(){
- if (modal.persist) {
- modal.persist.appendTo(modal.persist.data("modalPersistParent"));
- modal.persist = false;
- }
- modal.element.remove();
- });
- setContent(content, modal);
- return modal;
- };
- UI.modal.dialog.template = '<div class="uk-modal"><div class="uk-modal-dialog" style="min-height:0;"></div></div>';
- UI.modal.alert = function(content, options) {
- options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, options);
- var modal = UI.modal.dialog(([
- '<div class="uk-margin uk-modal-content">'+String(content)+'</div>',
- '<div class="uk-modal-footer uk-text-right"><button class="uk-button uk-button-primary uk-modal-close">'+options.labels.Ok+'</button></div>'
- ]).join(""), options);
- modal.on('show.uk.modal', function(){
- setTimeout(function(){
- modal.element.find('button:first').focus();
- }, 50);
- });
- return modal.show();
- };
- UI.modal.confirm = function(content, onconfirm, oncancel) {
- var options = arguments.length > 1 && arguments[arguments.length-1] ? arguments[arguments.length-1] : {};
- onconfirm = UI.$.isFunction(onconfirm) ? onconfirm : function(){};
- oncancel = UI.$.isFunction(oncancel) ? oncancel : function(){};
- options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, UI.$.isFunction(options) ? {}:options);
- var modal = UI.modal.dialog(([
- '<div class="uk-margin uk-modal-content">'+String(content)+'</div>',
- '<div class="uk-modal-footer uk-text-right"><button class="uk-button js-modal-confirm-cancel">'+options.labels.Cancel+'</button> <button class="uk-button uk-button-primary js-modal-confirm">'+options.labels.Ok+'</button></div>'
- ]).join(""), options);
- modal.element.find(".js-modal-confirm, .js-modal-confirm-cancel").on("click", function(){
- UI.$(this).is('.js-modal-confirm') ? onconfirm() : oncancel();
- modal.hide();
- });
- modal.on('show.uk.modal', function(){
- setTimeout(function(){
- modal.element.find('.js-modal-confirm').focus();
- }, 50);
- });
- return modal.show();
- };
- UI.modal.prompt = function(text, value, onsubmit, options) {
- onsubmit = UI.$.isFunction(onsubmit) ? onsubmit : function(value){};
- options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, options);
- var modal = UI.modal.dialog(([
- text ? '<div class="uk-modal-content uk-form">'+String(text)+'</div>':'',
- '<div class="uk-margin-small-top uk-modal-content uk-form"><p><input type="text" class="uk-width-1-1"></p></div>',
- '<div class="uk-modal-footer uk-text-right"><button class="uk-button uk-modal-close">'+options.labels.Cancel+'</button> <button class="uk-button uk-button-primary js-modal-ok">'+options.labels.Ok+'</button></div>'
- ]).join(""), options),
- input = modal.element.find("input[type='text']").val(value || '').on('keyup', function(e){
- if (e.keyCode == 13) {
- modal.element.find(".js-modal-ok").trigger('click');
- }
- });
- modal.element.find(".js-modal-ok").on("click", function(){
- if (onsubmit(input.val())!==false){
- modal.hide();
- }
- });
- return modal.show();
- };
- UI.modal.blockUI = function(content, options) {
- var modal = UI.modal.dialog(([
- '<div class="uk-margin uk-modal-content">'+String(content || '<div class="uk-text-center">...</div>')+'</div>'
- ]).join(""), UI.$.extend({bgclose:false, keyboard:false, modal:false}, options));
- modal.content = modal.element.find('.uk-modal-content:first');
- return modal.show();
- };
- UI.modal.labels = {
- 'Ok': 'Ok',
- 'Cancel': 'Cancel'
- };
- // helper functions
- function setContent(content, modal){
- if(!modal) return;
- if (typeof content === 'object') {
- // convert DOM object to a jQuery object
- content = content instanceof jQuery ? content : UI.$(content);
- if(content.parent().length) {
- modal.persist = content;
- modal.persist.data("modalPersistParent", content.parent());
- }
- }else if (typeof content === 'string' || typeof content === 'number') {
- // just insert the data as innerHTML
- content = UI.$('<div></div>').html(content);
- }else {
- // unsupported data type!
- content = UI.$('<div></div>').html('UIkit.modal Error: Unsupported data type: ' + typeof content);
- }
- content.appendTo(modal.element.find('.uk-modal-dialog'));
- return modal;
- }
- })(UIkit);
- (function(UI) {
- "use strict";
- UI.component('nav', {
- defaults: {
- toggle: ">li.uk-parent > a[href='javascript:void(0);']",
- lists: ">li.uk-parent > ul",
- multiple: false
- },
- boot: function() {
- // init code
- UI.ready(function(context) {
- UI.$("[data-uk-nav]", context).each(function() {
- var nav = UI.$(this);
- if (!nav.data("nav")) {
- var obj = UI.nav(nav, UI.Utils.options(nav.attr("data-uk-nav")));
- }
- });
- });
- },
- init: function() {
- var $this = this;
- this.on("click.uk.nav", this.options.toggle, function(e) {
- e.preventDefault();
- var ele = UI.$(this);
- $this.open(ele.parent()[0] == $this.element[0] ? ele : ele.parent("li"));
- });
- this.update(true);
- UI.domObserve(this.element, function(e) {
- if ($this.element.find(this.options.lists).not('[role]').length) {
- $this.update();
- }
- });
- },
- update: function(init) {
- var $this = this;
- this.find(this.options.lists).each(function() {
- var $ele = UI.$(this).attr('role', 'menu'),
- parent = $ele.closest('li'),
- active = parent.hasClass("uk-active");
- if (!parent.data('list-container')) {
- $ele.wrap('<div style="overflow:hidden;height:0;position:relative;"></div>');
- parent.data('list-container', $ele.parent()[active ? 'removeClass':'addClass']('uk-hidden'));
- }
- // Init ARIA
- parent.attr('aria-expanded', parent.hasClass("uk-open"));
- if (active) $this.open(parent, true);
- });
- },
- open: function(li, noanimation) {
- var $this = this, element = this.element, $li = UI.$(li), $container = $li.data('list-container');
- if (!this.options.multiple) {
- element.children('.uk-open').not(li).each(function() {
- var ele = UI.$(this);
- if (ele.data('list-container')) {
- ele.data('list-container').stop().animate({height: 0}, function() {
- UI.$(this).parent().removeClass('uk-open').end().addClass('uk-hidden');
- });
- }
- });
- }
- $li.toggleClass('uk-open');
- // Update ARIA
- $li.attr('aria-expanded', $li.hasClass('uk-open'));
- if ($container) {
- if ($li.hasClass('uk-open')) {
- $container.removeClass('uk-hidden');
- }
- if (noanimation) {
- $container.stop().height($li.hasClass('uk-open') ? 'auto' : 0);
- if (!$li.hasClass('uk-open')) {
- $container.addClass('uk-hidden');
- }
- this.trigger('display.uk.check');
- } else {
- $container.stop().animate({
- height: ($li.hasClass('uk-open') ? getHeight($container.find('ul:first')) : 0)
- }, function() {
- if (!$li.hasClass('uk-open')) {
- $container.addClass('uk-hidden');
- } else {
- $container.css('height', '');
- }
- $this.trigger('display.uk.check');
- });
- }
- }
- }
- });
- // helper
- function getHeight(ele) {
- var $ele = UI.$(ele), height = "auto";
- if ($ele.is(":visible")) {
- height = $ele.outerHeight();
- } else {
- var tmp = {
- position: $ele.css("position"),
- visibility: $ele.css("visibility"),
- display: $ele.css("display")
- };
- height = $ele.css({position: 'absolute', visibility: 'hidden', display: 'block'}).outerHeight();
- $ele.css(tmp); // reset element
- }
- return height;
- }
- })(UIkit);
- (function(UI) {
- "use strict";
- var scrollpos = {x: window.scrollX, y: window.scrollY},
- $win = UI.$win,
- $doc = UI.$doc,
- $html = UI.$html,
- Offcanvas = {
- show: function(element, options) {
- element = UI.$(element);
- if (!element.length) return;
- options = UI.$.extend({mode: 'push'}, options);
- var $body = UI.$('body'),
- bar = element.find('.uk-offcanvas-bar:first'),
- rtl = (UI.langdirection == 'right'),
- flip = bar.hasClass('uk-offcanvas-bar-flip') ? -1:1,
- dir = flip * (rtl ? -1 : 1),
- scrollbarwidth = window.innerWidth - $body.width();
- scrollpos = {x: window.pageXOffset, y: window.pageYOffset};
- bar.attr('mode', options.mode);
- element.addClass("uk-active");
- $body.css({width: window.innerWidth - scrollbarwidth, height: window.innerHeight}).addClass("uk-offcanvas-page");
- if (options.mode == 'push' || options.mode == 'reveal') {
- $body.css((rtl ? "margin-right" : "margin-left"), (rtl ? -1 : 1) * (bar.outerWidth() * dir));
- }
- if (options.mode == 'reveal') {
- bar.css('clip', 'rect(0, '+bar.outerWidth()+'px, 100vh, 0)');
- }
- $html.css('margin-top', scrollpos.y * -1).width(); // .width() - force redraw
- bar.addClass("uk-offcanvas-bar-show");
- this._initElement(element);
- bar.trigger('show.uk.offcanvas', [element, bar]);
- // Update ARIA
- element.attr('aria-hidden', 'false');
- },
- hide: function(force) {
- var $body = UI.$('body'),
- panel = UI.$(".uk-offcanvas.uk-active"),
- rtl = (UI.langdirection == "right"),
- bar = panel.find(".uk-offcanvas-bar:first"),
- finalize = function() {
- $body.removeClass("uk-offcanvas-page").css({"width": "", "height": "", "margin-left": "", "margin-right": ""});
- panel.removeClass("uk-active");
- bar.removeClass("uk-offcanvas-bar-show");
- $html.css('margin-top', '');
- window.scrollTo(scrollpos.x, scrollpos.y);
- bar.trigger('hide.uk.offcanvas', [panel, bar]);
- // Update ARIA
- panel.attr('aria-hidden', 'true');
- };
- if (!panel.length) return;
- if (bar.attr('mode') == 'none') force = true;
- if (UI.support.transition && !force) {
- $body.one(UI.support.transition.end, function() {
- finalize();
- }).css((rtl ? 'margin-right' : 'margin-left'), '');
- if (bar.attr('mode') == 'reveal') {
- bar.css('clip', '');
- }
- setTimeout(function(){
- bar.removeClass('uk-offcanvas-bar-show');
- }, 0);
- } else {
- finalize();
- }
- },
- _initElement: function(element) {
- if (element.data('OffcanvasInit')) return;
- element.on('click.uk.offcanvas swipeRight.uk.offcanvas swipeLeft.uk.offcanvas', function(e) {
- var target = UI.$(e.target);
- if (!e.type.match(/swipe/)) {
- if (!target.hasClass('uk-offcanvas-close')) {
- if (target.hasClass('uk-offcanvas-bar')) return;
- if (target.parents('.uk-offcanvas-bar:first').length) return;
- }
- }
- e.stopImmediatePropagation();
- Offcanvas.hide();
- });
- element.on('click', "a[href*='#']", function(e){
- var link = UI.$(this),
- href = link.attr('href');
- if (href == '#') {
- return;
- }
- UI.$doc.one('hide.uk.offcanvas', function() {
- var target;
- try {
- target = UI.$(link[0].hash);
- } catch (e){
- target = '';
- }
- if (!target.length) {
- target = UI.$('[name="'+link[0].hash.replace('#','')+'"]');
- }
- if (target.length && UI.Utils.scrollToElement) {
- UI.Utils.scrollToElement(target, UI.Utils.options(link.attr('data-uk-smooth-scroll') || '{}'));
- } else {
- window.location.href = href;
- }
- });
- Offcanvas.hide();
- });
- element.data('OffcanvasInit', true);
- }
- };
- UI.component('offcanvasTrigger', {
- boot: function() {
- // init code
- $html.on('click.offcanvas.uikit', '[data-uk-offcanvas]', function(e) {
- e.preventDefault();
- var ele = UI.$(this);
- if (!ele.data('offcanvasTrigger')) {
- var obj = UI.offcanvasTrigger(ele, UI.Utils.options(ele.attr('data-uk-offcanvas')));
- ele.trigger("click");
- }
- });
- $html.on('keydown.uk.offcanvas', function(e) {
- if (e.keyCode === 27) { // ESC
- Offcanvas.hide();
- }
- });
- },
- init: function() {
- var $this = this;
- this.options = UI.$.extend({
- target: $this.element.is('a') ? $this.element.attr('href') : false,
- mode: 'push'
- }, this.options);
- this.on('click', function(e) {
- e.preventDefault();
- Offcanvas.show($this.options.target, $this.options);
- });
- }
- });
- UI.offcanvas = Offcanvas;
- })(UIkit);
- (function(UI) {
- "use strict";
- var Animations;
- UI.component('switcher', {
- defaults: {
- connect : false,
- toggle : ">*",
- active : 0,
- animation : false,
- duration : 200,
- swiping : true
- },
- animating: false,
- boot: function() {
- // init code
- UI.ready(function(context) {
- UI.$("[data-uk-switcher]", context).each(function() {
- var switcher = UI.$(this);
- if (!switcher.data("switcher")) {
- var obj = UI.switcher(switcher, UI.Utils.options(switcher.attr("data-uk-switcher")));
- }
- });
- });
- },
- init: function() {
- var $this = this;
- this.on('click.uk.switcher', this.options.toggle, function(e) {
- e.preventDefault();
- $this.show(this);
- });
- if (!this.options.connect) {
- return;
- }
- this.connect = UI.$(this.options.connect);
- if (!this.connect.length) {
- return;
- }
- this.connect.on('click.uk.switcher', '[data-uk-switcher-item]', function(e) {
- e.preventDefault();
- var item = UI.$(this).attr('data-uk-switcher-item');
- if ($this.index == item) return;
- switch(item) {
- case 'next':
- case 'previous':
- $this.show($this.index + (item=='next' ? 1:-1));
- break;
- default:
- $this.show(parseInt(item, 10));
- }
- });
- if (this.options.swiping) {
- this.connect.on('swipeRight swipeLeft', function(e) {
- e.preventDefault();
- if (!window.getSelection().toString()) {
- $this.show($this.index + (e.type == 'swipeLeft' ? 1 : -1));
- }
- });
- }
- this.update();
- },
- update: function() {
- this.connect.children().removeClass('uk-active').attr('aria-hidden', 'true');
- var toggles = this.find(this.options.toggle),
- active = toggles.filter(".uk-active");
- if (active.length) {
- this.show(active, false);
- } else {
- if (this.options.active===false) return;
- active = toggles.eq(this.options.active);
- this.show(active.length ? active : toggles.eq(0), false);
- }
- // Init ARIA for toggles
- toggles.not(active).attr('aria-expanded', 'false');
- active.attr('aria-expanded', 'true');
- },
- show: function(tab, animate) {
- if (this.animating) {
- return;
- }
- if (isNaN(tab)) {
- tab = UI.$(tab);
- } else {
- var toggles = this.find(this.options.toggle);
- tab = tab < 0 ? toggles.length-1 : tab;
- tab = toggles.eq(toggles[tab] ? tab : 0);
- }
- var $this = this,
- toggles = this.find(this.options.toggle),
- active = UI.$(tab),
- animation = Animations[this.options.animation] || function(current, next) {
- if (!$this.options.animation) {
- return Animations.none.apply($this);
- }
- var anim = $this.options.animation.split(',');
- if (anim.length == 1) {
- anim[1] = anim[0];
- }
- anim[0] = anim[0].trim();
- anim[1] = anim[1].trim();
- return coreAnimation.apply($this, [anim, current, next]);
- };
- if (animate===false || !UI.support.animation) {
- animation = Animations.none;
- }
- if (active.hasClass("uk-disabled")) return;
- // Update ARIA for Toggles
- toggles.attr('aria-expanded', 'false');
- active.attr('aria-expanded', 'true');
- toggles.filter(".uk-active").removeClass("uk-active");
- active.addClass("uk-active");
- if (this.options.connect && this.connect.length) {
- this.index = this.find(this.options.toggle).index(active);
- if (this.index == -1 ) {
- this.index = 0;
- }
- this.connect.each(function() {
- var container = UI.$(this),
- children = UI.$(container.children()),
- current = UI.$(children.filter('.uk-active')),
- next = UI.$(children.eq($this.index));
- $this.animating = true;
- animation.apply($this, [current, next]).then(function(){
- current.removeClass("uk-active");
- next.addClass("uk-active");
- // Update ARIA for connect
- current.attr('aria-hidden', 'true');
- next.attr('aria-hidden', 'false');
- UI.Utils.checkDisplay(next, true);
- $this.animating = false;
- });
- });
- }
- this.trigger("show.uk.switcher", [active]);
- }
- });
- Animations = {
- 'none': function() {
- var d = UI.$.Deferred();
- d.resolve();
- return d.promise();
- },
- 'fade': function(current, next) {
- return coreAnimation.apply(this, ['uk-animation-fade', current, next]);
- },
- 'slide-bottom': function(current, next) {
- return coreAnimation.apply(this, ['uk-animation-slide-bottom', current, next]);
- },
- 'slide-top': function(current, next) {
- return coreAnimation.apply(this, ['uk-animation-slide-top', current, next]);
- },
- 'slide-vertical': function(current, next, dir) {
- var anim = ['uk-animation-slide-top', 'uk-animation-slide-bottom'];
- if (current && current.index() > next.index()) {
- anim.reverse();
- }
- return coreAnimation.apply(this, [anim, current, next]);
- },
- 'slide-left': function(current, next) {
- return coreAnimation.apply(this, ['uk-animation-slide-left', current, next]);
- },
- 'slide-right': function(current, next) {
- return coreAnimation.apply(this, ['uk-animation-slide-right', current, next]);
- },
- 'slide-horizontal': function(current, next, dir) {
- var anim = ['uk-animation-slide-right', 'uk-animation-slide-left'];
- if (current && current.index() > next.index()) {
- anim.reverse();
- }
- return coreAnimation.apply(this, [anim, current, next]);
- },
- 'scale': function(current, next) {
- return coreAnimation.apply(this, ['uk-animation-scale-up', current, next]);
- }
- };
- UI.switcher.animations = Animations;
- // helpers
- function coreAnimation(cls, current, next) {
- var d = UI.$.Deferred(), clsIn = cls, clsOut = cls, release;
- if (next[0]===current[0]) {
- d.resolve();
- return d.promise();
- }
- if (typeof(cls) == 'object') {
- clsIn = cls[0];
- clsOut = cls[1] || cls[0];
- }
- UI.$body.css('overflow-x', 'hidden'); // fix scroll jumping in iOS
- release = function() {
- if (current) current.hide().removeClass('uk-active '+clsOut+' uk-animation-reverse');
- next.addClass(clsIn).one(UI.support.animation.end, function() {
- setTimeout(function () {
- next.removeClass(''+clsIn+'').css({opacity:'', display:''});
- }, 0);
- d.resolve();
- UI.$body.css('overflow-x', '');
- if (current) current.css({opacity:'', display:''});
- }.bind(this)).show();
- };
- next.css('animation-duration', this.options.duration+'ms');
- if (current && current.length) {
- current.css('animation-duration', this.options.duration+'ms');
- current.css('display', 'none').addClass(clsOut+' uk-animation-reverse').one(UI.support.animation.end, function() {
- release();
- }.bind(this)).css('display', '');
- } else {
- next.addClass('uk-active');
- release();
- }
- return d.promise();
- }
- })(UIkit);
- (function(UI) {
- "use strict";
- UI.component('tab', {
- defaults: {
- target : '>li:not(.uk-tab-responsive, .uk-disabled)',
- connect : false,
- active : 0,
- animation : false,
- duration : 200,
- swiping : true
- },
- boot: function() {
- // init code
- UI.ready(function(context) {
- UI.$("[data-uk-tab]", context).each(function() {
- var tab = UI.$(this);
- if (!tab.data("tab")) {
- var obj = UI.tab(tab, UI.Utils.options(tab.attr("data-uk-tab")));
- }
- });
- });
- },
- init: function() {
- var $this = this;
- this.current = false;
- this.on("click.uk.tab", this.options.target, function(e) {
- e.preventDefault();
- if ($this.switcher && $this.switcher.animating) {
- return;
- }
- var current = $this.find($this.options.target).not(this);
- current.removeClass("uk-active").blur();
- $this.trigger("change.uk.tab", [UI.$(this).addClass("uk-active"), $this.current]);
- $this.current = UI.$(this);
- // Update ARIA
- if (!$this.options.connect) {
- current.attr('aria-expanded', 'false');
- UI.$(this).attr('aria-expanded', 'true');
- }
- });
- if (this.options.connect) {
- this.connect = UI.$(this.options.connect);
- }
- // init responsive tab
- this.responsivetab = UI.$('<li class="uk-tab-responsive uk-active"><a></a></li>').append('<div class="uk-dropdown uk-dropdown-small"><ul class="uk-nav uk-nav-dropdown"></ul><div>');
- this.responsivetab.dropdown = this.responsivetab.find('.uk-dropdown');
- this.responsivetab.lst = this.responsivetab.dropdown.find('ul');
- this.responsivetab.caption = this.responsivetab.find('a:first');
- if (this.element.hasClass("uk-tab-bottom")) this.responsivetab.dropdown.addClass("uk-dropdown-up");
- // handle click
- this.responsivetab.lst.on('click.uk.tab', 'a', function(e) {
- e.preventDefault();
- e.stopPropagation();
- var link = UI.$(this);
- $this.element.children('li:not(.uk-tab-responsive)').eq(link.data('index')).trigger('click');
- });
- this.on('show.uk.switcher change.uk.tab', function(e, tab) {
- $this.responsivetab.caption.html(tab.text());
- });
- this.element.append(this.responsivetab);
- // init UIkit components
- if (this.options.connect) {
- this.switcher = UI.switcher(this.element, {
- 'toggle' : '>li:not(.uk-tab-responsive)',
- 'connect' : this.options.connect,
- 'active' : this.options.active,
- 'animation' : this.options.animation,
- 'duration' : this.options.duration,
- 'swiping' : this.options.swiping
- });
- }
- UI.dropdown(this.responsivetab, {"mode": "click", "preventflip": "y"});
- // init
- $this.trigger("change.uk.tab", [this.element.find(this.options.target).not('.uk-tab-responsive').filter('.uk-active')]);
- this.check();
- UI.$win.on('resize orientationchange', UI.Utils.debounce(function(){
- if ($this.element.is(":visible")) $this.check();
- }, 100));
- this.on('display.uk.check', function(){
- if ($this.element.is(":visible")) $this.check();
- });
- },
- check: function() {
- var children = this.element.children('li:not(.uk-tab-responsive)').removeClass('uk-hidden');
- if (!children.length) {
- this.responsivetab.addClass('uk-hidden');
- return;
- }
- var top = (children.eq(0).offset().top + Math.ceil(children.eq(0).height()/2)),
- doresponsive = false,
- item, link, clone;
- this.responsivetab.lst.empty();
- children.each(function(){
- if (UI.$(this).offset().top > top) {
- doresponsive = true;
- }
- });
- if (doresponsive) {
- for (var i = 0; i < children.length; i++) {
- item = UI.$(children.eq(i));
- link = item.find('a');
- if (item.css('float') != 'none' && !item.attr('uk-dropdown')) {
- if (!item.hasClass('uk-disabled')) {
- clone = item[0].outerHTML.replace('<a ', '<a data-index="'+i+'" ');
- this.responsivetab.lst.append(clone);
- }
- item.addClass('uk-hidden');
- }
- }
- }
- this.responsivetab[this.responsivetab.lst.children('li').length ? 'removeClass':'addClass']('uk-hidden');
- }
- });
- })(UIkit);
- (function(UI){
- "use strict";
- UI.component('cover', {
- defaults: {
- automute : true
- },
- boot: function() {
- // auto init
- UI.ready(function(context) {
- UI.$("[data-uk-cover]", context).each(function(){
- var ele = UI.$(this);
- if(!ele.data("cover")) {
- var plugin = UI.cover(ele, UI.Utils.options(ele.attr("data-uk-cover")));
- }
- });
- });
- },
- init: function() {
- this.parent = this.element.parent();
- UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){
- this.check();
- }.bind(this), 100));
- this.on("display.uk.check", function(e) {
- if(this.element.is(":visible")) this.check();
- }.bind(this));
- this.check();
- if (this.element.is('iframe') && this.options.automute) {
- var src = this.element.attr('src');
- this.element.attr('src', '').on('load', function(){
- this.contentWindow.postMessage('{ "event": "command", "func": "mute", "method":"setVolume", "value":0}', '*');
- }).attr('src', [src, (src.indexOf('?') > -1 ? '&':'?'), 'enablejsapi=1&api=1'].join(''));
- }
- },
- check: function() {
- this.element.css({
- width : '',
- height : ''
- });
- this.dimension = {w: this.element.width(), h: this.element.height()};
- if (this.element.attr('width') && !isNaN(this.element.attr('width'))) {
- this.dimension.w = this.element.attr('width');
- }
- if (this.element.attr('height') && !isNaN(this.element.attr('height'))) {
- this.dimension.h = this.element.attr('height');
- }
- this.ratio = this.dimension.w / this.dimension.h;
- var w = this.parent.width(), h = this.parent.height(), width, height;
- // if element height < parent height (gap underneath)
- if ((w / this.ratio) < h) {
- width = Math.ceil(h * this.ratio);
- height = h;
- // element width < parent width (gap to right)
- } else {
- width = w;
- height = Math.ceil(w / this.ratio);
- }
- this.element.css({
- 'width' : width,
- 'height' : height
- });
- }
- });
- })(UIkit);
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) {
- define("uikit-accordion", ["uikit"], function(){
- return component || addon(UIkit);
- });
- }
- })(function(UI){
- "use strict";
- UI.component('accordion', {
- defaults: {
- showfirst : true,
- collapse : true,
- animate : true,
- easing : 'swing',
- duration : 300,
- toggle : '.uk-accordion-title',
- containers : '.uk-accordion-content',
- clsactive : 'uk-active'
- },
- boot: function() {
- // init code
- UI.ready(function(context) {
- setTimeout(function(){
- UI.$("[data-uk-accordion]", context).each(function(){
- var ele = UI.$(this);
- if (!ele.data("accordion")) {
- UI.accordion(ele, UI.Utils.options(ele.attr('data-uk-accordion')));
- }
- });
- }, 0);
- });
- },
- init: function() {
- var $this = this;
- this.element.on('click.uk.accordion', this.options.toggle, function(e) {
- e.preventDefault();
- $this.toggleItem(UI.$(this).data('wrapper'), $this.options.animate, $this.options.collapse);
- });
- this.update(true);
- UI.domObserve(this.element, function(e) {
- if ($this.element.children($this.options.containers).length) {
- $this.update();
- }
- });
- },
- toggleItem: function(wrapper, animated, collapse) {
- var $this = this;
- wrapper.data('toggle').toggleClass(this.options.clsactive);
- wrapper.data('content').toggleClass(this.options.clsactive);
- var active = wrapper.data('toggle').hasClass(this.options.clsactive);
- if (collapse) {
- this.toggle.not(wrapper.data('toggle')).removeClass(this.options.clsactive);
- this.content.not(wrapper.data('content')).removeClass(this.options.clsactive)
- .parent().stop().css('overflow', 'hidden').animate({ height: 0 }, {easing: this.options.easing, duration: animated ? this.options.duration : 0}).attr('aria-expanded', 'false');
- }
- wrapper.stop().css('overflow', 'hidden');
- if (animated) {
- wrapper.animate({ height: active ? getHeight(wrapper.data('content')) : 0 }, {easing: this.options.easing, duration: this.options.duration, complete: function() {
- if (active) {
- wrapper.css({'overflow': '', 'height': 'auto'});
- UI.Utils.checkDisplay(wrapper.data('content'));
- }
- $this.trigger('display.uk.check');
- }});
- } else {
- wrapper.height(active ? 'auto' : 0);
- if (active) {
- wrapper.css({'overflow': ''});
- UI.Utils.checkDisplay(wrapper.data('content'));
- }
- this.trigger('display.uk.check');
- }
- // Update ARIA
- wrapper.attr('aria-expanded', active);
- this.element.trigger('toggle.uk.accordion', [active, wrapper.data('toggle'), wrapper.data('content')]);
- },
- update: function(init) {
- var $this = this, $content, $wrapper, $toggle;
- this.toggle = this.find(this.options.toggle);
- this.content = this.find(this.options.containers);
- this.content.each(function(index) {
- $content = UI.$(this);
- if ($content.parent().data('wrapper')) {
- $wrapper = $content.parent();
- } else {
- $wrapper = UI.$(this).wrap('<div data-wrapper="true" style="overflow:hidden;height:0;position:relative;"></div>').parent();
- // Init ARIA
- $wrapper.attr('aria-expanded', 'false');
- }
- $toggle = $this.toggle.eq(index);
- $wrapper.data('toggle', $toggle);
- $wrapper.data('content', $content);
- $toggle.data('wrapper', $wrapper);
- $content.data('wrapper', $wrapper);
- });
- this.element.trigger('update.uk.accordion', [this]);
- if (init && this.options.showfirst) {
- this.toggleItem(this.toggle.eq(0).data('wrapper'), false, false);
- }
- }
- });
- // helper
- function getHeight(ele) {
- var $ele = UI.$(ele), height = "auto";
- if ($ele.is(":visible")) {
- height = $ele.outerHeight();
- } else {
- var tmp = {
- position : $ele.css("position"),
- visibility : $ele.css("visibility"),
- display : $ele.css("display")
- };
- height = $ele.css({position: 'absolute', visibility: 'hidden', display: 'block'}).outerHeight();
- $ele.css(tmp); // reset element
- }
- return height;
- }
- return UI.accordion;
- });
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) {
- define("uikit-autocomplete", ["uikit"], function(){
- return component || addon(UIkit);
- });
- }
- })(function(UI){
- "use strict";
- var active;
- UI.component('autocomplete', {
- defaults: {
- minLength: 3,
- param: 'search',
- method: 'post',
- delay: 300,
- loadingClass: 'uk-loading',
- flipDropdown: false,
- skipClass: 'uk-skip',
- hoverClass: 'uk-active',
- source: null,
- renderer: null,
- // template
- template: '<ul class="uk-nav uk-nav-autocomplete uk-autocomplete-results">{{~items}}<li data-value="{{$item.value}}"><a>{{$item.value}}</a></li>{{/items}}</ul>'
- },
- visible : false,
- value : null,
- selected : null,
- boot: function() {
- // init code
- UI.$html.on("focus.autocomplete.uikit", "[data-uk-autocomplete]", function(e) {
- var ele = UI.$(this);
- if (!ele.data("autocomplete")) {
- UI.autocomplete(ele, UI.Utils.options(ele.attr("data-uk-autocomplete")));
- }
- });
- // register outer click for autocompletes
- UI.$html.on("click.autocomplete.uikit", function(e) {
- if (active && e.target!=active.input[0]) active.hide();
- });
- },
- init: function() {
- var $this = this,
- select = false,
- trigger = UI.Utils.debounce(function(e) {
- if (select) {
- return (select = false);
- }
- $this.handle();
- }, this.options.delay);
- this.dropdown = this.find('.uk-dropdown');
- this.template = this.find('script[type="text/autocomplete"]').html();
- this.template = UI.Utils.template(this.template || this.options.template);
- this.input = this.find("input:first").attr("autocomplete", "off");
- if (!this.dropdown.length) {
- this.dropdown = UI.$('<div class="uk-dropdown"></div>').appendTo(this.element);
- }
- if (this.options.flipDropdown) {
- this.dropdown.addClass('uk-dropdown-flip');
- }
- this.dropdown.attr('aria-expanded', 'false');
- this.input.on({
- keydown: function(e) {
- if (e && e.which && !e.shiftKey && $this.visible) {
- switch (e.which) {
- case 13: // enter
- select = true;
- if ($this.selected) {
- e.preventDefault();
- $this.select();
- }
- break;
- case 38: // up
- e.preventDefault();
- $this.pick('prev', true);
- break;
- case 40: // down
- e.preventDefault();
- $this.pick('next', true);
- break;
- case 27:
- case 9: // esc, tab
- $this.hide();
- break;
- default:
- break;
- }
- }
- },
-
- keyup: trigger
- });
- this.dropdown.on("click", ".uk-autocomplete-results > *", function(){
- $this.select();
- });
- this.dropdown.on("mouseover", ".uk-autocomplete-results > *", function(){
- $this.pick(UI.$(this));
- });
- this.triggercomplete = trigger;
- },
- handle: function() {
- var $this = this, old = this.value;
- this.value = this.input.val();
- if (this.value.length < this.options.minLength) return this.hide();
- if (this.value != old) {
- $this.request();
- }
- return this;
- },
- pick: function(item, scrollinview) {
- var $this = this,
- items = UI.$(this.dropdown.find('.uk-autocomplete-results').children(':not(.'+this.options.skipClass+')')),
- selected = false;
- if (typeof item !== "string" && !item.hasClass(this.options.skipClass)) {
- selected = item;
- } else if (item == 'next' || item == 'prev') {
- if (this.selected) {
- var index = items.index(this.selected);
- if (item == 'next') {
- selected = items.eq(index + 1 < items.length ? index + 1 : 0);
- } else {
- selected = items.eq(index - 1 < 0 ? items.length - 1 : index - 1);
- }
- } else {
- selected = items[(item == 'next') ? 'first' : 'last']();
- }
- selected = UI.$(selected);
- }
- if (selected && selected.length) {
- this.selected = selected;
- items.removeClass(this.options.hoverClass);
- this.selected.addClass(this.options.hoverClass);
- // jump to selected if not in view
- if (scrollinview) {
- var top = selected.position().top,
- scrollTop = $this.dropdown.scrollTop(),
- dpheight = $this.dropdown.height();
- if (top > dpheight || top < 0) {
- $this.dropdown.scrollTop(scrollTop + top);
- }
- }
- }
- },
- select: function() {
- if(!this.selected) return;
- var data = this.selected.data();
- this.trigger("selectitem.uk.autocomplete", [data, this]);
- if (data.value) {
- this.input.val(data.value).trigger('change');
- }
- this.hide();
- },
- show: function() {
- if (this.visible) return;
- this.visible = true;
- this.element.addClass("uk-open");
- if (active && active!==this) {
- active.hide();
- }
- active = this;
- // Update aria
- this.dropdown.attr('aria-expanded', 'true');
- return this;
- },
- hide: function() {
- if (!this.visible) return;
- this.visible = false;
- this.element.removeClass("uk-open");
- if (active === this) {
- active = false;
- }
- // Update aria
- this.dropdown.attr('aria-expanded', 'false');
- return this;
- },
- request: function() {
- var $this = this,
- release = function(data) {
- if(data) {
- $this.render(data);
- }
- $this.element.removeClass($this.options.loadingClass);
- };
- this.element.addClass(this.options.loadingClass);
- if (this.options.source) {
- var source = this.options.source;
- switch(typeof(this.options.source)) {
- case 'function':
- this.options.source.apply(this, [release]);
- break;
- case 'object':
- if(source.length) {
- var items = [];
- source.forEach(function(item){
- if(item.value && item.value.toLowerCase().indexOf($this.value.toLowerCase())!=-1) {
- items.push(item);
- }
- });
- release(items);
- }
- break;
- case 'string':
- var params ={};
- params[this.options.param] = this.value;
- UI.$.ajax({
- url: this.options.source,
- data: params,
- type: this.options.method,
- dataType: 'json'
- }).done(function(json) {
- release(json || []);
- });
- break;
- default:
- release(null);
- }
- } else {
- this.element.removeClass($this.options.loadingClass);
- }
- },
- render: function(data) {
- this.dropdown.empty();
- this.selected = false;
- if (this.options.renderer) {
- this.options.renderer.apply(this, [data]);
- } else if(data && data.length) {
- this.dropdown.append(this.template({"items":data}));
- this.show();
- this.trigger('show.uk.autocomplete');
- }
- return this;
- }
- });
- return UI.autocomplete;
- });
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- // removed moment_js from core
- // customized by tzd
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) {
- define("uikit-datepicker", ["uikit"], function(){
- return component || addon(UIkit);
- });
- }
- })(function(UI){
- "use strict";
- // Datepicker
- var active = false, dropdown;
- UI.component('datepicker', {
- defaults: {
- mobile: false,
- weekstart: 1,
- i18n: {
- months : ['January','February','March','April','May','June','July','August','September','October','November','December'],
- weekdays : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
- },
- format: "DD.MM.YYYY",
- offsettop: 5,
- maxDate: false,
- minDate: false,
- pos: 'auto',
- addClass: '',
- template: function(data, opts) {
- var content = '', i;
- content += '<div class="uk-datepicker-nav uk-clearfix">';
- content += '<a href="" class="uk-datepicker-previous"></a>';
- content += '<a href="" class="uk-datepicker-next"></a>';
- if (UI.formSelect) {
- var currentyear = (new Date()).getFullYear(), options = [], months, years, minYear, maxYear;
- for (i=0;i<opts.i18n.months.length;i++) {
- if(i==data.month) {
- options.push('<option value="'+i+'" selected>'+opts.i18n.months[i]+'</option>');
- } else {
- options.push('<option value="'+i+'">'+opts.i18n.months[i]+'</option>');
- }
- }
- months = '<span class="uk-form-select">'+ opts.i18n.months[data.month] + '<select class="update-picker-month">'+options.join('')+'</select></span>';
- // --
- options = [];
- minYear = data.minDate ? data.minDate.year() : currentyear - 50;
- maxYear = data.maxDate ? data.maxDate.year() : currentyear + 20;
- for (i=minYear;i<=maxYear;i++) {
- if (i == data.year) {
- options.push('<option value="'+i+'" selected>'+i+'</option>');
- } else {
- options.push('<option value="'+i+'">'+i+'</option>');
- }
- }
- years = '<span class="uk-form-select">'+ data.year + '<select class="update-picker-year">'+options.join('')+'</select></span>';
- content += '<div class="uk-datepicker-heading">'+ months + ' ' + years +'</div>';
- } else {
- content += '<div class="uk-datepicker-heading">'+ opts.i18n.months[data.month] +' '+ data.year+'</div>';
- }
- content += '</div>';
- content += '<table class="uk-datepicker-table">';
- content += '<thead>';
- for(i = 0; i < data.weekdays.length; i++) {
- if (data.weekdays[i]) {
- content += '<th>'+data.weekdays[i]+'</th>';
- }
- }
- content += '</thead>';
- content += '<tbody>';
- for(i = 0; i < data.days.length; i++) {
- if (data.days[i] && data.days[i].length){
- content += '<tr>';
- for(var d = 0; d < data.days[i].length; d++) {
- if (data.days[i][d]) {
- var day = data.days[i][d],
- cls = [];
- if(!day.inmonth) cls.push("uk-datepicker-table-muted");
- if(day.selected) cls.push("uk-active");
- if(day.disabled) cls.push('uk-datepicker-date-disabled uk-datepicker-table-muted');
- content += '<td><a href="" class="'+cls.join(" ")+'" data-date="'+day.day.format()+'">'+day.day.format("D")+'</a></td>';
- }
- }
- content += '</tr>';
- }
- }
- content += '</tbody>';
- content += '</table>';
- return content;
- }
- },
- boot: function() {
- UI.$win.on("resize orientationchange", function() {
- if (active) {
- active.hide();
- }
- });
- // init code
- UI.$html.on("focus.datepicker.uikit", "[data-uk-datepicker]", function(e) {
- var ele = UI.$(this);
- if (!ele.data("datepicker")) {
- e.preventDefault();
- UI.datepicker(ele, UI.Utils.options(ele.attr("data-uk-datepicker")));
- ele.trigger("focus");
- }
- });
- UI.$html.on("click focus", '*', function(e) {
- var target = UI.$(e.target);
- if (active && target[0] != dropdown[0] && !target.data("datepicker") && !target.parents(".uk-datepicker:first").length) {
- active.hide();
- }
- });
- },
- init: function() {
- // use native datepicker on touch devices
- if (UI.support.touch && this.element.attr('type')=='date' && !this.options.mobile) {
- return;
- }
- var $this = this;
- this.current = this.element.val() ? moment(this.element.val(), this.options.format) : moment();
- this.on("click focus", function(){
- if (active!==$this) $this.pick(this.value ? this.value:($this.options.minDate ? $this.options.minDate :''));
- }).on("change", function(){
- if ($this.element.val() && !moment($this.element.val(), $this.options.format).isValid()) {
- $this.element.val(moment().format($this.options.format));
- }
- });
- // init dropdown
- if (!dropdown) {
- dropdown = UI.$('<div class="uk-dropdown uk-datepicker '+$this.options.addClass+'"></div>');
- dropdown.on("click", ".uk-datepicker-next, .uk-datepicker-previous, [data-date]", function(e){
- e.stopPropagation();
- e.preventDefault();
- var ele = UI.$(this);
- if (ele.hasClass('uk-datepicker-date-disabled')) return false;
- if (ele.is('[data-date]')) {
- active.current = moment(ele.data("date"));
- active.element.val(active.current.isValid() ? active.current.format(active.options.format) : null).trigger("change");
- dropdown.removeClass('uk-dropdown-shown');
- setTimeout(function() {
- dropdown.removeClass('uk-dropdown-active')
- },280);
- active.hide();
- } else {
- active.add((ele.hasClass("uk-datepicker-next") ? 1:-1), "months");
- }
- });
- dropdown.on('change', '.update-picker-month, .update-picker-year', function(){
- var select = UI.$(this);
- active[select.is('.update-picker-year') ? 'setYear':'setMonth'](Number(select.val()));
- });
- dropdown.appendTo("body");
- }
- },
- pick: function(initdate) {
- var offset = this.element.offset(),
- offset_left = parseInt(offset.left),
- offset_top = parseInt(offset.top),
- css = {
- 'left': offset_left,
- 'right': ""
- };
- this.current = isNaN(initdate) ? moment(initdate, this.options.format):moment();
- this.initdate = this.current.format("YYYY-MM-DD");
- this.update();
- // check if datepicker input is in modal
- if(($(this.element[0]).closest('.ui-dialog').length || $(this.element[0]).closest('.uk-modal').length) && !dropdown.hasClass('dropdown-modal')) {
- dropdown.addClass('dropdown-modal');
- }
- if (UI.langdirection == 'right' || ( window.innerWidth - offset_left - dropdown.outerWidth() < 0 ) ) {
- css.right = (window.innerWidth - (window.innerWidth - $('body').width())) - (css.left + this.element.outerWidth());
- css.left = "";
- }
- var posTop = (offset_top - this.element.outerHeight() + this.element.height()) - this.options.offsettop - dropdown.outerHeight(),
- posBottom = offset_top + this.element.outerHeight() + this.options.offsettop;
- css.top = posBottom;
- if (this.options.pos == 'top') {
- css.top = posTop;
- dropdown.addClass('dp-top');
- } else if(this.options.pos == 'auto' && (window.innerHeight - posBottom - dropdown.outerHeight() + UI.$win.scrollTop() < 0 && posTop >= 0) ) {
- css.top = posTop;
- dropdown.addClass('dp-top');
- }
- css.minWidth = dropdown.actual('outerWidth');
- dropdown.css(css).addClass('uk-dropdown-active uk-dropdown-shown');
- this.trigger('show.uk.datepicker');
- active = this;
- },
- add: function(unit, value) {
- this.current.add(unit, value);
- this.update();
- },
- setMonth: function(month) {
- this.current.month(month);
- this.update();
- },
- setYear: function(year) {
- this.current.year(year);
- this.update();
- },
- update: function() {
- var data = this.getRows(this.current.year(), this.current.month()),
- tpl = this.options.template(data, this.options);
- dropdown.html(tpl);
- this.trigger('update.uk.datepicker');
- },
- getRows: function(year, month) {
- var opts = this.options,
- now = moment().format('YYYY-MM-DD'),
- days = [31, (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month],
- before = new Date(year, month, 1, 12).getDay(),
- data = {"month":month, "year":year,"weekdays":[],"days":[], "maxDate": false, "minDate": false},
- row = [];
- // We need these to be midday to avoid issues from DST transition protection.
- if (opts.maxDate!==false){
- data.maxDate = isNaN(opts.maxDate) ? moment(opts.maxDate, opts.format).startOf('day').hours(12) : moment().add(opts.maxDate, 'days').startOf('day').hours(12);
- }
- if (opts.minDate!==false){
- data.minDate = isNaN(opts.minDate) ? moment(opts.minDate, opts.format).startOf('day').hours(12) : moment().add(opts.minDate-1, 'days').startOf('day').hours(12);
- }
- data.weekdays = (function(){
- for (var i=0, arr=[]; i < 7; i++) {
- var day = i + (opts.weekstart || 0);
- while (day >= 7) {
- day -= 7;
- }
- arr.push(opts.i18n.weekdays[day]);
- }
- return arr;
- })();
- if (opts.weekstart && opts.weekstart > 0) {
- before -= opts.weekstart;
- if (before < 0) {
- before += 7;
- }
- }
- var cells = days + before, after = cells;
- while(after > 7) { after -= 7; }
- cells += 7 - after;
- var day, isDisabled, isSelected, isToday, isInMonth;
- for (var i = 0, r = 0; i < cells; i++) {
- day = new Date(year, month, 1 + (i - before), 12);
- isDisabled = (data.minDate && data.minDate > day) || (data.maxDate && day > data.maxDate);
- isInMonth = !(i < before || i >= (days + before));
- day = moment(day);
- isSelected = this.initdate == day.format("YYYY-MM-DD");
- isToday = now == day.format("YYYY-MM-DD");
- row.push({"selected": isSelected, "today": isToday, "disabled": isDisabled, "day":day, "inmonth":isInMonth});
- if (++r === 7) {
- data.days.push(row);
- row = [];
- r = 0;
- }
- }
- return data;
- },
- hide: function() {
- if (active && active === this) {
- dropdown.removeClass('uk-dropdown-shown');
- setTimeout(function() {
- dropdown.removeClass('uk-dropdown-active dp-top')
- },280);
- active = false;
- this.trigger('hide.uk.datepicker');
- }
- }
- });
- UI.Utils.moment = moment();
- return UI.datepicker;
- });
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) {
- define("uikit-form-password", ["uikit"], function(){
- return component || addon(UIkit);
- });
- }
- })(function(UI){
- "use strict";
- UI.component('formPassword', {
- defaults: {
- "lblShow": "Show",
- "lblHide": "Hide"
- },
- boot: function() {
- // init code
- UI.$html.on("click.formpassword.uikit", "[data-uk-form-password]", function(e) {
- var ele = UI.$(this);
- if (!ele.data("formPassword")) {
- e.preventDefault();
- UI.formPassword(ele, UI.Utils.options(ele.attr("data-uk-form-password")));
- ele.trigger("click");
- }
- });
- },
- init: function() {
- var $this = this;
- this.on("click", function(e) {
- e.preventDefault();
- if($this.input.length) {
- var type = $this.input.attr("type");
- $this.input.attr("type", type=="text" ? "password":"text");
- $this.element.html($this.options[type=="text" ? "lblShow":"lblHide"]);
- }
- });
- this.input = this.element.next("input").length ? this.element.next("input") : this.element.prev("input");
- this.element.html(this.options[this.input.is("[type='password']") ? "lblShow":"lblHide"]);
- this.element.data("formPassword", this);
- }
- });
- return UI.formPassword;
- });
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) {
- define("uikit-form-select", ["uikit"], function(){
- return component || addon(UIkit);
- });
- }
- })(function(UI){
- "use strict";
- UI.component('formSelect', {
- defaults: {
- 'target': '>span:first',
- 'activeClass': 'uk-active'
- },
- boot: function() {
- // init code
- UI.ready(function(context) {
- UI.$("[data-uk-form-select]", context).each(function(){
- var ele = UI.$(this);
- if (!ele.data("formSelect")) {
- UI.formSelect(ele, UI.Utils.options(ele.attr("data-uk-form-select")));
- }
- });
- });
- },
- init: function() {
- var $this = this;
- this.target = this.find(this.options.target);
- this.select = this.find('select');
- // init + on change event
- this.select.on({
- change: (function(){
- var select = $this.select[0], fn = function(){
- try {
- if($this.options.target === 'input') {
- $this.target.val(select.options[select.selectedIndex].text);
- } else {
- $this.target.text(select.options[select.selectedIndex].text);
- }
- } catch(e) {}
- $this.element[$this.select.val() ? 'addClass':'removeClass']($this.options.activeClass);
- return fn;
- };
- return fn();
- })(),
- focus: function(){ $this.target.addClass('uk-focus') },
- blur: function(){ $this.target.removeClass('uk-focus') },
- mouseenter: function(){ $this.target.addClass('uk-hover') },
- mouseleave: function(){ $this.target.removeClass('uk-hover') }
- });
- this.element.data("formSelect", this);
- }
- });
- return UI.formSelect;
- });
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) {
- define("uikit-grid", ["uikit"], function(){
- return component || addon(UIkit);
- });
- }
- })(function(UI){
- "use strict";
- UI.component('grid', {
- defaults: {
- colwidth : 'auto',
- animation : true,
- duration : 300,
- gutter : 0,
- controls : false,
- filter : false,
- origin : UI.langdirection
- },
- boot: function() {
- // init code
- UI.ready(function(context) {
- UI.$('[data-uk-grid]', context).each(function(){
- var ele = UI.$(this);
- if(!ele.data("grid")) {
- UI.grid(ele, UI.Utils.options(ele.attr('data-uk-grid')));
- }
- });
- });
- },
- init: function() {
- var $this = this, gutter = String(this.options.gutter).trim().split(' ');
- this.gutterv = parseInt(gutter[0], 10);
- this.gutterh = parseInt((gutter[1] || gutter[0]), 10);
- // make sure parent element has the right position property
- this.element.css({'position': 'relative'});
- this.controls = null;
- this.origin = this.options.origin;
- if (this.options.controls) {
- this.controls = UI.$(this.options.controls);
- // filter
- this.controls.on('click', '[data-uk-filter]', function(e){
- e.preventDefault();
- $this.filter(UI.$(this).attr('data-uk-filter'));
- });
- // sort
- this.controls.on('click', '[data-uk-sort]', function(e){
- e.preventDefault();
- var cmd = UI.$(this).attr('data-uk-sort').split(':');
- $this.sort(cmd[0], cmd[1]);
- });
- }
- UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){
- if ($this.currentfilter) {
- $this.filter($this.currentfilter);
- } else {
- this.update();
- }
- }.bind(this), 100));
- this.on('display.uk.check', function(){
- if ($this.element.is(":visible")) $this.update();
- });
- UI.domObserve(this.element, function(e) {
- $this.update();
- });
- if (this.options.filter !== false) {
- this.filter(this.options.filter);
- } else {
- this.update();
- }
- },
- _prepareElements: function() {
- var children = this.element.children(':not([data-grid-prepared])'), css;
- // exit if no already prepared elements found
- if (!children.length) {
- return;
- }
- css = {
- 'position' : 'absolute',
- 'box-sizing' : 'border-box',
- 'width' : this.options.colwidth == 'auto' ? '' : this.options.colwidth
- };
- if (this.options.gutter) {
- css['padding-'+this.origin] = this.gutterh;
- css['padding-bottom'] = this.gutterv;
- this.element.css('margin-'+this.origin, this.gutterh * -1);
- }
- children.attr('data-grid-prepared', 'true').css(css);
- },
- update: function(elements) {
- var $this = this;
- this._prepareElements();
- elements = elements || this.element.children(':visible');
- var children = elements,
- maxwidth = this.element.width() + (2*this.gutterh) + 2,
- left = 0,
- top = 0,
- positions = [],
- item, width, height, pos, posi, i, z, max, size;
- this.trigger('beforeupdate.uk.grid', [children]);
- children.each(function(index){
- size = getElementSize(this);
- item = UI.$(this);
- width = size.outerWidth;
- height = size.outerHeight;
- left = 0;
- top = 0;
- for (i=0,max=positions.length;i<max;i++) {
- pos = positions[i];
- if (left <= pos.aX) { left = pos.aX; }
- if (maxwidth < (left + width)) { left = 0; }
- if (top <= pos.aY) { top = pos.aY; }
- }
- posi = {
- "ele" : item,
- "top" : top,
- "width" : width,
- "height" : height,
- "aY" : (top + height),
- "aX" : (left + width)
- };
- posi[$this.origin] = left;
- positions.push(posi);
- });
- var posPrev, maxHeight = 0, positionto;
- // fix top
- for (i=0,max=positions.length;i<max;i++) {
- pos = positions[i];
- top = 0;
- for (z=0;z<i;z++) {
- posPrev = positions[z];
- // (posPrev.left + 1) fixex 1px bug when using % based widths
- if (pos[this.origin] < posPrev.aX && (posPrev[this.origin] +1) < pos.aX) {
- top = posPrev.aY;
- }
- }
- pos.top = top;
- pos.aY = top + pos.height;
- maxHeight = Math.max(maxHeight, pos.aY);
- }
- maxHeight = maxHeight - this.gutterv;
- if (this.options.animation) {
- this.element.stop().animate({'height': maxHeight}, 100);
- positions.forEach(function(pos){
- positionto = {"top": pos.top, opacity: 1};
- positionto[$this.origin] = pos[$this.origin];
- pos.ele.stop().animate(positionto, this.options.duration);
- }.bind(this));
- } else {
- this.element.css('height', maxHeight);
- positions.forEach(function(pos){
- positionto = {"top": pos.top, opacity: 1};
- positionto[$this.origin] = pos[$this.origin];
- pos.ele.css(positionto);
- }.bind(this));
- }
- // make sure to trigger possible scrollpies etc.
- setTimeout(function() {
- UI.$doc.trigger('scrolling.uk.document');
- }, 2 * this.options.duration * (this.options.animation ? 1:0));
- this.trigger('afterupdate.uk.grid', [children]);
- },
- filter: function(filter) {
- this.currentfilter = filter;
- filter = filter || [];
- if (typeof(filter) === 'number') {
- filter = filter.toString();
- }
- if (typeof(filter) === 'string') {
- filter = filter.split(/,/).map(function(item){ return item.trim(); });
- }
- var $this = this, children = this.element.children(), elements = {"visible": [], "hidden": []}, visible, hidden;
- children.each(function(index){
- var ele = UI.$(this), f = ele.attr('data-uk-filter'), infilter = filter.length ? false : true;
- if (f) {
- f = f.split(/,/).map(function(item){ return item.trim(); });
- filter.forEach(function(item){
- if (f.indexOf(item) > -1) infilter = true;
- });
- }
- elements[infilter ? "visible":"hidden"].push(ele);
- });
- // convert to jQuery collections
- elements.hidden = UI.$(elements.hidden).map(function () {return this[0];});
- elements.visible = UI.$(elements.visible).map(function () {return this[0];});
- elements.hidden.attr('aria-hidden', 'true').filter(':visible').fadeOut(this.options.duration);
- elements.visible.attr('aria-hidden', 'false').filter(':hidden').css('opacity', 0).show();
- $this.update(elements.visible);
- if (this.controls && this.controls.length) {
- this.controls.find('[data-uk-filter]').removeClass('uk-active').filter('[data-uk-filter="'+filter+'"]').addClass('uk-active');
- }
- },
- sort: function(by, order){
- order = order || 1;
- // covert from string (asc|desc) to number
- if (typeof(order) === 'string') {
- order = order.toLowerCase() == 'desc' ? -1 : 1;
- }
- var elements = this.element.children();
- elements.sort(function(a, b){
- a = UI.$(a);
- b = UI.$(b);
- return (b.data(by) || '') < (a.data(by) || '') ? order : (order*-1);
- }).appendTo(this.element);
- this.update(elements.filter(':visible'));
- if (this.controls && this.controls.length) {
- this.controls.find('[data-uk-sort]').removeClass('uk-active').filter('[data-uk-sort="'+by+':'+(order == -1 ? 'desc':'asc')+'"]').addClass('uk-active');
- }
- }
- });
- /*!
- * getSize v1.2.2
- * measure size of elements
- * MIT license
- * https://github.com/desandro/get-size
- */
- function _getSize() {
- var prefixes = 'Webkit Moz ms Ms O'.split(' ');
- var docElemStyle = document.documentElement.style;
- function getStyleProperty( propName ) {
- if ( !propName ) {
- return;
- }
- // test standard property first
- if ( typeof docElemStyle[ propName ] === 'string' ) {
- return propName;
- }
- // capitalize
- propName = propName.charAt(0).toUpperCase() + propName.slice(1);
- // test vendor specific properties
- var prefixed;
- for ( var i=0, len = prefixes.length; i < len; i++ ) {
- prefixed = prefixes[i] + propName;
- if ( typeof docElemStyle[ prefixed ] === 'string' ) {
- return prefixed;
- }
- }
- }
- // -------------------------- helpers -------------------------- //
- // get a number from a string, not a percentage
- function getStyleSize( value ) {
- var num = parseFloat( value );
- // not a percent like '100%', and a number
- var isValid = value.indexOf('%') === -1 && !isNaN( num );
- return isValid && num;
- }
- function noop() {}
- var logError = typeof console === 'undefined' ? noop : function( message ) {
- console.error( message );
- };
- // -------------------------- measurements -------------------------- //
- var measurements = [
- 'paddingLeft',
- 'paddingRight',
- 'paddingTop',
- 'paddingBottom',
- 'marginLeft',
- 'marginRight',
- 'marginTop',
- 'marginBottom',
- 'borderLeftWidth',
- 'borderRightWidth',
- 'borderTopWidth',
- 'borderBottomWidth'
- ];
- function getZeroSize() {
- var size = {
- width: 0,
- height: 0,
- innerWidth: 0,
- innerHeight: 0,
- outerWidth: 0,
- outerHeight: 0
- };
- for ( var i=0, len = measurements.length; i < len; i++ ) {
- var measurement = measurements[i];
- size[ measurement ] = 0;
- }
- return size;
- }
- // -------------------------- setup -------------------------- //
- var isSetup = false;
- var getStyle, boxSizingProp, isBoxSizeOuter;
- /**
- * setup vars and functions
- * do it on initial getSize(), rather than on script load
- * For Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=548397
- */
- function setup() {
- // setup once
- if ( isSetup ) {
- return;
- }
- isSetup = true;
- var getComputedStyle = window.getComputedStyle;
- getStyle = ( function() {
- var getStyleFn = getComputedStyle ?
- function( elem ) {
- return getComputedStyle( elem, null );
- } :
- function( elem ) {
- return elem.currentStyle;
- };
- return function getStyle( elem ) {
- var style = getStyleFn( elem );
- if ( !style ) {
- logError( 'Style returned ' + style +
- '. Are you running this code in a hidden iframe on Firefox? ' +
- 'See http://bit.ly/getsizebug1' );
- }
- return style;
- };
- })();
- // -------------------------- box sizing -------------------------- //
- boxSizingProp = getStyleProperty('boxSizing');
- /**
- * WebKit measures the outer-width on style.width on border-box elems
- * IE & Firefox measures the inner-width
- */
- if ( boxSizingProp ) {
- var div = document.createElement('div');
- div.style.width = '200px';
- div.style.padding = '1px 2px 3px 4px';
- div.style.borderStyle = 'solid';
- div.style.borderWidth = '1px 2px 3px 4px';
- div.style[ boxSizingProp ] = 'border-box';
- var body = document.body || document.documentElement;
- body.appendChild( div );
- var style = getStyle( div );
- isBoxSizeOuter = getStyleSize( style.width ) === 200;
- body.removeChild( div );
- }
- }
- // -------------------------- getSize -------------------------- //
- function getSize( elem ) {
- setup();
- // use querySeletor if elem is string
- if ( typeof elem === 'string' ) {
- elem = document.querySelector( elem );
- }
- // do not proceed on non-objects
- if ( !elem || typeof elem !== 'object' || !elem.nodeType ) {
- return;
- }
- var style = getStyle( elem );
- // if hidden, everything is 0
- if ( style.display === 'none' ) {
- return getZeroSize();
- }
- var size = {};
- size.width = elem.offsetWidth;
- size.height = elem.offsetHeight;
- var isBorderBox = size.isBorderBox = !!( boxSizingProp &&
- style[ boxSizingProp ] && style[ boxSizingProp ] === 'border-box' );
- // get all measurements
- for ( var i=0, len = measurements.length; i < len; i++ ) {
- var measurement = measurements[i];
- var value = style[ measurement ];
- var num = parseFloat( value );
- // any 'auto', 'medium' value will be 0
- size[ measurement ] = !isNaN( num ) ? num : 0;
- }
- var paddingWidth = size.paddingLeft + size.paddingRight;
- var paddingHeight = size.paddingTop + size.paddingBottom;
- var marginWidth = size.marginLeft + size.marginRight;
- var marginHeight = size.marginTop + size.marginBottom;
- var borderWidth = size.borderLeftWidth + size.borderRightWidth;
- var borderHeight = size.borderTopWidth + size.borderBottomWidth;
- var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter;
- // overwrite width and height if we can get it from style
- var styleWidth = getStyleSize( style.width );
- if ( styleWidth !== false ) {
- size.width = styleWidth +
- // add padding and border unless it's already including it
- ( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth );
- }
- var styleHeight = getStyleSize( style.height );
- if ( styleHeight !== false ) {
- size.height = styleHeight +
- // add padding and border unless it's already including it
- ( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight );
- }
- size.innerWidth = size.width - ( paddingWidth + borderWidth );
- size.innerHeight = size.height - ( paddingHeight + borderHeight );
- size.outerWidth = size.width + marginWidth;
- size.outerHeight = size.height + marginHeight;
- return size;
- }
- return getSize;
- }
- function getElementSize(ele) {
- return _getSize()(ele);
- }
- });
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) { // AMD
- define("uikit-lightbox", ["uikit"], function(){
- return component || addon(UIkit);
- });
- }
- })(function(UI){
- "use strict";
- var modal, cache = {};
- UI.component('lightbox', {
- defaults: {
- allowfullscreen : true,
- duration : 400,
- group : false,
- keyboard : true
- },
- index : 0,
- items : false,
- boot: function() {
- UI.$html.on('click', '[data-uk-lightbox]', function(e){
- e.preventDefault();
- var link = UI.$(this);
- if (!link.data("lightbox")) {
- UI.lightbox(link, UI.Utils.options(link.attr("data-uk-lightbox")));
- }
- link.data("lightbox").show(link);
- });
- // keyboard navigation
- UI.$doc.on('keyup', function(e) {
- if (modal && modal.is(':visible') && modal.lightbox.options.keyboard) {
- e.preventDefault();
- switch(e.keyCode) {
- case 37:
- modal.lightbox.previous();
- break;
- case 39:
- modal.lightbox.next();
- break;
- }
- }
- });
- },
- init: function() {
- var siblings = [];
- this.index = 0;
- this.siblings = [];
- if (this.element && this.element.length) {
- var domSiblings = this.options.group ? UI.$([
- '[data-uk-lightbox*="'+this.options.group+'"]',
- "[data-uk-lightbox*='"+this.options.group+"']"
- ].join(',')) : this.element;
- domSiblings.each(function() {
- var ele = UI.$(this);
- siblings.push({
- 'source': ele.attr('href'),
- 'title' : ele.attr('data-title') || ele.attr('title'),
- 'type' : ele.attr("data-lightbox-type") || 'auto',
- 'link' : ele
- });
- });
- this.index = domSiblings.index(this.element);
- this.siblings = siblings;
- } else if (this.options.group && this.options.group.length) {
- this.siblings = this.options.group;
- }
- this.trigger('lightbox-init', [this]);
- },
- show: function(index) {
- this.modal = getModal(this);
- // stop previous animation
- this.modal.dialog.stop();
- this.modal.content.stop();
- var $this = this, promise = UI.$.Deferred(), data, item;
- index = index || 0;
- // index is a jQuery object or DOM element
- if (typeof(index) == 'object') {
- this.siblings.forEach(function(s, idx){
- if (index[0] === s.link[0]) {
- index = idx;
- }
- });
- }
- // fix index if needed
- if ( index < 0 ) {
- index = this.siblings.length - index;
- } else if (!this.siblings[index]) {
- index = 0;
- }
- item = this.siblings[index];
- data = {
- lightbox : $this,
- source : item.source,
- type : item.type,
- index : index,
- promise : promise,
- title : item.title,
- item : item,
- meta : {
- content : '',
- width : null,
- height : null
- }
- };
- this.index = index;
- this.modal.content.empty();
- if (!this.modal.is(':visible')) {
- this.modal.content.css({width:'', height:''}).empty();
- this.modal.modal.show();
- }
- this.modal.loader.removeClass('uk-hidden');
- promise.promise().done(function() {
- $this.data = data;
- $this.fitSize(data);
- }).fail(function(){
- data.meta.content = '<div class="uk-position-cover uk-flex uk-flex-middle uk-flex-center"><strong>Loading resource failed!</strong></div>';
- data.meta.width = 400;
- data.meta.height = 300;
- $this.data = data;
- $this.fitSize(data);
- });
- $this.trigger('showitem.uk.lightbox', [data]);
- },
- fitSize: function() {
- var $this = this,
- data = this.data,
- pad = this.modal.dialog.outerWidth() - this.modal.dialog.width(),
- dpadTop = parseInt(this.modal.dialog.css('margin-top'), 10),
- dpadBot = parseInt(this.modal.dialog.css('margin-bottom'), 10),
- dpad = dpadTop + dpadBot,
- content = data.meta.content,
- duration = $this.options.duration;
- if (this.siblings.length > 1) {
- content = [
- content,
- '<a href="javascript:void(0);" class="uk-slidenav uk-slidenav-contrast uk-slidenav-previous uk-hidden-touch" data-lightbox-previous></a>',
- '<a href="javascript:void(0);" class="uk-slidenav uk-slidenav-contrast uk-slidenav-next uk-hidden-touch" data-lightbox-next></a>'
- ].join('');
- }
- // calculate width
- var tmp = UI.$('<div> </div>').css({
- opacity : 0,
- position : 'absolute',
- top : 0,
- left : 0,
- width : '100%',
- 'max-width' : $this.modal.dialog.css('max-width'),
- padding : $this.modal.dialog.css('padding'),
- margin : $this.modal.dialog.css('margin')
- }), maxwidth, maxheight, w = data.meta.width, h = data.meta.height;
- tmp.appendTo('body').width();
- maxwidth = tmp.width();
- maxheight = window.innerHeight - dpad;
- tmp.remove();
- this.modal.dialog.find('.uk-modal-caption').remove();
- if (data.title) {
- this.modal.dialog.append('<div class="uk-modal-caption">'+data.title+'</div>');
- maxheight -= this.modal.dialog.find('.uk-modal-caption').outerHeight();
- }
- if (maxwidth < data.meta.width) {
- h = Math.floor( h * (maxwidth / w) );
- w = maxwidth;
- }
- if (maxheight < h) {
- h = Math.floor(maxheight);
- w = Math.ceil(data.meta.width * (maxheight/data.meta.height));
- }
- this.modal.content.css('opacity', 0).width(w).html(content);
- if (data.type == 'iframe') {
- this.modal.content.find('iframe:first').height(h);
- }
- var dh = h + pad,
- t = Math.floor(window.innerHeight/2 - dh/2) - dpad;
- if (t < 0) { t = 0; }
- this.modal.closer.addClass('uk-hidden');
- if ($this.modal.data('mwidth') == w && $this.modal.data('mheight') == h) {
- duration = 0;
- }
- this.modal.dialog.animate({width: w + pad, height: h + pad, top: t }, duration, 'swing', function() {
- $this.modal.loader.addClass('uk-hidden');
- $this.modal.content.css({width:''}).animate({'opacity': 1}, function() {
- $this.modal.closer.removeClass('uk-hidden');
- });
- $this.modal.data({'mwidth': w, 'mheight': h});
- });
- },
- next: function() {
- this.show(this.siblings[(this.index+1)] ? (this.index+1) : 0);
- },
- previous: function() {
- this.show(this.siblings[(this.index-1)] ? (this.index-1) : this.siblings.length-1);
- }
- });
- // Plugins
- UI.plugin('lightbox', 'image', {
- init: function(lightbox) {
- lightbox.on("showitem.uk.lightbox", function(e, data){
- if (data.type == 'image' || data.source && data.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)) {
- var resolve = function(source, width, height) {
- data.meta = {
- content : '<img class="uk-responsive-width" width="'+width+'" height="'+height+'" src ="'+source+'">',
- width : width,
- height : height
- };
- data.type = 'image';
- data.promise.resolve();
- };
- if (!cache[data.source]) {
- var img = new Image();
- img.onerror = function(){
- data.promise.reject('Loading image failed');
- };
- img.onload = function(){
- cache[data.source] = {width: img.width, height: img.height};
- resolve(data.source, cache[data.source].width, cache[data.source].height);
- };
- img.src = data.source;
- } else {
- resolve(data.source, cache[data.source].width, cache[data.source].height);
- }
- }
- });
- }
- });
- UI.plugin("lightbox", "youtube", {
- init: function(lightbox) {
- var youtubeRegExp = /(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,
- youtubeRegExpShort = /youtu\.be\/(.*)/;
- lightbox.on("showitem.uk.lightbox", function(e, data){
- var id, matches, resolve = function(id, width, height) {
- data.meta = {
- content: '<iframe src="//www.youtube.com/embed/'+id+'" width="'+width+'" height="'+height+'" style="max-width:100%;"'+(modal.lightbox.options.allowfullscreen?' allowfullscreen':'')+'></iframe>',
- width: width,
- height: height
- };
- data.type = 'iframe';
- data.promise.resolve();
- };
- if (matches = data.source.match(youtubeRegExp)) {
- id = matches[2];
- }
- if (matches = data.source.match(youtubeRegExpShort)) {
- id = matches[1];
- }
- if (id) {
- if(!cache[id]) {
- var img = new Image(), lowres = false;
- img.onerror = function(){
- cache[id] = {width:640, height:320};
- resolve(id, cache[id].width, cache[id].height);
- };
- img.onload = function(){
- //youtube default 404 thumb, fall back to lowres
- if (img.width == 120 && img.height == 90) {
- if (!lowres) {
- lowres = true;
- img.src = '//img.youtube.com/vi/' + id + '/0.jpg';
- } else {
- cache[id] = {width: 640, height: 320};
- resolve(id, cache[id].width, cache[id].height);
- }
- } else {
- cache[id] = {width: img.width, height: img.height};
- resolve(id, img.width, img.height);
- }
- };
- img.src = '//img.youtube.com/vi/'+id+'/maxresdefault.jpg';
- } else {
- resolve(id, cache[id].width, cache[id].height);
- }
- e.stopImmediatePropagation();
- }
- });
- }
- });
- UI.plugin("lightbox", "vimeo", {
- init: function(lightbox) {
- var regex = /(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/, matches;
- lightbox.on("showitem.uk.lightbox", function(e, data){
- var id, resolve = function(id, width, height) {
- data.meta = {
- content: '<iframe src="//player.vimeo.com/video/'+id+'" width="'+width+'" height="'+height+'" style="width:100%;box-sizing:border-box;"'+(modal.lightbox.options.allowfullscreen?' allowfullscreen':'')+'></iframe>',
- width: width,
- height: height
- };
- data.type = 'iframe';
- data.promise.resolve();
- };
- if (matches = data.source.match(regex)) {
- id = matches[2];
- if(!cache[id]) {
- UI.$.ajax({
- type : 'GET',
- url : '//vimeo.com/api/oembed.json?url=' + encodeURI(data.source),
- jsonp : 'callback',
- dataType : 'jsonp',
- success : function(data) {
- cache[id] = {width:data.width, height:data.height};
- resolve(id, cache[id].width, cache[id].height);
- }
- });
- } else {
- resolve(id, cache[id].width, cache[id].height);
- }
- e.stopImmediatePropagation();
- }
- });
- }
- });
- UI.plugin("lightbox", "video", {
- init: function(lightbox) {
- lightbox.on("showitem.uk.lightbox", function(e, data){
- var resolve = function(source, width, height) {
- data.meta = {
- content: '<video class="uk-responsive-width" src="'+source+'" width="'+width+'" height="'+height+'" controls></video>',
- width: width,
- height: height
- };
- data.type = 'video';
- data.promise.resolve();
- };
- if (data.type == 'video' || data.source.match(/\.(mp4|webm|ogv)$/i)) {
- if (!cache[data.source]) {
- var vid = UI.$('<video style="position:fixed;visibility:hidden;top:-10000px;"></video>').attr('src', data.source).appendTo('body');
- var idle = setInterval(function() {
- if (vid[0].videoWidth) {
- clearInterval(idle);
- cache[data.source] = {width: vid[0].videoWidth, height: vid[0].videoHeight};
- resolve(data.source, cache[data.source].width, cache[data.source].height);
- vid.remove();
- }
- }, 20);
- } else {
- resolve(data.source, cache[data.source].width, cache[data.source].height);
- }
- }
- });
- }
- });
- UIkit.plugin("lightbox", "iframe", {
- init: function (lightbox) {
- lightbox.on("showitem.uk.lightbox", function (e, data) {
- var resolve = function (source, width, height) {
- data.meta = {
- content: '<iframe class="uk-responsive-width" src="' + source + '" width="' + width + '" height="' + height + '"'+(modal.lightbox.options.allowfullscreen?' allowfullscreen':'')+'></iframe>',
- width: width,
- height: height
- };
- data.type = 'iframe';
- data.promise.resolve();
- };
- if (data.type === 'iframe' || data.source.match(/\.(html|php)$/)) {
- resolve(data.source, (lightbox.options.width || 800), (lightbox.options.height || 600));
- }
- });
- }
- });
- function getModal(lightbox) {
- if (modal) {
- modal.lightbox = lightbox;
- return modal;
- }
- // init lightbox container
- modal = UI.$([
- '<div class="uk-modal">',
- '<div class="uk-modal-dialog uk-modal-dialog-lightbox uk-slidenav-position" style="margin-left:auto;margin-right:auto;width:200px;height:200px;top:'+Math.abs(window.innerHeight/2 - 200)+'px;">',
- '<a href="javascript:void(0);" class="uk-modal-close uk-close uk-close-alt"></a>',
- '<div class="uk-lightbox-content"></div>',
- '<div class="uk-modal-spinner uk-hidden"></div>',
- '</div>',
- '</div>'
- ].join('')).appendTo('body');
- modal.dialog = modal.find('.uk-modal-dialog:first');
- modal.content = modal.find('.uk-lightbox-content:first');
- modal.loader = modal.find('.uk-modal-spinner:first');
- modal.closer = modal.find('.uk-close.uk-close-alt');
- modal.modal = UI.modal(modal, {modal:false});
- // next / previous
- modal.on("swipeRight swipeLeft", function(e) {
- modal.lightbox[e.type=='swipeLeft' ? 'next':'previous']();
- }).on("click", "[data-lightbox-previous], [data-lightbox-next]", function(e){
- e.preventDefault();
- modal.lightbox[UI.$(this).is('[data-lightbox-next]') ? 'next':'previous']();
- });
- // destroy content on modal hide
- modal.on("hide.uk.modal", function(e) {
- modal.content.html('');
- });
- var resizeCache = {w: window.innerWidth, h:window.innerHeight};
- UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(e){
- if (resizeCache.w !== window.innerWidth && modal.is(':visible') && !UI.Utils.isFullscreen()) {
- modal.lightbox.fitSize();
- }
- resizeCache = {w: window.innerWidth, h:window.innerHeight};
- }, 100));
- modal.lightbox = lightbox;
- return modal;
- }
- UI.lightbox.create = function(items, options) {
- if (!items) return;
- var group = [], o;
- items.forEach(function(item) {
- group.push(UI.$.extend({
- source : '',
- title : '',
- type : 'auto',
- link : false
- }, (typeof(item) == 'string' ? {'source': item} : item)));
- });
- o = UI.lightbox(UI.$.extend({}, options, {'group':group}));
- return o;
- };
- return UI.lightbox;
- });
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- /*
- * Based on Nestable jQuery Plugin - Copyright (c) 2012 David Bushell - http://dbushell.com/
- */
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) {
- define("uikit-nestable", ["uikit"], function(){
- return component || addon(UIkit);
- });
- }
- })(function(UI) {
- "use strict";
- var hasTouch = 'ontouchstart' in window,
- html = UI.$html,
- touchedlists = [],
- $win = UI.$win,
- draggingElement;
- var eStart = hasTouch ? 'touchstart' : 'mousedown',
- eMove = hasTouch ? 'touchmove' : 'mousemove',
- eEnd = hasTouch ? 'touchend' : 'mouseup',
- eCancel = hasTouch ? 'touchcancel' : 'mouseup';
- UI.component('nestable', {
- defaults: {
- listBaseClass : 'uk-nestable',
- listClass : 'uk-nestable-list',
- listItemClass : 'uk-nestable-item',
- dragClass : 'uk-nestable-dragged',
- movingClass : 'uk-nestable-moving',
- noChildrenClass : 'uk-nestable-nochildren',
- emptyClass : 'uk-nestable-empty',
- handleClass : '',
- collapsedClass : 'uk-collapsed',
- placeholderClass: 'uk-nestable-placeholder',
- noDragClass : 'uk-nestable-nodrag',
- group : false,
- maxDepth : 10,
- threshold : 20,
- idlethreshold : 10,
- },
- boot: function() {
- // adjust document scrolling
- UI.$html.on('mousemove touchmove', function(e) {
- if (draggingElement) {
- var top = draggingElement.offset().top;
- if (top < UI.$win.scrollTop()) {
- UI.$win.scrollTop(UI.$win.scrollTop() - Math.ceil(draggingElement.height()/2));
- } else if ( (top + draggingElement.height()) > (window.innerHeight + UI.$win.scrollTop()) ) {
- UI.$win.scrollTop(UI.$win.scrollTop() + Math.ceil(draggingElement.height()/2));
- }
- }
- });
- // init code
- UI.ready(function(context) {
- UI.$("[data-uk-nestable]", context).each(function(){
- var ele = UI.$(this);
- if (!ele.data("nestable")) {
- UI.nestable(ele, UI.Utils.options(ele.attr("data-uk-nestable")));
- }
- });
- });
- },
- init: function() {
- var $this = this;
- Object.keys(this.options).forEach(function(key){
- if(String(key).indexOf('Class')!=-1) {
- $this.options['_'+key] = '.' + $this.options[key];
- }
- });
- this.find(this.options._listItemClass).find(">ul").addClass(this.options.listClass);
- this.checkEmptyList();
- this.reset();
- this.element.data('nestable-group', this.options.group || UI.Utils.uid('nestable-group'));
- this.find(this.options._listItemClass).each(function() {
- $this.setParent(UI.$(this));
- });
- this.on('click', '[data-nestable-action]', function(e) {
- if ($this.dragEl || (!hasTouch && e.button !== 0)) {
- return;
- }
- e.preventDefault();
- var target = UI.$(e.currentTarget),
- action = target.data('nestableAction'),
- item = target.closest($this.options._listItemClass);
- if (action === 'collapse') {
- $this.collapseItem(item);
- }
- if (action === 'expand') {
- $this.expandItem(item);
- }
- if (action === 'toggle') {
- $this.toggleItem(item);
- }
- });
- var onStartEvent = function(e) {
- var handle = UI.$(e.target),
- link = handle.is('a[href]') ? handle:handle.parents('a[href]');
- if (e.target === $this.element[0]) {
- return;
- }
- if (handle.is($this.options._noDragClass) || handle.closest($this.options._noDragClass).length) {
- return;
- }
- if (handle.is('[data-nestable-action]') || handle.closest('[data-nestable-action]').length) {
- return;
- }
- if ($this.options.handleClass && !handle.hasClass($this.options.handleClass)) {
- if ($this.options.handleClass) {
- handle = handle.closest($this.options._handleClass);
- }
- }
- if (!handle.length || $this.dragEl || (!hasTouch && e.button !== 0) || (hasTouch && e.touches.length !== 1)) {
- return;
- }
- if (e.originalEvent && e.originalEvent.touches) {
- e = evt.originalEvent.touches[0];
- }
- $this.delayMove = function(evt) {
- link = false;
- evt.preventDefault();
- $this.dragStart(e);
- $this.trigger('start.uk.nestable', [$this]);
- $this.delayMove = false;
- };
- $this.delayMove.x = parseInt(e.pageX, 10);
- $this.delayMove.y = parseInt(e.pageY, 10);
- $this.delayMove.threshold = $this.options.idlethreshold;
- if (link.length && eEnd == 'touchend') {
- $this.one(eEnd, function(){
- if (link && link.attr('href').trim()) {
- location.href = link.attr('href');
- }
- });
- }
- e.preventDefault();
- };
- var onMoveEvent = function(e) {
- if (e.originalEvent && e.originalEvent.touches) {
- e = e.originalEvent.touches[0];
- }
- if ($this.delayMove && (Math.abs(e.pageX - $this.delayMove.x) > $this.delayMove.threshold || Math.abs(e.pageY - $this.delayMove.y) > $this.delayMove.threshold)) {
- if (!window.getSelection().toString()) {
- $this.delayMove(e);
- } else {
- $this.delayMove = false;
- }
- }
- if ($this.dragEl) {
- e.preventDefault();
- $this.dragMove(e);
- $this.trigger('move.uk.nestable', [$this]);
- }
- };
- var onEndEvent = function(e) {
- if ($this.dragEl) {
- e.preventDefault();
- $this.dragStop(hasTouch ? e.touches[0] : e);
- }
- draggingElement = false;
- $this.delayMove = false;
- };
- if (hasTouch) {
- this.element[0].addEventListener(eStart, onStartEvent, false);
- window.addEventListener(eMove, onMoveEvent, false);
- window.addEventListener(eEnd, onEndEvent, false);
- window.addEventListener(eCancel, onEndEvent, false);
- } else {
- this.on(eStart, onStartEvent);
- $win.on(eMove, onMoveEvent);
- $win.on(eEnd, onEndEvent);
- }
- },
- serialize: function() {
- var data,
- depth = 0,
- list = this,
- step = function(level, depth) {
- var array = [ ], items = level.children(list.options._listItemClass);
- items.each(function() {
- var li = UI.$(this),
- item = {}, attribute,
- sub = li.children(list.options._listClass);
- for (var i = 0, attr, val; i < li[0].attributes.length; i++) {
- attribute = li[0].attributes[i];
- if (attribute.name.indexOf('data-') === 0) {
- attr = attribute.name.substr(5);
- val = UI.Utils.str2json(attribute.value);
- item[attr] = (val || attribute.value=='false' || attribute.value=='0') ? val:attribute.value;
- }
- }
- if (sub.length) {
- item.children = step(sub, depth + 1);
- }
- array.push(item);
- });
- return array;
- };
- data = step(list.element, depth);
- return data;
- },
- list: function(options) {
- var data = [],
- list = this,
- depth = 0,
- step = function(level, depth, parent) {
- var items = level.children(options._listItemClass);
- items.each(function(index) {
- var li = UI.$(this),
- item = UI.$.extend({parent_id: (parent ? parent : null), depth: depth, order: index}, li.data()),
- sub = li.children(options._listClass);
- data.push(item);
- if (sub.length) {
- step(sub, depth + 1, li.data(options.idProperty || 'id'));
- }
- });
- };
- options = UI.$.extend({}, list.options, options);
- step(list.element, depth);
- return data;
- },
- reset: function() {
- this.mouse = {
- offsetX : 0,
- offsetY : 0,
- startX : 0,
- startY : 0,
- lastX : 0,
- lastY : 0,
- nowX : 0,
- nowY : 0,
- distX : 0,
- distY : 0,
- dirAx : 0,
- dirX : 0,
- dirY : 0,
- lastDirX : 0,
- lastDirY : 0,
- distAxX : 0,
- distAxY : 0
- };
- this.moving = false;
- this.dragEl = null;
- this.dragRootEl = null;
- this.dragDepth = 0;
- this.hasNewRoot = false;
- this.pointEl = null;
- for (var i=0; i<touchedlists.length; i++) {
- this.checkEmptyList(touchedlists[i]);
- }
- touchedlists = [];
- },
- toggleItem: function(li) {
- this[li.hasClass(this.options.collapsedClass) ? "expandItem":"collapseItem"](li);
- },
- expandItem: function(li) {
- li.removeClass(this.options.collapsedClass);
- },
- collapseItem: function(li) {
- var lists = li.children(this.options._listClass);
- if (lists.length) {
- li.addClass(this.options.collapsedClass);
- }
- },
- expandAll: function() {
- var list = this;
- this.find(list.options._listItemClass).each(function() {
- list.expandItem(UI.$(this));
- });
- },
- collapseAll: function() {
- var list = this;
- this.find(list.options._listItemClass).each(function() {
- list.collapseItem(UI.$(this));
- });
- },
- setParent: function(li) {
- if (li.children(this.options._listClass).length) {
- li.addClass("uk-parent");
- }
- },
- unsetParent: function(li) {
- li.removeClass('uk-parent '+this.options.collapsedClass);
- li.children(this.options._listClass).remove();
- },
- dragStart: function(e) {
- var mouse = this.mouse,
- target = UI.$(e.target),
- dragItem = target.closest(this.options._listItemClass),
- offset = dragItem.offset();
- this.placeEl = dragItem;
- mouse.offsetX = e.pageX - offset.left;
- mouse.offsetY = e.pageY - offset.top;
- mouse.startX = mouse.lastX = offset.left;
- mouse.startY = mouse.lastY = offset.top;
- this.dragRootEl = this.element;
- this.dragEl = UI.$('<ul></ul>').addClass(this.options.listClass + ' ' + this.options.dragClass).append(dragItem.clone());
- this.dragEl.css('width', dragItem.width());
- this.placeEl.addClass(this.options.placeholderClass);
- draggingElement = this.dragEl;
- this.tmpDragOnSiblings = [dragItem[0].previousSibling, dragItem[0].nextSibling];
- UI.$body.append(this.dragEl);
- this.dragEl.css({
- left : offset.left,
- top : offset.top
- });
- // total depth of dragging item
- var i, depth, items = this.dragEl.find(this.options._listItemClass);
- for (i = 0; i < items.length; i++) {
- depth = UI.$(items[i]).parents(this.options._listClass+','+this.options._listBaseClass).length;
- if (depth > this.dragDepth) {
- this.dragDepth = depth;
- }
- }
- html.addClass(this.options.movingClass);
- },
- dragStop: function(e) {
- var el = UI.$(this.placeEl),
- root = this.placeEl.parents(this.options._listBaseClass+':first');
- this.placeEl.removeClass(this.options.placeholderClass);
- this.dragEl.remove();
- if (this.element[0] !== root[0]) {
- root.trigger('change.uk.nestable',[root.data('nestable'), el, 'added']);
- this.element.trigger('change.uk.nestable', [this, el, 'removed']);
- } else {
- this.element.trigger('change.uk.nestable',[this, el, "moved"]);
- }
- this.trigger('stop.uk.nestable', [this, el]);
- this.reset();
- html.removeClass(this.options.movingClass);
- },
- dragMove: function(e) {
- var list, parent, prev, next, depth,
- opt = this.options,
- mouse = this.mouse,
- maxDepth = this.dragRootEl ? this.dragRootEl.data('nestable').options.maxDepth : opt.maxDepth;
- this.dragEl.css({
- left : e.pageX - mouse.offsetX,
- top : e.pageY - mouse.offsetY
- });
- // mouse position last events
- mouse.lastX = mouse.nowX;
- mouse.lastY = mouse.nowY;
- // mouse position this events
- mouse.nowX = e.pageX;
- mouse.nowY = e.pageY;
- // distance mouse moved between events
- mouse.distX = mouse.nowX - mouse.lastX;
- mouse.distY = mouse.nowY - mouse.lastY;
- // direction mouse was moving
- mouse.lastDirX = mouse.dirX;
- mouse.lastDirY = mouse.dirY;
- // direction mouse is now moving (on both axis)
- mouse.dirX = mouse.distX === 0 ? 0 : mouse.distX > 0 ? 1 : -1;
- mouse.dirY = mouse.distY === 0 ? 0 : mouse.distY > 0 ? 1 : -1;
- // axis mouse is now moving on
- var newAx = Math.abs(mouse.distX) > Math.abs(mouse.distY) ? 1 : 0;
- // do nothing on first move
- if (!mouse.moving) {
- mouse.dirAx = newAx;
- mouse.moving = true;
- return;
- }
- // calc distance moved on this axis (and direction)
- if (mouse.dirAx !== newAx) {
- mouse.distAxX = 0;
- mouse.distAxY = 0;
- } else {
- mouse.distAxX += Math.abs(mouse.distX);
- if (mouse.dirX !== 0 && mouse.dirX !== mouse.lastDirX) {
- mouse.distAxX = 0;
- }
- mouse.distAxY += Math.abs(mouse.distY);
- if (mouse.dirY !== 0 && mouse.dirY !== mouse.lastDirY) {
- mouse.distAxY = 0;
- }
- }
- mouse.dirAx = newAx;
- /**
- * move horizontal
- */
- if (mouse.dirAx && mouse.distAxX >= opt.threshold) {
- // reset move distance on x-axis for new phase
- mouse.distAxX = 0;
- prev = this.placeEl.prev('li');
- // increase horizontal level if previous sibling exists, is not collapsed, and does not have a 'no children' class
- if (mouse.distX > 0 && prev.length && !prev.hasClass(opt.collapsedClass) && !prev.hasClass(opt.noChildrenClass)) {
- // cannot increase level when item above is collapsed
- list = prev.find(opt._listClass).last();
- // check if depth limit has reached
- depth = this.placeEl.parents(opt._listClass+','+opt._listBaseClass).length;
- if (depth + this.dragDepth <= maxDepth) {
- // create new sub-level if one doesn't exist
- if (!list.length) {
- list = UI.$('<ul/>').addClass(opt.listClass);
- list.append(this.placeEl);
- prev.append(list);
- this.setParent(prev);
- } else {
- // else append to next level up
- list = prev.children(opt._listClass).last();
- list.append(this.placeEl);
- }
- }
- }
- // decrease horizontal level
- if (mouse.distX < 0) {
- // we cannot decrease the level if an item precedes the current one
- next = this.placeEl.next(opt._listItemClass);
- if (!next.length) {
- // get parent ul of the list item
- var parentUl = this.placeEl.closest([opt._listBaseClass, opt._listClass].join(','));
- // try to get the li surrounding the ul
- var surroundingLi = parentUl.closest(opt._listItemClass);
- // if the ul is inside of a li (meaning it is nested)
- if (surroundingLi.length) {
- // we can decrease the horizontal level
- surroundingLi.after(this.placeEl);
- // if the previous parent ul is now empty
- if (!parentUl.children().length) {
- this.unsetParent(surroundingLi);
- }
- }
- }
- }
- }
- var isEmpty = false;
- // find list item under cursor
- var pointX = e.pageX - (window.pageXOffset || document.scrollLeft || 0),
- pointY = e.pageY - (window.pageYOffset || document.documentElement.scrollTop);
- this.pointEl = UI.$(document.elementFromPoint(pointX, pointY));
- if (opt.handleClass && this.pointEl.hasClass(opt.handleClass)) {
- this.pointEl = this.pointEl.closest(opt._listItemClass);
- } else {
- var nestableitem = this.pointEl.closest(opt._listItemClass);
- if (nestableitem.length) {
- this.pointEl = nestableitem;
- }
- }
- if (this.placeEl.find(this.pointEl).length) {
- return;
- }
- if (this.pointEl.data('nestable') && !this.pointEl.children().length) {
- isEmpty = true;
- this.checkEmptyList(this.pointEl);
- } else if (!this.pointEl.length || !this.pointEl.hasClass(opt.listItemClass)) {
- return;
- }
- // find parent list of item under cursor
- var pointElRoot = this.element,
- tmpRoot = this.pointEl.closest(this.options._listBaseClass),
- isNewRoot = pointElRoot[0] != tmpRoot[0];
- /**
- * move vertical
- */
- if (!mouse.dirAx || isNewRoot || isEmpty) {
- // check if groups match if dragging over new root
- if (isNewRoot && opt.group !== tmpRoot.data('nestable-group')) {
- return;
- } else {
- touchedlists.push(pointElRoot);
- }
- // check depth limit
- depth = this.dragDepth - 1 + this.pointEl.parents(opt._listClass+','+opt._listBaseClass).length;
- if (depth > maxDepth) {
- return;
- }
- var before = e.pageY < (this.pointEl.offset().top + this.pointEl.height() / 2);
- parent = this.placeEl.parent();
- if (isEmpty) {
- this.pointEl.append(this.placeEl);
- } else if (before) {
- this.pointEl.before(this.placeEl);
- } else {
- this.pointEl.after(this.placeEl);
- }
- if (!parent.children().length) {
- if (!parent.data("nestable")) this.unsetParent(parent.parent());
- }
- this.checkEmptyList(this.dragRootEl);
- this.checkEmptyList(pointElRoot);
- // parent root list has changed
- if (isNewRoot) {
- this.dragRootEl = tmpRoot;
- this.hasNewRoot = this.element[0] !== this.dragRootEl[0];
- }
- }
- },
- checkEmptyList: function(list) {
- list = list ? UI.$(list) : this.element;
- if (this.options.emptyClass) {
- list[!list.children().length ? 'addClass':'removeClass'](this.options.emptyClass);
- }
- }
- });
- return UI.nestable;
- });
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) {
- define("uikit-notify", ["uikit"], function(){
- return component || addon(UIkit);
- });
- }
- })(function(UI){
- "use strict";
- var containers = {},
- messages = {},
- notify = function(options){
- if (UI.$.type(options) == 'string') {
- options = { message: options };
- }
- if (arguments[1]) {
- options = UI.$.extend(options, UI.$.type(arguments[1]) == 'string' ? {status:arguments[1]} : arguments[1]);
- }
- return (new Message(options)).show();
- },
- closeAll = function(group, instantly){
- var id;
- if (group) {
- for(id in messages) { if(group===messages[id].group) messages[id].close(instantly); }
- } else {
- for(id in messages) { messages[id].close(instantly); }
- }
- };
- var Message = function(options){
- this.options = UI.$.extend({}, Message.defaults, options);
- this.uuid = UI.Utils.uid("notifymsg");
- this.element = UI.$([
- '<div class="uk-notify-message">',
- '<a class="uk-close"></a>',
- '<div></div>',
- '</div>'
- ].join('')).data("notifyMessage", this);
- this.content(this.options.message);
- // status
- if (this.options.status) {
- this.element.addClass('uk-notify-message-'+this.options.status);
- this.currentstatus = this.options.status;
- }
- this.group = this.options.group;
- messages[this.uuid] = this;
- if(!containers[this.options.pos]) {
- containers[this.options.pos] = UI.$('<div class="uk-notify uk-notify-'+this.options.pos+'"></div>').appendTo('body').on("click", ".uk-notify-message", function(){
- var message = UI.$(this).data("notifyMessage");
- message.element.trigger('manualclose.uk.notify', [message]);
- message.close();
- });
- }
- };
- UI.$.extend(Message.prototype, {
- uuid: false,
- element: false,
- timout: false,
- currentstatus: "",
- group: false,
- show: function() {
- if (this.element.is(":visible")) return;
- var $this = this;
- containers[this.options.pos].show().prepend(this.element);
- var marginbottom = parseInt(this.element.css("margin-bottom"), 10);
- this.element.css({"opacity":0, "margin-top": -1*this.element.outerHeight(), "margin-bottom":0}).animate({"opacity":1, "margin-top": 0, "margin-bottom":marginbottom}, function(){
- if ($this.options.timeout) {
- var closefn = function(){ $this.close(); };
- $this.timeout = setTimeout(closefn, $this.options.timeout);
- $this.element.hover(
- function() { clearTimeout($this.timeout); },
- function() { $this.timeout = setTimeout(closefn, $this.options.timeout); }
- );
- }
- });
- return this;
- },
- close: function(instantly) {
- var $this = this,
- finalize = function(){
- $this.element.remove();
- if (!containers[$this.options.pos].children().length) {
- containers[$this.options.pos].hide();
- }
- $this.options.onClose.apply($this, []);
- $this.element.trigger('close.uk.notify', [$this]);
- delete messages[$this.uuid];
- };
- if (this.timeout) clearTimeout(this.timeout);
- if (instantly) {
- finalize();
- } else {
- this.element.animate({"opacity":0, "margin-top": -1* this.element.outerHeight(), "margin-bottom":0}, function(){
- finalize();
- });
- }
- },
- content: function(html){
- var container = this.element.find(">div");
- if(!html) {
- return container.html();
- }
- container.html(html);
- return this;
- },
- status: function(status) {
- if (!status) {
- return this.currentstatus;
- }
- this.element.removeClass('uk-notify-message-'+this.currentstatus).addClass('uk-notify-message-'+status);
- this.currentstatus = status;
- return this;
- }
- });
- Message.defaults = {
- message: "",
- status: "",
- timeout: 5000,
- group: null,
- pos: 'top-center',
- onClose: function() {}
- };
- UI.notify = notify;
- UI.notify.message = Message;
- UI.notify.closeAll = closeAll;
- return notify;
- });
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) {
- define("uikit-slideshow", ["uikit"], function() {
- return component || addon(UIkit);
- });
- }
- })(function(UI) {
- "use strict";
- var Animations, playerId = 0;
- UI.component('slideshow', {
- defaults: {
- animation : "fade",
- duration : 500,
- height : "auto",
- start : 0,
- autoplay : false,
- autoplayInterval : 7000,
- videoautoplay : true,
- videomute : true,
- slices : 15,
- pauseOnHover : true,
- kenburns : false,
- kenburnsanimations : [
- 'uk-animation-middle-left',
- 'uk-animation-top-right',
- 'uk-animation-bottom-left',
- 'uk-animation-top-center',
- '', // middle-center
- 'uk-animation-bottom-right'
- ]
- },
- current : false,
- interval : null,
- hovering : false,
- boot: function() {
- // init code
- UI.ready(function(context) {
- UI.$('[data-uk-slideshow]', context).each(function() {
- var slideshow = UI.$(this);
- if (!slideshow.data("slideshow")) {
- UI.slideshow(slideshow, UI.Utils.options(slideshow.attr("data-uk-slideshow")));
- }
- });
- });
- },
- init: function() {
- var $this = this;
- this.container = this.element.hasClass('uk-slideshow') ? this.element : UI.$(this.find('.uk-slideshow:first'));
- this.current = this.options.start;
- this.animating = false;
- this.fixFullscreen = navigator.userAgent.match(/(iPad|iPhone|iPod)/g) && this.container.hasClass('uk-slideshow-fullscreen'); // viewport unit fix for height:100vh - should be fixed in iOS 8
- if (this.options.kenburns) {
- this.kbanimduration = this.options.kenburns === true ? '15s': this.options.kenburns;
- if (!String(this.kbanimduration).match(/(ms|s)$/)) {
- this.kbanimduration += 'ms';
- }
- if (typeof(this.options.kenburnsanimations) == 'string') {
- this.options.kenburnsanimations = this.options.kenburnsanimations.split(',');
- }
- }
- this.update();
- this.on("click.uk.slideshow", '[data-uk-slideshow-item]', function(e) {
- e.preventDefault();
- var slide = UI.$(this).attr('data-uk-slideshow-item');
- if ($this.current == slide) return;
- switch(slide) {
- case 'next':
- case 'previous':
- $this[slide=='next' ? 'next':'previous']();
- break;
- default:
- $this.show(parseInt(slide, 10));
- }
- $this.stop();
- });
- UI.$win.on("resize load", UI.Utils.debounce(function() {
- $this.resize();
- if ($this.fixFullscreen) {
- $this.container.css('height', window.innerHeight);
- $this.slides.css('height', window.innerHeight);
- }
- }, 100));
- // chrome image load fix
- setTimeout(function(){
- $this.resize();
- }, 80);
- // Set autoplay
- if (this.options.autoplay) {
- this.start();
- }
- if (this.options.videoautoplay && this.slides.eq(this.current).data('media')) {
- this.playmedia(this.slides.eq(this.current).data('media'));
- }
- if (this.options.kenburns) {
- this.applyKenBurns(this.slides.eq(this.current));
- }
- this.container.on({
- mouseenter: function() { if ($this.options.pauseOnHover) $this.hovering = true; },
- mouseleave: function() { $this.hovering = false; }
- });
- this.on('swipeRight swipeLeft', function(e) {
- $this[e.type=='swipeLeft' ? 'next' : 'previous']();
- });
- this.on('display.uk.check', function(){
- if ($this.element.is(":visible")) {
- $this.resize();
- if ($this.fixFullscreen) {
- $this.container.css('height', window.innerHeight);
- $this.slides.css('height', window.innerHeight);
- }
- }
- });
- UI.domObserve(this.element, function(e) {
- if ($this.container.children(':not([data-slide])').length) {
- $this.update(true);
- }
- });
- },
- update: function(resize) {
- var $this = this, canvas, processed = 0;
- this.slides = this.container.children();
- this.slidesCount = this.slides.length;
- if (!this.slides.eq(this.current).length) {
- this.current = 0;
- }
- this.slides.each(function(index) {
- var slide = UI.$(this);
- if (slide.data('processed')) {
- return;
- }
- var media = slide.children('img,video,iframe').eq(0), type = 'html';
- slide.data('media', media);
- slide.data('sizer', media);
- if (media.length) {
- var placeholder;
- type = media[0].nodeName.toLowerCase();
- switch(media[0].nodeName) {
- case 'IMG':
- var cover = UI.$('<div class="uk-cover-background uk-position-cover"></div>').css({'background-image':'url('+ media.attr('src') + ')'});
- if (media.attr('width') && media.attr('height')) {
- placeholder = UI.$('<canvas></canvas>').attr({width:media.attr('width'), height:media.attr('height')});
- media.replaceWith(placeholder);
- media = placeholder;
- placeholder = undefined;
- }
- media.css({width: '100%',height: 'auto', opacity:0});
- slide.prepend(cover).data('cover', cover);
- break;
- case 'IFRAME':
- var src = media[0].src, iframeId = 'sw-'+(++playerId);
- media
- .attr('src', '').on('load', function(){
- if (index !== $this.current || (index == $this.current && !$this.options.videoautoplay)) {
- $this.pausemedia(media);
- }
- if ($this.options.videomute) {
- $this.mutemedia(media);
- var inv = setInterval((function(ic) {
- return function() {
- $this.mutemedia(media);
- if (++ic >= 4) clearInterval(inv);
- }
- })(0), 250);
- }
- })
- .data('slideshow', $this) // add self-reference for the vimeo-ready listener
- .attr('data-player-id', iframeId) // add frameId for the vimeo-ready listener
- .attr('src', [src, (src.indexOf('?') > -1 ? '&':'?'), 'enablejsapi=1&api=1&player_id='+iframeId].join(''))
- .addClass('uk-position-absolute');
- // disable pointer events
- if(!UI.support.touch) media.css('pointer-events', 'none');
- placeholder = true;
- if (UI.cover) {
- UI.cover(media);
- media.attr('data-uk-cover', '{}');
- }
- break;
- case 'VIDEO':
- media.addClass('uk-cover-object uk-position-absolute');
- placeholder = true;
- if ($this.options.videomute) $this.mutemedia(media);
- }
- if (placeholder) {
- canvas = UI.$('<canvas></canvas>').attr({'width': media[0].width, 'height': media[0].height});
- var img = UI.$('<img style="width:100%;height:auto;">').attr('src', canvas[0].toDataURL());
- slide.prepend(img);
- slide.data('sizer', img);
- }
- } else {
- slide.data('sizer', slide);
- }
- if ($this.hasKenBurns(slide)) {
- slide.data('cover').css({
- '-webkit-animation-duration': $this.kbanimduration,
- 'animation-duration': $this.kbanimduration
- });
- }
- slide.data('processed', ++processed);
- slide.attr('data-slide', type);
- });
- if (processed) {
- this.triggers = this.find('[data-uk-slideshow-item]');
- // Set start slide
- this.slides.attr('aria-hidden', 'true').removeClass('uk-active').eq(this.current).addClass('uk-active').attr('aria-hidden', 'false');
- this.triggers.filter('[data-uk-slideshow-item="'+this.current+'"]').addClass('uk-active');
- }
- if (resize && processed) {
- this.resize();
- }
- },
- resize: function() {
- if (this.container.hasClass('uk-slideshow-fullscreen')) return;
- var height = this.options.height;
- if (this.options.height === 'auto') {
- height = 0;
- this.slides.css('height', '').each(function() {
- height = Math.max(height, UI.$(this).height());
- });
- }
- this.container.css('height', height);
- this.slides.css('height', height);
- },
- show: function(index, direction) {
- if (this.animating || this.current == index) return;
- this.animating = true;
- var $this = this,
- current = this.slides.eq(this.current),
- next = this.slides.eq(index),
- dir = direction ? direction : this.current < index ? 1 : -1,
- currentmedia = current.data('media'),
- animation = Animations[this.options.animation] ? this.options.animation : 'fade',
- nextmedia = next.data('media'),
- finalize = function() {
- if (!$this.animating) return;
- if (currentmedia && currentmedia.is('video,iframe')) {
- $this.pausemedia(currentmedia);
- }
- if (nextmedia && nextmedia.is('video,iframe')) {
- $this.playmedia(nextmedia);
- }
- next.addClass("uk-active").attr('aria-hidden', 'false');
- current.removeClass("uk-active").attr('aria-hidden', 'true');
- $this.animating = false;
- $this.current = index;
- UI.Utils.checkDisplay(next, '[class*="uk-animation-"]:not(.uk-cover-background.uk-position-cover)');
- $this.trigger('show.uk.slideshow', [next, current, $this]);
- };
- $this.applyKenBurns(next);
- // animation fallback
- if (!UI.support.animation) {
- animation = 'none';
- }
- current = UI.$(current);
- next = UI.$(next);
- $this.trigger('beforeshow.uk.slideshow', [next, current, $this]);
- Animations[animation].apply(this, [current, next, dir]).then(finalize);
- $this.triggers.removeClass('uk-active');
- $this.triggers.filter('[data-uk-slideshow-item="'+index+'"]').addClass('uk-active');
- },
- applyKenBurns: function(slide) {
- if (!this.hasKenBurns(slide)) {
- return;
- }
- var animations = this.options.kenburnsanimations,
- index = this.kbindex || 0;
- slide.data('cover').attr('class', 'uk-cover-background uk-position-cover').width();
- slide.data('cover').addClass(['uk-animation-scale', 'uk-animation-reverse', animations[index].trim()].join(' '));
- this.kbindex = animations[index + 1] ? (index+1):0;
- },
- hasKenBurns: function(slide) {
- return (this.options.kenburns && slide.data('cover'));
- },
- next: function() {
- this.show(this.slides[this.current + 1] ? (this.current + 1) : 0, 1);
- },
- previous: function() {
- this.show(this.slides[this.current - 1] ? (this.current - 1) : (this.slides.length - 1), -1);
- },
- start: function() {
- this.stop();
- var $this = this;
- this.interval = setInterval(function() {
- if (!$this.hovering) $this.next();
- }, this.options.autoplayInterval);
- },
- stop: function() {
- if (this.interval) clearInterval(this.interval);
- },
- playmedia: function(media) {
- if (!(media && media[0])) return;
- switch(media[0].nodeName) {
- case 'VIDEO':
- if (!this.options.videomute) {
- media[0].muted = false;
- }
- media[0].play();
- break;
- case 'IFRAME':
- if (!this.options.videomute) {
- media[0].contentWindow.postMessage('{ "event": "command", "func": "unmute", "method":"setVolume", "value":1}', '*');
- }
- media[0].contentWindow.postMessage('{ "event": "command", "func": "playVideo", "method":"play"}', '*');
- break;
- }
- },
- pausemedia: function(media) {
- switch(media[0].nodeName) {
- case 'VIDEO':
- media[0].pause();
- break;
- case 'IFRAME':
- media[0].contentWindow.postMessage('{ "event": "command", "func": "pauseVideo", "method":"pause"}', '*');
- break;
- }
- },
- mutemedia: function(media) {
- switch(media[0].nodeName) {
- case 'VIDEO':
- media[0].muted = true;
- break;
- case 'IFRAME':
- media[0].contentWindow.postMessage('{ "event": "command", "func": "mute", "method":"setVolume", "value":0}', '*');
- break;
- }
- }
- });
- Animations = {
- 'none': function() {
- var d = UI.$.Deferred();
- d.resolve();
- return d.promise();
- },
- 'scroll': function(current, next, dir) {
- var d = UI.$.Deferred();
- current.css('animation-duration', this.options.duration+'ms');
- next.css('animation-duration', this.options.duration+'ms');
- next.css('opacity', 1).one(UI.support.animation.end, function() {
- current.css('opacity', 0).removeClass(dir == -1 ? 'uk-slideshow-scroll-backward-out' : 'uk-slideshow-scroll-forward-out');
- next.removeClass(dir == -1 ? 'uk-slideshow-scroll-backward-in' : 'uk-slideshow-scroll-forward-in');
- d.resolve();
- }.bind(this));
- current.addClass(dir == -1 ? 'uk-slideshow-scroll-backward-out' : 'uk-slideshow-scroll-forward-out');
- next.addClass(dir == -1 ? 'uk-slideshow-scroll-backward-in' : 'uk-slideshow-scroll-forward-in');
- next.width(); // force redraw
- return d.promise();
- },
- 'swipe': function(current, next, dir) {
- var d = UI.$.Deferred();
- current.css('animation-duration', this.options.duration+'ms');
- next.css('animation-duration', this.options.duration+'ms');
- next.css('opacity', 1).one(UI.support.animation.end, function() {
- current.css('opacity', 0).removeClass(dir === -1 ? 'uk-slideshow-swipe-backward-out' : 'uk-slideshow-swipe-forward-out');
- next.removeClass(dir === -1 ? 'uk-slideshow-swipe-backward-in' : 'uk-slideshow-swipe-forward-in');
- d.resolve();
- }.bind(this));
- current.addClass(dir == -1 ? 'uk-slideshow-swipe-backward-out' : 'uk-slideshow-swipe-forward-out');
- next.addClass(dir == -1 ? 'uk-slideshow-swipe-backward-in' : 'uk-slideshow-swipe-forward-in');
- next.width(); // force redraw
- return d.promise();
- },
- 'scale': function(current, next, dir) {
- var d = UI.$.Deferred();
- current.css('animation-duration', this.options.duration+'ms');
- next.css('animation-duration', this.options.duration+'ms');
- next.css('opacity', 1);
- current.one(UI.support.animation.end, function() {
- current.css('opacity', 0).removeClass('uk-slideshow-scale-out');
- d.resolve();
- }.bind(this));
- current.addClass('uk-slideshow-scale-out');
- current.width(); // force redraw
- return d.promise();
- },
- 'fade': function(current, next, dir) {
- var d = UI.$.Deferred();
- current.css('animation-duration', this.options.duration+'ms');
- next.css('animation-duration', this.options.duration+'ms');
- next.css('opacity', 1);
- // for plain text content slides - looks smoother
- if (!(next.data('cover') || next.data('placeholder'))) {
- next.css('opacity', 1).one(UI.support.animation.end, function() {
- next.removeClass('uk-slideshow-fade-in');
- }).addClass('uk-slideshow-fade-in');
- }
- current.one(UI.support.animation.end, function() {
- current.css('opacity', 0).removeClass('uk-slideshow-fade-out');
- d.resolve();
- }.bind(this));
- current.addClass('uk-slideshow-fade-out');
- current.width(); // force redraw
- return d.promise();
- }
- };
- UI.slideshow.animations = Animations;
- // Listen for messages from the vimeo player
- window.addEventListener('message', function onMessageReceived(e) {
- var data = e.data, iframe;
- if (typeof(data) == 'string') {
- try {
- data = JSON.parse(data);
- } catch(err) {
- data = {};
- }
- }
- if (e.origin && e.origin.indexOf('vimeo') > -1 && data.event == 'ready' && data.player_id) {
- iframe = UI.$('[data-player-id="'+ data.player_id+'"]');
- if (iframe.length) {
- iframe.data('slideshow').mutemedia(iframe);
- }
- }
- }, false);
- });
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) {
- define("uikit-slider", ["uikit"], function(){
- return component || addon(UIkit);
- });
- }
- })(function(UI){
- "use strict";
- var dragging, delayIdle, anchor, dragged, store = {};
- UI.component('slider', {
- defaults: {
- center : false,
- threshold : 10,
- infinite : true,
- autoplay : false,
- autoplayInterval : 7000,
- pauseOnHover : true,
- activecls : 'uk-active'
- },
- boot: function() {
- // init code
- UI.ready(function(context) {
- setTimeout(function(){
- UI.$('[data-uk-slider]', context).each(function(){
- var ele = UI.$(this);
- if (!ele.data('slider')) {
- UI.slider(ele, UI.Utils.options(ele.attr('data-uk-slider')));
- }
- });
- }, 0);
- });
- },
- init: function() {
- var $this = this;
- this.container = this.element.find('.uk-slider');
- this.focus = 0;
- UI.$win.on('resize load', UI.Utils.debounce(function() {
- $this.update(true);
- }, 100));
- this.on('click.uk.slider', '[data-uk-slider-item]', function(e) {
- e.preventDefault();
- var item = UI.$(this).attr('data-uk-slider-item');
- if ($this.focus == item) return;
- // stop autoplay
- $this.stop();
- switch(item) {
- case 'next':
- case 'previous':
- $this[item=='next' ? 'next':'previous']();
- break;
- default:
- $this.updateFocus(parseInt(item, 10));
- }
- });
- this.container.on({
- 'touchstart mousedown': function(evt) {
- if (evt.originalEvent && evt.originalEvent.touches) {
- evt = evt.originalEvent.touches[0];
- }
- // ignore right click button
- if (evt.button && evt.button==2 || !$this.active) {
- return;
- }
- // stop autoplay
- $this.stop();
- anchor = UI.$(evt.target).is('a') ? UI.$(evt.target) : UI.$(evt.target).parents('a:first');
- dragged = false;
- if (anchor.length) {
- anchor.one('click', function(e){
- if (dragged) e.preventDefault();
- });
- }
- delayIdle = function(e) {
- dragged = true;
- dragging = $this;
- store = {
- touchx : parseInt(e.pageX, 10),
- dir : 1,
- focus : $this.focus,
- base : $this.options.center ? 'center':'area'
- };
- if (e.originalEvent && e.originalEvent.touches) {
- e = e.originalEvent.touches[0];
- }
- dragging.element.data({
- 'pointer-start': {x: parseInt(e.pageX, 10), y: parseInt(e.pageY, 10)},
- 'pointer-pos-start': $this.pos
- });
- $this.container.addClass('uk-drag');
- delayIdle = false;
- };
- delayIdle.x = parseInt(evt.pageX, 10);
- delayIdle.threshold = $this.options.threshold;
- },
- mouseenter: function() { if ($this.options.pauseOnHover) $this.hovering = true; },
- mouseleave: function() { $this.hovering = false; }
- });
- this.update(true);
- this.on('display.uk.check', function(){
- if ($this.element.is(":visible")) {
- $this.update(true);
- }
- });
- // prevent dragging links + images
- this.element.find('a,img').attr('draggable', 'false');
- // Set autoplay
- if (this.options.autoplay) {
- this.start();
- }
- UI.domObserve(this.element, function(e) {
- if ($this.element.children(':not([data-slide])').length) {
- $this.update(true);
- }
- });
- },
- update: function(focus) {
- var $this = this, pos = 0, maxheight = 0, item, width, cwidth, size;
- this.items = this.container.children().filter(':visible');
- this.vp = this.element[0].getBoundingClientRect().width;
- this.container.css({'min-width': '', 'min-height': ''});
- this.items.each(function(idx){
- item = UI.$(this).attr('data-slide', idx);
- size = item.css({'left': '', 'width':''})[0].getBoundingClientRect();
- width = size.width;
- cwidth = item.width();
- maxheight = Math.max(maxheight, size.height);
- item.css({'left': pos, 'width':width}).data({'idx':idx, 'left': pos, 'width': width, 'cwidth':cwidth, 'area': (pos+width), 'center':(pos - ($this.vp/2 - cwidth/2))});
- pos += width;
- });
- this.container.css({'min-width': pos, 'min-height': maxheight});
- if (this.options.infinite && (pos <= (2*this.vp) || this.items.length < 5) && !this.itemsResized) {
- // fill with cloned items
- this.container.children().each(function(idx){
- $this.container.append($this.items.eq(idx).clone(true).attr('id', ''));
- }).each(function(idx){
- $this.container.append($this.items.eq(idx).clone(true).attr('id', ''));
- });
- this.itemsResized = true;
- return this.update();
- }
- this.cw = pos;
- this.pos = 0;
- this.active = pos >= this.vp;
- this.container.css({
- '-ms-transform': '',
- '-webkit-transform': '',
- 'transform': ''
- });
- if (focus) this.updateFocus(this.focus);
- },
- updatePos: function(pos) {
- this.pos = pos;
- this.container.css({
- '-ms-transform': 'translateX('+pos+'px)',
- '-webkit-transform': 'translateX('+pos+'px)',
- 'transform': 'translateX('+pos+'px)'
- });
- },
- updateFocus: function(idx, dir) {
- if (!this.active) {
- return;
- }
- dir = dir || (idx > this.focus ? 1:-1);
- var item = this.items.eq(idx), area, i;
- if (this.options.infinite) {
- this.infinite(idx, dir);
- }
- if (this.options.center) {
- this.updatePos(item.data('center')*-1);
- this.items.filter('.'+this.options.activecls).removeClass(this.options.activecls);
- item.addClass(this.options.activecls);
- } else {
- if (this.options.infinite) {
- this.updatePos(item.data('left')*-1);
- } else {
- area = 0;
- for (i=idx;i<this.items.length;i++) {
- area += this.items.eq(i).data('width');
- }
- if (area > this.vp) {
- this.updatePos(item.data('left')*-1);
- } else {
- if (dir == 1) {
- area = 0;
- for (i=this.items.length-1;i>=0;i--) {
- area += this.items.eq(i).data('width');
- if (area == this.vp) {
- idx = i;
- break;
- }
- if (area > this.vp) {
- idx = (i < this.items.length-1) ? i+1 : i;
- break;
- }
- }
- if (area > this.vp) {
- this.updatePos((this.container.width() - this.vp) * -1);
- } else {
- this.updatePos(this.items.eq(idx).data('left')*-1);
- }
- }
- }
- }
- }
- // mark elements
- var left = this.items.eq(idx).data('left');
- this.items.removeClass('uk-slide-before uk-slide-after').each(function(i){
- if (i!==idx) {
- UI.$(this).addClass(UI.$(this).data('left') < left ? 'uk-slide-before':'uk-slide-after');
- }
- });
- this.focus = idx;
- this.trigger('focusitem.uk.slider', [idx,this.items.eq(idx),this]);
- },
- next: function() {
- var focus = this.items[this.focus + 1] ? (this.focus + 1) : (this.options.infinite ? 0:this.focus);
- this.updateFocus(focus, 1);
- },
- previous: function() {
- var focus = this.items[this.focus - 1] ? (this.focus - 1) : (this.options.infinite ? (this.items[this.focus - 1] ? this.items-1:this.items.length-1):this.focus);
- this.updateFocus(focus, -1);
- },
- start: function() {
- this.stop();
- var $this = this;
- this.interval = setInterval(function() {
- if (!$this.hovering) $this.next();
- }, this.options.autoplayInterval);
- },
- stop: function() {
- if (this.interval) clearInterval(this.interval);
- },
- infinite: function(baseidx, direction) {
- var $this = this, item = this.items.eq(baseidx), i, z = baseidx, move = [], area = 0;
- if (direction == 1) {
- for (i=0;i<this.items.length;i++) {
- if (z != baseidx) {
- area += this.items.eq(z).data('width');
- move.push(this.items.eq(z));
- }
- if (area > this.vp) {
- break;
- }
- z = z+1 == this.items.length ? 0:z+1;
- }
- if (move.length) {
- move.forEach(function(itm){
- var left = item.data('area');
- itm.css({'left': left}).data({
- 'left' : left,
- 'area' : (left+itm.data('width')),
- 'center': (left - ($this.vp/2 - itm.data('cwidth')/2))
- });
- item = itm;
- });
- }
- } else {
- for (i=this.items.length-1;i >-1 ;i--) {
- area += this.items.eq(z).data('width');
- if (z != baseidx) {
- move.push(this.items.eq(z));
- }
- if (area > this.vp) {
- break;
- }
- z = z-1 == -1 ? this.items.length-1:z-1;
- }
- if (move.length) {
- move.forEach(function(itm){
- var left = item.data('left') - itm.data('width');
- itm.css({'left': left}).data({
- 'left' : left,
- 'area' : (left+itm.data('width')),
- 'center': (left - ($this.vp/2 - itm.data('cwidth')/2))
- });
- item = itm;
- });
- }
- }
- }
- });
- // handle dragging
- UI.$doc.on('mousemove.uk.slider touchmove.uk.slider', function(e) {
- if (e.originalEvent && e.originalEvent.touches) {
- e = e.originalEvent.touches[0];
- }
- if (delayIdle && Math.abs(e.pageX - delayIdle.x) > delayIdle.threshold) {
- if (!window.getSelection().toString()) {
- delayIdle(e);
- } else {
- dragging = delayIdle = false;
- }
- }
- if (!dragging) {
- return;
- }
- var x, xDiff, pos, dir, focus, item, next, diff, i, z, itm;
- if (e.clientX || e.clientY) {
- x = e.clientX;
- } else if (e.pageX || e.pageY) {
- x = e.pageX - document.body.scrollLeft - document.documentElement.scrollLeft;
- }
- focus = store.focus;
- xDiff = x - dragging.element.data('pointer-start').x;
- pos = dragging.element.data('pointer-pos-start') + xDiff;
- dir = x > dragging.element.data('pointer-start').x ? -1:1;
- item = dragging.items.eq(store.focus);
- if (dir == 1) {
- diff = item.data('left') + Math.abs(xDiff);
- for (i=0,z=store.focus;i<dragging.items.length;i++) {
- itm = dragging.items.eq(z);
- if (z != store.focus && itm.data('left') < diff && itm.data('area') > diff) {
- focus = z;
- break;
- }
- z = z+1 == dragging.items.length ? 0:z+1;
- }
- } else {
- diff = item.data('left') - Math.abs(xDiff);
- for (i=0,z=store.focus;i<dragging.items.length;i++) {
- itm = dragging.items.eq(z);
- if (z != store.focus && itm.data('area') <= item.data('left') && itm.data('center') < diff) {
- focus = z;
- break;
- }
- z = z-1 == -1 ? dragging.items.length-1:z-1;
- }
- }
- if (dragging.options.infinite && focus!=store._focus) {
- dragging.infinite(focus, dir);
- }
- dragging.updatePos(pos);
- store.dir = dir;
- store._focus = focus;
- store.touchx = parseInt(e.pageX, 10);
- store.diff = diff;
- });
- UI.$doc.on('mouseup.uk.slider touchend.uk.slider', function(e) {
- if (dragging) {
- dragging.container.removeClass('uk-drag');
- // TODO is this needed?
- dragging.items.eq(store.focus);
- var itm, focus = false, i, z;
- if (store.dir == 1) {
- for (i=0,z=store.focus;i<dragging.items.length;i++) {
- itm = dragging.items.eq(z);
- if (z != store.focus && itm.data('left') > store.diff) {
- focus = z;
- break;
- }
- z = z+1 == dragging.items.length ? 0:z+1;
- }
- if (!dragging.options.infinite && !focus) {
- focus = dragging.items.length;
- }
- } else {
- for (i=0,z=store.focus;i<dragging.items.length;i++) {
- itm = dragging.items.eq(z);
- if (z != store.focus && itm.data('left') < store.diff) {
- focus = z;
- break;
- }
- z = z-1 == -1 ? dragging.items.length-1:z-1;
- }
- if (!dragging.options.infinite && !focus) {
- focus = 0
- }
- }
- dragging.updateFocus(focus!==false ? focus:store._focus);
- }
- dragging = delayIdle = false;
- });
- return UI.slider;
- });
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- /*
- * Based on nativesortable - Copyright (c) Brian Grinstead - https://github.com/bgrins/nativesortable
- */
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) {
- define("uikit-sortable", ["uikit"], function(){
- return component || addon(UIkit);
- });
- }
- })(function(UI){
- "use strict";
- var supportsTouch = ('ontouchstart' in window || 'MSGesture' in window) || (window.DocumentTouch && document instanceof DocumentTouch),
- draggingPlaceholder, currentlyDraggingElement, currentlyDraggingTarget, dragging, moving, clickedlink, delayIdle, touchedlists, moved, overElement, startEvent;
- var POINTER_DOWN = supportsTouch ? ('MSGesture' in window ? 'pointerdown':'touchstart') : 'mousedown',
- POINTER_MOVE = supportsTouch ? ('MSGesture' in window ? 'pointermove':'touchmove') : 'mousemove',
- POINTER_UP = supportsTouch ? ('MSGesture' in window ? 'pointerup':'touchend') : 'mouseup';
- function closestSortable(ele) {
- ele = UI.$(ele);
- do {
- if (ele.data('sortable')) {
- return ele;
- }
- ele = UI.$(ele).parent();
- } while(ele.length);
- return ele;
- }
- UI.component('sortable', {
- defaults: {
- animation : 150,
- threshold : 10,
- childClass : 'uk-sortable-item',
- placeholderClass : 'uk-sortable-placeholder',
- overClass : 'uk-sortable-over',
- draggingClass : 'uk-sortable-dragged',
- dragMovingClass : 'uk-sortable-moving',
- baseClass : 'uk-sortable',
- noDragClass : 'uk-sortable-nodrag',
- emptyClass : 'uk-sortable-empty',
- dragCustomClass : '',
- handleClass : false,
- group : false,
- stop : function() {},
- start : function() {},
- change : function() {}
- },
- boot: function() {
- // auto init
- UI.ready(function(context) {
- UI.$("[data-uk-sortable]", context).each(function(){
- var ele = UI.$(this);
- if(!ele.data("sortable")) {
- UI.sortable(ele, UI.Utils.options(ele.attr("data-uk-sortable")));
- }
- });
- });
- UI.$html.on(POINTER_MOVE, function(e) {
- if (delayIdle) {
- var src = e.originalEvent.targetTouches ? e.originalEvent.targetTouches[0] : e;
- if (Math.abs(src.pageX - delayIdle.pos.x) > delayIdle.threshold || Math.abs(src.pageY - delayIdle.pos.y) > delayIdle.threshold) {
- delayIdle.apply(src);
- }
- }
- if (draggingPlaceholder) {
- if (!moving) {
- moving = true;
- draggingPlaceholder.show();
- draggingPlaceholder.$current.addClass(draggingPlaceholder.$sortable.options.placeholderClass);
- draggingPlaceholder.$sortable.element.children().addClass(draggingPlaceholder.$sortable.options.childClass);
- UI.$html.addClass(draggingPlaceholder.$sortable.options.dragMovingClass);
- }
- var offset = draggingPlaceholder.data('mouse-offset'),
- ev = e.originalEvent.touches && e.originalEvent.touches[0] || e.originalEvent,
- left = parseInt(ev.pageX, 10) + offset.left,
- top = parseInt(ev.pageY, 10) + offset.top;
- draggingPlaceholder.css({'left': left, 'top': top });
- // adjust document scrolling
- if (top + (draggingPlaceholder.height()/3) > document.body.offsetHeight) {
- return;
- }
- if (top < UI.$win.scrollTop()) {
- UI.$win.scrollTop(UI.$win.scrollTop() - Math.ceil(draggingPlaceholder.height()/3));
- } else if ( (top + (draggingPlaceholder.height()/3)) > (window.innerHeight + UI.$win.scrollTop()) ) {
- UI.$win.scrollTop(UI.$win.scrollTop() + Math.ceil(draggingPlaceholder.height()/3));
- }
- }
- });
- UI.$html.on(POINTER_UP, function(e) {
- delayIdle = clickedlink = false;
- // dragging?
- if (!currentlyDraggingElement || !draggingPlaceholder) {
- // completely reset dragging attempt. will cause weird delay behavior elsewise
- currentlyDraggingElement = draggingPlaceholder = null;
- return;
- }
- // inside or outside of sortable?
- var sortable = closestSortable(currentlyDraggingElement),
- component = draggingPlaceholder.$sortable,
- ev = { type: e.type };
- if (sortable[0]) {
- component.dragDrop(ev, component.element);
- }
- component.dragEnd(ev, component.element);
- });
- },
- init: function() {
- var $this = this,
- element = this.element[0];
- touchedlists = [];
- this.checkEmptyList();
- this.element.data('sortable-group', this.options.group ? this.options.group : UI.Utils.uid('sortable-group'));
- var handleDragStart = delegate(function(e) {
- if (e.data && e.data.sortable) {
- return;
- }
- var $target = UI.$(e.target),
- $link = $target.is('a[href]') ? $target:$target.parents('a[href]');
- if ($target.is(':input')) {
- return;
- }
- if ($this.options.handleClass) {
- var handle = $target.hasClass($this.options.handleClass) ? $target : $target.closest('.'+$this.options.handleClass, $this.element);
- if (!handle.length) return;
- }
- e.preventDefault();
- if ($link.length) {
- $link.one('click', function(e){
- e.preventDefault();
- }).one(POINTER_UP, function(){
- if (!moved) {
- $link.trigger('click');
- if (supportsTouch && $link.attr('href').trim()) {
- location.href = $link.attr('href');
- }
- }
- });
- }
- e.data = e.data || {};
- e.data.sortable = element;
- return $this.dragStart(e, this);
- });
- var handleDragEnter = delegate(UI.Utils.debounce(function(e) {
- return $this.dragEnter(e, this);
- }), 40);
- var handleDragLeave = delegate(function(e) {
- // Prevent dragenter on a child from allowing a dragleave on the container
- var previousCounter = $this.dragenterData(this);
- $this.dragenterData(this, previousCounter - 1);
- // This is a fix for child elements firing dragenter before the parent fires dragleave
- if (!$this.dragenterData(this)) {
- UI.$(this).removeClass($this.options.overClass);
- $this.dragenterData(this, false);
- }
- });
- var handleTouchMove = delegate(function(e) {
- if (!currentlyDraggingElement ||
- currentlyDraggingElement === this ||
- currentlyDraggingTarget === this) {
- return true;
- }
- $this.element.children().removeClass($this.options.overClass);
- currentlyDraggingTarget = this;
- $this.moveElementNextTo(currentlyDraggingElement, this);
- return prevent(e);
- });
- // Bind/unbind standard mouse/touch events as a polyfill.
- function addDragHandlers() {
- if (supportsTouch && startEvent.touches && startEvent.touches.length) {
- element.addEventListener(POINTER_MOVE, handleTouchMove, false);
- } else {
- element.addEventListener('mouseover', handleDragEnter, false);
- element.addEventListener('mouseout', handleDragLeave, false);
- }
- // document.addEventListener("selectstart", prevent, false);
- }
- function removeDragHandlers() {
- if (supportsTouch && startEvent.touches && startEvent.touches.length) {
- element.removeEventListener(POINTER_MOVE, handleTouchMove, false);
- } else {
- element.removeEventListener('mouseover', handleDragEnter, false);
- element.removeEventListener('mouseout', handleDragLeave, false);
- }
- // document.removeEventListener("selectstart", prevent, false);
- }
- this.addDragHandlers = addDragHandlers;
- this.removeDragHandlers = removeDragHandlers;
- function handleDragMove(e) {
- if (!currentlyDraggingElement) {
- return;
- }
- $this.dragMove(e, $this);
- }
- function delegate(fn) {
- return function(e) {
- var touch, target, context;
- startEvent = e;
- if (e) {
- touch = e.touches && e.touches[0] || e;
- target = touch.target || e.target;
- // Fix event.target for a touch event
- if (supportsTouch && document.elementFromPoint) {
- target = document.elementFromPoint(touch.pageX - document.body.scrollLeft, touch.pageY - document.body.scrollTop);
- }
- overElement = UI.$(target);
- }
- if (UI.$(target).hasClass('.'+$this.options.childClass)) {
- fn.apply(target, [e]);
- } else if (target !== element) {
- // If a child is initiating the event or ending it, then use the container as context for the callback.
- context = moveUpToChildNode(element, target);
- if (context) {
- fn.apply(context, [e]);
- }
- }
- };
- }
- window.addEventListener(POINTER_MOVE, handleDragMove, false);
- element.addEventListener(POINTER_DOWN, handleDragStart, false);
- },
- dragStart: function(e, elem) {
- moved = false;
- moving = false;
- dragging = false;
- var $this = this,
- target = UI.$(e.target);
- if (!supportsTouch && e.button==2) {
- return;
- }
- if (target.is('.'+$this.options.noDragClass) || target.closest('.'+$this.options.noDragClass).length) {
- return;
- }
- // prevent dragging if taget is a form field
- if (target.is(':input')) {
- return;
- }
- currentlyDraggingElement = elem;
- // init drag placeholder
- if (draggingPlaceholder) {
- draggingPlaceholder.remove();
- }
- var $current = UI.$(currentlyDraggingElement), offset = $current.offset(), ev = e.touches && e.touches[0] || e;
- delayIdle = {
- pos : { x:ev.pageX, y:ev.pageY },
- threshold : $this.options.handleClass ? 1 : $this.options.threshold,
- apply : function(evt) {
- draggingPlaceholder = UI.$('<div class="'+([$this.options.draggingClass, $this.options.dragCustomClass].join(' '))+'"></div>').css({
- display : 'none',
- top : offset.top,
- left : offset.left,
- width : $current.width(),
- height : $current.height(),
- padding : $current.css('padding')
- }).data({
- 'mouse-offset': {
- 'left' : offset.left - parseInt(ev.pageX, 10),
- 'top' : offset.top - parseInt(ev.pageY, 10)
- },
- 'origin' : $this.element,
- 'index' : $current.index()
- }).append($current.html()).appendTo('body');
- draggingPlaceholder.$current = $current;
- draggingPlaceholder.$sortable = $this;
- $current.data({
- 'start-list': $current.parent(),
- 'start-index': $current.index(),
- 'sortable-group': $this.options.group
- });
- $this.addDragHandlers();
- $this.options.start(this, currentlyDraggingElement);
- $this.trigger('start.uk.sortable', [$this, currentlyDraggingElement, draggingPlaceholder]);
- moved = true;
- delayIdle = false;
- }
- };
- },
- dragMove: function(e, elem) {
- overElement = UI.$(document.elementFromPoint(e.pageX - (document.body.scrollLeft || document.scrollLeft || 0), e.pageY - (document.body.scrollTop || document.documentElement.scrollTop || 0)));
- var overRoot = overElement.closest('.'+this.options.baseClass),
- groupOver = overRoot.data("sortable-group"),
- $current = UI.$(currentlyDraggingElement),
- currentRoot = $current.parent(),
- groupCurrent = $current.data("sortable-group"),
- overChild;
- if (overRoot[0] !== currentRoot[0] && groupCurrent !== undefined && groupOver === groupCurrent) {
- overRoot.data('sortable').addDragHandlers();
- touchedlists.push(overRoot);
- overRoot.children().addClass(this.options.childClass);
- // swap root
- if (overRoot.children().length > 0) {
- overChild = overElement.closest('.'+this.options.childClass);
- if (overChild.length) {
- overChild.before($current);
- } else {
- overRoot.append($current);
- }
- } else { // empty list
- overElement.append($current);
- }
- UIkit.$doc.trigger('mouseover');
- }
- this.checkEmptyList();
- this.checkEmptyList(currentRoot);
- },
- dragEnter: function(e, elem) {
- if (!currentlyDraggingElement || currentlyDraggingElement === elem) {
- return true;
- }
- var previousCounter = this.dragenterData(elem);
- this.dragenterData(elem, previousCounter + 1);
- // Prevent dragenter on a child from allowing a dragleave on the container
- if (previousCounter === 0) {
- var currentlist = UI.$(elem).parent(),
- startlist = UI.$(currentlyDraggingElement).data("start-list");
- if (currentlist[0] !== startlist[0]) {
- var groupOver = currentlist.data('sortable-group'),
- groupCurrent = UI.$(currentlyDraggingElement).data("sortable-group");
- if ((groupOver || groupCurrent) && (groupOver != groupCurrent)) {
- return false;
- }
- }
- UI.$(elem).addClass(this.options.overClass);
- this.moveElementNextTo(currentlyDraggingElement, elem);
- }
- return false;
- },
- dragEnd: function(e, elem) {
- var $this = this;
- // avoid triggering event twice
- if (currentlyDraggingElement) {
- // TODO: trigger on right element?
- this.options.stop(elem);
- this.trigger('stop.uk.sortable', [this]);
- }
- currentlyDraggingElement = null;
- currentlyDraggingTarget = null;
- touchedlists.push(this.element);
- touchedlists.forEach(function(el, i) {
- UI.$(el).children().each(function() {
- if (this.nodeType === 1) {
- UI.$(this).removeClass($this.options.overClass)
- .removeClass($this.options.placeholderClass)
- .removeClass($this.options.childClass);
- $this.dragenterData(this, false);
- }
- });
- });
- touchedlists = [];
- UI.$html.removeClass(this.options.dragMovingClass);
- this.removeDragHandlers();
- if (draggingPlaceholder) {
- draggingPlaceholder.remove();
- draggingPlaceholder = null;
- }
- },
- dragDrop: function(e, elem) {
- if (e.type === 'drop') {
- if (e.stopPropagation) {
- e.stopPropagation();
- }
- if (e.preventDefault) {
- e.preventDefault();
- }
- }
- this.triggerChangeEvents();
- },
- triggerChangeEvents: function() {
- // trigger events once
- if (!currentlyDraggingElement) return;
- var $current = UI.$(currentlyDraggingElement),
- oldRoot = draggingPlaceholder.data("origin"),
- newRoot = $current.closest('.'+this.options.baseClass),
- triggers = [],
- el = UI.$(currentlyDraggingElement);
- // events depending on move inside lists or across lists
- if (oldRoot[0] === newRoot[0] && draggingPlaceholder.data('index') != $current.index() ) {
- triggers.push({sortable: this, mode: 'moved'});
- } else if (oldRoot[0] != newRoot[0]) {
- triggers.push({sortable: UI.$(newRoot).data('sortable'), mode: 'added'}, {sortable: UI.$(oldRoot).data('sortable'), mode: 'removed'});
- }
- triggers.forEach(function (trigger, i) {
- if (trigger.sortable) {
- trigger.sortable.element.trigger('change.uk.sortable', [trigger.sortable, el, trigger.mode]);
- }
- });
- },
- dragenterData: function(element, val) {
- element = UI.$(element);
- if (arguments.length == 1) {
- return parseInt(element.data('child-dragenter'), 10) || 0;
- } else if (!val) {
- element.removeData('child-dragenter');
- } else {
- element.data('child-dragenter', Math.max(0, val));
- }
- },
- moveElementNextTo: function(element, elementToMoveNextTo) {
- dragging = true;
- var $this = this,
- list = UI.$(element).parent().css('min-height', ''),
- next = isBelow(element, elementToMoveNextTo) ? elementToMoveNextTo : elementToMoveNextTo.nextSibling,
- children = list.children(),
- count = children.length;
- if (!$this.options.animation) {
- elementToMoveNextTo.parentNode.insertBefore(element, next);
- UI.Utils.checkDisplay($this.element.parent());
- return;
- }
- list.css('min-height', list.height());
- children.stop().each(function(){
- var ele = UI.$(this),
- offset = ele.position();
- offset.width = ele.width();
- ele.data('offset-before', offset);
- });
- elementToMoveNextTo.parentNode.insertBefore(element, next);
- UI.Utils.checkDisplay($this.element.parent());
- children = list.children().each(function() {
- var ele = UI.$(this);
- ele.data('offset-after', ele.position());
- }).each(function() {
- var ele = UI.$(this),
- before = ele.data('offset-before');
- ele.css({'position':'absolute', 'top':before.top, 'left':before.left, 'min-width':before.width });
- });
- children.each(function(){
- var ele = UI.$(this),
- before = ele.data('offset-before'),
- offset = ele.data('offset-after');
- ele.css('pointer-events', 'none').width();
- setTimeout(function(){
- ele.animate({'top':offset.top, 'left':offset.left}, $this.options.animation, function() {
- ele.css({'position':'','top':'', 'left':'', 'min-width': '', 'pointer-events':''}).removeClass($this.options.overClass).removeData('child-dragenter');
- count--;
- if (!count) {
- list.css('min-height', '');
- UI.Utils.checkDisplay($this.element.parent());
- }
- });
- }, 0);
- });
- },
- serialize: function() {
- var data = [], item, attribute;
- this.element.children().each(function(j, child) {
- item = {};
- for (var i = 0, attr, val; i < child.attributes.length; i++) {
- attribute = child.attributes[i];
- if (attribute.name.indexOf('data-') === 0) {
- attr = attribute.name.substr(5);
- val = UI.Utils.str2json(attribute.value);
- item[attr] = (val || attribute.value=='false' || attribute.value=='0') ? val:attribute.value;
- }
- }
- data.push(item);
- });
- return data;
- },
- checkEmptyList: function(list) {
- list = list ? UI.$(list) : this.element;
- if (this.options.emptyClass) {
- list[!list.children().length ? 'addClass':'removeClass'](this.options.emptyClass);
- }
- }
- });
- // helpers
- function isBelow(el1, el2) {
- var parent = el1.parentNode;
- if (el2.parentNode != parent) {
- return false;
- }
- var cur = el1.previousSibling;
- while (cur && cur.nodeType !== 9) {
- if (cur === el2) {
- return true;
- }
- cur = cur.previousSibling;
- }
- return false;
- }
- function moveUpToChildNode(parent, child) {
- var cur = child;
- if (cur == parent) { return null; }
- while (cur) {
- if (cur.parentNode === parent) {
- return cur;
- }
- cur = cur.parentNode;
- if ( !cur || !cur.ownerDocument || cur.nodeType === 11 ) {
- break;
- }
- }
- return null;
- }
- function prevent(e) {
- if (e.stopPropagation) {
- e.stopPropagation();
- }
- if (e.preventDefault) {
- e.preventDefault();
- }
- e.returnValue = false;
- }
- return UI.sortable;
- });
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) {
- define("uikit-sticky", ["uikit"], function(){
- return component || addon(UIkit);
- });
- }
- })(function(UI){
- "use strict";
- var $win = UI.$win,
- $doc = UI.$doc,
- sticked = [],
- direction = 1;
- UI.component('sticky', {
- defaults: {
- top : 0,
- bottom : 0,
- animation : '',
- clsinit : 'uk-sticky-init',
- clsactive : 'uk-active',
- clsinactive : '',
- getWidthFrom : '',
- showup : false,
- boundary : false,
- media : false,
- target : false,
- disabled : false
- },
- boot: function() {
- // should be more efficient than using $win.scroll(checkscrollposition):
- UI.$doc.on('scrolling.uk.document', function(e, data) {
- if (!data || !data.dir) return;
- direction = data.dir.y;
- checkscrollposition();
- });
- UI.$win.on('resize orientationchange', UI.Utils.debounce(function() {
- if (!sticked.length) return;
- for (var i = 0; i < sticked.length; i++) {
- sticked[i].reset(true);
- sticked[i].self.computeWrapper();
- }
- checkscrollposition();
- }, 100));
- // init code
- UI.ready(function(context) {
- setTimeout(function(){
- UI.$("[data-uk-sticky]", context).each(function(){
- var $ele = UI.$(this);
- if (!$ele.data("sticky")) {
- UI.sticky($ele, UI.Utils.options($ele.attr('data-uk-sticky')));
- }
- });
- checkscrollposition();
- }, 0);
- });
- },
- init: function() {
- var boundary = this.options.boundary, boundtoparent;
- this.wrapper = this.element.wrap('<div class="uk-sticky-placeholder"></div>').parent();
- this.computeWrapper();
- this.wrapper.css({
- 'margin-top' : this.element.css('margin-top'),
- 'margin-bottom' : this.element.css('margin-bottom'),
- 'margin-left' : this.element.css('margin-left'),
- 'margin-right' : this.element.css('margin-right')
- })
- this.element.css('margin', 0);
- if (boundary) {
- if (boundary === true || boundary[0] === '!') {
- boundary = boundary === true ? this.wrapper.parent() : this.wrapper.closest(boundary.substr(1));
- boundtoparent = true;
- } else if (typeof boundary === "string") {
- boundary = UI.$(boundary);
- }
- }
- this.sticky = {
- self : this,
- options : this.options,
- element : this.element,
- currentTop : null,
- wrapper : this.wrapper,
- init : false,
- getWidthFrom : UI.$(this.options.getWidthFrom || this.wrapper),
- boundary : boundary,
- boundtoparent : boundtoparent,
- top : 0,
- calcTop : function() {
- var top = this.options.top;
- // dynamic top parameter
- if (this.options.top && typeof(this.options.top) == 'string') {
- // e.g. 50vh
- if (this.options.top.match(/^(-|)(\d+)vh$/)) {
- top = window.innerHeight * parseInt(this.options.top, 10)/100;
- // e.g. #elementId, or .class-1,class-2,.class-3 (first found is used)
- } else {
- var topElement = UI.$(this.options.top).first();
- if (topElement.length && topElement.is(':visible')) {
- top = -1 * ((topElement.offset().top + topElement.outerHeight()) - this.wrapper.offset().top);
- }
- }
- }
- this.top = top;
- },
- reset: function(force) {
- this.calcTop();
- var finalize = function() {
- this.element.css({"position":"", "top":"", "width":"", "left":"", "margin":"0"});
- this.element.removeClass([this.options.animation, 'uk-animation-reverse', this.options.clsactive].join(' '));
- this.element.addClass(this.options.clsinactive);
- this.element.trigger('inactive.uk.sticky');
- this.currentTop = null;
- this.animate = false;
- }.bind(this);
- if (!force && this.options.animation && UI.support.animation && !UI.Utils.isInView(this.wrapper)) {
- this.animate = true;
- this.element.removeClass(this.options.animation).one(UI.support.animation.end, function(){
- finalize();
- }).width(); // force redraw
- this.element.addClass(this.options.animation+' '+'uk-animation-reverse');
- } else {
- finalize();
- }
- },
- check: function() {
- if (this.options.disabled) {
- return false;
- }
- if (this.options.media) {
- switch(typeof(this.options.media)) {
- case 'number':
- if (window.innerWidth < this.options.media) {
- return false;
- }
- break;
- case 'string':
- if (window.matchMedia && !window.matchMedia(this.options.media).matches) {
- return false;
- }
- break;
- }
- }
- var scrollTop = $win.scrollTop(),
- documentHeight = $doc.height(),
- dwh = documentHeight - window.innerHeight,
- extra = (scrollTop > dwh) ? dwh - scrollTop : 0,
- elementTop = this.wrapper.offset().top,
- etse = elementTop - this.top - extra,
- active = (scrollTop >= etse);
- if (active && this.options.showup) {
- // set inactiv if scrolling down
- if (direction == 1) {
- active = false;
- }
- // set inactive when wrapper is still in view
- if (direction == -1 && !this.element.hasClass(this.options.clsactive) && UI.Utils.isInView(this.wrapper)) {
- active = false;
- }
- }
- return active;
- }
- };
- this.sticky.calcTop();
- sticked.push(this.sticky);
- },
- update: function() {
- checkscrollposition(this.sticky);
- },
- enable: function() {
- this.options.disabled = false;
- this.update();
- },
- disable: function(force) {
- this.options.disabled = true;
- this.sticky.reset(force);
- },
- computeWrapper: function() {
- this.wrapper.css({
- 'height' : ['absolute','fixed'].indexOf(this.element.css('position')) == -1 ? this.element.outerHeight() : '',
- 'float' : this.element.css('float') != 'none' ? this.element.css('float') : ''
- });
- if (this.element.css('position') == 'fixed') {
- this.element.css({
- width: this.sticky.getWidthFrom.length ? this.sticky.getWidthFrom.width() : this.element.width()
- });
- }
- }
- });
- function checkscrollposition(direction) {
- var stickies = arguments.length ? arguments : sticked;
- if (!stickies.length || $win.scrollTop() < 0) return;
- var scrollTop = $win.scrollTop(),
- documentHeight = $doc.height(),
- windowHeight = $win.height(),
- dwh = documentHeight - windowHeight,
- extra = (scrollTop > dwh) ? dwh - scrollTop : 0,
- newTop, containerBottom, stickyHeight, sticky;
- for (var i = 0; i < stickies.length; i++) {
- sticky = stickies[i];
- if (!sticky.element.is(":visible") || sticky.animate) {
- continue;
- }
- if (!sticky.check()) {
- if (sticky.currentTop !== null) {
- sticky.reset();
- }
- } else {
- if (sticky.top < 0) {
- newTop = 0;
- } else {
- stickyHeight = sticky.element.outerHeight();
- newTop = documentHeight - stickyHeight - sticky.top - sticky.options.bottom - scrollTop - extra;
- newTop = newTop < 0 ? newTop + sticky.top : sticky.top;
- }
- if (sticky.boundary && sticky.boundary.length) {
- var bTop = sticky.boundary.offset().top;
- if (sticky.boundtoparent) {
- containerBottom = documentHeight - (bTop + sticky.boundary.outerHeight()) + parseInt(sticky.boundary.css('padding-bottom'));
- } else {
- containerBottom = documentHeight - bTop;
- }
- newTop = (scrollTop + stickyHeight) > (documentHeight - containerBottom - (sticky.top < 0 ? 0 : sticky.top)) ? (documentHeight - containerBottom) - (scrollTop + stickyHeight) : newTop;
- }
- if (sticky.currentTop != newTop) {
- sticky.element.css({
- position : "fixed",
- top : newTop,
- width : sticky.getWidthFrom.length ? sticky.getWidthFrom.width() : sticky.element.width()
- });
- if (!sticky.init) {
- sticky.element.addClass(sticky.options.clsinit);
- if (location.hash && scrollTop > 0 && sticky.options.target) {
- var $target = UI.$(location.hash);
- if ($target.length) {
- setTimeout((function($target, sticky){
- return function() {
- sticky.element.width(); // force redraw
- var offset = $target.offset(),
- maxoffset = offset.top + $target.outerHeight(),
- stickyOffset = sticky.element.offset(),
- stickyHeight = sticky.element.outerHeight(),
- stickyMaxOffset = stickyOffset.top + stickyHeight;
- if (stickyOffset.top < maxoffset && offset.top < stickyMaxOffset) {
- scrollTop = offset.top - stickyHeight - sticky.options.target;
- window.scrollTo(0, scrollTop);
- }
- };
- })($target, sticky), 0);
- }
- }
- }
- sticky.element.addClass(sticky.options.clsactive).removeClass(sticky.options.clsinactive);
- sticky.element.trigger('active.uk.sticky');
- sticky.element.css('margin', '');
- if (sticky.options.animation && sticky.init && !UI.Utils.isInView(sticky.wrapper)) {
- sticky.element.addClass(sticky.options.animation);
- }
- sticky.currentTop = newTop;
- }
- }
- sticky.init = true;
- }
- }
- return UI.sticky;
- });
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) {
- define("uikit-tooltip", ["uikit"], function(){
- return component || addon(UIkit);
- });
- }
- })(function(UI){
- "use strict";
- var $tooltip, // tooltip container
- tooltipdelay, checkdelay;
- UI.component('tooltip', {
- defaults: {
- offset: 5,
- pos: 'top',
- animation: false,
- delay: 0, // in miliseconds
- cls: "",
- activeClass: "uk-active",
- src: function(ele) {
- var title = ele.attr('title');
- if (title !== undefined) {
- ele.data('cached-title', title).removeAttr('title');
- }
- return ele.data("cached-title");
- }
- },
- tip: "",
- boot: function() {
- // init code
- UI.$html.on("mouseenter.tooltip.uikit focus.tooltip.uikit", "[data-uk-tooltip]", function(e) {
- var ele = UI.$(this);
- if (!ele.data("tooltip")) {
- UI.tooltip(ele, UI.Utils.options(ele.attr("data-uk-tooltip")));
- ele.trigger("mouseenter");
- }
- });
- },
- init: function() {
- var $this = this;
- if (!$tooltip) {
- $tooltip = UI.$('<div class="uk-tooltip"></div>').appendTo("body");
- }
- this.on({
- focus : function(e) { $this.show(); },
- blur : function(e) { $this.hide(); },
- mouseenter : function(e) { $this.show(); },
- mouseleave : function(e) { $this.hide(); }
- });
- },
- show: function() {
- this.tip = typeof(this.options.src) === "function" ? this.options.src(this.element) : this.options.src;
- if (tooltipdelay) clearTimeout(tooltipdelay);
- if (checkdelay) clearTimeout(checkdelay);
- if (typeof(this.tip) === 'string' ? !this.tip.length:true) return;
- $tooltip.stop().css({"top": -2000, "visibility": "hidden"}).removeClass(this.options.activeClass).show();
- $tooltip.html('<div class="uk-tooltip-inner">' + this.tip + '</div>');
- var $this = this,
- pos = UI.$.extend({}, this.element.offset(), {width: this.element[0].offsetWidth, height: this.element[0].offsetHeight}),
- width = $tooltip[0].offsetWidth,
- height = $tooltip[0].offsetHeight,
- offset = typeof(this.options.offset) === "function" ? this.options.offset.call(this.element) : this.options.offset,
- position = typeof(this.options.pos) === "function" ? this.options.pos.call(this.element) : this.options.pos,
- tmppos = position.split("-"),
- tcss = {
- "display" : "none",
- "visibility" : "visible",
- "top" : (pos.top + pos.height + height),
- "left" : pos.left
- };
- // prevent strange position
- // when tooltip is in offcanvas etc.
- if (UI.$html.css('position')=='fixed' || UI.$body.css('position')=='fixed'){
- var bodyoffset = UI.$('body').offset(),
- htmloffset = UI.$('html').offset(),
- docoffset = {'top': (htmloffset.top + bodyoffset.top), 'left': (htmloffset.left + bodyoffset.left)};
- pos.left -= docoffset.left;
- pos.top -= docoffset.top;
- }
- if ((tmppos[0] == "left" || tmppos[0] == "right") && UI.langdirection == 'right') {
- tmppos[0] = tmppos[0] == "left" ? "right" : "left";
- }
- var variants = {
- "bottom" : {top: pos.top + pos.height + offset, left: pos.left + pos.width / 2 - width / 2},
- "top" : {top: pos.top - height - offset, left: pos.left + pos.width / 2 - width / 2},
- "left" : {top: pos.top + pos.height / 2 - height / 2, left: pos.left - width - offset},
- "right" : {top: pos.top + pos.height / 2 - height / 2, left: pos.left + pos.width + offset}
- };
- UI.$.extend(tcss, variants[tmppos[0]]);
- if (tmppos.length == 2) tcss.left = (tmppos[1] == 'left') ? (pos.left) : ((pos.left + pos.width) - width);
- var boundary = this.checkBoundary(tcss.left, tcss.top, width, height);
- if(boundary) {
- switch(boundary) {
- case "x":
- if (tmppos.length == 2) {
- position = tmppos[0]+"-"+(tcss.left < 0 ? "left": "right");
- } else {
- position = tcss.left < 0 ? "right": "left";
- }
- break;
- case "y":
- if (tmppos.length == 2) {
- position = (tcss.top < 0 ? "bottom": "top")+"-"+tmppos[1];
- } else {
- position = (tcss.top < 0 ? "bottom": "top");
- }
- break;
- case "xy":
- if (tmppos.length == 2) {
- position = (tcss.top < 0 ? "bottom": "top")+"-"+(tcss.left < 0 ? "left": "right");
- } else {
- position = tcss.left < 0 ? "right": "left";
- }
- break;
- }
- tmppos = position.split("-");
- UI.$.extend(tcss, variants[tmppos[0]]);
- if (tmppos.length == 2) tcss.left = (tmppos[1] == 'left') ? (pos.left) : ((pos.left + pos.width) - width);
- }
- tcss.left -= UI.$body.position().left;
- tooltipdelay = setTimeout(function(){
- $tooltip.css(tcss).attr("class", ["uk-tooltip", "uk-tooltip-"+position, $this.options.cls].join(' '));
- if ($this.options.animation) {
- $tooltip.css({opacity: 0, display: 'block'}).addClass($this.options.activeClass).animate({opacity: 1}, parseInt($this.options.animation, 10) || 400);
- } else {
- $tooltip.show().addClass($this.options.activeClass);
- }
- tooltipdelay = false;
- // close tooltip if element was removed or hidden
- checkdelay = setInterval(function(){
- if(!$this.element.is(':visible')) $this.hide();
- }, 150);
- }, parseInt(this.options.delay, 10) || 0);
- },
- hide: function() {
- if(this.element.is("input") && this.element[0]===document.activeElement) return;
- if(tooltipdelay) clearTimeout(tooltipdelay);
- if (checkdelay) clearTimeout(checkdelay);
- $tooltip.stop();
- if (this.options.animation) {
- var $this = this;
- $tooltip.fadeOut(parseInt(this.options.animation, 10) || 400, function(){
- $tooltip.removeClass($this.options.activeClass)
- });
- } else {
- $tooltip.hide().removeClass(this.options.activeClass);
- }
- },
- content: function() {
- return this.tip;
- },
- checkBoundary: function(left, top, width, height) {
- var axis = "";
- if(left < 0 || ((left - UI.$win.scrollLeft())+width) > window.innerWidth) {
- axis += "x";
- }
- if(top < 0 || ((top - UI.$win.scrollTop())+height) > window.innerHeight) {
- axis += "y";
- }
- return axis;
- }
- });
- return UI.tooltip;
- });
- /*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) {
- define("uikit-timepicker", ["uikit"], function(){
- return component || addon(UIkit);
- });
- }
- })(function(UI){
- "use strict";
- UI.component('timepicker', {
- defaults: {
- format : '24h',
- delay : 0,
- start : 0,
- end : 24
- },
- boot: function() {
- // init code
- UI.$html.on("focus.timepicker.uikit", "[data-uk-timepicker]", function(e) {
- var ele = UI.$(this);
- if (!ele.data("timepicker")) {
- var obj = UI.timepicker(ele, UI.Utils.options(ele.attr("data-uk-timepicker")));
- setTimeout(function(){
- obj.autocomplete.input.focus();
- }, 40);
- }
- });
- },
- init: function() {
- var $this = this, times = getTimeRange(this.options.start, this.options.end), container;
- this.options.minLength = 0;
- this.options.template = '<ul class="uk-nav uk-nav-autocomplete uk-autocomplete-results">{{~items}}<li data-value="{{$item.value}}"><a class="needsclick">{{$item.value}}</a></li>{{/items}}</ul>';
- this.options.source = function(release) {
- release(times[$this.options.format] || times['12h']);
- };
- if (this.element.is('input')) {
- this.element.wrap('<div class="uk-autocomplete"></div>');
- container = this.element.parent();
- } else {
- container = this.element.addClass('uk-autocomplete');
- }
- this.autocomplete = UI.autocomplete(container, this.options);
- this.autocomplete.dropdown.addClass('uk-dropdown-small uk-dropdown-scrollable');
- this.autocomplete.on('show.uk.autocomplete', function() {
- var selected = $this.autocomplete.dropdown.find('[data-value="'+$this.autocomplete.input.val()+'"]');
- setTimeout(function(){
- $this.autocomplete.pick(selected, true);
- }, 10);
- });
- this.autocomplete.input.on('focus', function(){
- $this.autocomplete.value = Math.random();
- $this.autocomplete.triggercomplete();
- }).on('blur', UI.Utils.debounce(function() {
- $this.checkTime();
- }, 100));
- this.element.data("timepicker", this);
- },
- checkTime: function() {
- var arr, timeArray, meridian = 'AM', hour, minute, time = this.autocomplete.input.val();
- if (this.options.format == '12h') {
- arr = time.split(' ');
- timeArray = arr[0].split(':');
- meridian = arr[1];
- } else {
- timeArray = time.split(':');
- }
- hour = parseInt(timeArray[0], 10);
- minute = parseInt(timeArray[1], 10);
- if (isNaN(hour)) hour = 0;
- if (isNaN(minute)) minute = 0;
- if (this.options.format == '12h') {
- if (hour > 12) {
- hour = 12;
- } else if (hour < 0) {
- hour = 12;
- }
- if (meridian === 'am' || meridian === 'a') {
- meridian = 'AM';
- } else if (meridian === 'pm' || meridian === 'p') {
- meridian = 'PM';
- }
- if (meridian !== 'AM' && meridian !== 'PM') {
- meridian = 'AM';
- }
- } else {
- if (hour >= 24) {
- hour = 23;
- } else if (hour < 0) {
- hour = 0;
- }
- }
- if (minute < 0) {
- minute = 0;
- } else if (minute >= 60) {
- minute = 0;
- }
- this.autocomplete.input.val(this.formatTime(hour, minute, meridian)).trigger('change');
- },
- formatTime: function(hour, minute, meridian) {
- hour = hour < 10 ? '0' + hour : hour;
- minute = minute < 10 ? '0' + minute : minute;
- return hour + ':' + minute + (this.options.format == '12h' ? ' ' + meridian : '');
- }
- });
- // helper
- function getTimeRange(start, end) {
- start = start || 0;
- end = end || 24;
- var times = {'12h':[], '24h':[]}, i, h;
- for (i = start, h=''; i<end; i++) {
- h = ''+i;
- if (i<10) h = '0'+h;
- times['24h'].push({value: (h+':00')});
- times['24h'].push({value: (h+':30')});
- if (i === 0) {
- h = 12;
- times['12h'].push({value: (h+':00 AM')});
- times['12h'].push({value: (h+':30 AM')});
- }
- if (i > 0 && i<13 && i!==12) {
- times['12h'].push({value: (h+':00 AM')});
- times['12h'].push({value: (h+':30 AM')});
- }
- if (i >= 12) {
- h = h-12;
- if (h === 0) h = 12;
- if (h < 10) h = '0'+String(h);
- times['12h'].push({value: (h+':00 PM')});
- times['12h'].push({value: (h+':30 PM')});
- }
- }
- return times;
- }
- });
- /*! UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
- (function(addon) {
- var component;
- if (window.UIkit) {
- component = addon(UIkit);
- }
- if (typeof define == "function" && define.amd) {
- define("uikit-upload", ["uikit"], function(){
- return component || addon(UIkit);
- });
- }
- })(function(UI){
- "use strict";
- UI.component('uploadSelect', {
- init: function() {
- var $this = this;
- this.on("change", function() {
- xhrupload($this.element[0].files, $this.options);
- var twin = $this.element.clone(true).data('uploadSelect', $this);
- $this.element.replaceWith(twin);
- $this.element = twin;
- });
- }
- });
- UI.component('uploadDrop', {
- defaults: {
- 'dragoverClass': 'uk-dragover'
- },
- init: function() {
- var $this = this, hasdragCls = false;
- this.on("drop", function(e){
- if (e.originalEvent.dataTransfer && e.originalEvent.dataTransfer.files) {
- e.stopPropagation();
- e.preventDefault();
- $this.element.removeClass($this.options.dragoverClass);
- $this.element.trigger('dropped.uk.upload', [e.originalEvent.dataTransfer.files]);
- xhrupload(e.originalEvent.dataTransfer.files, $this.options);
- }
- }).on("dragenter", function(e){
- e.stopPropagation();
- e.preventDefault();
- }).on("dragover", function(e){
- e.stopPropagation();
- e.preventDefault();
- if (!hasdragCls) {
- $this.element.addClass($this.options.dragoverClass);
- hasdragCls = true;
- }
- }).on("dragleave", function(e){
- e.stopPropagation();
- e.preventDefault();
- $this.element.removeClass($this.options.dragoverClass);
- hasdragCls = false;
- });
- }
- });
- UI.support.ajaxupload = (function() {
- function supportFileAPI() {
- var fi = document.createElement('INPUT'); fi.type = 'file'; return 'files' in fi;
- }
- function supportAjaxUploadProgressEvents() {
- var xhr = new XMLHttpRequest(); return !! (xhr && ('upload' in xhr) && ('onprogress' in xhr.upload));
- }
- function supportFormData() {
- return !! window.FormData;
- }
- return supportFileAPI() && supportAjaxUploadProgressEvents() && supportFormData();
- })();
- function xhrupload(files, settings) {
- if (!UI.support.ajaxupload){
- return this;
- }
- settings = UI.$.extend({}, xhrupload.defaults, settings);
- if (!files.length){
- return;
- }
- if (settings.allow !== '*.*') {
- for(var i=0,file;file=files[i];i++) {
- if(!matchName(settings.allow, file.name)) {
- if(typeof(settings.notallowed) == 'string') {
- alert(settings.notallowed);
- } else {
- settings.notallowed(file, settings);
- }
- return;
- }
- }
- }
- var complete = settings.complete;
- if (settings.single){
- var count = files.length,
- uploaded = 0,
- allow = true;
- settings.beforeAll(files);
- settings.complete = function(response, xhr){
- uploaded = uploaded + 1;
- complete(response, xhr);
- if (settings.filelimit && uploaded >= settings.filelimit){
- allow = false;
- }
- if (allow && uploaded<count){
- upload([files[uploaded]], settings);
- } else {
- settings.allcomplete(response, xhr);
- }
- };
- upload([files[0]], settings);
- } else {
- settings.complete = function(response, xhr){
- complete(response, xhr);
- settings.allcomplete(response, xhr);
- };
- upload(files, settings);
- }
- function upload(files, settings){
- // upload all at once
- var formData = new FormData(), xhr = new XMLHttpRequest();
- if (settings.before(settings, files)===false) return;
- for (var i = 0, f; f = files[i]; i++) { formData.append(settings.param, f); }
- for (var p in settings.params) { formData.append(p, settings.params[p]); }
- // Add any event handlers here...
- xhr.upload.addEventListener("progress", function(e){
- var percent = (e.loaded / e.total)*100;
- settings.progress(percent, e);
- }, false);
- xhr.addEventListener("loadstart", function(e){ settings.loadstart(e); }, false);
- xhr.addEventListener("load", function(e){ settings.load(e); }, false);
- xhr.addEventListener("loadend", function(e){ settings.loadend(e); }, false);
- xhr.addEventListener("error", function(e){ settings.error(e); }, false);
- xhr.addEventListener("abort", function(e){ settings.abort(e); }, false);
- xhr.open(settings.method, settings.action, true);
- if (settings.type=="json") {
- xhr.setRequestHeader("Accept", "application/json");
- }
- for (var h in settings.headers) {
- xhr.setRequestHeader(h, settings.headers[h]);
- }
- xhr.onreadystatechange = function() {
- settings.readystatechange(xhr);
- if (xhr.readyState==4){
- var response = xhr.responseText;
- if (settings.type=="json") {
- try {
- response = UI.$.parseJSON(response);
- } catch(e) {
- response = false;
- }
- }
- settings.complete(response, xhr);
- }
- };
- settings.beforeSend(xhr);
- xhr.send(formData);
- }
- }
- xhrupload.defaults = {
- action: '',
- single: true,
- method: 'POST',
- param : 'files[]',
- params: {},
- allow : '*.*',
- type : 'text',
- filelimit: false,
- headers: {},
- // events
- before : function(o){},
- beforeSend : function(xhr){},
- beforeAll : function(){},
- loadstart : function(){},
- load : function(){},
- loadend : function(){},
- error : function(){},
- abort : function(){},
- progress : function(){},
- complete : function(){},
- allcomplete : function(){},
- readystatechange: function(){},
- notallowed : function(file, settings){ alert('Only the following file types are allowed: '+settings.allow); }
- };
- function matchName(pattern, path) {
- var parsedPattern = '^' + pattern.replace(/\//g, '\\/').
- replace(/\*\*/g, '(\\/[^\\/]+)*').
- replace(/\*/g, '[^\\/]+').
- replace(/((?!\\))\?/g, '$1.') + '$';
- parsedPattern = '^' + parsedPattern + '$';
- return (path.match(new RegExp(parsedPattern, 'i')) !== null);
- }
- UI.Utils.xhrupload = xhrupload;
- return xhrupload;
- });
- // http://getuikit.com/docs/documentation_javascript.html#js-override
- if (typeof UIkit !== 'undefined') {
- UIkit.on('beforeready.uk.dom', function () {
- // accrodion
- if (typeof UIkit.components.accordion !== "undefined") { // check if accordion component is defined
- $.extend(UIkit.components.accordion.prototype.defaults, {
- easing: $.bez([ 0.35,0,0.25,1 ]),
- duration: 200
- });
- }
- // dropdown
- if (typeof UIkit.components.dropdown.prototype !== "undefined") { // check if dropdown component is defined
- $.extend(UIkit.components.dropdown.prototype.defaults, {
- remaintime: 150,
- delay: 50
- });
- (function() {
- var old_show_function = UIkit.components.dropdown.prototype.show;
- UIkit.components.dropdown.prototype.show = function() {
- this.dropdown
- .css({
- 'min-width': this.dropdown.outerWidth()
- })
- .addClass('uk-dropdown-active uk-dropdown-shown');
- return old_show_function.apply(this, arguments);
- }
- })();
- (function() {
- var old_hide_function = UIkit.components.dropdown.prototype.hide;
- UIkit.components.dropdown.prototype.hide = function() {
- var this_dropdown = this.dropdown;
- this_dropdown.removeClass('uk-dropdown-shown');
- var dropdown_timeout = setTimeout(function() {
- this_dropdown.removeClass('uk-dropdown-active')
- },280);
- return old_hide_function.apply(this, arguments);
- }
- })();
- }
- // modal
- if (typeof UIkit.components.modal !== "undefined") { // check if modal component is defined
- $.extend(UIkit.components.modal.prototype.defaults, {
- center: true
- });
- UIkit.modal.dialog.template = '<div class="uk-modal uk-modal-dialog-replace"><div class="uk-modal-dialog" style="min-height:0;"></div></div>';
- $body
- .on('show.uk.modal', '.uk-modal-dialog-replace', function () {
- // customize uikit dialog
- setTimeout(function () {
- var dialogReplace = $('.uk-modal-dialog-replace');
- if (dialogReplace.find('.uk-button-primary').length) {
- var actionBtn = dialogReplace.find('.uk-button-primary').toggleClass('uk-button-primary md-btn-flat-primary');
- if (actionBtn.next('button')) {
- actionBtn.next('button').after(actionBtn);
- }
- }
- if (dialogReplace.find('.uk-button').length) {
- dialogReplace.find('.uk-button').toggleClass('uk-button md-btn md-btn-flat');
- }
- if (dialogReplace.find('.uk-margin-small-top').length) {
- dialogReplace.find('.uk-margin-small-top').toggleClass('uk-margin-small-top uk-margin-top');
- }
- if (dialogReplace.find('input.uk-width-1-1').length) {
- dialogReplace.find('input.uk-width-1-1').toggleClass('uk-width-1-1 md-input');
- // reinitialize md inputs
- altair_md.inputs();
- }
- if (dialogReplace.find('.uk-form').length) {
- dialogReplace.find('.uk-form').removeClass('uk-form');
- }
- }, 50)
- });
- }
- // tooltip
- if (typeof UIkit.components.tooltip !== "undefined") { // check if tooltip component is defined
- $.extend(UIkit.components.tooltip.prototype.defaults, {
- animation: 280,
- offset: 8
- });
- }
- // sortable
- if (typeof UIkit.components.sortable !== "undefined") { // check if sortable component is defined
- if(Modernizr.touch) {
- $('[data-uk-sortable]').children().addClass('needsclick');
- }
- }
- });
- }
|