123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034 |
- (function($)
- {
- "use strict";
- $(document).ready(function()
- {
- //global variables that are used on several ocassions
- $.avia_utilities = $.avia_utilities || {};
-
- if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && 'ontouchstart' in document.documentElement)
- {
- $.avia_utilities.isMobile = true;
- }
- else
- {
- $.avia_utilities.isMobile = false;
- }
-
- //activate fixed bg fallback for mobile
- if($.fn.avia_mobile_fixed)
- $('.avia-bg-style-fixed').avia_mobile_fixed();
-
- //activate parallax scrolling for backgrounds.
- if($.fn.avia_parallax)
- $('.av-parallax').avia_parallax();
-
- //calculate the browser height and append a css rule to the head
- if($.fn.avia_browser_height)
- $('.av-minimum-height, .avia-fullscreen-slider').avia_browser_height();
-
- //calculate the height of each video section
- if($.fn.avia_video_section)
- $('.av-section-with-video-bg').avia_video_section();
-
- //creates team social icon tooltip
- new $.AviaTooltip({'class': "avia-tooltip", data: "avia-tooltip", delay:0, scope: "body"});
-
- //creates icon element tooltip
- new $.AviaTooltip({'class': "avia-tooltip avia-icon-tooltip", data: "avia-icon-tooltip", delay:0, scope: "body"});
- activate_shortcode_scripts();
-
- //layer slider height helper
- $('.avia-layerslider').layer_slider_height_helper();
-
- //"ajax" portfolio
- $('.grid-links-ajax').avia_portfolio_preview();
-
- // actiavte the masonry script: sorting/loading/etc
- if($.fn.avia_masonry)
- $('.av-masonry').avia_masonry();
-
- //activate the accordion
- if($.fn.aviaccordion)
- $('.aviaccordion').aviaccordion();
-
-
- //activate the accordion
- if($.fn.avia_textrotator)
- $('.av-rotator-container').avia_textrotator();
-
-
-
- });
- $(window).load(function(){
- //initialize after images are loaded
- });
- // -------------------------------------------------------------------------------------------
- // ACTIVATE ALL SHORTCODES
- // -------------------------------------------------------------------------------------------
- function activate_waypoints(container)
- {
- //activates simple css animations of the content once the user scrolls to an elements
- if($.fn.avia_waypoints)
- {
- if(typeof container == 'undefined'){ container = 'body';};
- $('.avia_animate_when_visible', container).avia_waypoints();
- $('.avia_animate_when_almost_visible', container).avia_waypoints({ offset: '80%'});
-
- if(container == 'body') container = '.avia_desktop body';
- $('.av-animated-generic', container).avia_waypoints({ offset: '95%'});
- }
- }
- function activate_shortcode_scripts(container)
- {
- if(typeof container == 'undefined'){ container = 'body';}
-
- //activates the form shortcode
- if($.fn.avia_ajax_form)
- {
- $('.avia_ajax_form:not( .avia-disable-default-ajax )', container).avia_ajax_form();
- }
-
- activate_waypoints(container);
-
- //activate the video api
- if($.fn.aviaVideoApi)
- {
- $('.avia-slideshow iframe[src*="youtube.com"], .av_youtube_frame, .avia-slideshow iframe[src*="vimeo.com"], .avia-slideshow video').aviaVideoApi({}, 'li');
- }
-
- //activates the toggle shortcode
- if($.fn.avia_sc_toggle)
- {
- $('.togglecontainer', container).avia_sc_toggle();
- }
-
- //activates the tabs shortcode
- if($.fn.avia_sc_tabs)
- {
- $('.top_tab', container).avia_sc_tabs();
- $('.sidebar_tab', container).avia_sc_tabs({sidebar:true});
- }
- //activates behavior and animation for gallery
- if($.fn.avia_sc_gallery)
- {
- $('.avia-gallery', container).avia_sc_gallery();
- }
-
- //activates animated number shortcode
- if($.fn.avia_sc_animated_number)
- {
- $('.avia-animated-number', container).avia_sc_animated_number();
- }
-
- //animation for elements that are not connected like icon shortcode
- if($.fn.avia_sc_animation_delayed)
- {
- $('.av_font_icon', container).avia_sc_animation_delayed({delay:100});
- $('.avia-image-container', container).avia_sc_animation_delayed({delay:100});
- $('.av-hotspot-image-container', container).avia_sc_animation_delayed({delay:100});
- $('.av-animated-generic', container).avia_sc_animation_delayed({delay:100});
- }
- //activates animation for iconlist
- if($.fn.avia_sc_iconlist)
- {
- $('.avia-icon-list', container).avia_sc_iconlist();
- }
- //activates animation for progress bar
- if($.fn.avia_sc_progressbar)
- {
- $('.avia-progress-bar-container', container).avia_sc_progressbar();
- }
- //activates animation for testimonial
- if($.fn.avia_sc_testimonial)
- {
- $('.avia-testimonial-wrapper', container).avia_sc_testimonial();
- }
-
- //activate the fullscreen slider
- $('.avia-slideshow.av_fullscreen', container).aviaFullscreenSlider();
-
- //activate the aviaslider
- $('.avia-slideshow:not(.av_fullscreen)', container).aviaSlider();
-
- //content slider
- $('.avia-content-slider-active', container).aviaSlider({wrapElement: '.avia-content-slider-inner', slideElement:'.slide-entry-wrap', fullfade:true});
- //testimonial slider
- $('.avia-slider-testimonials', container).aviaSlider({wrapElement: '.avia-testimonial-row', slideElement:'.avia-testimonial', fullfade:true});
-
- //load and activate maps
- if($.fn.aviaMaps)
- {
- $('.avia-google-map-container', container).aviaMaps();
- }
-
- //load magazine sorting
- if($.fn.aviaMagazine)
- {
- $('.av-magazine-tabs-active', container).aviaMagazine();
- }
-
- //load image hotspot
- if($.fn.aviaHotspots)
- {
- $('.av-hotspot-image-container', container).aviaHotspots();
- }
-
- //load countdown
- if($.fn.aviaCountdown)
- {
- $('.av-countdown-timer', container).aviaCountdown();
- }
-
- //load countdown
- if($.fn.aviaCountdown)
- {
- $('.av-countdown-timer', container).aviaCountdown();
- }
-
-
- }
- // -------------------------------------------------------------------------------------------
- //
- // AVIA Countdown
- //
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- "use strict";
-
- var _units = ['weeks','days','hours','minutes','seconds'],
- _second = 1000,
- _minute = _second * 60,
- _hour = _minute * 60,
- _day = _hour * 24,
- _week = _day * 7,
- ticker = function(_self)
- {
- var _time = {},
- _now = new Date(),
- _timestamp = _self.end - _now;
-
- if(_timestamp <= 0)
- {
- clearInterval(_self.countdown);
- return;
- }
-
- _self.time.weeks = Math.floor( _timestamp / _week);
- _self.time.days = Math.floor((_timestamp % _week) / _day);
- _self.time.hours = Math.floor((_timestamp % _day) / _hour);
- _self.time.minutes = Math.floor((_timestamp % _hour) / _minute);
- _self.time.seconds = Math.floor((_timestamp % _minute) / _second);
-
- switch(_self.data.maximum)
- {
- case 1: _self.time.seconds = Math.floor(_timestamp / _second); break;
- case 2: _self.time.minutes = Math.floor(_timestamp / _minute); break;
- case 3: _self.time.hours = Math.floor(_timestamp / _hour); break;
- case 4: _self.time.days = Math.floor(_timestamp / _day); break;
- }
-
- for (var i in _self.time)
- {
- if(typeof _self.update[i] == "object")
- {
- if(_self.firstrun || _self.oldtime[i] != _self.time[i])
- {
- var labelkey = ( _self.time[i] === 1 ) ? "single" : "multi";
-
- _self.update[i].time_container.text(_self.time[i]);
- _self.update[i].label_container.text(_self.update[i][labelkey]);
- }
- }
- }
-
- //show ticker
- if(_self.firstrun) _self.container.addClass('av-countdown-active')
-
- _self.oldtime = $.extend( {}, _self.time );
- _self.firstrun = false;
- };
-
-
- $.fn.aviaCountdown = function( options )
- {
- if(!this.length) return;
- return this.each(function()
- {
- var _self = {};
- _self.update = {};
- _self.time = {};
- _self.oldtime = {};
- _self.firstrun = true;
-
- _self.container = $(this);
- _self.data = _self.container.data();
- _self.end = new Date(_self.data.year, _self.data.month, _self.data.day, _self.data.hour, _self.data.minute );
-
- for (var i in _units)
- {
- _self.update[_units[i]] = {
- time_container: _self.container.find('.av-countdown-' + _units[i] + ' .av-countdown-time'),
- label_container: _self.container.find('.av-countdown-' + _units[i] + ' .av-countdown-time-label'),
- };
-
- if(_self.update[_units[i]].label_container.length)
- {
- _self.update[_units[i]].single = _self.update[_units[i]].label_container.data('label');
- _self.update[_units[i]].multi = _self.update[_units[i]].label_container.data('label-multi');
- }
- }
-
- ticker(_self);
- _self.countdown = setInterval(function(){ ticker(_self); }, _self.data.interval);
-
- });
- }
-
- }(jQuery));
- // -------------------------------------------------------------------------------------------
- //
- // AVIA Image Hotspots
- //
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- "use strict";
- $.fn.aviaHotspots = function( options )
- {
- if(!this.length) return;
- return this.each(function()
- {
- var _self = {};
-
- _self.container = $(this);
- _self.hotspots = _self.container.find('.av-image-hotspot');
-
- _self.container.on('avia_start_animation', function()
- {
- setTimeout(function()
- {
- _self.hotspots.each(function(i)
- {
- var current = $(this);
- setTimeout(function(){ current.addClass('av-display-hotspot'); },300 * i);
- });
- },400);
- });
- });
- }
-
- }(jQuery));
- // -------------------------------------------------------------------------------------------
- //
- // AVIA Magazine function for magazine sorting
- //
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- "use strict";
-
- var animating = false,
- methods = {
-
- switchMag: function(clicked, _self)
- {
- var current = $(clicked)
-
- if(current.is('.active_sort') || animating) return;
-
- var filter = current.data('filter'),
- oldContainer = _self.container.filter(':visible'),
- newContainer = _self.container.filter('.' + filter);
-
- //switch Class
- animating = true;
- _self.sort_buttons.removeClass('active_sort');
- current.addClass('active_sort');
-
- //apply fixed heiht for transition
- _self.magazine.height(_self.magazine.outerHeight());
-
- //switch items
- oldContainer.avia_animate({opacity:0}, 200, function()
- {
- oldContainer.css({display:'none'});
- newContainer.css({opacity:0, display:'block'}).avia_animate({opacity:1}, 150, function()
- {
- _self.magazine.avia_animate({height: (newContainer.outerHeight() + _self.sort_bar.outerHeight())}, 150, function()
- {
- _self.magazine.height('auto');
- animating = false;
- });
-
- });
- });
- }
- };
-
-
- $.fn.aviaMagazine = function( options )
- {
- if(!this.length) return;
- return this.each(function()
- {
- var _self = {};
-
- _self.magazine = $(this),
- _self.sort_buttons = _self.magazine.find('.av-magazine-sort a');
- _self.container = _self.magazine.find('.av-magazine-group');
- _self.sort_bar = _self.magazine.find('.av-magazine-top-bar');
-
- _self.sort_buttons.on('click', function(e){ e.preventDefault(); methods.switchMag(this, _self); } );
- });
- }
-
- }(jQuery));
- // -------------------------------------------------------------------------------------------
- //
- // AVIA MAPS API - loads the google maps api asynchronously
- //
- // afterwards applies the map to the container
- //
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- "use strict";
- $.AviaMapsAPI = function(options, container)
- {
- if(typeof window.av_google_map == 'undefined')
- {
- $.avia_utilities.log('Map creation stopped, var av_google_map not found'); return
- }
-
- // gatehr container and map data
- this.container = container;
- this.$container = $( container );
- this.$body = $('body');
- this.$mapid = this.$container.data('mapid') - 1;
- this.$data = window.av_google_map[this.$mapid];
- this.retina = window.devicePixelRatio > 1;
-
- // set up the whole api object
- this._init( options );
- }
-
- $.AviaMapsAPI.apiFiles =
- {
- loading: false,
- finished: false,
- src: 'https://maps.googleapis.com/maps/api/js?v=3.6&callback=aviaOnGoogleMapsLoaded'
- }
-
- $.AviaMapsAPI.prototype =
- {
- _init: function()
- {
- this._bind_execution();
- this._getAPI();
- },
-
- _getAPI: function( )
- {
- //make sure the api file is loaded only once
- if((typeof window.google == 'undefined' || typeof window.google.maps == 'undefined') && $.AviaMapsAPI.apiFiles.loading == false)
- {
- $.AviaMapsAPI.apiFiles.loading = true;
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.src = $.AviaMapsAPI.apiFiles.src;
-
- document.body.appendChild(script);
- }
- else if((typeof window.google != 'undefined' && typeof window.google.maps != 'undefined') || $.AviaMapsAPI.apiFiles.loading == false)
- //else if($.AviaMapsAPI.apiFiles.finished === true)
- {
- this._applyMap();
- }
- },
-
- _bind_execution: function()
- {
- this.$body.on('av-google-maps-api-loaded', $.proxy( this._applyMap, this) );
- },
-
- _applyMap: function()
- {
- if(typeof this.map != 'undefined') return;
- if(!this.$data.marker || !this.$data.marker[0] || !this.$data.marker[0].long || !this.$data.marker[0].long)
- {
- $.avia_utilities.log('Latitude or Longitude missing', 'map-error');
- return;
- }
-
- var _self = this,
- mobile_drag = $.avia_utilities.isMobile ? this.$data.mobile_drag_control : true,
- zoomValue = this.$data.zoom == "auto" ? 10 : this.$data.zoom;
-
- this.mapVars = {
- mapMaker: false, //mapmaker tiles are user generated content maps. might hold more info but also be inaccurate
- mapTypeControl: false,
- backgroundColor:'transparent',
- streetViewControl: false,
- panControl: this.$data.pan_control,
- zoomControl: this.$data.zoom_control,
- draggable: mobile_drag,
- scrollwheel: false,
- zoom: zoomValue,
- mapTypeId:google.maps.MapTypeId.ROADMAP,
- center: new google.maps.LatLng(this.$data.marker[0].lat, this.$data.marker[0].long),
- styles:[{featureType: "poi", elementType: "labels", stylers: [ { visibility: "off" }] }]
- };
- this.map = new google.maps.Map(this.container, this.mapVars);
-
- this._applyMapStyle();
-
- if(this.$data.zoom == "auto")
- {
- this._setAutoZoom();
- }
-
- google.maps.event.addListenerOnce(this.map, 'tilesloaded', function() {
- _self._addMarkers();
- });
- },
-
- _setAutoZoom: function()
- {
- var bounds = new google.maps.LatLngBounds();
-
- for (var key in this.$data.marker)
- {
- bounds.extend( new google.maps.LatLng (this.$data.marker[key].lat , this.$data.marker[key].long) );
- }
-
- this.map.fitBounds(bounds);
- },
-
- _applyMapStyle: function()
- {
- var stylers = [], style = [], mapType;
-
- if(this.$data.hue != "") stylers.push({hue: this.$data.hue});
- if(this.$data.saturation != "") stylers.push({saturation: this.$data.saturation});
-
- if(stylers.length)
- {
- style = [{
- featureType: "all",
- elementType: "all",
- stylers: stylers
- }, {
- featureType: "poi",
- stylers: [
- { visibility: "off" }
- ]
- }];
-
- mapType = new google.maps.StyledMapType(style, { name:"av_map_style" });
- this.map.mapTypes.set('av_styled_map', mapType);
- this.map.setMapTypeId('av_styled_map');
- }
- },
-
- _addMarkers: function()
- {
- for (var key in this.$data.marker)
- {
- var _self = this;
-
- (function(key, _self)
- {
- setTimeout(function()
- {
- var marker = "";
-
- if(!_self.$data.marker[key] || !_self.$data.marker[key].long || !_self.$data.marker[key].long)
- {
- $.avia_utilities.log('Latitude or Longitude for single marker missing', 'map-error');
- return;
- }
-
- _self.$data.LatLng = new google.maps.LatLng(_self.$data.marker[key].lat, _self.$data.marker[key].long);
-
- var markerArgs = {
- flat: false,
- position: _self.$data.LatLng,
- animation: google.maps.Animation.BOUNCE,
- map: _self.map,
- title: _self.$data.marker[key].address,
- optimized: false
- };
-
- //set a custom marker image if available. also set the size and reduce the marker on retina size so its sharp
- if(_self.$data.marker[key].icon && _self.$data.marker[key].imagesize)
- {
- var size = _self.$data.marker[key].imagesize, half = "", full = "";
-
- if(_self.retina && size > 40) size = 40; //retina downsize to at least half the px size
- half = new google.maps.Point(size / 2, size ) ; //used to position the marker
- full = new google.maps.Size(size , size ) ; //marker size
- markerArgs.icon = new google.maps.MarkerImage(_self.$data.marker[key].icon, null, null, half, full);
- }
-
- marker = new google.maps.Marker(markerArgs);
-
- setTimeout(function(){ marker.setAnimation(null); _self._infoWindow(_self.map, marker, _self.$data.marker[key]); },500);
-
- },200 * (parseInt(key,10) + 1));
-
- }(key, _self));
- }
- },
-
- _infoWindow: function(map, marker, data)
- {
- var info = $.trim(data.content);
-
- if(info != "")
- {
- var infowindow = new google.maps.InfoWindow({
- content: info
- });
-
- google.maps.event.addListener(marker, 'click', function() {
- infowindow.open(map,marker);
- });
-
- if(data.tooltip_display) infowindow.open(map,marker);
- }
- }
-
-
- }
- //simple wrapper to call the api. makes sure that the api data is not applied twice
- $.fn.aviaMaps = function( options )
- {
- return this.each(function()
- {
- var self = $.data( this, 'aviaMapsApi' );
-
- if(!self)
- {
- self = $.data( this, 'aviaMapsApi', new $.AviaMapsAPI( options, this ) );
- }
- });
- }
-
- })( jQuery );
- //this function is executed once the api file is loaded
- window.aviaOnGoogleMapsLoaded = function(){ $('body').trigger('av-google-maps-api-loaded'); $.AviaMapsAPI.apiFiles.finished = true; };
- // -------------------------------------------------------------------------------------------
- //
- // AVIA VIDEO API - make sure that youtube, vimeo and html 5 use the same interface
- //
- // requires froogaloop vimeo library and youtube iframe api (yt can be loaded async)
- //
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- "use strict";
- $.AviaVideoAPI = function(options, video, option_container)
- {
- // actual video element. either iframe or video
- this.$video = $( video );
-
- // container where the AviaVideoAPI object will be stored as data, and that can receive events like play, pause etc
- // also the container that allows to overwrite javacript options by adding html data- attributes
- this.$option_container = option_container ? $( option_container ) : this.$video;
-
- //mobile device?
- this.isMobile = $.avia_utilities.isMobile;
-
- //iamge fallback use
- this.fallback = this.isMobile ? this.$option_container.is('.av-mobile-fallback-image') : false;
-
- if(this.fallback) return;
-
- // set up the whole api object
- this._init( options );
-
- }
- $.AviaVideoAPI.defaults = {
-
- loop: false,
- mute: false,
- controls: false,
- events: 'play pause mute unmute loop toggle reset unload'
- };
-
- $.AviaVideoAPI.apiFiles =
- {
- youtube : {loaded: false, src: 'https://www.youtube.com/iframe_api' }
- }
-
- $.AviaVideoAPI.prototype =
- {
- _init: function( options )
- {
- // set slider options
- this.options = this._setOptions(options);
-
- // info which video service we are using: html5, vimeo or youtube
- this.type = this._getPlayerType();
-
- // store the player object to the this.player variable created by one of the APIs (mediaelement, youtube, vimeo)
- this._setPlayer();
-
- // set to true once the events are bound so it doesnt happen a second time by accident or racing condition
- this.eventsBound = false;
-
- // info if the video is playing
- this.playing = false;
-
- //set css class that video is currently not playing
- this.$option_container.addClass('av-video-paused');
-
- //play pause indicator
- this.pp = $.avia_utilities.playpause(this.$option_container);
- },
-
-
- //set the video options by first merging the default options and the passed options, then checking the video element if any data attributes overwrite the option set
- _setOptions: function(options)
- {
- var newOptions = $.extend( true, {}, $.AviaVideoAPI.defaults, options ),
- htmlData = this.$option_container.data(),
- i = "";
- //overwritte passed option set with any data properties on the html element
- for (i in htmlData)
- {
- if (htmlData.hasOwnProperty(i) && (typeof htmlData[i] === "string" || typeof htmlData[i] === "number" || typeof htmlData[i] === "boolean"))
- {
- newOptions[i] = htmlData[i];
- }
- }
-
- return newOptions;
- },
-
-
- //get the player type
- _getPlayerType: function()
- {
- var vid_src = this.$video.get(0).src || this.$video.data('src');
-
-
- if(this.$video.is('video')) return 'html5';
- if(this.$video.is('.av_youtube_frame')) return 'youtube';
- if(vid_src.indexOf('vimeo.com') != -1 ) return 'vimeo';
- if(vid_src.indexOf('youtube.com') != -1) return 'youtube';
- },
-
- //get the player object
- _setPlayer: function()
- {
- var _self = this;
-
- switch(this.type)
- {
- case "html5":
-
- this.player = this.$video.data('mediaelementplayer');
- this._playerReady();
-
- break;
-
- case "vimeo":
-
- this.player = Froogaloop(this.$video.get(0));
- this._playerReady();
-
- break;
-
- case "youtube":
-
- this._getAPI(this.type);
- $('body').on('av-youtube-iframe-api-loaded', function(){ _self._playerReady(); });
-
- break;
- }
- },
-
- _getAPI: function( api )
- {
- //make sure the api file is loaded only once
- if($.AviaVideoAPI.apiFiles[api].loaded === false)
- {
- $.AviaVideoAPI.apiFiles[api].loaded = true;
- //load the file async
- var tag = document.createElement('script'),
- first = document.getElementsByTagName('script')[0];
-
- tag.src = $.AviaVideoAPI.apiFiles[api].src;
- first.parentNode.insertBefore(tag, first);
- }
- },
-
-
-
- //wait for player to be ready, then bind events
- _playerReady: function()
- {
- var _self = this;
-
- this.$option_container.on('av-video-loaded', function(){ _self._bindEvents(); });
-
- switch(this.type)
- {
- case "html5":
-
- this.$video.on('av-mediajs-loaded', function(){ _self.$option_container.trigger('av-video-loaded'); });
- this.$video.on('av-mediajs-ended' , function(){ _self.$option_container.trigger('av-video-ended'); });
-
- break;
- case "vimeo":
-
- //finish event must be applied after ready event for firefox
- _self.player.addEvent('ready', function(){ _self.$option_container.trigger('av-video-loaded');
- _self.player.addEvent('finish', function(){ _self.$option_container.trigger('av-video-ended'); });
- });
-
- // vimeo sometimes does not fire. fallback jquery load event should fix this
- // currently not used because it causes firefox problems
- /*
- this.$video.load(function()
- {
- if(_self.eventsBound == true || typeof _self.eventsBound == 'undefined') return;
- _self.$option_container.trigger('av-video-loaded');
- $.avia_utilities.log('VIMEO Fallback Trigger');
- });
- */
-
-
- break;
-
- case "youtube":
-
- var params = _self.$video.data();
-
- if(_self._supports_video()) params.html5 = 1;
-
- _self.player = new YT.Player(_self.$video.attr('id'), {
- videoId: params.videoid,
- height: _self.$video.attr('height'),
- width: _self.$video.attr('width'),
- playerVars: params,
- events: {
- 'onReady': function(){ _self.$option_container.trigger('av-video-loaded'); },
- 'onError': function(player){ $.avia_utilities.log('YOUTUBE ERROR:', 'error', player); },
- 'onStateChange': function(event){
- if (event.data === YT.PlayerState.ENDED)
- {
- var command = _self.options.loop != false ? 'loop' : 'av-video-ended';
- _self.$option_container.trigger(command);
- }
- }
- }
- });
-
-
- break;
- }
-
- //fallback always trigger after 2 seconds
- setTimeout(function()
- {
- if(_self.eventsBound == true || typeof _self.eventsBound == 'undefined' || _self.type == 'youtube' ) { return; }
- $.avia_utilities.log('Fallback Video Trigger "'+_self.type+'":', 'log', _self);
-
- _self.$option_container.trigger('av-video-loaded');
-
- },2000);
-
- },
-
- //bind events we should listen to, to the player
- _bindEvents: function()
- {
- if(this.eventsBound == true || typeof this.eventsBound == 'undefined')
- {
- return;
- }
-
- var _self = this, volume = 'unmute';
-
- this.eventsBound = true;
-
- this.$option_container.on(this.options.events, function(e)
- {
- _self.api(e.type);
- });
-
- if(!_self.isMobile)
- {
- //set up initial options
- if(this.options.mute != false) { volume = "mute"; }
- if(this.options.loop != false) { _self.api('loop'); }
-
- _self.api(volume);
- }
-
- //set timeout to prevent racing conditions with other scripts
- setTimeout(function()
- {
- _self.$option_container.trigger('av-video-events-bound').addClass('av-video-events-bound');
- },50);
- },
-
-
- _supports_video: function() {
- return !!document.createElement('video').canPlayType;
- },
-
-
- /************************************************************************
- PUBLIC Methods
- *************************************************************************/
-
- api: function( action )
- {
- //commands on mobile can not be executed if the player was not started manually
- if(this.isMobile && !this.was_started()) return;
-
- // prevent calling of unbound function
- if(this.options.events.indexOf(action) === -1) return;
-
- // broadcast that the command was executed
- this.$option_container.trigger('av-video-'+action+'-executed');
-
- // calls the function based on action. eg: _html5_play()
- if(typeof this[ '_' + this.type + '_' + action] == 'function')
- {
- this[ '_' + this.type + '_' + action].call(this);
- }
-
- //call generic function eg: _toggle() or _play()
- if(typeof this[ '_' + action] == 'function')
- {
- this[ '_' + action].call(this);
- }
-
- },
-
- was_started: function()
- {
- if(!this.player) return false;
-
- switch(this.type)
- {
- case "html5":
- if(this.player.getCurrentTime() > 0) return true;
- break;
-
- case "vimeo":
- if(this.player.api('getCurrentTime') > 0) return true;
- break;
-
- case "youtube":
- if(this.player.getPlayerState() !== -1) return true;
- break;
- }
-
- return false;
- },
-
- /************************************************************************
- Generic Methods, are always executed and usually set variables
- *************************************************************************/
- _play: function()
- {
- this.playing = true;
- this.$option_container.addClass('av-video-playing').removeClass('av-video-paused');
- },
-
- _pause: function()
- {
- this.playing = false;
- this.$option_container.removeClass('av-video-playing').addClass('av-video-paused');
- },
-
- _loop: function()
- {
- this.options.loop = true;
- },
-
- _toggle: function( )
- {
- var command = this.playing == true ? 'pause' : 'play';
-
- this.api(command);
- this.pp.set(command);
- },
-
-
- /************************************************************************
- VIMEO Methods
- *************************************************************************/
-
- _vimeo_play: function( )
- {
- this.player.api('play');
- },
-
- _vimeo_pause: function( )
- {
- this.player.api('pause');
- },
-
- _vimeo_mute: function( )
- {
- this.player.api('setVolume', 0);
- },
-
- _vimeo_unmute: function( )
- {
- this.player.api('setVolume', 0.7);
- },
-
- _vimeo_loop: function( )
- {
- // currently throws error, must be set in iframe
- // this.player.api('setLoop', true);
- },
-
- _vimeo_reset: function( )
- {
- this.player.api('seekTo',0);
- },
-
- _vimeo_unload: function()
- {
- this.player.api('unload');
- },
-
- /************************************************************************
- YOUTUBE Methods
- *************************************************************************/
-
- _youtube_play: function( )
- {
- this.player.playVideo();
- },
-
- _youtube_pause: function( )
- {
- this.player.pauseVideo()
- },
-
- _youtube_mute: function( )
- {
- this.player.mute();
- },
-
- _youtube_unmute: function( )
- {
- this.player.unMute();
- },
-
- _youtube_loop: function( )
- {
- // does not work properly with iframe api. needs to manual loop on "end" event
- // this.player.setLoop(true);
- if(this.playing == true) this.player.seekTo(0);
- },
-
- _youtube_reset: function( )
- {
- this.player.stopVideo();
- },
-
- _youtube_unload: function()
- {
- this.player.clearVideo();
- },
-
- /************************************************************************
- HTML5 Methods
- *************************************************************************/
-
- _html5_play: function( )
- {
- //disable stoping of other videos in case the user wants to run section bgs
- this.player.options.pauseOtherPlayers = false;
- this.player.play();
- },
-
- _html5_pause: function( )
- {
- this.player.pause();
- },
-
- _html5_mute: function( )
- {
- this.player.setMuted(true);
- },
-
- _html5_unmute: function( )
- {
- this.player.setVolume(0.7);
- },
-
- _html5_loop: function( )
- {
- this.player.options.loop = true;
- },
-
- _html5_reset: function( )
- {
- this.player.setCurrentTime(0);
- },
-
- _html5_unload: function()
- {
- this._html5_pause();
- this._html5_reset();
- }
- }
- //simple wrapper to call the api. makes sure that the api data is not applied twice
- $.fn.aviaVideoApi = function( options , apply_to_parent)
- {
- return this.each(function()
- {
- // by default save the object as data to the initial video.
- // in the case of slideshows its more benefitial to save it to a parent element (eg: the slide)
- var applyTo = this;
-
- if(apply_to_parent)
- {
- applyTo = $(this).parents(apply_to_parent).get(0);
- }
-
- var self = $.data( applyTo, 'aviaVideoApi' );
-
- if(!self)
- {
- self = $.data( applyTo, 'aviaVideoApi', new $.AviaVideoAPI( options, this, applyTo ) );
- }
- });
- }
-
- })( jQuery );
- window.onYouTubeIframeAPIReady = function(){ $('body').trigger('av-youtube-iframe-api-loaded'); };
- // -------------------------------------------------------------------------------------------
- // Masonry
- // -------------------------------------------------------------------------------------------
- $.fn.avia_masonry = function(options)
- {
- //return if we didnt find anything
- if(!this.length) return this;
-
- var the_body = $('body'),
- the_win = $(window),
- isMobile = $.avia_utilities.isMobile,
- loading = false,
- methods = {
-
-
- masonry_filter: function()
- {
- var current = $(this),
- linktext = current.html(),
- selector = current.data('filter'),
- masonry = current.parents('.av-masonry:eq(0)'),
- container = masonry.find('.av-masonry-container:eq(0)'),
- links = masonry.find('.av-masonry-sort a'),
- activeCat = masonry.find('.av-current-sort-title');
-
- links.removeClass('active_sort');
- current.addClass('active_sort');
- container.attr('id', 'masonry_id_'+selector);
-
- if(activeCat.length) activeCat.html(linktext);
-
- methods.applyMasonry(container, selector, function()
- {
- container.css({overflow:'visible'});
- });
-
- return false;
- },
-
- applyMasonry: function(container, selector, callback)
- {
- var filters = selector ? {filter: '.'+selector} : {};
-
- container.isotope(filters, function()
- {
- the_win.trigger('av-height-change');
- });
-
- if(typeof callback == 'function')
- {
- setTimeout(callback, 0);
- }
- },
-
- show_bricks: function(bricks, callback)
- {
- bricks.each(function(i)
- {
- var currentLink = $(this),
- browserPrefix = $.avia_utilities.supports('transition'),
- multiplier = isMobile ? 0 : 100;
-
- setTimeout(function()
- {
- if(browserPrefix === false)
- {
- currentLink.css({visibility:"visible", opacity:0}).animate({opacity:1},1500);
- }
- else
- {
- currentLink.addClass('av-masonry-item-loaded');
- }
-
- if(i == bricks.length - 1 && typeof callback == 'function')
- {
- callback.call();
- the_win.trigger('av-height-change');
- }
-
- }, (multiplier * i));
- });
- },
-
- loadMore: function(e)
- {
- e.preventDefault();
-
- if(loading) return false;
-
- loading = true;
-
- var current = $(this),
- data = current.data(),
- masonry = current.parents('.av-masonry:eq(0)'),
- container = masonry.find('.av-masonry-container'),
- items = masonry.find('.av-masonry-entry'),
- loader = $.avia_utilities.loading(),
- finished = function(){ loading = false; loader.hide(); the_body.trigger('av_resize_finished'); };
-
- //calculate a new offset
- if(!data.offset){ data.offset = 0; }
- data.offset += data.items;
- data.action = 'avia_ajax_masonry_more';
- data.loaded = []; //prevents duplicate entries from beeing loaded when randomized is active
-
- items.each(function(){
- var item_id = $(this).data('av-masonry-item');
- if(item_id) data.loaded.push( item_id );
- });
-
- $.ajax({
- url: avia_framework_globals.ajaxurl,
- type: "POST",
- data:data,
- beforeSend: function()
- {
- loader.show();
- },
- success: function(response)
- {
- if(response.indexOf("{av-masonry-loaded}") !== -1)
- {
- //fetch the response. if any php warnings were displayed before rendering of the items the are removed by the string split
- var response = response.split('{av-masonry-loaded}'),
- new_items = $(response.pop()).filter('.isotope-item');
-
- //check if we got more items than we need. if not we have reached the end of items
- if(new_items.length > data.items)
- {
- new_items = new_items.not(':last');
- }
- else
- {
- current.addClass('av-masonry-no-more-items');
- }
-
- var load_container = $('<div class="loadcontainer"></div>').append(new_items);
-
-
-
- $.avia_utilities.preload({container: load_container, single_callback: function()
- {
- var links = masonry.find('.av-masonry-sort a'),
- filter_container = masonry.find('.av-sort-by-term');
-
- filter_container.hide();
-
- loader.hide();
- container.isotope( 'insert', new_items);
- $.avia_utilities.avia_ajax_call(masonry);
- setTimeout( function(){ methods.show_bricks( new_items , finished); },150);
- setTimeout(function(){ the_win.trigger('av-height-change'); }, 550);
- if(links)
- {
- $(links).each(function(filterlinkindex){
- var filterlink = $(this),
- sort = filterlink.data('filter');
- if(new_items)
- {
- $(new_items).each(function(itemindex){
- var item = $(this);
-
- if(item.hasClass(sort))
- {
- var term_count = filterlink.find('.avia-term-count').text();
- filterlink.find('.avia-term-count').text(' ' + (parseInt(term_count) + 1) + ' ');
-
- if(filterlink.hasClass('avia_hide_sort'))
- {
- filterlink.removeClass('avia_hide_sort').addClass('avia_show_sort');
- masonry.find('.av-masonry-sort .'+sort+'_sep').removeClass('avia_hide_sort').addClass('avia_show_sort');
- masonry.find('.av-masonry-sort .av-sort-by-term').removeClass('hidden');
- }
- }
- });
- }
- });
- }
- filter_container.fadeIn();
- }
- });
- }
- else
- {
- finished();
- }
- },
- error: finished,
- complete: function()
- {
-
- }
- });
- }
- };
- return this.each(function()
- {
- var masonry = $(this),
- container = masonry.find('.av-masonry-container'),
- bricks = masonry.find('.isotope-item'),
- filter = masonry.find('.av-masonry-sort').css({visibility:"visible", opacity:0}).on('click', 'a', methods.masonry_filter),
- load_more = masonry.find('.av-masonry-load-more').css({visibility:"visible", opacity:0});
-
- $.avia_utilities.preload({container: container, single_callback: function()
- {
- var start_animation = function()
- {
- filter.animate({opacity:1}, 400);
-
- //fix for non aligned elements because of scrollbar
- if(container.outerHeight() + container.offset().top + $('#footer').outerHeight() > $(window).height())
- {
- $('html').css({'overflow-y':'scroll'});
- }
-
- methods.applyMasonry(container, false, function()
- {
- masonry.addClass('avia_sortable_active');
- container.removeClass('av-js-disabled ');
- });
-
- methods.show_bricks(bricks, function()
- {
- load_more.css({opacity:1}).on('click', methods.loadMore);
- });
-
- //container.isotope( 'reLayout' );
- };
-
- if(isMobile)
- {
- start_animation();
- }
- else
- {
- masonry.waypoint(start_animation , { offset: '80%'} );
- }
-
- // update columnWidth on window resize
- $(window).on( 'debouncedresize', function()
- {
- methods.applyMasonry(container, false, function()
- {
- masonry.addClass('avia_sortable_active');
- });
- });
- }
- });
-
-
- });
- };
-
- // -------------------------------------------------------------------------------------------
- // Avia AJAX Portfolio
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- "use strict";
- $.avia_utilities = $.avia_utilities || {};
-
- $.fn.avia_portfolio_preview = function(passed_options)
- {
- var win = $(window),
- the_body = $('body'),
- isMobile = $.avia_utilities.isMobile,
- defaults =
- {
- open_in: '.portfolio-details-inner',
- easing: 'easeOutQuint',
- timing: 800,
- transition: 'slide' // 'fade' or 'slide'
- },
-
- options = $.extend({}, defaults, passed_options);
-
- return this.each(function()
- {
- var container = $(this),
- portfolio_id = container.data('portfolio-id'),
- target_wrap = $('.portfolio_preview_container[data-portfolio-id="' + portfolio_id + '"]'),
- target_container = target_wrap.find(options.open_in),
- items = container.find('.grid-entry'),
- content_retrieved = {},
- is_open = false,
- animating = false,
- index_open = false,
- ajax_call = false,
- methods,
- controls,
- loader = $.avia_utilities.loading();
-
- methods =
- {
- load_item: function(e)
- {
- e.preventDefault();
- var link = $(this),
- post_container = link.parents('.post-entry:eq(0)'),
- post_id = "ID_" + post_container.data('ajax-id'),
- clickedIndex = items.index(post_container);
-
- //check if current item is the clicked item or if we are currently animating
- if(post_id === is_open || animating == true)
- {
- return false;
- }
-
- animating = true;
-
- container.find('.active_portfolio_item').removeClass('active_portfolio_item');
- post_container.addClass('active_portfolio_item');
- loader.show();
-
- methods.ajax_get_contents(post_id, clickedIndex);
- },
-
- scroll_top: function()
- {
- setTimeout(function()
- {
- var target_offset = target_wrap.offset().top - 175,
- window_offset = win.scrollTop();
-
- if(window_offset > target_offset || target_offset - window_offset > 100 )
- {
- $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target_offset }, options.timing, options.easing);
- }
- },10);
- },
-
- attach_item: function(post_id)
- {
- content_retrieved[post_id] = $(content_retrieved[post_id]).appendTo(target_container);
- ajax_call = true;
- },
-
- remove_video: function()
- {
- var del = target_wrap.find('iframe, .avia-video').parents('.ajax_slide:not(.open_slide)');
-
- if(del.length > 0)
- {
- del.remove();
- content_retrieved["ID_" + del.data('slideId')] = undefined;
- }
- },
-
- show_item: function(post_id, clickedIndex)
- {
-
- //check if current item is the clicked item or if we are currently animating
- if(post_id === is_open)
- {
- return false;
- }
- animating = true;
-
-
- loader.hide();
-
- if(false === is_open)
- {
- target_wrap.addClass('open_container');
- content_retrieved[post_id].addClass('open_slide');
-
- methods.scroll_top();
-
- target_wrap.css({display:'none'}).slideDown(options.timing, options.easing, function()
- {
- if(ajax_call)
- {
- activate_shortcode_scripts(content_retrieved[post_id]);
- $.avia_utilities.avia_ajax_call(content_retrieved[post_id]);
- the_body.trigger('av_resize_finished');
- ajax_call = false;
- }
-
- methods.remove_video();
- the_body.trigger('av_resize_finished');
- });
-
- index_open = clickedIndex;
- is_open = post_id;
- animating = false;
-
-
-
- }
- else
- {
- methods.scroll_top();
-
- var initCSS = { zIndex:3 },
- easing = options.easing;
-
- if(index_open > clickedIndex) { initCSS.left = '-110%'; }
- if(options.transition === 'fade'){ initCSS.left = '0%'; initCSS.opacity = 0; easing = 'easeOutQuad'; }
-
- //fixate height for container during animation
- target_container.height(target_container.height()); //outerHeight = border problems?
-
- content_retrieved[post_id].css(initCSS).avia_animate({'left':"0%", opacity:1}, options.timing, easing);
- content_retrieved[is_open].avia_animate({opacity:0}, options.timing, easing, function()
- {
- content_retrieved[is_open].attr({'style':""}).removeClass('open_slide');
- content_retrieved[post_id].addClass('open_slide');
- //+ 2 fixes border problem (slides move up and down 2 px on transition)
- target_container.avia_animate({height: content_retrieved[post_id].outerHeight() + 2}, options.timing/2, options.easing, function()
- {
- target_container.attr({'style':""});
- is_open = post_id;
- index_open = clickedIndex;
- animating = false;
-
- methods.remove_video();
- if(ajax_call)
- {
- the_body.trigger('av_resize_finished');
- activate_shortcode_scripts(content_retrieved[post_id]);
- $.avia_utilities.avia_ajax_call(content_retrieved[post_id]);
- ajax_call = false;
- }
-
- });
-
- });
- }
- },
-
- ajax_get_contents: function(post_id, clickedIndex)
- {
- if(content_retrieved[post_id] !== undefined)
- {
- methods.show_item(post_id, clickedIndex);
- return;
- }
-
- content_retrieved[post_id] = $('#avia-tmpl-portfolio-preview-' + post_id.replace(/ID_/,"")).html();
-
- //this line is necessary to prevent w3 total cache from messing up the portfolio if inline js is compressed
- content_retrieved[post_id] = content_retrieved[post_id].replace('/*<![CDATA[*/','').replace('*]]>','');
-
- methods.attach_item(post_id);
-
- $.avia_utilities.preload({container: content_retrieved[post_id] , single_callback: function(){ methods.show_item(post_id, clickedIndex); }});
- },
-
- add_controls: function()
- {
- controls = target_wrap.find('.ajax_controlls');
- target_wrap.avia_keyboard_controls({27:'.avia_close', 37:'.ajax_previous', 39:'.ajax_next'});
- //target_wrap.avia_swipe_trigger({prev:'.ajax_previous', next:'.ajax_next'});
-
- items.each(function(){
-
- var current = $(this), overlay;
-
- current.addClass('no_combo').bind('click', function(event)
- {
- overlay = current.find('.slideshow_overlay');
-
- if(overlay.length)
- {
- event.stopPropagation();
- methods.load_item.apply(current.find('a:eq(0)'));
- return false;
- }
- });
-
-
- });
- },
-
- control_click: function()
- {
- var showItem,
- activeID = container.find('.active_portfolio_item').data('ajax-id'),
- active = container.find('.post-entry-'+activeID);
-
- switch(this.hash)
- {
- case '#next':
-
- showItem = active.nextAll('.post-entry:visible:eq(0)').find('a:eq(0)');
- if(!showItem.length) { showItem = $('.post-entry:visible:eq(0)', container).find('a:eq(0)'); }
- showItem.trigger('click');
-
- break;
- case '#prev':
-
- showItem = active.prevAll('.post-entry:visible:eq(0)').find('a:eq(0)');
- if(!showItem.length) { showItem = $('.post-entry:visible:last', container).find('a:eq(0)'); }
- showItem.trigger('click');
-
- break;
- case '#close':
-
- animating = true;
-
- target_wrap.slideUp( options.timing, options.easing, function()
- {
- container.find('.active_portfolio_item').removeClass('active_portfolio_item');
- content_retrieved[is_open].attr({'style':""}).removeClass('open_slide');
- target_wrap.removeClass('open_container');
- animating = is_open = index_open = false;
- methods.remove_video();
- the_body.trigger('av_resize_finished');
- });
-
- break;
- }
- return false;
- },
-
-
- resize_reset: function()
- {
- if(is_open === false)
- {
- target_container.html('');
- content_retrieved = [];
- }
- }
- };
-
- methods.add_controls();
-
- container.on("click", "a", methods.load_item);
- controls.on("click", "a", methods.control_click);
- if(jQuery.support.leadingWhitespace) { win.bind('debouncedresize', methods.resize_reset); }
-
- });
- };
- }(jQuery));
- // -------------------------------------------------------------------------------------------
- // Fullscreen Slideshow
- //
- // extends avia slideshow script with a more sophisticated preloader and fixed size for slider
- // -------------------------------------------------------------------------------------------
- $.AviaFullscreenSlider = function(options, slider)
- {
- this.$slider = $( slider );
- this.$inner = this.$slider.find('.avia-slideshow-inner');
- this.$innerLi = this.$inner.find('>li');
- this.$caption = this.$inner.find('.avia-slide-wrap .caption_container');
- this.$win = $( window );
- this.isMobile = $.avia_utilities.isMobile;
- this.property = {};
- this.scrollPos = "0";
- this.transform3d= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
- this.ticking = false;
-
-
- if($.avia_utilities.supported.transition === undefined)
- {
- $.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
- }
-
- this._init( options );
- }
- $.AviaFullscreenSlider.defaults = {
- //height of the slider in percent
- height: 100,
-
- //subtract elements from the height
- subtract: '#wpadminbar, #header, #main>.title_container'
-
-
- };
- $.AviaFullscreenSlider.prototype =
- {
- _init: function( options )
- {
- var _self = this;
- //set the default options
- this.options = $.extend( true, {}, $.AviaFullscreenSlider.defaults, options );
-
- if(this.$slider.data('slide_height')) this.options.height = this.$slider.data('slide_height');
-
- //elements that get subtracted from the image height
- this.$subtract = $(this.options.subtract);
-
-
- // set the slideshow size
- this._setSize();
-
- // set resizing script on window resize
- this.$win.on( 'debouncedresize', $.proxy( this._setSize, this) );
-
- //parallax scroll if element if leaving viewport
- setTimeout(function()
- {
- if(!_self.isMobile) //disable parallax scrolling on mobile
- _self.$win.on( 'scroll', $.proxy( _self._on_scroll, _self) );
-
- },100);
- /**/
-
- //activate the defaule slider
- this.$slider.aviaSlider({bg_slider:true});
-
-
- },
-
- _on_scroll: function(e)
- {
- var _self = this;
-
- if(!_self.ticking) {
- _self.ticking = true;
- window.requestAnimationFrame( $.proxy( _self._parallax_scroll, _self) );
- }
- },
-
-
- _fetch_properties: function(slide_height)
- {
- this.property.offset = this.$slider.offset().top;
- this.property.wh = this.$win.height();
- this.property.height = slide_height || this.$slider.outerHeight();
-
- //re-position the slider
- this._parallax_scroll();
- },
-
- _setSize: function( )
- {
- if(!$.fn.avia_browser_height)
- {
-
- var viewport = this.$win.height(),
- slide_height = Math.ceil( (viewport / 100) * this.options.height );
-
- if(this.$subtract.length && this.options.height == 100)
- {
- this.$subtract.each(function()
- {
- slide_height -= this.offsetHeight - 0.5;
- });
- }
- else
- {
- slide_height -= 1;
- }
- this.$slider.height(slide_height).removeClass('av-default-height-applied');
- this.$inner.css('padding',0);
- }
-
-
- this._fetch_properties(slide_height);
- },
-
- _parallax_scroll: function(e)
- {
- if(this.isMobile) return; //disable parallax scrolling on mobile
-
- var winTop = this.$win.scrollTop(),
- winBottom = winTop + this.property.wh,
- scrollPos = "0",
- prop = {}, prop2 = {};
-
- if(this.property.offset < winTop && winTop <= this.property.offset + this.property.height)
- {
- scrollPos = Math.round( (winTop - this.property.offset) * 0.3 );
- }
-
- if(this.scrollPos != scrollPos)
- {
- //slide background parallax
- this.scrollPos = scrollPos;
-
- //currently no 3d transform, because of browser quirks
- //this.transform3d = false;
-
- if(this.transform3d)
- {
- prop[$.avia_utilities.supported.transition+"transform"] = "translate3d(0px,"+ scrollPos +"px,0px)";
- }
- else
- {
- prop[$.avia_utilities.supported.transition+"transform"] = "translate(0px,"+ scrollPos +"px)";
- }
-
-
- this.$inner.css(prop);
-
-
-
- //slider caption parallax
-
- // prop2[$.avia_utilities.supported.transition+"transform"] = "translate(0px,-"+ ( scrollPos * 1) +"px)";
- /*
- prop2['opacity'] = Math.ceil((this.$slider.height() - (scrollPos * 2)) / 100)/ 10;
- prop2['opacity'] = prop2['opacity'] < 0 ? 0 : prop2['opacity'];
- this.$caption.css(prop2);
- */
- }
-
- this.ticking = false;
- }
- };
- $.fn.aviaFullscreenSlider = function( options )
- {
- return this.each(function()
- {
- var active = $.data( this, 'aviaFullscreenSlider' );
- if(!active)
- {
- //make sure that the function doesnt get aplied a second time
- $.data( this, 'aviaFullscreenSlider', 1 );
-
- //create the preparations for fullscreen slider
- new $.AviaFullscreenSlider( options, this );
- }
- });
- }
-
- // -------------------------------------------------------------------------------------------
- // makes sure that the fixed container height is removed once the layerslider is loaded, so it adapts to the screen resolution
- // -------------------------------------------------------------------------------------------
- $.AviaParallaxElement = function(options, element)
- {
- this.$el = $( element ).addClass('active-parallax');
- this.$win = $( window );
- this.$body = $( 'body' );
- this.$parent = this.$el.parent();
- this.property = {};
- this.isMobile = $.avia_utilities.isMobile;
- this.ratio = this.$el.data('avia-parallax-ratio') || 0.5;
- this.transform = document.documentElement.className.indexOf('avia_transform') !== -1 ? true : false;
- this.transform3d= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
- this.ticking = false;
-
- if($.avia_utilities.supported.transition === undefined)
- {
- $.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
- }
-
- this._init( options );
- }
-
- $.AviaParallaxElement.prototype = {
-
- _init: function( options )
- {
- var _self = this;
- if(_self.isMobile)
- {
- return; //disable parallax scrolling on mobile
- }
-
- //fetch window constants
- setTimeout(function()
- {
- _self._fetch_properties();
- },30);
-
- this.$win.on("debouncedresize av-height-change", $.proxy( _self._fetch_properties, _self));
- this.$body.on("av_resize_finished", $.proxy( _self._fetch_properties, _self));
-
-
-
- //activate the scrolling
- setTimeout(function()
- {
- _self.$win.on( 'scroll', $.proxy( _self._on_scroll, _self) );
-
- },100);
- },
-
- _fetch_properties: function()
- {
- this.property.offset = this.$parent.offset().top;
- this.property.wh = this.$win.height();
- this.property.height = this.$parent.outerHeight();
-
- //set the height of the element based on the windows height, offset ratio and parent height
- this.$el.height(Math.ceil((this.property.wh * this.ratio) + this.property.height));
-
- //re-position the element
- this._parallax_scroll();
- },
-
- _on_scroll: function(e)
- {
- var _self = this;
-
- if(!_self.ticking) {
- _self.ticking = true;
- window.requestAnimationFrame( $.proxy( _self._parallax_scroll, _self) );
- }
- },
-
- _parallax_scroll: function(e)
- {
- var winTop = this.$win.scrollTop(),
- winBottom = winTop + this.property.wh,
- scrollPos = "0",
- prop = {};
-
- //shift element when it moves into viewport
- if(this.property.offset < winBottom && winTop <= this.property.offset + this.property.height)
- {
- scrollPos = Math.ceil( (winBottom - this.property.offset) * this.ratio );
-
- //parallax movement via backround position change, although
- if(this.transform3d)
- {
- prop[$.avia_utilities.supported.transition+"transform"] = "translate3d(0px,"+ scrollPos +"px, 0px)";
- }
- else if(this.transform)
- {
- prop[$.avia_utilities.supported.transition+"transform"] = "translate(0px,"+ scrollPos +"px)";
- }
- else
- {
- prop["background-position"] = "0px "+ scrollPos +"px";
- }
-
- this.$el.css(prop);
- }
-
- this.ticking = false;
- }
- };
- $.fn.avia_parallax = function(options)
- {
- return this.each(function()
- {
- var self = $.data( this, 'aviaParallax' );
- if(!self)
- {
- self = $.data( this, 'aviaParallax', new $.AviaParallaxElement( options, this ) );
- }
- });
- }
- // -------------------------------------------------------------------------------------------
- // Helper to allow fixed bgs on mobile
- // -------------------------------------------------------------------------------------------
- $.fn.avia_mobile_fixed = function(options)
- {
- var isMobile = $.avia_utilities.isMobile;
- if(!isMobile) return;
-
- return this.each(function()
- {
- var current = $(this).addClass('av-parallax-section'),
- $background = current.attr('style'),
- $attachment_class = current.data('section-bg-repeat'),
- template = "";
-
- if($attachment_class == 'stretch' || $attachment_class == 'no-repeat' )
- {
- $attachment_class = " avia-full-stretch";
- }
- else
- {
- $attachment_class = "";
- }
-
- template = "<div class='av-parallax " + $attachment_class + "' data-avia-parallax-ratio='0.0' style = '" + $background + "' ></div>";
-
- current.prepend(template);
- current.attr('style','');
- });
- }
-
- // -------------------------------------------------------------------------------------------
- // makes sure that the fixed container height is removed once the layerslider is loaded, so it adapts to the screen resolution
- // -------------------------------------------------------------------------------------------
- $.fn.layer_slider_height_helper = function(options)
- {
- return this.each(function()
- {
- var container = $(this),
- first_div = container.find('>div:first'),
- timeout = false,
- counter = 0,
- reset_size = function()
- {
- if(first_div.height() > 0 || counter > 5)
- {
- container.height('auto');
- }
- else
- {
- timeout = setTimeout(reset_size, 500);
- counter++;
- }
- };
- if(!first_div.length) return;
- timeout = setTimeout(reset_size, 0);
- });
- }
- // -------------------------------------------------------------------------------------------
- // testimonial shortcode javascript
- // -------------------------------------------------------------------------------------------
- $.fn.avia_sc_testimonial = function(options)
- {
- return this.each(function()
- {
- var container = $(this), elements = container.find('.avia-testimonial');
- //trigger displaying of thumbnails
- container.on('avia_start_animation', function()
- {
- elements.each(function(i)
- {
- var element = $(this);
- setTimeout(function(){ element.addClass('avia_start_animation') }, (i * 150));
- });
- });
- });
- }
- // -------------------------------------------------------------------------------------------
- // Progress bar shortcode javascript
- // -------------------------------------------------------------------------------------------
- $.fn.avia_sc_progressbar = function(options)
- {
- return this.each(function()
- {
- var container = $(this), elements = container.find('.progress');
- //trigger displaying of thumbnails
- container.on('avia_start_animation', function()
- {
- elements.each(function(i)
- {
- var element = $(this);
- setTimeout(function(){ element.addClass('avia_start_animation') }, (i * 250));
- });
- });
- });
- }
- // -------------------------------------------------------------------------------------------
- // Iconlist shortcode javascript
- // -------------------------------------------------------------------------------------------
- $.fn.avia_sc_iconlist = function(options)
- {
- return this.each(function()
- {
- var iconlist = $(this), elements = iconlist.find('>li');
- //trigger displaying of thumbnails
- iconlist.on('avia_start_animation', function()
- {
- elements.each(function(i)
- {
- var element = $(this);
- setTimeout(function(){ element.addClass('avia_start_animation') }, (i * 350));
- });
- });
- });
- }
- // -------------------------------------------------------------------------------------------
- // shortcode javascript for delayed animation even when non connected elements are used
- // -------------------------------------------------------------------------------------------
- $.fn.avia_sc_animation_delayed = function(options)
- {
- var global_timer = 0,
- delay = options.delay || 50;
- return this.each(function()
- {
- var elements = $(this);
- //trigger displaying of thumbnails
- elements.on('avia_start_animation', function()
- {
- var element = $(this);
- global_timer ++;
- setTimeout(function(){ element.addClass('avia_start_delayed_animation'); global_timer --; }, (global_timer * delay));
- });
- });
- }
- // -------------------------------------------------------------------------------------------
- // Section Height Helper
- // -------------------------------------------------------------------------------------------
- $.fn.avia_browser_height = function()
- {
- if(!this.length) return;
-
- var win = $(window),
- html_el = $('html'),
- subtract = $('#wpadminbar, #header.av_header_top:not(.html_header_transparency #header), #main>.title_container'),
- css_block = $("<style type='text/css' id='av-browser-height'></style>").appendTo('head:first'),
- sidebar_menu= $('.html_header_sidebar #top #header_main'),
- full_slider = $('.html_header_sidebar .avia-fullscreen-slider.avia-builder-el-0.avia-builder-el-no-sibling').addClass('av-solo-full'),
- calc_height = function()
- {
- var css = "",
- wh100 = win.height(),
- ww100 = win.width(),
- wh100_mod = wh100,
- whCover = (wh100 / 9) * 16,
- wwCover = (ww100 / 16) * 9,
- wh75 = Math.round( wh100 * 0.75 ),
- wh50 = Math.round( wh100 * 0.5 ),
- wh25 = Math.round( wh100 * 0.25 ),
- solo = 0;
-
- if(sidebar_menu.length) solo = sidebar_menu.height();
-
- subtract.each(function(){ wh100_mod -= this.offsetHeight - 1; });
-
- var whCoverMod = (wh100_mod / 9) * 16;
-
- //fade in of section content with minimum height once the height has been calculated
- css += ".avia-section.av-minimum-height .container{opacity: 1; }\n";
-
- //various section heights (100-25% as well as 100% - header/adminbar in case its the first builder element)
- css += ".av-minimum-height-100 .container, .avia-fullscreen-slider .avia-slideshow, #top.avia-blank .av-minimum-height-100 .container{height:"+wh100+"px;}\n";
- css += ".av-minimum-height-75 .container {height:"+wh75+"px;}\n";
- css += ".av-minimum-height-50 .container {height:"+wh50+"px;}\n";
- css += ".av-minimum-height-25 .container {height:"+wh25+"px;}\n";
- css += ".avia-builder-el-0.av-minimum-height-100 .container, .avia-builder-el-0.avia-fullscreen-slider .avia-slideshow{height:"+wh100_mod+"px;}\n";
-
- css += "#top .av-solo-full .avia-slideshow {min-height:"+solo+"px;}\n";
-
- //fullscreen video calculations
- if(ww100/wh100 < 16/9)
- {
- css += "#top .av-element-cover iframe, #top .av-element-cover embed, #top .av-element-cover object, #top .av-element-cover video{width:"+whCover+"px; left: -"+(whCover - ww100)/2+"px;}\n";
- }
- else
- {
- css += "#top .av-element-cover iframe, #top .av-element-cover embed, #top .av-element-cover object, #top .av-element-cover video{height:"+wwCover+"px; top: -"+(wwCover - wh100)/2+"px;}\n";
- }
-
- if(ww100/wh100_mod < 16/9)
- {
- css += "#top .avia-builder-el-0 .av-element-cover iframe, #top .avia-builder-el-0 .av-element-cover embed, #top .avia-builder-el-0 .av-element-cover object, #top .avia-builder-el-0 .av-element-cover video{width:"+whCoverMod+"px; left: -"+(whCoverMod - ww100)/2+"px;}\n";
- }
- else
- {
- css += "#top .avia-builder-el-0 .av-element-cover iframe, #top .avia-builder-el-0 .av-element-cover embed, #top .avia-builder-el-0 .av-element-cover object, #top .avia-builder-el-0 .av-element-cover video{height:"+wwCover+"px; top: -"+(wwCover - wh100_mod)/2+"px;}\n";
- }
-
- //ie8 needs different insert method
- try{
- css_block.text(css);
- }
- catch(err){
- css_block.remove();
- css_block = $("<style type='text/css' id='av-browser-height'>"+css+"</style>").appendTo('head:first');
- }
-
-
- setTimeout(function(){ win.trigger('av-height-change'); /*broadcast the height change*/ },100);
- };
-
- win.on( 'debouncedresize', calc_height);
- calc_height();
- }
- // -------------------------------------------------------------------------------------------
- // Video Section helper
- // -------------------------------------------------------------------------------------------
- $.fn.avia_video_section = function()
- {
- if(!this.length) return;
-
- var elements = this.length, content = "",
- win = $(window),
- css_block = $("<style type='text/css' id='av-section-height'></style>").appendTo('head:first'),
- calc_height = function(section, counter)
- {
- if(counter === 0) { content = "";}
-
- var css = "",
- the_id = '#' +section.attr('id'),
- wh100 = section.height(),
- ww100 = section.width(),
- aspect = section.data('sectionVideoRatio').split(':'),
- video_w = aspect[0],
- video_h = aspect[1],
- whCover = (wh100 / video_h ) * video_w,
- wwCover = (ww100 / video_w ) * video_h;
-
- //fullscreen video calculations
- if(ww100/wh100 < video_w/video_h)
- {
- css += "#top "+the_id+" .av-section-video-bg iframe, #top "+the_id+" .av-section-video-bg embed, #top "+the_id+" .av-section-video-bg object, #top "+the_id+" .av-section-video-bg video{width:"+whCover+"px; left: -"+(whCover - ww100)/2+"px;}\n";
- }
- else
- {
- css += "#top "+the_id+" .av-section-video-bg iframe, #top "+the_id+" .av-section-video-bg embed, #top "+the_id+" .av-section-video-bg object, #top "+the_id+" .av-section-video-bg video{height:"+wwCover+"px; top: -"+(wwCover - wh100)/2+"px;}\n";
- }
-
- content = content + css;
-
- if(elements == counter + 1)
- {
- //ie8 needs different insert method
- try{
- css_block.text(content);
- }
- catch(err){
- css_block.remove();
- css_block = $("<style type='text/css' id='av-section-height'>"+content+"</style>").appendTo('head:first');
- }
- }
- };
-
-
- return this.each(function(i)
- {
- var self = $(this);
-
- win.on( 'debouncedresize', function(){ calc_height(self, i); });
- calc_height(self, i);
- });
-
- }
- // -------------------------------------------------------------------------------------------
- // Gallery shortcode javascript
- // -------------------------------------------------------------------------------------------
- $.fn.avia_sc_gallery = function(options)
- {
- return this.each(function()
- {
- var gallery = $(this), images = gallery.find('img'), big_prev = gallery.find('.avia-gallery-big');
- //trigger displaying of thumbnails
- gallery.on('avia_start_animation', function()
- {
- images.each(function(i)
- {
- var image = $(this);
- setTimeout(function(){ image.addClass('avia_start_animation') }, (i * 110));
- });
- });
-
- if(gallery.hasClass('deactivate_avia_lazyload')) gallery.trigger('avia_start_animation');
- //trigger thumbnail hover and big prev image change
- if(big_prev.length)
- {
- gallery.on('mouseenter','.avia-gallery-thumb a', function()
- {
- var _self = this;
- big_prev.attr('data-onclick', _self.getAttribute("data-onclick"));
- big_prev.height(big_prev.height());
- big_prev.attr('href', _self.href)
- var newImg = _self.getAttribute("data-prev-img"),
- oldImg = big_prev.find('img'),
- oldImgSrc = oldImg.attr('src');
- if(newImg != oldImgSrc)
- {
- var next_img = new Image();
- next_img.src = newImg;
-
- var $next = $(next_img);
-
- if(big_prev.hasClass('avia-gallery-big-no-crop-thumb'))
- {
- $next.css({'height':big_prev.height(),'width':'auto'});
- }
-
- big_prev.stop().animate({opacity:0}, function()
- {
- $next.insertAfter(oldImg);
- oldImg.remove();
- big_prev.animate({opacity:1});
-
- big_prev.attr('title',$(_self).attr('title'));
-
- });
- }
- });
- big_prev.on('click', function()
- {
- var imagelink = gallery.find('.avia-gallery-thumb a').eq(this.getAttribute("data-onclick") - 1);
- if(imagelink && !imagelink.hasClass('aviaopeninbrowser'))
- {
- imagelink.trigger('click');
- }
- else if(imagelink)
- {
- var imgurl = imagelink.attr("href");
- if(imagelink.hasClass('aviablank') && imgurl != '' )
- {
- window.open(imgurl, '_blank');
- }
- else if( imgurl != '' )
- {
- window.open(imgurl, '_self');
- }
- }
- return false;
- });
- $(window).on("debouncedresize", function()
- {
- big_prev.height('auto');
- });
- }
- });
- }
- // -------------------------------------------------------------------------------------------
- // Toggle shortcode javascript
- // -------------------------------------------------------------------------------------------
- $.fn.avia_sc_toggle = function(options)
- {
- var defaults =
- {
- single: '.single_toggle',
- heading: '.toggler',
- content: '.toggle_wrap',
- sortContainer:'.taglist'
- };
- var win = $(window),
- options = $.extend(defaults, options);
- return this.each(function()
- {
- var container = $(this).addClass('enable_toggles'),
- toggles = $(options.single, container),
- heading = $(options.heading, container),
- allContent = $(options.content, container),
- sortLinks = $(options.sortContainer + " a", container);
- heading.each(function(i)
- {
- var thisheading = $(this), content = thisheading.next(options.content, container);
- function scroll_to_viewport()
- {
- //check if toggle title is in viewport. if not scroll up
- var el_offset = content.offset().top,
- scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10);
- if(win.scrollTop() > el_offset)
- {
- $('html:not(:animated),body:not(:animated)').animate({scrollTop: scoll_target},200);
- }
- }
- if(content.css('visibility') != "hidden")
- {
- thisheading.addClass('activeTitle');
- }
- thisheading.on('click', function()
- {
- if(content.css('visibility') != "hidden")
- {
- content.slideUp(200, function()
- {
- content.removeClass('active_tc').attr({style:''});
- win.trigger('av-height-change');
- });
- thisheading.removeClass('activeTitle');
- }
- else
- {
- if(container.is('.toggle_close_all'))
- {
- allContent.not(content).slideUp(200, function()
- {
- $(this).removeClass('active_tc').attr({style:''});
- scroll_to_viewport();
- });
- heading.removeClass('activeTitle');
- }
- content.addClass('active_tc').slideDown(200,
-
- function()
- {
- if(!container.is('.toggle_close_all'))
- {
- scroll_to_viewport();
- }
-
- win.trigger('av-height-change');
- }
-
- );
- thisheading.addClass('activeTitle');
- location.replace(thisheading.data('fake-id'));
- }
-
-
-
- });
- });
- sortLinks.click(function(e){
- e.preventDefault();
- var show = toggles.filter('[data-tags~="'+$(this).data('tag')+'"]'),
- hide = toggles.not('[data-tags~="'+$(this).data('tag')+'"]');
- sortLinks.removeClass('activeFilter');
- $(this).addClass('activeFilter');
- heading.filter('.activeTitle').trigger('click');
- show.slideDown();
- hide.slideUp();
- });
- function trigger_default_open(hash)
- {
- if(!hash && window.location.hash) hash = window.location.hash;
- if(!hash) return;
-
- var open = heading.filter('[data-fake-id="'+hash+'"]');
- if(open.length)
- {
- if(!open.is('.activeTitle')) open.trigger('click');
- window.scrollTo(0, container.offset().top - 70);
- }
- }
- trigger_default_open(false);
-
- $('a').on('click',function(){
- var hash = $(this).attr('href');
- if(typeof hash != "undefined" && hash)
- {
- hash = hash.replace(/^.*?#/,'');
- trigger_default_open('#'+hash);
- }
- });
- });
- };
- // -------------------------------------------------------------------------------------------
- // Tab Shortcode
- // -------------------------------------------------------------------------------------------
- $.fn.avia_sc_tabs= function(options)
- {
- var defaults =
- {
- heading: '.tab',
- content:'.tab_content',
- active:'active_tab',
- sidebar: false
- };
- var win = $(window)
- options = $.extend(defaults, options);
- return this.each(function()
- {
- var container = $(this),
- tab_titles = $('<div class="tab_titles"></div>').prependTo(container),
- tabs = $(options.heading, container),
- content = $(options.content, container),
- newtabs = false,
- oldtabs = false;
- newtabs = tabs.clone();
- oldtabs = tabs.addClass('fullsize-tab');
- tabs = newtabs;
- tabs.prependTo(tab_titles).each(function(i)
- {
- var tab = $(this), the_oldtab = false;
- if(newtabs) the_oldtab = oldtabs.filter(':eq('+i+')');
- tab.addClass('tab_counter_'+i).bind('click', function()
- {
- open_content(tab, i, the_oldtab);
- return false;
- });
- if(newtabs)
- {
- the_oldtab.bind('click', function()
- {
- open_content(the_oldtab, i, tab);
- return false;
- });
- }
- });
- set_size();
- trigger_default_open(false);
- win.on("debouncedresize", set_size);
-
- $('a').on('click',function(){
- var hash = $(this).attr('href');
- if(typeof hash != "undefined" && hash)
- {
- hash = hash.replace(/^.*?#/,'');
- trigger_default_open('#'+hash);
- }
- });
- function set_size()
- {
- if(!options.sidebar) return;
- content.css({'min-height': tab_titles.outerHeight() + 1});
- }
- function open_content(tab, i, alternate_tab)
- {
- if(!tab.is('.'+options.active))
- {
- $('.'+options.active, container).removeClass(options.active);
- $('.'+options.active+'_content', container).removeClass(options.active+'_content');
- tab.addClass(options.active);
- var new_loc = tab.data('fake-id');
- if(typeof new_loc == 'string') location.replace(new_loc);
- if(alternate_tab) alternate_tab.addClass(options.active);
- var active_c = content.filter(':eq('+i+')').addClass(options.active+'_content');
- if(typeof click_container != 'undefined' && click_container.length)
- {
- sidebar_shadow.height(active_c.outerHeight());
- }
-
- //check if tab title is in viewport. if not scroll up
- var el_offset = active_c.offset().top,
- scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10);
-
- if(win.scrollTop() > el_offset)
- {
- $('html:not(:animated),body:not(:animated)').scrollTop(scoll_target);
- }
- }
- }
- function trigger_default_open(hash)
- {
- if(!hash && window.location.hash) hash = window.location.hash;
- if(!hash) return;
-
- var open = tabs.filter('[data-fake-id="'+hash+'"]');
- if(open.length)
- {
- if(!open.is('.active_tab')) open.trigger('click');
- window.scrollTo(0, container.offset().top - 70);
- }
- }
- });
- };
- // -------------------------------------------------------------------------------------------
- // Big Number animation shortcode javascript
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- $.fn.avia_sc_animated_number = function(options)
- {
- var skipStep = false,
- start_count = function(element, countTo, increment, current, fakeCountTo)
- {
- //calculate the new number
- var newCount = current + increment;
-
- //if the number is bigger than our final number set the number and finish
- if(newCount >= fakeCountTo)
- {
- element.text(countTo); //exit
- }
- else
- {
- var prepend = "", addZeros = countTo.toString().length - newCount.toString().length
-
- //if the number has less digits than the final number some zeros where omitted. add them to the front
- for(var i = addZeros; i > 0; i--){ prepend += "0"; }
-
- element.text(prepend + newCount);
- window.requestAnimationFrame(function(){ start_count(element, countTo, increment, newCount, fakeCountTo) });
- }
- };
-
- return this.each(function()
- {
- var number_container = $(this), elements = number_container.find('.avia-single-number'), countTimer = number_container.data('timer') || 3000;
-
- //prepare elements
- elements.each(function(i)
- {
- var element = $(this), text = element.text();
- if(window.addEventListener) element.text( text.replace(/./g, "0")); /*https://github.com/AviaThemes/wp-themes/issues/812*/
- });
-
- //trigger number animation
- number_container.addClass('number_prepared').on('avia_start_animation', function()
- {
- if(number_container.is('.avia_animation_done')) return;
- number_container.addClass('avia_animation_done');
-
- elements.each(function(i)
- {
- var element = $(this), countTo = element.data('number'), fakeCountTo = countTo, current = parseInt(element.text(),10), zeroOnly = /^0+$/.test(countTo), increment = 0;
-
- //fallback for decimals like 00 or 000
- if(zeroOnly && countTo !== 0) fakeCountTo = countTo.replace(/0/g, '9');
-
- increment = Math.round( fakeCountTo * 32 / countTimer);
- if(increment == 0 || increment % 10 == 0) increment += 1;
-
- setTimeout(function(){ start_count(element, countTo, increment, current, fakeCountTo);}, 300);
- });
- });
- });
- }
- })(jQuery);
- // -------------------------------------------------------------------------------------------
- // contact form ajax
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- $.fn.avia_ajax_form = function(variables)
- {
- var defaults =
- {
- sendPath: 'send.php',
- responseContainer: '.ajaxresponse'
- };
- var options = $.extend(defaults, variables);
- return this.each(function()
- {
- var form = $(this),
- form_sent = false,
- send =
- {
- formElements: form.find('textarea, select, input[type=text], input[type=checkbox], input[type=hidden]'),
- validationError:false,
- button : form.find('input:submit'),
- dataObj : {}
- },
- responseContainer = form.next(options.responseContainer+":eq(0)");
- send.button.bind('click', checkElements);
-
-
- //change type of email forms on mobile so the e-mail keyboard with @ sign is used
- if($.avia_utilities.isMobile)
- {
- send.formElements.each(function(i)
- {
- var currentElement = $(this), is_email = currentElement.hasClass('is_email');
- if(is_email) currentElement.attr('type','email');
- });
- }
-
- function checkElements( e )
- {
- // reset validation var and send data
- send.validationError = false;
- send.datastring = 'ajax=true';
- send.formElements.each(function(i)
- {
- var currentElement = $(this),
- surroundingElement = currentElement.parent(),
- value = currentElement.val(),
- name = currentElement.attr('name'),
- classes = currentElement.attr('class'),
- nomatch = true;
- if(currentElement.is(':checkbox'))
- {
- if(currentElement.is(':checked')) { value = true } else {value = ''}
- }
- send.dataObj[name] = encodeURIComponent(value);
- if(classes && classes.match(/is_empty/))
- {
- if(value == '')
- {
- surroundingElement.removeClass("valid error ajax_alert").addClass("error");
- send.validationError = true;
- }
- else
- {
- surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
- }
- nomatch = false;
- }
- if(classes && classes.match(/is_email/))
- {
- if(!value.match(/^[\w|\.|\-]+@\w[\w|\.|\-]*\.[a-zA-Z]{2,20}$/))
- {
- surroundingElement.removeClass("valid error ajax_alert").addClass("error");
- send.validationError = true;
- }
- else
- {
- surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
- }
- nomatch = false;
- }
- if(classes && classes.match(/is_phone/))
- {
- if(!value.match(/^(\d|\s|\-|\/|\(|\)|\[|\]|e|x|t|ension|\.|\+|\_|\,|\:|\;){3,}$/))
- {
- surroundingElement.removeClass("valid error ajax_alert").addClass("error");
- send.validationError = true;
- }
- else
- {
- surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
- }
- nomatch = false;
- }
- if(classes && classes.match(/is_number/))
- {
- if(!($.isNumeric(value)) || value == "")
- {
- surroundingElement.removeClass("valid error ajax_alert").addClass("error");
- send.validationError = true;
- }
- else
- {
- surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
- }
- nomatch = false;
- }
- if(classes && classes.match(/captcha/))
- {
- var verifier = form.find("#" + name + "_verifier").val(),
- lastVer = verifier.charAt(verifier.length-1),
- finalVer = verifier.charAt(lastVer);
- if(value != finalVer)
- {
- surroundingElement.removeClass("valid error ajax_alert").addClass("error");
- send.validationError = true;
- }
- else
- {
- surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
- }
- nomatch = false;
- }
- if(nomatch && value != '')
- {
- surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
- }
- });
- if(send.validationError == false)
- {
- if(form.data('av-custom-send'))
- {
- mailchimp_send();
- }
- else
- {
- send_ajax_form();
- }
- }
-
- return false;
- }
-
-
- function send_ajax_form()
- {
- if(form_sent){ return false; }
- form_sent = true;
- send.button.addClass('av-sending-button');
- send.button.val(send.button.data('sending-label'));
-
- var redirect_to = form.data('avia-redirect') || false,
- action = form.attr('action');
-
- responseContainer.load(action+' '+options.responseContainer, send.dataObj, function()
- {
- if(redirect_to && action != redirect_to)
- {
- form.attr('action', redirect_to);
- location.href = redirect_to;
- // form.submit();
- }
- else
- {
- responseContainer.removeClass('hidden').css({display:"block"});
- form.slideUp(400, function(){responseContainer.slideDown(400, function(){ $('body').trigger('av_resize_finished'); }); send.formElements.val('');});
- }
- });
- }
-
-
- function mailchimp_send()
- {
- if(form_sent){ return false; }
- form_sent = true;
-
- var original_label = send.button.val();
- send.button.addClass('av-sending-button');
- send.button.val(send.button.data('sending-label'));
- send.dataObj.ajax_mailchimp = true;
-
- var redirect_to = form.data('avia-redirect') || false,
- action = form.attr('action'),
- error_msg_container = form.find('.av-form-error-container'),
- form_id = form.data('avia-form-id');
-
- $.ajax({
- url: action,
- type: "POST",
- data:send.dataObj,
- beforeSend: function()
- {
- if(error_msg_container.length)
- {
- error_msg_container.slideUp(400, function()
- {
- error_msg_container.remove();
- $('body').trigger('av_resize_finished');
- });
- }
- },
- success: function(responseText)
- {
- var response = jQuery("<div>").append(jQuery.parseHTML(responseText)),
- error = response.find('.av-form-error-container');
-
- if(error.length)
- {
- form_sent = false;
- form.prepend(error);
- error.css({display:"none"}).slideDown(400, function()
- {
- $('body').trigger('av_resize_finished');
- });
- send.button.removeClass('av-sending-button');
- send.button.val(original_label);
- }
- else
- {
- if(redirect_to && action != redirect_to)
- {
- form.attr('action', redirect_to);
- location.href = redirect_to;
- // form.submit();
- }
- else
- {
- var success_text = response.find(options.responseContainer + "_" + form_id);
-
- responseContainer.html(success_text).removeClass('hidden').css({display:"block"});
-
- form.slideUp(400, function()
- {
- responseContainer.slideDown(400, function()
- {
- $('body').trigger('av_resize_finished');
- });
-
- send.formElements.val('');
- });
- }
- }
-
- },
- error: function()
- {
-
- },
- complete: function()
- {
-
- }
- });
- }
-
-
- });
- };
- })(jQuery);
- // -------------------------------------------------------------------------------------------
- // Aviaccordion Slideshow
- //
- // accordion slider script
- // -------------------------------------------------------------------------------------------
- $.AviaccordionSlider = function(options, slider)
- {
- this.$slider = $( slider );
- this.$inner = this.$slider.find('.aviaccordion-inner');
- this.$slides = this.$inner.find('.aviaccordion-slide');
- this.$images = this.$inner.find('.aviaccordion-image');
- this.$last = this.$slides.filter(':last');
- this.$titles = this.$slider.find('.aviaccordion-preview');
- this.$titlePos = this.$slider.find('.aviaccordion-preview-title-pos');
- this.$titleWrap = this.$slider.find('.aviaccordion-preview-title-wrap');
- this.$win = $( window );
-
- if($.avia_utilities.supported.transition === undefined)
- {
- $.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
- }
-
- this.browserPrefix = $.avia_utilities.supported.transition;
- this.cssActive = this.browserPrefix !== false ? true : false;
- this.transform3d = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
- this.isMobile = $.avia_utilities.isMobile;
- this.property = this.browserPrefix + 'transform',
- this.count = this.$slides.length;
- this.open = false;
- this.autoplay = false;
- this.increaseTitle = this.$slider.is(".aviaccordion-title-on-hover");
- // this.cssActive = false; //testing no css3 browser
-
- this._init( options );
- }
- $.AviaccordionSlider.prototype =
- {
- _init: function( options )
- {
- var _self = this;
- _self.options = $.extend({}, options, this.$slider.data());
- $.avia_utilities.preload({container: this.$slider , single_callback: function(){ _self._kickOff(); }});
- },
-
- _kickOff: function()
- {
- var _self = this;
-
- _self._calcMovement();
- _self._bindEvents();
- _self._showImages();
- _self._autoplay();
- },
-
- _autoplay: function()
- {
- var _self = this;
-
- if(_self.options.autoplay)
- {
- _self.autoplay = setInterval(function()
- {
- _self.open = _self.open === false ? 0 : _self.open + 1;
- if(_self.open >= _self.count) _self.open = 0;
- _self._move({}, _self.open);
-
- }, _self.options.interval * 1000)
- }
- },
-
- _showImages: function()
- {
- var _self = this, counter = 0, delay = 300, title_delay = this.count * delay;
-
- if(this.cssActive)
- {
- setTimeout(function(){ _self.$slider.addClass('av-animation-active'); } , 10);
- }
-
- this.$images.each(function(i)
- {
- var current = $(this), timer = delay * (i + 1);
-
- setTimeout(function()
- {
- current.avia_animate({opacity:1}, 400, function()
- {
- current.css($.avia_utilities.supported.transition + "transform", "none");
- });
- },timer);
- });
-
- if(_self.increaseTitle) title_delay = 0;
-
- this.$titlePos.each(function(i)
- {
- var current = $(this), new_timer = title_delay + 100 * (i + 1);
-
- setTimeout(function()
- {
- current.avia_animate({opacity:1}, 200, function()
- {
- current.css($.avia_utilities.supported.transition + "transform", "none");
- });
- },new_timer);
- });
- },
-
- _bindEvents: function()
- {
- var trigger = this.isMobile ? "click" : "mouseenter";
-
- this.$slider.on(trigger,'.aviaccordion-slide', $.proxy( this._move, this));
- this.$slider.on('mouseleave','.aviaccordion-inner', $.proxy( this._move, this));
- this.$win.on('debouncedresize', $.proxy( this._calcMovement, this));
- this.$slider.on('av-prev av-next', $.proxy( this._moveTo, this));
-
- if(this.isMobile)
- {
- this.$slider.avia_swipe_trigger({next: this.$slider, prev: this.$slider, event:{prev: 'av-prev', next: 'av-next'}});
- }
-
- },
-
- _titleHeight: function()
- {
- var th = 0;
-
- this.$titleWrap.css({'height':'auto'}).each(function()
- {
- var new_h = $(this).outerHeight();
- if( new_h > th) th = new_h;
-
- }).css({'height':th + 2});
-
- },
-
- _calcMovement: function(event, allow_repeat)
- {
- var _self = this,
- containerWidth = this.$slider.width(),
- defaultPos = this.$last.data('av-left'),
- imgWidth = this.$images.filter(':last').width() || containerWidth,
- imgWidthPercent = Math.floor((100 / containerWidth) * imgWidth),
- allImageWidth = imgWidthPercent * _self.count,
- modifier = 3, // 10 - _self.count,
- tempMinLeft = 100 - imgWidthPercent,
- minLeft = tempMinLeft > defaultPos / modifier ? tempMinLeft : 0,
- oneLeft = minLeft / (_self.count -1 ),
- titleWidth = imgWidth;
-
-
-
- if(allImageWidth < 110 && allow_repeat !== false)
- {
- //set height if necessary
- var slideHeight = this.$slider.height(),
- maxHeight = (slideHeight / allImageWidth) * 110 ;
-
- this.$slider.css({'max-height': maxHeight});
- _self._calcMovement(event, false);
- return;
- }
-
- //backup so the minimized slides dont get too small
- if(oneLeft < 2) minLeft = 0;
-
- this.$slides.each(function(i)
- {
- var current = $(this), newLeft = 0, newRight = 0, defaultLeft = current.data('av-left');
-
- if( minLeft !== 0)
- {
- newLeft = oneLeft * i;
- newRight = imgWidthPercent + newLeft - oneLeft;
- }
- else
- {
- newLeft = defaultLeft / Math.abs(modifier);
- newRight = 100 - ((newLeft / i) * (_self.count - i));
- }
-
- if(i == 1 && _self.increaseTitle) { titleWidth = newRight + 1; }
-
- if(_self.cssActive)
- {
- //if we are not animating based on the css left value but on css transform we need to subtract the left value
- newLeft = newLeft - defaultLeft;
- newRight = newRight - defaultLeft;
- defaultLeft = 0;
- }
-
- current.data('av-calc-default', defaultLeft);
- current.data('av-calc-left', newLeft);
- current.data('av-calc-right', newRight);
-
- });
-
- if(_self.increaseTitle) { _self.$titles.css({width: titleWidth + "%"});}
- },
-
- _moveTo: function(event)
- {
- var direction = event.type == "av-next" ? 1 : -1,
- nextSlide = this.open === false ? 0 : this.open + direction;
-
- if(nextSlide >= 0 && nextSlide < this.$slides.length) this._move(event, nextSlide);
- },
-
- _move: function(event, direct_open)
- {
- var _self = this,
- slide = event.currentTarget,
- itemNo = typeof direct_open != "undefined" ? direct_open : this.$slides.index(slide);
-
- this.open = itemNo;
-
- if(_self.autoplay && typeof slide != "undefined") { clearInterval(_self.autoplay); _self.autoplay == false; }
-
- this.$slides.removeClass('aviaccordion-active-slide').each(function(i)
- {
- var current = $(this),
- dataSet = current.data(),
- trans_val = i <= itemNo ? dataSet.avCalcLeft : dataSet.avCalcRight,
- transition = {},
- reset = event.type == 'mouseleave' ? 1 : 0,
- active = itemNo === i ? _self.$titleWrap.eq(i) : false;
-
- if(active) current.addClass('aviaccordion-active-slide');
-
- if(reset)
- {
- trans_val = dataSet.avCalcDefault;
- this.open = false;
- }
-
- if(_self.cssActive) //do a css3 animation
- {
- //move the slides
- transition[_self.property] = _self.transform3d ? "translate3d(" + trans_val + "%, 0, 0)" : "translate(" + trans_val + "%,0)"; //3d or 2d transform?
- current.css(transition);
- }
- else
- {
- transition.left = trans_val + "%";
- current.stop().animate(transition, 700, 'easeOutQuint');
- }
- });
- }
- };
- $.fn.aviaccordion = function( options )
- {
- return this.each(function()
- {
- var active = $.data( this, 'AviaccordionSlider' );
- if(!active)
- {
- //make sure that the function doesnt get aplied a second time
- $.data( this, 'AviaccordionSlider', 1 );
-
- //create the preparations for fullscreen slider
- new $.AviaccordionSlider( options, this );
- }
- });
- }
- // -------------------------------------------------------------------------------------------
- // Aviaccordion Slideshow
- //
- // accordion slider script
- // -------------------------------------------------------------------------------------------
- $.AviaTextRotator = function(options, slider)
- {
- this.$win = $( window );
- this.$slider = $( slider );
- this.$inner = this.$slider.find('.av-rotator-text');
- this.$slides = this.$inner.find('.av-rotator-text-single');
- this.$current = this.$slides.eq(0);
- this.open = 0;
- this.count = this.$slides.length;
-
- if($.avia_utilities.supported.transition === undefined)
- {
- $.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
- }
-
- this.browserPrefix = $.avia_utilities.supported.transition;
- this.cssActive = this.browserPrefix !== false ? true : false;
- this.property = this.browserPrefix + 'transform',
-
- //this.cssActive = false; //testing no css3 browser
-
- this._init( options );
- }
- $.AviaTextRotator.prototype =
- {
- _init: function( options )
- {
- var _self = this;
-
- if(this.count <= 1) return;
-
- _self.options = $.extend({}, options, this.$slider.data());
- _self.$inner.addClass('av-rotation-active');
- if(_self.options.fixwidth == 1) this.$inner.width(this.$current.width());
- _self._autoplay();
- },
-
- _autoplay: function()
- {
- var _self = this;
-
- _self.autoplay = setInterval(function()
- {
- _self.open = _self.open === false ? 0 : _self.open + 1;
- if(_self.open >= _self.count) _self.open = 0;
- _self._move({}, _self.open);
-
- }, _self.options.interval * 1000)
- },
-
- _move: function(event)
- {
- var _self = this,
- modifier = 30 * _self.options.animation,
- fade_out = {opacity:0},
- fade_start = {display:'inline', opacity:0},
- fade_in = {opacity:1};
-
- this.$next = _self.$slides.eq(this.open);
-
- if(this.cssActive)
- {
- fade_out[_self.property] = "translate(0px," + modifier +"px)";
- fade_start[_self.property] = "translate(0px," + (modifier * -1) +"px)";
- fade_in[_self.property] = "translate(0px,0px)";
- }
- else
- {
- fade_out['top'] = modifier;
- fade_start['top'] = (modifier * -1);
- fade_in['top'] = 0;
- }
-
-
- _self.$current.avia_animate(fade_out, function()
- {
- _self.$current.css({display:'none'});
- _self.$next.css(fade_start).avia_animate(fade_in, function()
- {
- _self.$current = _self.$slides.eq(_self.open);
- });
- });
- }
- };
- $.fn.avia_textrotator = function( options )
- {
- return this.each(function()
- {
- var active = $.data( this, 'AviaTextRotator' );
- if(!active)
- {
- //make sure that the function doesnt get aplied a second time
- $.data( this, 'AviaTextRotator', 1 );
-
- //create the preparations for fullscreen slider
- new $.AviaTextRotator( options, this );
- }
- });
- }
- // -------------------------------------------------------------------------------------------
- // HELPER FUNCTIONS
- // -------------------------------------------------------------------------------------------
- //waipoint script when something comes into viewport
- $.fn.avia_waypoints = function(options_passed)
- {
- if(! $('html').is('.avia_transform')) return;
- var defaults = { offset: 'bottom-in-view' , triggerOnce: true},
- options = $.extend({}, defaults, options_passed),
- isMobile = $.avia_utilities.isMobile;
- return this.each(function()
- {
- var element = $(this);
-
- setTimeout(function()
- {
- if(isMobile)
- {
- element.addClass('avia_start_animation').trigger('avia_start_animation');
- }
- else
- {
- element.waypoint(function(direction)
- {
- $(this.element).addClass('avia_start_animation').trigger('avia_start_animation');
-
- }, options );
- }
- },100)
-
- });
- };
- // window resize script
- var $event = $.event, $special, resizeTimeout;
- $special = $event.special.debouncedresize = {
- setup: function() {
- $( this ).on( "resize", $special.handler );
- },
- teardown: function() {
- $( this ).off( "resize", $special.handler );
- },
- handler: function( event, execAsap ) {
- // Save the context
- var context = this,
- args = arguments,
- dispatch = function() {
- // set correct event type
- event.type = "debouncedresize";
- $event.dispatch.apply( context, args );
- };
- if ( resizeTimeout ) {
- clearTimeout( resizeTimeout );
- }
- execAsap ?
- dispatch() :
- resizeTimeout = setTimeout( dispatch, $special.threshold );
- },
- threshold: 150
- };
- $.easing['jswing'] = $.easing['swing'];
- $.extend( $.easing,
- {
- def: 'easeOutQuad',
- swing: function (x, t, b, c, d) { return $.easing[$.easing.def](x, t, b, c, d); },
- easeInQuad: function (x, t, b, c, d) { return c*(t/=d)*t + b; },
- easeOutQuad: function (x, t, b, c, d) { return -c *(t/=d)*(t-2) + b; },
- easeInOutQuad: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t + b; return -c/2 * ((--t)*(t-2) - 1) + b; },
- easeInCubic: function (x, t, b, c, d) { return c*(t/=d)*t*t + b; },
- easeOutCubic: function (x, t, b, c, d) { return c*((t=t/d-1)*t*t + 1) + b; },
- easeInOutCubic: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t + b; return c/2*((t-=2)*t*t + 2) + b; },
- easeInQuart: function (x, t, b, c, d) { return c*(t/=d)*t*t*t + b; },
- easeOutQuart: function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b; },
- easeInOutQuart: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t*t + b; return -c/2 * ((t-=2)*t*t*t - 2) + b; },
- easeInQuint: function (x, t, b, c, d) { return c*(t/=d)*t*t*t*t + b; },
- easeOutQuint: function (x, t, b, c, d) { return c*((t=t/d-1)*t*t*t*t + 1) + b; },
- easeInOutQuint: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; return c/2*((t-=2)*t*t*t*t + 2) + b; },
- easeInSine: function (x, t, b, c, d) { return -c * Math.cos(t/d * (Math.PI/2)) + c + b; },
- easeOutSine: function (x, t, b, c, d) { return c * Math.sin(t/d * (Math.PI/2)) + b; },
- easeInOutSine: function (x, t, b, c, d) { return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; },
- easeInExpo: function (x, t, b, c, d) { return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; },
- easeOutExpo: function (x, t, b, c, d) { return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; },
- easeInOutExpo: function (x, t, b, c, d) {
- if (t==0) return b;
- if (t==d) return b+c;
- if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
- return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
- },
- easeInCirc: function (x, t, b, c, d) { return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; },
- easeOutCirc: function (x, t, b, c, d) {return c * Math.sqrt(1 - (t=t/d-1)*t) + b; },
- easeInOutCirc: function (x, t, b, c, d) { if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; },
- easeInElastic: function (x, t, b, c, d) {
- var s=1.70158;var p=0;var a=c;
- if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
- if (a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
- },
- easeOutElastic: function (x, t, b, c, d) {
- var s=1.70158;var p=0;var a=c;
- if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
- if (a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
- },
- easeInOutElastic: function (x, t, b, c, d) {
- var s=1.70158;var p=0;var a=c;
- if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
- if (a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
- return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
- },
- easeInBack: function (x, t, b, c, d, s) {
- if (s == undefined) s = 1.70158;
- return c*(t/=d)*t*((s+1)*t - s) + b;
- },
- easeOutBack: function (x, t, b, c, d, s) {
- if (s == undefined) s = 1.70158;
- return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
- },
- easeInOutBack: function (x, t, b, c, d, s) {
- if (s == undefined) s = 1.70158;
- if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
- return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
- },
- easeInBounce: function (x, t, b, c, d) {
- return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
- },
- easeOutBounce: function (x, t, b, c, d) {
- if ((t/=d) < (1/2.75)) {
- return c*(7.5625*t*t) + b;
- } else if (t < (2/2.75)) {
- return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
- } else if (t < (2.5/2.75)) {
- return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
- } else {
- return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
- }
- },
- easeInOutBounce: function (x, t, b, c, d) {
- if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
- return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
- }
- });
- })( jQuery );
- /*utility functions*/
- (function($)
- {
- "use strict";
- $.avia_utilities = $.avia_utilities || {};
- /************************************************************************
- gloabl loading function
- *************************************************************************/
- $.avia_utilities.loading = function(attach_to, delay){
- var loader = {
- active: false,
- show: function()
- {
- if(loader.active === false)
- {
- loader.active = true;
- loader.loading_item.css({display:'block', opacity:0});
- }
- loader.loading_item.stop().animate({opacity:0.7});
- },
- hide: function()
- {
- if(typeof delay === 'undefined'){ delay = 600; }
- loader.loading_item.stop().delay( delay ).animate({opacity:0}, function()
- {
- loader.loading_item.css({display:'none'});
- loader.active = false;
- });
- },
- attach: function()
- {
- if(typeof attach_to === 'undefined'){ attach_to = 'body';}
- loader.loading_item = $('<div class="avia_loading_icon"></div>').css({display:"none"}).appendTo(attach_to);
- }
- }
- loader.attach();
- return loader;
- };
-
- /************************************************************************
- gloabl play/pause visualizer function
- *************************************************************************/
- $.avia_utilities.playpause = function(attach_to, delay){
- var pp = {
- active: false,
- to1: "",
- to2: "",
- set: function(status)
- {
- pp.loading_item.removeClass('av-play av-pause');
- pp.to1 = setTimeout(function(){ pp.loading_item.addClass('av-' + status); },10);
- pp.to2 = setTimeout(function(){ pp.loading_item.removeClass('av-' + status); },1500);
- },
- attach: function()
- {
- if(typeof attach_to === 'undefined'){ attach_to = 'body';}
- pp.loading_item = $('<div class="avia_playpause_icon"></div>').css({display:"none"}).appendTo(attach_to);
- }
- }
- pp.attach();
- return pp;
- };
-
-
- /************************************************************************
- preload images, as soon as all are loaded trigger a special load ready event
- *************************************************************************/
- $.avia_utilities.preload = function(options_passed)
- {
- new $.AviaPreloader(options_passed);
- }
-
- $.AviaPreloader = function(options)
- {
- this.win = $(window);
- this.defaults =
- {
- container: 'body',
- maxLoops: 10,
- trigger_single: true,
- single_callback: function(){},
- global_callback: function(){}
- };
- this.options = $.extend({}, this.defaults, options);
- this.preload_images = 0;
-
- this.load_images();
- }
-
- $.AviaPreloader.prototype =
- {
- load_images: function()
- {
- var _self = this;
-
- if(typeof _self.options.container === 'string'){ _self.options.container = $(_self.options.container); }
- _self.options.container.each(function()
- {
- var container = $(this);
-
- container.images = container.find('img');
- container.allImages = container.images;
-
- _self.preload_images += container.images.length;
- setTimeout(function(){ _self.checkImage(container); }, 10);
- });
- },
-
- checkImage: function(container)
- {
- var _self = this;
-
- container.images.each(function()
- {
- if(this.complete === true)
- {
- container.images = container.images.not(this);
- _self.preload_images -= 1;
- }
- });
- if(container.images.length && _self.options.maxLoops >= 0)
- {
- _self.options.maxLoops-=1;
- setTimeout(function(){ _self.checkImage(container); }, 500);
- }
- else
- {
- _self.preload_images = _self.preload_images - container.images.length;
- _self.trigger_loaded(container);
- }
- },
- trigger_loaded: function(container)
- {
- var _self = this;
-
- if(_self.options.trigger_single !== false)
- {
- _self.win.trigger('avia_images_loaded_single', [container]);
- _self.options.single_callback.call(container);
- }
- if(_self.preload_images === 0)
- {
- _self.win.trigger('avia_images_loaded');
- _self.options.global_callback.call();
- }
- }
- }
- /************************************************************************
- CSS Easing transformation table
- *************************************************************************/
- /*
- Easing transform table from jquery.animate-enhanced plugin
- http://github.com/benbarnett/jQuery-Animate-Enhanced
- */
- $.avia_utilities.css_easings = {
- linear: 'linear',
- swing: 'ease-in-out',
- bounce: 'cubic-bezier(0.0, 0.35, .5, 1.3)',
- easeInQuad: 'cubic-bezier(0.550, 0.085, 0.680, 0.530)' ,
- easeInCubic: 'cubic-bezier(0.550, 0.055, 0.675, 0.190)' ,
- easeInQuart: 'cubic-bezier(0.895, 0.030, 0.685, 0.220)' ,
- easeInQuint: 'cubic-bezier(0.755, 0.050, 0.855, 0.060)' ,
- easeInSine: 'cubic-bezier(0.470, 0.000, 0.745, 0.715)' ,
- easeInExpo: 'cubic-bezier(0.950, 0.050, 0.795, 0.035)' ,
- easeInCirc: 'cubic-bezier(0.600, 0.040, 0.980, 0.335)' ,
- easeInBack: 'cubic-bezier(0.600, -0.280, 0.735, 0.04)' ,
- easeOutQuad: 'cubic-bezier(0.250, 0.460, 0.450, 0.940)' ,
- easeOutCubic: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)' ,
- easeOutQuart: 'cubic-bezier(0.165, 0.840, 0.440, 1.000)' ,
- easeOutQuint: 'cubic-bezier(0.230, 1.000, 0.320, 1.000)' ,
- easeOutSine: 'cubic-bezier(0.390, 0.575, 0.565, 1.000)' ,
- easeOutExpo: 'cubic-bezier(0.190, 1.000, 0.220, 1.000)' ,
- easeOutCirc: 'cubic-bezier(0.075, 0.820, 0.165, 1.000)' ,
- easeOutBack: 'cubic-bezier(0.175, 0.885, 0.320, 1.275)' ,
- easeInOutQuad: 'cubic-bezier(0.455, 0.030, 0.515, 0.955)' ,
- easeInOutCubic: 'cubic-bezier(0.645, 0.045, 0.355, 1.000)' ,
- easeInOutQuart: 'cubic-bezier(0.770, 0.000, 0.175, 1.000)' ,
- easeInOutQuint: 'cubic-bezier(0.860, 0.000, 0.070, 1.000)' ,
- easeInOutSine: 'cubic-bezier(0.445, 0.050, 0.550, 0.950)' ,
- easeInOutExpo: 'cubic-bezier(1.000, 0.000, 0.000, 1.000)' ,
- easeInOutCirc: 'cubic-bezier(0.785, 0.135, 0.150, 0.860)' ,
- easeInOutBack: 'cubic-bezier(0.680, -0.550, 0.265, 1.55)' ,
- easeInOutBounce:'cubic-bezier(0.580, -0.365, 0.490, 1.365)',
- easeOutBounce: 'cubic-bezier(0.760, 0.085, 0.490, 1.365)'
- };
- /************************************************************************
- check if a css feature is supported and save it to the supported array
- *************************************************************************/
- $.avia_utilities.supported = {};
- $.avia_utilities.supports = (function()
- {
- var div = document.createElement('div'),
- vendors = ['Khtml', 'Ms','Moz','Webkit']; // vendors = ['Khtml', 'Ms','Moz','Webkit','O'];
- return function(prop, vendor_overwrite)
- {
- if ( div.style[prop] !== undefined ) { return ""; }
- if (vendor_overwrite !== undefined) { vendors = vendor_overwrite; }
- prop = prop.replace(/^[a-z]/, function(val)
- {
- return val.toUpperCase();
- });
- var len = vendors.length;
- while(len--)
- {
- if ( div.style[vendors[len] + prop] !== undefined )
- {
- return "-" + vendors[len].toLowerCase() + "-";
- }
- }
- return false;
- };
- }());
- /************************************************************************
- animation function
- *************************************************************************/
- $.fn.avia_animate = function(prop, speed, easing, callback)
- {
- if(typeof speed === 'function') {callback = speed; speed = false; }
- if(typeof easing === 'function'){callback = easing; easing = false;}
- if(typeof speed === 'string'){easing = speed; speed = false;}
- if(callback === undefined || callback === false){ callback = function(){}; }
- if(easing === undefined || easing === false) { easing = 'easeInQuad'; }
- if(speed === undefined || speed === false) { speed = 400; }
- if($.avia_utilities.supported.transition === undefined)
- {
- $.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
- }
-
-
- if($.avia_utilities.supported.transition !== false )
- {
- var prefix = $.avia_utilities.supported.transition + 'transition',
- cssRule = {},
- cssProp = {},
- thisStyle = document.body.style,
- end = (thisStyle.WebkitTransition !== undefined) ? 'webkitTransitionEnd' : (thisStyle.OTransition !== undefined) ? 'oTransitionEnd' : 'transitionend';
- //translate easing into css easing
- easing = $.avia_utilities.css_easings[easing];
- //create css transformation rule
- cssRule[prefix] = 'all '+(speed/1000)+'s '+easing;
- //add namespace to the transition end trigger
- end = end + ".avia_animate";
-
- //since jquery 1.10 the items passed need to be {} and not [] so make sure they are converted properly
- for (var rule in prop)
- {
- if (prop.hasOwnProperty(rule)) { cssProp[rule] = prop[rule]; }
- }
- prop = cssProp;
-
-
-
- this.each(function()
- {
- var element = $(this), css_difference = false, rule, current_css;
- for (rule in prop)
- {
- if (prop.hasOwnProperty(rule))
- {
- current_css = element.css(rule);
- if(prop[rule] != current_css && prop[rule] != current_css.replace(/px|%/g,""))
- {
- css_difference = true;
- break;
- }
- }
- }
- if(css_difference)
- {
- var endTriggered = false;
-
- element.on(end, function(event)
- {
- if(event.target != event.currentTarget) return false;
-
- if(endTriggered == true) return false;
- endTriggered = true;
- cssRule[prefix] = "none";
- element.off(end);
- element.css(cssRule);
- setTimeout(function(){ callback.call(element); });
- });
-
-
- //desktop safari fallback if we are in another tab to trigger the end event
- setTimeout(function(){
- if(!endTriggered && !avia_is_mobile && $('html').is('.avia-safari') ) {
- element.trigger(end);
- $.avia_utilities.log('Safari Fallback '+end+' trigger');
- }
- }, speed + 100);
-
- setTimeout(function(){ element.css(cssRule);},10);
- setTimeout(function(){ element.css(prop); },20);
- }
- else
- {
- setTimeout(function(){ callback.call(element); });
- }
- });
- }
- else // if css animation is not available use default JS animation
- {
- this.animate(prop, speed, easing, callback);
- }
- return this;
- };
- })( jQuery );
- /* ======================================================================================================================================================
- Avia Slideshow
- ====================================================================================================================================================== */
- (function($)
- {
- "use strict";
- $.AviaSlider = function(options, slider)
- {
- var self = this;
-
- this.$win = $( window );
-
- this.$slider = $( slider );
-
- this.isMobile = $.avia_utilities.isMobile;
-
- this._prepareSlides(options);
-
- //default preload images then init slideshow
- $.avia_utilities.preload({container: this.$slider , single_callback: function(){ self._init( options ); }});
- }
- $.AviaSlider.defaults = {
- //interval between autorotation switches
- interval:5,
- //autorotation active or not
- autoplay:false,
-
- //set if the loop will stop at the last/first slide or if the slides will loop infinite
- //set to false for infinite loop, "last" to stop at the last slide or "first" to stop at the first slide
- stopinfiniteloop: false,
- //fade or slide animation
- animation:'slide',
- //transition speed when switching slide
- transitionSpeed:900,
- //easing method for the transition
- easing:'easeInOutQuart',
- //slide wrapper
- wrapElement: '>ul',
- //slide element
- slideElement: '>li',
- //pause if mouse cursor is above item
- hoverpause: false,
-
- //attach images as background
- bg_slider: false,
-
- //delay of miliseconds to wait before showing the next slide
- show_slide_delay: 0,
-
- //if slider animation is set to "fade" the fullfade property sets the crossfade behaviour
- fullfade: false
- };
- $.AviaSlider.prototype =
- {
- _init: function( options )
- {
- // set slider options
- this.options = this._setOptions(options);
- //slidewrap
- this.$sliderUl = this.$slider.find(this.options.wrapElement);
- // slide elements
- this.$slides = this.$sliderUl.find(this.options.slideElement);
- // goto dots
- this.gotoButtons = this.$slider.find('.avia-slideshow-dots a');
-
- //perma caption
- this.permaCaption = this.$slider.find('>.av-slideshow-caption');
- // slide count
- this.itemsCount = this.$slides.length;
- // current image index
- this.current = 0;
- //loop count
- this.loopCount = 0;
- // control if the slicebox is animating
- this.isAnimating = false;
- // css browser prefix like -webkit-, -moz-
- this.browserPrefix = $.avia_utilities.supports('transition');
-
- // css3 animation?
- this.cssActive = this.browserPrefix !== false ? true : false;
-
- // css3D animation?
- this.css3DActive = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
-
- //store the aviaVideoApi object for the current slide if available
- this.video = false;
-
- //if we have a bg slider no images were preloaded yet. in that case start preloading and attaching images
- if(this.options.bg_slider == true)
- {
- //create array that holds all image urls to preload
- this.imageUrls = [];
-
- //create a preloader icon to indicate loading
- this.loader = $.avia_utilities.loading(this.$slider);
-
- //preload the images ony by one
- this._bgPreloadImages();
-
- }
- else //if it was a default slider all images are already loaded and we can start showing the slider
- {
- //kickoff the slider: bind functions, show first slide, if active start the autorotation timer
- this._kickOff();
- }
- },
- //set the slider options by first merging the efault options and the passed options, then checking the slider element if any data attributes overwrite the option set
- _setOptions: function(options)
- {
- var newOptions = $.extend( true, {}, $.AviaSlider.defaults, options ),
- htmlData = this.$slider.data(),
- i = "";
- //overwritte passed option set with any data properties on the html element
- for (i in htmlData)
- {
- if (htmlData.hasOwnProperty(i))
- {
- if(typeof htmlData[i] === "string" || typeof htmlData[i] === "number" || typeof htmlData[i] === "boolean")
- {
- newOptions[i] = htmlData[i];
- }
- }
- }
- return newOptions;
- },
-
- _prepareSlides: function(options)
- {
- //if its a mobile device find all video slides that need to be altered
- if(this.isMobile)
- {
- var alter = this.$slider.find('.av-mobile-fallback-image');
- alter.each(function()
- {
- var current = $(this).removeClass('av-video-slide').data({'avia_video_events': true, 'video-ratio':0}),
- fallback = current.data('mobile-img');
-
- current.find('.av-click-overlay, .mejs-mediaelement, .mejs-container').remove();
-
- if(!fallback)
- {
- var appendTo = current.find('.avia-slide-wrap');
- $('<p class="av-fallback-message"><span>Please set a mobile device fallback image for this video in your wordpress backend</span></p>').appendTo(appendTo);
- }
-
- if(options && options.bg_slider)
- {
- current.data('img-url', fallback);
- }
- else
- {
- var image = $('<img src="'+fallback+'" alt="" title="" />');
- current.find('.avia-slide-wrap').append(image);
- }
-
- });
- }
-
- },
-
- //start preloading the background images
- _bgPreloadImages : function(callback)
- {
- this._getImageURLS();
- this._preloadSingle(0, function()
- {
- this._kickOff();
- this._preloadNext(1);
- });
- },
-
- //if we are using a background image slider, fetch the images from a data attribute and preload them one by one
- _getImageURLS: function()
- {
- var _self = this;
-
- //collect url strings of the images to preload
- this.$slides.each(function(i)
- {
- _self.imageUrls[i] = [];
- _self.imageUrls[i]['url'] = $(this).data("img-url");
-
- //if no image is passed we can set the slide to loaded
- if(typeof _self.imageUrls[i]['url'] == 'string')
- {
- _self.imageUrls[i]['status'] = false;
- }
- else
- {
- _self.imageUrls[i]['status'] = true;
- }
- });
- },
-
-
- _preloadSingle: function(key, callback)
- {
- var _self = this,
- objImage = new Image();
-
- if(typeof _self.imageUrls[key]['url'] == 'string')
- {
- $(objImage).bind('load error', function()
- {
- _self.imageUrls[key]['status'] = true;
- _self.$slides.eq(key).css('background-image','url(' + _self.imageUrls[key]['url'] + ')');
- if(typeof callback == 'function') callback.apply( _self, [objImage, key] );
- });
-
- objImage.src = _self.imageUrls[key]['url'];
- }
- else
- {
- if(typeof callback == 'function') callback.apply( _self, [objImage, key] );
- }
- },
-
- _preloadNext: function(key)
- {
- if(typeof this.imageUrls[key] != "undefined")
- {
- this._preloadSingle(key, function()
- {
- this._preloadNext(key + 1);
- });
- }
- },
-
- //bind click events of slide controlls to the public functions
- _bindEvents: function()
- {
- var self = this,
- win = $( window );
- this.$slider.on('click','.next-slide', $.proxy( this.next, this) );
- this.$slider.on('click','.prev-slide', $.proxy( this.previous, this) );
- this.$slider.on('click','.goto-slide', $.proxy( this.go2, this) );
- if(this.options.hoverpause)
- {
- this.$slider.on('mouseenter', $.proxy( this.pause, this) );
- this.$slider.on('mouseleave', $.proxy( this.resume, this) );
- }
- if(this.options.stopinfiniteloop && this.options.autoplay)
- {
- if(this.options.stopinfiniteloop == 'last')
- {
- this.$slider.on('avia_slider_last_slide', $.proxy(this._stopSlideshow, this) );
- }
- else if(this.options.stopinfiniteloop == 'first')
- {
- this.$slider.on('avia_slider_first_slide', $.proxy(this._stopSlideshow, this) );
- }
- }
- win.on( 'debouncedresize.aviaSlider', $.proxy( this._setSize, this) );
- //if its a desktop browser add arrow navigation, otherwise add touch nav
- if(!this.isMobile)
- {
- this.$slider.avia_keyboard_controls();
- }
- else
- {
- this.$slider.avia_swipe_trigger();
- }
-
- self._attach_video_events();
- },
- //kickoff the slider by binding all functions to slides and buttons, show the first slide and start autoplay
- _kickOff: function()
- {
- var self = this,
- first_slide = self.$slides.eq(0),
- video = first_slide.data('video-ratio');
-
- // bind events to to the controll buttons
- self._bindEvents();
-
- this.$slider.removeClass('av-default-height-applied');
-
- //show the first slide. if its a video set the correct size, otherwise make sure to remove the % padding
- if(video)
- {
- self._setSize(true);
- }
- else
- {
- if(this.options.keep_pading != true)
- {
- self.$sliderUl.css('padding',0);
- self.$win.trigger('av-height-change');
- }
- }
-
- first_slide.css({visibility:'visible', opacity:0}).avia_animate({opacity:1}, function()
- {
- var current = $(this).addClass('active-slide');
-
- if(self.permaCaption.length)
- {
- self.permaCaption.addClass('active-slide');
- }
- });
-
-
-
- // start autoplay if active
- if( self.options.autoplay )
- {
- self._startSlideshow();
- }
-
- },
- //calculate which slide should be displayed next and call the executing transition function
- _navigate : function( dir, pos ) {
-
- if( this.isAnimating || this.itemsCount < 2 || !this.$slider.is(":visible") )
- {
- return false;
- }
-
- this.isAnimating = true;
- // current item's index
- this.prev = this.current;
- // if position is passed
- if( pos !== undefined )
- {
- this.current = pos;
- dir = this.current > this.prev ? 'next' : 'prev';
- }
- // if not check the boundaries
- else if( dir === 'next' )
- {
- this.current = this.current < this.itemsCount - 1 ? this.current + 1 : 0;
-
- if( this.current === 0 && this.options.autoplay_stopper == 1 && this.options.autoplay )
- {
- this.isAnimating = false;
- this.current = this.prev;
- this._stopSlideshow();
- return false;
- }
- }
- else if( dir === 'prev' )
- {
- this.current = this.current > 0 ? this.current - 1 : this.itemsCount - 1;
- }
- //set goto button
- this.gotoButtons.removeClass('active').eq(this.current).addClass('active');
- //set slideshow size
- this._setSize();
-
- //if we are using a background slider make sure that the image is loaded. if not preload it, then show the slide
- if(this.options.bg_slider == true)
- {
- if(this.imageUrls[this.current]['status'] == true )
- {
- this['_' + this.options.animation].call(this, dir);
- }
- else
- {
- this.loader.show();
- this._preloadSingle(this.current, function()
- {
- this['_' + this.options.animation].call(this, dir);
- this.loader.hide();
- });
- }
- }
- else //no background loader -> images are already loaded
- {
- //call the executing function. for example _slide, or _fade. since the function call is absed on a var we can easily extend the slider with new animations
- this['_' + this.options.animation].call(this, dir);
- }
- if(this.current == 0)
- {
- this.loopCount++;
- this.$slider.trigger('avia_slider_first_slide');
- }
- else if(this.current == this.itemsCount - 1)
- {
- this.$slider.trigger('avia_slider_last_slide');
- }
- else
- {
- this.$slider.trigger('avia_slider_navigate_slide');
- }
- },
- //if the next slide has a different height than the current change the slideshow height
- _setSize: function(instant)
- {
- //if images are attached as bg images the slider has a fixed height
- if(this.options.bg_slider == true) return;
-
- var self = this,
- slide = this.$slides.eq(this.current),
- current = Math.floor(this.$sliderUl.height()),
- ratio = slide.data('video-ratio'),
- setTo = ratio ? this.$sliderUl.width() / ratio : Math.floor(slide.height()),
- video_height = slide.data('video-height'), //forced video height %. needs to be set only once
- video_toppos = slide.data('video-toppos'); //forced video top position
-
- this.$sliderUl.height(current).css('padding',0); //make sure to set the slideheight to an actual value
-
- if(setTo != current)
- {
- if(instant == true)
- {
- this.$sliderUl.css({height:setTo});
- this.$win.trigger('av-height-change');
- }
- else
- {
- this.$sliderUl.avia_animate({height:setTo}, function()
- {
- self.$win.trigger('av-height-change');
- });
- }
- }
-
- if(video_height && video_height!= "set")
- {
- slide.find('iframe, embed, video, object, .av_youtube_frame').css({height: video_height + '%', top: video_toppos + '%'});
- slide.data('video-height','set');
- }
- },
-
- _slide: function(dir)
- {
- var sliderWidth = this.$slider.width(),
- direction = dir === 'next' ? -1 : 1,
- property = this.browserPrefix + 'transform',
- reset = {}, transition = {}, transition2 = {},
- trans_val = ( sliderWidth * direction * -1),
- trans_val2 = ( sliderWidth * direction);
-
- //do a css3 animation
- if(this.cssActive)
- {
- property = this.browserPrefix + 'transform';
- //do a translate 3d transformation if available, since it uses hardware acceleration
- if(this.css3DActive)
- {
- reset[property] = "translate3d(" + trans_val + "px, 0, 0)";
- transition[property] = "translate3d(" + trans_val2 + "px, 0, 0)";
- transition2[property] = "translate3d(0,0,0)";
- }
- else //do a 2d transform. still faster than a position "left" change
- {
- reset[property] = "translate(" + trans_val + "px,0)";
- transition[property] = "translate(" + trans_val2 + "px,0)";
- transition2[property] = "translate(0,0)"; }
- }
- else
- {
- reset.left = trans_val;
- transition.left = trans_val2;
- transition2.left = 0;
- }
-
- this._slide_animate(reset, transition, transition2);
- },
-
- _slide_up: function(dir)
- {
- var sliderHeight = this.$slider.height(),
- direction = dir === 'next' ? -1 : 1,
- property = this.browserPrefix + 'transform',
- reset = {}, transition = {}, transition2 = {},
- trans_val = ( sliderHeight * direction * -1),
- trans_val2 = ( sliderHeight * direction);
-
- //do a css3 animation
- if(this.cssActive)
- {
- property = this.browserPrefix + 'transform';
- //do a translate 3d transformation if available, since it uses hardware acceleration
- if(this.css3DActive)
- {
- reset[property] = "translate3d( 0," + trans_val + "px, 0)";
- transition[property] = "translate3d( 0," + trans_val2 + "px, 0)";
- transition2[property] = "translate3d(0,0,0)";
- }
- else //do a 2d transform. still faster than a position "left" change
- {
- reset[property] = "translate( 0," + trans_val + "px)";
- transition[property] = "translate( 0," + trans_val2 + "px)";
- transition2[property] = "translate(0,0)"; }
- }
- else
- {
- reset.top = trans_val;
- transition.top = trans_val2;
- transition2.top = 0;
- }
-
- this._slide_animate(reset, transition, transition2);
- },
-
-
- //slide animation: do a slide transition by css3 transform if possible. if not simply do a position left transition
- _slide_animate: function( reset , transition , transition2 )
- {
-
- var self = this,
- displaySlide = this.$slides.eq(this.current),
- hideSlide = this.$slides.eq(this.prev);
-
- hideSlide.trigger('pause');
- if( !displaySlide.data('disableAutoplay') ) displaySlide.trigger('play');
- displaySlide.css({visibility:'visible', zIndex:4, opacity:1, left:0, top:0});
- displaySlide.css(reset);
-
- hideSlide.avia_animate(transition, this.options.transitionSpeed, this.options.easing);
-
- var after_slide = function()
- {
- self.isAnimating = false;
- displaySlide.addClass('active-slide');
- hideSlide.css({visibility:'hidden'}).removeClass('active-slide');
- self.$slider.trigger('avia-transition-done');
- }
-
- if(self.options.show_slide_delay > 0)
- {
- setTimeout(function() { displaySlide.avia_animate(transition2, self.options.transitionSpeed, self.options.easing, after_slide); },self.options.show_slide_delay);
- }
- else
- {
- displaySlide.avia_animate(transition2, self.options.transitionSpeed, self.options.easing, after_slide);
- }
- },
-
- //simple fade transition of the slideshow
- _fade: function()
- {
- var self = this,
- displaySlide = this.$slides.eq(this.current),
- hideSlide = this.$slides.eq(this.prev),
- properties = {visibility:'visible', zIndex:3, opacity:0},
- fadeCallback = function()
- {
- self.isAnimating = false;
- displaySlide.addClass('active-slide');
- hideSlide.css({visibility:'hidden', zIndex:2}).removeClass('active-slide');
- self.$slider.trigger('avia-transition-done');
-
- };
-
- hideSlide.trigger('pause');
- if( !displaySlide.data('disableAutoplay') ) displaySlide.trigger('play');
-
- if(self.options.fullfade == true)
- {
- hideSlide.avia_animate({opacity:0}, 200, 'linear', function()
- {
- displaySlide.css(properties).avia_animate({opacity:1}, self.options.transitionSpeed, 'linear',fadeCallback);
- });
- }
- else
- {
- displaySlide.css(properties).avia_animate({opacity:1}, self.options.transitionSpeed/2, 'linear', function()
- {
- hideSlide.avia_animate({opacity:0}, 200, 'linear', fadeCallback);
- });
- }
-
- },
-
-
- /************************************************************************
- Video functions
- *************************************************************************/
-
- //bind events to the video that tell the slider to autorotate once a video has been played
- _attach_video_events: function()
- {
- var self = this, $html = $('html');
-
- self.$slides.each(function(i)
- {
- var currentSlide = $(this),
- caption = currentSlide.find('.caption_fullwidth, .av-click-overlay'),
- mejs = currentSlide.find('.mejs-mediaelement');
-
- if(currentSlide.data('avia_video_events') != true)
- {
- currentSlide.data('avia_video_events', true);
-
- currentSlide.on('av-video-events-bound', { slide: currentSlide, wrap: mejs , iteration: i , self: self }, onReady);
-
- currentSlide.on('av-video-ended', { slide: currentSlide , self: self}, onFinish);
-
- currentSlide.on('av-video-play-executed', function(){ setTimeout(function(){ self.pause() }, 100); });
-
- caption.on('click', { slide: currentSlide }, toggle);
-
- // also if the player was loaded before the _bindEvents function was bound trigger it manually
- if(currentSlide.is('.av-video-events-bound')) currentSlide.trigger('av-video-events-bound');
- }
- });
-
-
- //helper functions
- function onReady( event )
- {
- //autostart for first slide
- if(event.data.iteration === 0)
- {
- event.data.wrap.css('opacity',0);
- if(!event.data.self.isMobile && !event.data.slide.data('disableAutoplay')) { event.data.slide.trigger('play'); }
- setTimeout(function(){ event.data.wrap.avia_animate({opacity:1}, 400); }, 50);
- }
- else if ($html.is('.avia-msie') && !event.data.slide.is('.av-video-service-html5'))
- {
- /*
- * Internet Explorer fires the ready event for external videos once they become visible
- * as oposed to other browsers which always fire immediately.
- */
- if( !event.data.slide.data('disableAutoplay') ) event.data.slide.trigger('play');
- }
-
- }
-
-
-
-
- function onFinish( event )
- {
- //if the video is not looped resume the slideshow
- if(!event.data.slide.is('.av-single-slide') && !event.data.slide.is('.av-loop-video'))
- {
- event.data.slide.trigger('reset');
- self._navigate( 'next' );
- self.resume();
- }
-
- //safari 8 workaround for self hosted videos which wont loop by default
- if(event.data.slide.is('.av-loop-video') && event.data.slide.is('.av-video-service-html5'))
- {
- if($html.is('.avia-safari-8'))
- {
- setTimeout(function(){ event.data.slide.trigger('play'); },1);
- }
- }
- }
-
- function toggle( event )
- {
- if(event.target.tagName != "A")
- {
- event.data.slide.trigger('toggle');
- }
- }
-
- },
-
-
-
- /************************************************************************
- Slideshow control functions
- *************************************************************************/
-
- _timer: function(callback, delay, first)
- {
- var self = this, start, remaining = delay;
-
- self.timerId = 0;
-
- this.pause = function() {
- window.clearTimeout(self.timerId);
- remaining -= new Date() - start;
- };
- this.resume = function() {
- start = new Date();
- self.timerId = window.setTimeout(callback, remaining);
- };
- this.destroy = function()
- {
- window.clearTimeout(self.timerId);
- };
- this.resume(true);
- },
- //start autorotation
- _startSlideshow: function()
- {
- var self = this;
-
- this.isPlaying = true;
-
- this.slideshow = new this._timer( function()
- {
- self._navigate( 'next' );
-
- if ( self.options.autoplay )
- {
- self._startSlideshow();
- }
- }, (this.options.interval * 1000));
- },
- //stop autorotation
- _stopSlideshow: function()
- {
- if ( this.options.autoplay ) {
- this.slideshow.destroy();
- this.isPlaying = false;
- this.options.autoplay = false;
- }
- },
- // public method: shows next image
- next : function(e)
- {
- e.preventDefault();
- this._stopSlideshow();
- this._navigate( 'next' );
- },
- // public method: shows previous image
- previous : function(e)
- {
- e.preventDefault();
- this._stopSlideshow();
- this._navigate( 'prev' );
- },
- // public method: goes to a specific image
- go2 : function( pos )
- {
- //if we didnt pass a number directly lets asume someone clicked on a link that triggered the goto transition
- if(isNaN(pos))
- {
- //in that case prevent the default link behavior and set the slide number to the links hash
- pos.preventDefault();
- pos = pos.currentTarget.hash.replace('#','');
- }
- pos -= 1;
- if( pos === this.current || pos >= this.itemsCount || pos < 0 )
- {
- return false;
- }
- this._stopSlideshow();
- this._navigate( false, pos );
- },
- // public method: starts the slideshow
- // any call to next(), previous() or goto() will stop the slideshow autoplay
- play : function()
- {
- if( !this.isPlaying )
- {
- this.isPlaying = true;
- this._navigate( 'next' );
- this.options.autoplay = true;
- this._startSlideshow();
- }
- },
- // public methos: pauses the slideshow
- pause : function()
- {
- if( this.isPlaying )
- {
- this.slideshow.pause();
- }
- },
- // publiccmethos: resumes the slideshow
- resume : function()
- {
- if( this.isPlaying )
- {
- this.slideshow.resume();
- }
- },
- // public methos: destroys the instance
- destroy : function( callback )
- {
- this.slideshow.destroy( callback );
- }
- }
- //simple wrapper to call the slideshow. makes sure that the slide data is not applied twice
- $.fn.aviaSlider = function( options )
- {
- return this.each(function()
- {
- var self = $.data( this, 'aviaSlider' );
- if(!self)
- {
- self = $.data( this, 'aviaSlider', new $.AviaSlider( options, this ) );
- }
- });
- }
- })( jQuery );
- // -------------------------------------------------------------------------------------------
- // keyboard controls
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- "use strict";
- /************************************************************************
- keyboard arrow nav
- *************************************************************************/
- $.fn.avia_keyboard_controls = function(options_passed)
- {
- var defaults =
- {
- 37: '.prev-slide', // prev
- 39: '.next-slide' // next
- },
- methods = {
- mousebind: function(slider)
- {
- slider.hover(
- function(){ slider.mouseover = true; },
- function(){ slider.mouseover = false; }
- );
- },
- keybind: function(slider)
- {
- $(document).keydown(function(e)
- {
- if(slider.mouseover && typeof slider.options[e.keyCode] !== 'undefined')
- {
- var item;
- if(typeof slider.options[e.keyCode] === 'string')
- {
- item = slider.find(slider.options[e.keyCode]);
- }
- else
- {
- item = slider.options[e.keyCode];
- }
- if(item.length)
- {
- item.trigger('click', ['keypress']);
- return false;
- }
- }
- });
- }
- };
- return this.each(function()
- {
- var slider = $(this);
- slider.options = $.extend({}, defaults, options_passed);
- slider.mouseover = false;
- methods.mousebind(slider);
- methods.keybind(slider);
- });
- };
- /************************************************************************
- swipe nav
- *************************************************************************/
- $.fn.avia_swipe_trigger = function(passed_options)
- {
- var win = $(window),
- isMobile = $.avia_utilities.isMobile,
- defaults =
- {
- prev: '.prev-slide',
- next: '.next-slide',
- event: {
- prev: 'click',
- next: 'click'
- }
- },
- methods = {
- activate_touch_control: function(slider)
- {
- var i, differenceX, differenceY;
- slider.touchPos = {};
- slider.hasMoved = false;
- slider.on('touchstart', function(event)
- {
- slider.touchPos.X = event.originalEvent.touches[0].clientX;
- slider.touchPos.Y = event.originalEvent.touches[0].clientY;
- });
- slider.on('touchend', function(event)
- {
- slider.touchPos = {};
- if(slider.hasMoved) { event.preventDefault(); }
- slider.hasMoved = false;
- });
- slider.on('touchmove', function(event)
- {
- if(!slider.touchPos.X)
- {
- slider.touchPos.X = event.originalEvent.touches[0].clientX;
- slider.touchPos.Y = event.originalEvent.touches[0].clientY;
- }
- else
- {
- differenceX = event.originalEvent.touches[0].clientX - slider.touchPos.X;
- differenceY = event.originalEvent.touches[0].clientY - slider.touchPos.Y;
- //check if user is scrolling the window or moving the slider
- if(Math.abs(differenceX) > Math.abs(differenceY))
- {
- event.preventDefault();
- if(slider.touchPos !== event.originalEvent.touches[0].clientX)
- {
- if(Math.abs(differenceX) > 50)
- {
- i = differenceX > 0 ? 'prev' : 'next';
- if(typeof slider.options[i] === 'string')
- {
- slider.find(slider.options[i]).trigger(slider.options.event[i], ['swipe']);
- }
- else
- {
- slider.options[i].trigger(slider.options.event[i], ['swipe']);
- }
- slider.hasMoved = true;
- slider.touchPos = {};
- return false;
- }
- }
- }
- }
- });
- }
- };
- return this.each(function()
- {
- if(isMobile)
- {
- var slider = $(this);
- slider.options = $.extend({}, defaults, passed_options);
- methods.activate_touch_control(slider);
- }
- });
- };
- }(jQuery));
|