shortcodes.js 137 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034
  1. (function($)
  2. {
  3. "use strict";
  4. $(document).ready(function()
  5. {
  6. //global variables that are used on several ocassions
  7. $.avia_utilities = $.avia_utilities || {};
  8. if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && 'ontouchstart' in document.documentElement)
  9. {
  10. $.avia_utilities.isMobile = true;
  11. }
  12. else
  13. {
  14. $.avia_utilities.isMobile = false;
  15. }
  16. //activate fixed bg fallback for mobile
  17. if($.fn.avia_mobile_fixed)
  18. $('.avia-bg-style-fixed').avia_mobile_fixed();
  19. //activate parallax scrolling for backgrounds.
  20. if($.fn.avia_parallax)
  21. $('.av-parallax').avia_parallax();
  22. //calculate the browser height and append a css rule to the head
  23. if($.fn.avia_browser_height)
  24. $('.av-minimum-height, .avia-fullscreen-slider').avia_browser_height();
  25. //calculate the height of each video section
  26. if($.fn.avia_video_section)
  27. $('.av-section-with-video-bg').avia_video_section();
  28. //creates team social icon tooltip
  29. new $.AviaTooltip({'class': "avia-tooltip", data: "avia-tooltip", delay:0, scope: "body"});
  30. //creates icon element tooltip
  31. new $.AviaTooltip({'class': "avia-tooltip avia-icon-tooltip", data: "avia-icon-tooltip", delay:0, scope: "body"});
  32. activate_shortcode_scripts();
  33. //layer slider height helper
  34. $('.avia-layerslider').layer_slider_height_helper();
  35. //"ajax" portfolio
  36. $('.grid-links-ajax').avia_portfolio_preview();
  37. // actiavte the masonry script: sorting/loading/etc
  38. if($.fn.avia_masonry)
  39. $('.av-masonry').avia_masonry();
  40. //activate the accordion
  41. if($.fn.aviaccordion)
  42. $('.aviaccordion').aviaccordion();
  43. //activate the accordion
  44. if($.fn.avia_textrotator)
  45. $('.av-rotator-container').avia_textrotator();
  46. });
  47. $(window).load(function(){
  48. //initialize after images are loaded
  49. });
  50. // -------------------------------------------------------------------------------------------
  51. // ACTIVATE ALL SHORTCODES
  52. // -------------------------------------------------------------------------------------------
  53. function activate_waypoints(container)
  54. {
  55. //activates simple css animations of the content once the user scrolls to an elements
  56. if($.fn.avia_waypoints)
  57. {
  58. if(typeof container == 'undefined'){ container = 'body';};
  59. $('.avia_animate_when_visible', container).avia_waypoints();
  60. $('.avia_animate_when_almost_visible', container).avia_waypoints({ offset: '80%'});
  61. if(container == 'body') container = '.avia_desktop body';
  62. $('.av-animated-generic', container).avia_waypoints({ offset: '95%'});
  63. }
  64. }
  65. function activate_shortcode_scripts(container)
  66. {
  67. if(typeof container == 'undefined'){ container = 'body';}
  68. //activates the form shortcode
  69. if($.fn.avia_ajax_form)
  70. {
  71. $('.avia_ajax_form:not( .avia-disable-default-ajax )', container).avia_ajax_form();
  72. }
  73. activate_waypoints(container);
  74. //activate the video api
  75. if($.fn.aviaVideoApi)
  76. {
  77. $('.avia-slideshow iframe[src*="youtube.com"], .av_youtube_frame, .avia-slideshow iframe[src*="vimeo.com"], .avia-slideshow video').aviaVideoApi({}, 'li');
  78. }
  79. //activates the toggle shortcode
  80. if($.fn.avia_sc_toggle)
  81. {
  82. $('.togglecontainer', container).avia_sc_toggle();
  83. }
  84. //activates the tabs shortcode
  85. if($.fn.avia_sc_tabs)
  86. {
  87. $('.top_tab', container).avia_sc_tabs();
  88. $('.sidebar_tab', container).avia_sc_tabs({sidebar:true});
  89. }
  90. //activates behavior and animation for gallery
  91. if($.fn.avia_sc_gallery)
  92. {
  93. $('.avia-gallery', container).avia_sc_gallery();
  94. }
  95. //activates animated number shortcode
  96. if($.fn.avia_sc_animated_number)
  97. {
  98. $('.avia-animated-number', container).avia_sc_animated_number();
  99. }
  100. //animation for elements that are not connected like icon shortcode
  101. if($.fn.avia_sc_animation_delayed)
  102. {
  103. $('.av_font_icon', container).avia_sc_animation_delayed({delay:100});
  104. $('.avia-image-container', container).avia_sc_animation_delayed({delay:100});
  105. $('.av-hotspot-image-container', container).avia_sc_animation_delayed({delay:100});
  106. $('.av-animated-generic', container).avia_sc_animation_delayed({delay:100});
  107. }
  108. //activates animation for iconlist
  109. if($.fn.avia_sc_iconlist)
  110. {
  111. $('.avia-icon-list', container).avia_sc_iconlist();
  112. }
  113. //activates animation for progress bar
  114. if($.fn.avia_sc_progressbar)
  115. {
  116. $('.avia-progress-bar-container', container).avia_sc_progressbar();
  117. }
  118. //activates animation for testimonial
  119. if($.fn.avia_sc_testimonial)
  120. {
  121. $('.avia-testimonial-wrapper', container).avia_sc_testimonial();
  122. }
  123. //activate the fullscreen slider
  124. $('.avia-slideshow.av_fullscreen', container).aviaFullscreenSlider();
  125. //activate the aviaslider
  126. $('.avia-slideshow:not(.av_fullscreen)', container).aviaSlider();
  127. //content slider
  128. $('.avia-content-slider-active', container).aviaSlider({wrapElement: '.avia-content-slider-inner', slideElement:'.slide-entry-wrap', fullfade:true});
  129. //testimonial slider
  130. $('.avia-slider-testimonials', container).aviaSlider({wrapElement: '.avia-testimonial-row', slideElement:'.avia-testimonial', fullfade:true});
  131. //load and activate maps
  132. if($.fn.aviaMaps)
  133. {
  134. $('.avia-google-map-container', container).aviaMaps();
  135. }
  136. //load magazine sorting
  137. if($.fn.aviaMagazine)
  138. {
  139. $('.av-magazine-tabs-active', container).aviaMagazine();
  140. }
  141. //load image hotspot
  142. if($.fn.aviaHotspots)
  143. {
  144. $('.av-hotspot-image-container', container).aviaHotspots();
  145. }
  146. //load countdown
  147. if($.fn.aviaCountdown)
  148. {
  149. $('.av-countdown-timer', container).aviaCountdown();
  150. }
  151. //load countdown
  152. if($.fn.aviaCountdown)
  153. {
  154. $('.av-countdown-timer', container).aviaCountdown();
  155. }
  156. }
  157. // -------------------------------------------------------------------------------------------
  158. //
  159. // AVIA Countdown
  160. //
  161. // -------------------------------------------------------------------------------------------
  162. (function($)
  163. {
  164. "use strict";
  165. var _units = ['weeks','days','hours','minutes','seconds'],
  166. _second = 1000,
  167. _minute = _second * 60,
  168. _hour = _minute * 60,
  169. _day = _hour * 24,
  170. _week = _day * 7,
  171. ticker = function(_self)
  172. {
  173. var _time = {},
  174. _now = new Date(),
  175. _timestamp = _self.end - _now;
  176. if(_timestamp <= 0)
  177. {
  178. clearInterval(_self.countdown);
  179. return;
  180. }
  181. _self.time.weeks = Math.floor( _timestamp / _week);
  182. _self.time.days = Math.floor((_timestamp % _week) / _day);
  183. _self.time.hours = Math.floor((_timestamp % _day) / _hour);
  184. _self.time.minutes = Math.floor((_timestamp % _hour) / _minute);
  185. _self.time.seconds = Math.floor((_timestamp % _minute) / _second);
  186. switch(_self.data.maximum)
  187. {
  188. case 1: _self.time.seconds = Math.floor(_timestamp / _second); break;
  189. case 2: _self.time.minutes = Math.floor(_timestamp / _minute); break;
  190. case 3: _self.time.hours = Math.floor(_timestamp / _hour); break;
  191. case 4: _self.time.days = Math.floor(_timestamp / _day); break;
  192. }
  193. for (var i in _self.time)
  194. {
  195. if(typeof _self.update[i] == "object")
  196. {
  197. if(_self.firstrun || _self.oldtime[i] != _self.time[i])
  198. {
  199. var labelkey = ( _self.time[i] === 1 ) ? "single" : "multi";
  200. _self.update[i].time_container.text(_self.time[i]);
  201. _self.update[i].label_container.text(_self.update[i][labelkey]);
  202. }
  203. }
  204. }
  205. //show ticker
  206. if(_self.firstrun) _self.container.addClass('av-countdown-active')
  207. _self.oldtime = $.extend( {}, _self.time );
  208. _self.firstrun = false;
  209. };
  210. $.fn.aviaCountdown = function( options )
  211. {
  212. if(!this.length) return;
  213. return this.each(function()
  214. {
  215. var _self = {};
  216. _self.update = {};
  217. _self.time = {};
  218. _self.oldtime = {};
  219. _self.firstrun = true;
  220. _self.container = $(this);
  221. _self.data = _self.container.data();
  222. _self.end = new Date(_self.data.year, _self.data.month, _self.data.day, _self.data.hour, _self.data.minute );
  223. for (var i in _units)
  224. {
  225. _self.update[_units[i]] = {
  226. time_container: _self.container.find('.av-countdown-' + _units[i] + ' .av-countdown-time'),
  227. label_container: _self.container.find('.av-countdown-' + _units[i] + ' .av-countdown-time-label'),
  228. };
  229. if(_self.update[_units[i]].label_container.length)
  230. {
  231. _self.update[_units[i]].single = _self.update[_units[i]].label_container.data('label');
  232. _self.update[_units[i]].multi = _self.update[_units[i]].label_container.data('label-multi');
  233. }
  234. }
  235. ticker(_self);
  236. _self.countdown = setInterval(function(){ ticker(_self); }, _self.data.interval);
  237. });
  238. }
  239. }(jQuery));
  240. // -------------------------------------------------------------------------------------------
  241. //
  242. // AVIA Image Hotspots
  243. //
  244. // -------------------------------------------------------------------------------------------
  245. (function($)
  246. {
  247. "use strict";
  248. $.fn.aviaHotspots = function( options )
  249. {
  250. if(!this.length) return;
  251. return this.each(function()
  252. {
  253. var _self = {};
  254. _self.container = $(this);
  255. _self.hotspots = _self.container.find('.av-image-hotspot');
  256. _self.container.on('avia_start_animation', function()
  257. {
  258. setTimeout(function()
  259. {
  260. _self.hotspots.each(function(i)
  261. {
  262. var current = $(this);
  263. setTimeout(function(){ current.addClass('av-display-hotspot'); },300 * i);
  264. });
  265. },400);
  266. });
  267. });
  268. }
  269. }(jQuery));
  270. // -------------------------------------------------------------------------------------------
  271. //
  272. // AVIA Magazine function for magazine sorting
  273. //
  274. // -------------------------------------------------------------------------------------------
  275. (function($)
  276. {
  277. "use strict";
  278. var animating = false,
  279. methods = {
  280. switchMag: function(clicked, _self)
  281. {
  282. var current = $(clicked)
  283. if(current.is('.active_sort') || animating) return;
  284. var filter = current.data('filter'),
  285. oldContainer = _self.container.filter(':visible'),
  286. newContainer = _self.container.filter('.' + filter);
  287. //switch Class
  288. animating = true;
  289. _self.sort_buttons.removeClass('active_sort');
  290. current.addClass('active_sort');
  291. //apply fixed heiht for transition
  292. _self.magazine.height(_self.magazine.outerHeight());
  293. //switch items
  294. oldContainer.avia_animate({opacity:0}, 200, function()
  295. {
  296. oldContainer.css({display:'none'});
  297. newContainer.css({opacity:0, display:'block'}).avia_animate({opacity:1}, 150, function()
  298. {
  299. _self.magazine.avia_animate({height: (newContainer.outerHeight() + _self.sort_bar.outerHeight())}, 150, function()
  300. {
  301. _self.magazine.height('auto');
  302. animating = false;
  303. });
  304. });
  305. });
  306. }
  307. };
  308. $.fn.aviaMagazine = function( options )
  309. {
  310. if(!this.length) return;
  311. return this.each(function()
  312. {
  313. var _self = {};
  314. _self.magazine = $(this),
  315. _self.sort_buttons = _self.magazine.find('.av-magazine-sort a');
  316. _self.container = _self.magazine.find('.av-magazine-group');
  317. _self.sort_bar = _self.magazine.find('.av-magazine-top-bar');
  318. _self.sort_buttons.on('click', function(e){ e.preventDefault(); methods.switchMag(this, _self); } );
  319. });
  320. }
  321. }(jQuery));
  322. // -------------------------------------------------------------------------------------------
  323. //
  324. // AVIA MAPS API - loads the google maps api asynchronously
  325. //
  326. // afterwards applies the map to the container
  327. //
  328. // -------------------------------------------------------------------------------------------
  329. (function($)
  330. {
  331. "use strict";
  332. $.AviaMapsAPI = function(options, container)
  333. {
  334. if(typeof window.av_google_map == 'undefined')
  335. {
  336. $.avia_utilities.log('Map creation stopped, var av_google_map not found'); return
  337. }
  338. // gatehr container and map data
  339. this.container = container;
  340. this.$container = $( container );
  341. this.$body = $('body');
  342. this.$mapid = this.$container.data('mapid') - 1;
  343. this.$data = window.av_google_map[this.$mapid];
  344. this.retina = window.devicePixelRatio > 1;
  345. // set up the whole api object
  346. this._init( options );
  347. }
  348. $.AviaMapsAPI.apiFiles =
  349. {
  350. loading: false,
  351. finished: false,
  352. src: 'https://maps.googleapis.com/maps/api/js?v=3.6&callback=aviaOnGoogleMapsLoaded'
  353. }
  354. $.AviaMapsAPI.prototype =
  355. {
  356. _init: function()
  357. {
  358. this._bind_execution();
  359. this._getAPI();
  360. },
  361. _getAPI: function( )
  362. {
  363. //make sure the api file is loaded only once
  364. if((typeof window.google == 'undefined' || typeof window.google.maps == 'undefined') && $.AviaMapsAPI.apiFiles.loading == false)
  365. {
  366. $.AviaMapsAPI.apiFiles.loading = true;
  367. var script = document.createElement('script');
  368. script.type = 'text/javascript';
  369. script.src = $.AviaMapsAPI.apiFiles.src;
  370. document.body.appendChild(script);
  371. }
  372. else if((typeof window.google != 'undefined' && typeof window.google.maps != 'undefined') || $.AviaMapsAPI.apiFiles.loading == false)
  373. //else if($.AviaMapsAPI.apiFiles.finished === true)
  374. {
  375. this._applyMap();
  376. }
  377. },
  378. _bind_execution: function()
  379. {
  380. this.$body.on('av-google-maps-api-loaded', $.proxy( this._applyMap, this) );
  381. },
  382. _applyMap: function()
  383. {
  384. if(typeof this.map != 'undefined') return;
  385. if(!this.$data.marker || !this.$data.marker[0] || !this.$data.marker[0].long || !this.$data.marker[0].long)
  386. {
  387. $.avia_utilities.log('Latitude or Longitude missing', 'map-error');
  388. return;
  389. }
  390. var _self = this,
  391. mobile_drag = $.avia_utilities.isMobile ? this.$data.mobile_drag_control : true,
  392. zoomValue = this.$data.zoom == "auto" ? 10 : this.$data.zoom;
  393. this.mapVars = {
  394. mapMaker: false, //mapmaker tiles are user generated content maps. might hold more info but also be inaccurate
  395. mapTypeControl: false,
  396. backgroundColor:'transparent',
  397. streetViewControl: false,
  398. panControl: this.$data.pan_control,
  399. zoomControl: this.$data.zoom_control,
  400. draggable: mobile_drag,
  401. scrollwheel: false,
  402. zoom: zoomValue,
  403. mapTypeId:google.maps.MapTypeId.ROADMAP,
  404. center: new google.maps.LatLng(this.$data.marker[0].lat, this.$data.marker[0].long),
  405. styles:[{featureType: "poi", elementType: "labels", stylers: [ { visibility: "off" }] }]
  406. };
  407. this.map = new google.maps.Map(this.container, this.mapVars);
  408. this._applyMapStyle();
  409. if(this.$data.zoom == "auto")
  410. {
  411. this._setAutoZoom();
  412. }
  413. google.maps.event.addListenerOnce(this.map, 'tilesloaded', function() {
  414. _self._addMarkers();
  415. });
  416. },
  417. _setAutoZoom: function()
  418. {
  419. var bounds = new google.maps.LatLngBounds();
  420. for (var key in this.$data.marker)
  421. {
  422. bounds.extend( new google.maps.LatLng (this.$data.marker[key].lat , this.$data.marker[key].long) );
  423. }
  424. this.map.fitBounds(bounds);
  425. },
  426. _applyMapStyle: function()
  427. {
  428. var stylers = [], style = [], mapType;
  429. if(this.$data.hue != "") stylers.push({hue: this.$data.hue});
  430. if(this.$data.saturation != "") stylers.push({saturation: this.$data.saturation});
  431. if(stylers.length)
  432. {
  433. style = [{
  434. featureType: "all",
  435. elementType: "all",
  436. stylers: stylers
  437. }, {
  438. featureType: "poi",
  439. stylers: [
  440. { visibility: "off" }
  441. ]
  442. }];
  443. mapType = new google.maps.StyledMapType(style, { name:"av_map_style" });
  444. this.map.mapTypes.set('av_styled_map', mapType);
  445. this.map.setMapTypeId('av_styled_map');
  446. }
  447. },
  448. _addMarkers: function()
  449. {
  450. for (var key in this.$data.marker)
  451. {
  452. var _self = this;
  453. (function(key, _self)
  454. {
  455. setTimeout(function()
  456. {
  457. var marker = "";
  458. if(!_self.$data.marker[key] || !_self.$data.marker[key].long || !_self.$data.marker[key].long)
  459. {
  460. $.avia_utilities.log('Latitude or Longitude for single marker missing', 'map-error');
  461. return;
  462. }
  463. _self.$data.LatLng = new google.maps.LatLng(_self.$data.marker[key].lat, _self.$data.marker[key].long);
  464. var markerArgs = {
  465. flat: false,
  466. position: _self.$data.LatLng,
  467. animation: google.maps.Animation.BOUNCE,
  468. map: _self.map,
  469. title: _self.$data.marker[key].address,
  470. optimized: false
  471. };
  472. //set a custom marker image if available. also set the size and reduce the marker on retina size so its sharp
  473. if(_self.$data.marker[key].icon && _self.$data.marker[key].imagesize)
  474. {
  475. var size = _self.$data.marker[key].imagesize, half = "", full = "";
  476. if(_self.retina && size > 40) size = 40; //retina downsize to at least half the px size
  477. half = new google.maps.Point(size / 2, size ) ; //used to position the marker
  478. full = new google.maps.Size(size , size ) ; //marker size
  479. markerArgs.icon = new google.maps.MarkerImage(_self.$data.marker[key].icon, null, null, half, full);
  480. }
  481. marker = new google.maps.Marker(markerArgs);
  482. setTimeout(function(){ marker.setAnimation(null); _self._infoWindow(_self.map, marker, _self.$data.marker[key]); },500);
  483. },200 * (parseInt(key,10) + 1));
  484. }(key, _self));
  485. }
  486. },
  487. _infoWindow: function(map, marker, data)
  488. {
  489. var info = $.trim(data.content);
  490. if(info != "")
  491. {
  492. var infowindow = new google.maps.InfoWindow({
  493. content: info
  494. });
  495. google.maps.event.addListener(marker, 'click', function() {
  496. infowindow.open(map,marker);
  497. });
  498. if(data.tooltip_display) infowindow.open(map,marker);
  499. }
  500. }
  501. }
  502. //simple wrapper to call the api. makes sure that the api data is not applied twice
  503. $.fn.aviaMaps = function( options )
  504. {
  505. return this.each(function()
  506. {
  507. var self = $.data( this, 'aviaMapsApi' );
  508. if(!self)
  509. {
  510. self = $.data( this, 'aviaMapsApi', new $.AviaMapsAPI( options, this ) );
  511. }
  512. });
  513. }
  514. })( jQuery );
  515. //this function is executed once the api file is loaded
  516. window.aviaOnGoogleMapsLoaded = function(){ $('body').trigger('av-google-maps-api-loaded'); $.AviaMapsAPI.apiFiles.finished = true; };
  517. // -------------------------------------------------------------------------------------------
  518. //
  519. // AVIA VIDEO API - make sure that youtube, vimeo and html 5 use the same interface
  520. //
  521. // requires froogaloop vimeo library and youtube iframe api (yt can be loaded async)
  522. //
  523. // -------------------------------------------------------------------------------------------
  524. (function($)
  525. {
  526. "use strict";
  527. $.AviaVideoAPI = function(options, video, option_container)
  528. {
  529. // actual video element. either iframe or video
  530. this.$video = $( video );
  531. // container where the AviaVideoAPI object will be stored as data, and that can receive events like play, pause etc
  532. // also the container that allows to overwrite javacript options by adding html data- attributes
  533. this.$option_container = option_container ? $( option_container ) : this.$video;
  534. //mobile device?
  535. this.isMobile = $.avia_utilities.isMobile;
  536. //iamge fallback use
  537. this.fallback = this.isMobile ? this.$option_container.is('.av-mobile-fallback-image') : false;
  538. if(this.fallback) return;
  539. // set up the whole api object
  540. this._init( options );
  541. }
  542. $.AviaVideoAPI.defaults = {
  543. loop: false,
  544. mute: false,
  545. controls: false,
  546. events: 'play pause mute unmute loop toggle reset unload'
  547. };
  548. $.AviaVideoAPI.apiFiles =
  549. {
  550. youtube : {loaded: false, src: 'https://www.youtube.com/iframe_api' }
  551. }
  552. $.AviaVideoAPI.prototype =
  553. {
  554. _init: function( options )
  555. {
  556. // set slider options
  557. this.options = this._setOptions(options);
  558. // info which video service we are using: html5, vimeo or youtube
  559. this.type = this._getPlayerType();
  560. // store the player object to the this.player variable created by one of the APIs (mediaelement, youtube, vimeo)
  561. this._setPlayer();
  562. // set to true once the events are bound so it doesnt happen a second time by accident or racing condition
  563. this.eventsBound = false;
  564. // info if the video is playing
  565. this.playing = false;
  566. //set css class that video is currently not playing
  567. this.$option_container.addClass('av-video-paused');
  568. //play pause indicator
  569. this.pp = $.avia_utilities.playpause(this.$option_container);
  570. },
  571. //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
  572. _setOptions: function(options)
  573. {
  574. var newOptions = $.extend( true, {}, $.AviaVideoAPI.defaults, options ),
  575. htmlData = this.$option_container.data(),
  576. i = "";
  577. //overwritte passed option set with any data properties on the html element
  578. for (i in htmlData)
  579. {
  580. if (htmlData.hasOwnProperty(i) && (typeof htmlData[i] === "string" || typeof htmlData[i] === "number" || typeof htmlData[i] === "boolean"))
  581. {
  582. newOptions[i] = htmlData[i];
  583. }
  584. }
  585. return newOptions;
  586. },
  587. //get the player type
  588. _getPlayerType: function()
  589. {
  590. var vid_src = this.$video.get(0).src || this.$video.data('src');
  591. if(this.$video.is('video')) return 'html5';
  592. if(this.$video.is('.av_youtube_frame')) return 'youtube';
  593. if(vid_src.indexOf('vimeo.com') != -1 ) return 'vimeo';
  594. if(vid_src.indexOf('youtube.com') != -1) return 'youtube';
  595. },
  596. //get the player object
  597. _setPlayer: function()
  598. {
  599. var _self = this;
  600. switch(this.type)
  601. {
  602. case "html5":
  603. this.player = this.$video.data('mediaelementplayer');
  604. this._playerReady();
  605. break;
  606. case "vimeo":
  607. this.player = Froogaloop(this.$video.get(0));
  608. this._playerReady();
  609. break;
  610. case "youtube":
  611. this._getAPI(this.type);
  612. $('body').on('av-youtube-iframe-api-loaded', function(){ _self._playerReady(); });
  613. break;
  614. }
  615. },
  616. _getAPI: function( api )
  617. {
  618. //make sure the api file is loaded only once
  619. if($.AviaVideoAPI.apiFiles[api].loaded === false)
  620. {
  621. $.AviaVideoAPI.apiFiles[api].loaded = true;
  622. //load the file async
  623. var tag = document.createElement('script'),
  624. first = document.getElementsByTagName('script')[0];
  625. tag.src = $.AviaVideoAPI.apiFiles[api].src;
  626. first.parentNode.insertBefore(tag, first);
  627. }
  628. },
  629. //wait for player to be ready, then bind events
  630. _playerReady: function()
  631. {
  632. var _self = this;
  633. this.$option_container.on('av-video-loaded', function(){ _self._bindEvents(); });
  634. switch(this.type)
  635. {
  636. case "html5":
  637. this.$video.on('av-mediajs-loaded', function(){ _self.$option_container.trigger('av-video-loaded'); });
  638. this.$video.on('av-mediajs-ended' , function(){ _self.$option_container.trigger('av-video-ended'); });
  639. break;
  640. case "vimeo":
  641. //finish event must be applied after ready event for firefox
  642. _self.player.addEvent('ready', function(){ _self.$option_container.trigger('av-video-loaded');
  643. _self.player.addEvent('finish', function(){ _self.$option_container.trigger('av-video-ended'); });
  644. });
  645. // vimeo sometimes does not fire. fallback jquery load event should fix this
  646. // currently not used because it causes firefox problems
  647. /*
  648. this.$video.load(function()
  649. {
  650. if(_self.eventsBound == true || typeof _self.eventsBound == 'undefined') return;
  651. _self.$option_container.trigger('av-video-loaded');
  652. $.avia_utilities.log('VIMEO Fallback Trigger');
  653. });
  654. */
  655. break;
  656. case "youtube":
  657. var params = _self.$video.data();
  658. if(_self._supports_video()) params.html5 = 1;
  659. _self.player = new YT.Player(_self.$video.attr('id'), {
  660. videoId: params.videoid,
  661. height: _self.$video.attr('height'),
  662. width: _self.$video.attr('width'),
  663. playerVars: params,
  664. events: {
  665. 'onReady': function(){ _self.$option_container.trigger('av-video-loaded'); },
  666. 'onError': function(player){ $.avia_utilities.log('YOUTUBE ERROR:', 'error', player); },
  667. 'onStateChange': function(event){
  668. if (event.data === YT.PlayerState.ENDED)
  669. {
  670. var command = _self.options.loop != false ? 'loop' : 'av-video-ended';
  671. _self.$option_container.trigger(command);
  672. }
  673. }
  674. }
  675. });
  676. break;
  677. }
  678. //fallback always trigger after 2 seconds
  679. setTimeout(function()
  680. {
  681. if(_self.eventsBound == true || typeof _self.eventsBound == 'undefined' || _self.type == 'youtube' ) { return; }
  682. $.avia_utilities.log('Fallback Video Trigger "'+_self.type+'":', 'log', _self);
  683. _self.$option_container.trigger('av-video-loaded');
  684. },2000);
  685. },
  686. //bind events we should listen to, to the player
  687. _bindEvents: function()
  688. {
  689. if(this.eventsBound == true || typeof this.eventsBound == 'undefined')
  690. {
  691. return;
  692. }
  693. var _self = this, volume = 'unmute';
  694. this.eventsBound = true;
  695. this.$option_container.on(this.options.events, function(e)
  696. {
  697. _self.api(e.type);
  698. });
  699. if(!_self.isMobile)
  700. {
  701. //set up initial options
  702. if(this.options.mute != false) { volume = "mute"; }
  703. if(this.options.loop != false) { _self.api('loop'); }
  704. _self.api(volume);
  705. }
  706. //set timeout to prevent racing conditions with other scripts
  707. setTimeout(function()
  708. {
  709. _self.$option_container.trigger('av-video-events-bound').addClass('av-video-events-bound');
  710. },50);
  711. },
  712. _supports_video: function() {
  713. return !!document.createElement('video').canPlayType;
  714. },
  715. /************************************************************************
  716. PUBLIC Methods
  717. *************************************************************************/
  718. api: function( action )
  719. {
  720. //commands on mobile can not be executed if the player was not started manually
  721. if(this.isMobile && !this.was_started()) return;
  722. // prevent calling of unbound function
  723. if(this.options.events.indexOf(action) === -1) return;
  724. // broadcast that the command was executed
  725. this.$option_container.trigger('av-video-'+action+'-executed');
  726. // calls the function based on action. eg: _html5_play()
  727. if(typeof this[ '_' + this.type + '_' + action] == 'function')
  728. {
  729. this[ '_' + this.type + '_' + action].call(this);
  730. }
  731. //call generic function eg: _toggle() or _play()
  732. if(typeof this[ '_' + action] == 'function')
  733. {
  734. this[ '_' + action].call(this);
  735. }
  736. },
  737. was_started: function()
  738. {
  739. if(!this.player) return false;
  740. switch(this.type)
  741. {
  742. case "html5":
  743. if(this.player.getCurrentTime() > 0) return true;
  744. break;
  745. case "vimeo":
  746. if(this.player.api('getCurrentTime') > 0) return true;
  747. break;
  748. case "youtube":
  749. if(this.player.getPlayerState() !== -1) return true;
  750. break;
  751. }
  752. return false;
  753. },
  754. /************************************************************************
  755. Generic Methods, are always executed and usually set variables
  756. *************************************************************************/
  757. _play: function()
  758. {
  759. this.playing = true;
  760. this.$option_container.addClass('av-video-playing').removeClass('av-video-paused');
  761. },
  762. _pause: function()
  763. {
  764. this.playing = false;
  765. this.$option_container.removeClass('av-video-playing').addClass('av-video-paused');
  766. },
  767. _loop: function()
  768. {
  769. this.options.loop = true;
  770. },
  771. _toggle: function( )
  772. {
  773. var command = this.playing == true ? 'pause' : 'play';
  774. this.api(command);
  775. this.pp.set(command);
  776. },
  777. /************************************************************************
  778. VIMEO Methods
  779. *************************************************************************/
  780. _vimeo_play: function( )
  781. {
  782. this.player.api('play');
  783. },
  784. _vimeo_pause: function( )
  785. {
  786. this.player.api('pause');
  787. },
  788. _vimeo_mute: function( )
  789. {
  790. this.player.api('setVolume', 0);
  791. },
  792. _vimeo_unmute: function( )
  793. {
  794. this.player.api('setVolume', 0.7);
  795. },
  796. _vimeo_loop: function( )
  797. {
  798. // currently throws error, must be set in iframe
  799. // this.player.api('setLoop', true);
  800. },
  801. _vimeo_reset: function( )
  802. {
  803. this.player.api('seekTo',0);
  804. },
  805. _vimeo_unload: function()
  806. {
  807. this.player.api('unload');
  808. },
  809. /************************************************************************
  810. YOUTUBE Methods
  811. *************************************************************************/
  812. _youtube_play: function( )
  813. {
  814. this.player.playVideo();
  815. },
  816. _youtube_pause: function( )
  817. {
  818. this.player.pauseVideo()
  819. },
  820. _youtube_mute: function( )
  821. {
  822. this.player.mute();
  823. },
  824. _youtube_unmute: function( )
  825. {
  826. this.player.unMute();
  827. },
  828. _youtube_loop: function( )
  829. {
  830. // does not work properly with iframe api. needs to manual loop on "end" event
  831. // this.player.setLoop(true);
  832. if(this.playing == true) this.player.seekTo(0);
  833. },
  834. _youtube_reset: function( )
  835. {
  836. this.player.stopVideo();
  837. },
  838. _youtube_unload: function()
  839. {
  840. this.player.clearVideo();
  841. },
  842. /************************************************************************
  843. HTML5 Methods
  844. *************************************************************************/
  845. _html5_play: function( )
  846. {
  847. //disable stoping of other videos in case the user wants to run section bgs
  848. this.player.options.pauseOtherPlayers = false;
  849. this.player.play();
  850. },
  851. _html5_pause: function( )
  852. {
  853. this.player.pause();
  854. },
  855. _html5_mute: function( )
  856. {
  857. this.player.setMuted(true);
  858. },
  859. _html5_unmute: function( )
  860. {
  861. this.player.setVolume(0.7);
  862. },
  863. _html5_loop: function( )
  864. {
  865. this.player.options.loop = true;
  866. },
  867. _html5_reset: function( )
  868. {
  869. this.player.setCurrentTime(0);
  870. },
  871. _html5_unload: function()
  872. {
  873. this._html5_pause();
  874. this._html5_reset();
  875. }
  876. }
  877. //simple wrapper to call the api. makes sure that the api data is not applied twice
  878. $.fn.aviaVideoApi = function( options , apply_to_parent)
  879. {
  880. return this.each(function()
  881. {
  882. // by default save the object as data to the initial video.
  883. // in the case of slideshows its more benefitial to save it to a parent element (eg: the slide)
  884. var applyTo = this;
  885. if(apply_to_parent)
  886. {
  887. applyTo = $(this).parents(apply_to_parent).get(0);
  888. }
  889. var self = $.data( applyTo, 'aviaVideoApi' );
  890. if(!self)
  891. {
  892. self = $.data( applyTo, 'aviaVideoApi', new $.AviaVideoAPI( options, this, applyTo ) );
  893. }
  894. });
  895. }
  896. })( jQuery );
  897. window.onYouTubeIframeAPIReady = function(){ $('body').trigger('av-youtube-iframe-api-loaded'); };
  898. // -------------------------------------------------------------------------------------------
  899. // Masonry
  900. // -------------------------------------------------------------------------------------------
  901. $.fn.avia_masonry = function(options)
  902. {
  903. //return if we didnt find anything
  904. if(!this.length) return this;
  905. var the_body = $('body'),
  906. the_win = $(window),
  907. isMobile = $.avia_utilities.isMobile,
  908. loading = false,
  909. methods = {
  910. masonry_filter: function()
  911. {
  912. var current = $(this),
  913. linktext = current.html(),
  914. selector = current.data('filter'),
  915. masonry = current.parents('.av-masonry:eq(0)'),
  916. container = masonry.find('.av-masonry-container:eq(0)'),
  917. links = masonry.find('.av-masonry-sort a'),
  918. activeCat = masonry.find('.av-current-sort-title');
  919. links.removeClass('active_sort');
  920. current.addClass('active_sort');
  921. container.attr('id', 'masonry_id_'+selector);
  922. if(activeCat.length) activeCat.html(linktext);
  923. methods.applyMasonry(container, selector, function()
  924. {
  925. container.css({overflow:'visible'});
  926. });
  927. return false;
  928. },
  929. applyMasonry: function(container, selector, callback)
  930. {
  931. var filters = selector ? {filter: '.'+selector} : {};
  932. container.isotope(filters, function()
  933. {
  934. the_win.trigger('av-height-change');
  935. });
  936. if(typeof callback == 'function')
  937. {
  938. setTimeout(callback, 0);
  939. }
  940. },
  941. show_bricks: function(bricks, callback)
  942. {
  943. bricks.each(function(i)
  944. {
  945. var currentLink = $(this),
  946. browserPrefix = $.avia_utilities.supports('transition'),
  947. multiplier = isMobile ? 0 : 100;
  948. setTimeout(function()
  949. {
  950. if(browserPrefix === false)
  951. {
  952. currentLink.css({visibility:"visible", opacity:0}).animate({opacity:1},1500);
  953. }
  954. else
  955. {
  956. currentLink.addClass('av-masonry-item-loaded');
  957. }
  958. if(i == bricks.length - 1 && typeof callback == 'function')
  959. {
  960. callback.call();
  961. the_win.trigger('av-height-change');
  962. }
  963. }, (multiplier * i));
  964. });
  965. },
  966. loadMore: function(e)
  967. {
  968. e.preventDefault();
  969. if(loading) return false;
  970. loading = true;
  971. var current = $(this),
  972. data = current.data(),
  973. masonry = current.parents('.av-masonry:eq(0)'),
  974. container = masonry.find('.av-masonry-container'),
  975. items = masonry.find('.av-masonry-entry'),
  976. loader = $.avia_utilities.loading(),
  977. finished = function(){ loading = false; loader.hide(); the_body.trigger('av_resize_finished'); };
  978. //calculate a new offset
  979. if(!data.offset){ data.offset = 0; }
  980. data.offset += data.items;
  981. data.action = 'avia_ajax_masonry_more';
  982. data.loaded = []; //prevents duplicate entries from beeing loaded when randomized is active
  983. items.each(function(){
  984. var item_id = $(this).data('av-masonry-item');
  985. if(item_id) data.loaded.push( item_id );
  986. });
  987. $.ajax({
  988. url: avia_framework_globals.ajaxurl,
  989. type: "POST",
  990. data:data,
  991. beforeSend: function()
  992. {
  993. loader.show();
  994. },
  995. success: function(response)
  996. {
  997. if(response.indexOf("{av-masonry-loaded}") !== -1)
  998. {
  999. //fetch the response. if any php warnings were displayed before rendering of the items the are removed by the string split
  1000. var response = response.split('{av-masonry-loaded}'),
  1001. new_items = $(response.pop()).filter('.isotope-item');
  1002. //check if we got more items than we need. if not we have reached the end of items
  1003. if(new_items.length > data.items)
  1004. {
  1005. new_items = new_items.not(':last');
  1006. }
  1007. else
  1008. {
  1009. current.addClass('av-masonry-no-more-items');
  1010. }
  1011. var load_container = $('<div class="loadcontainer"></div>').append(new_items);
  1012. $.avia_utilities.preload({container: load_container, single_callback: function()
  1013. {
  1014. var links = masonry.find('.av-masonry-sort a'),
  1015. filter_container = masonry.find('.av-sort-by-term');
  1016. filter_container.hide();
  1017. loader.hide();
  1018. container.isotope( 'insert', new_items);
  1019. $.avia_utilities.avia_ajax_call(masonry);
  1020. setTimeout( function(){ methods.show_bricks( new_items , finished); },150);
  1021. setTimeout(function(){ the_win.trigger('av-height-change'); }, 550);
  1022. if(links)
  1023. {
  1024. $(links).each(function(filterlinkindex){
  1025. var filterlink = $(this),
  1026. sort = filterlink.data('filter');
  1027. if(new_items)
  1028. {
  1029. $(new_items).each(function(itemindex){
  1030. var item = $(this);
  1031. if(item.hasClass(sort))
  1032. {
  1033. var term_count = filterlink.find('.avia-term-count').text();
  1034. filterlink.find('.avia-term-count').text(' ' + (parseInt(term_count) + 1) + ' ');
  1035. if(filterlink.hasClass('avia_hide_sort'))
  1036. {
  1037. filterlink.removeClass('avia_hide_sort').addClass('avia_show_sort');
  1038. masonry.find('.av-masonry-sort .'+sort+'_sep').removeClass('avia_hide_sort').addClass('avia_show_sort');
  1039. masonry.find('.av-masonry-sort .av-sort-by-term').removeClass('hidden');
  1040. }
  1041. }
  1042. });
  1043. }
  1044. });
  1045. }
  1046. filter_container.fadeIn();
  1047. }
  1048. });
  1049. }
  1050. else
  1051. {
  1052. finished();
  1053. }
  1054. },
  1055. error: finished,
  1056. complete: function()
  1057. {
  1058. }
  1059. });
  1060. }
  1061. };
  1062. return this.each(function()
  1063. {
  1064. var masonry = $(this),
  1065. container = masonry.find('.av-masonry-container'),
  1066. bricks = masonry.find('.isotope-item'),
  1067. filter = masonry.find('.av-masonry-sort').css({visibility:"visible", opacity:0}).on('click', 'a', methods.masonry_filter),
  1068. load_more = masonry.find('.av-masonry-load-more').css({visibility:"visible", opacity:0});
  1069. $.avia_utilities.preload({container: container, single_callback: function()
  1070. {
  1071. var start_animation = function()
  1072. {
  1073. filter.animate({opacity:1}, 400);
  1074. //fix for non aligned elements because of scrollbar
  1075. if(container.outerHeight() + container.offset().top + $('#footer').outerHeight() > $(window).height())
  1076. {
  1077. $('html').css({'overflow-y':'scroll'});
  1078. }
  1079. methods.applyMasonry(container, false, function()
  1080. {
  1081. masonry.addClass('avia_sortable_active');
  1082. container.removeClass('av-js-disabled ');
  1083. });
  1084. methods.show_bricks(bricks, function()
  1085. {
  1086. load_more.css({opacity:1}).on('click', methods.loadMore);
  1087. });
  1088. //container.isotope( 'reLayout' );
  1089. };
  1090. if(isMobile)
  1091. {
  1092. start_animation();
  1093. }
  1094. else
  1095. {
  1096. masonry.waypoint(start_animation , { offset: '80%'} );
  1097. }
  1098. // update columnWidth on window resize
  1099. $(window).on( 'debouncedresize', function()
  1100. {
  1101. methods.applyMasonry(container, false, function()
  1102. {
  1103. masonry.addClass('avia_sortable_active');
  1104. });
  1105. });
  1106. }
  1107. });
  1108. });
  1109. };
  1110. // -------------------------------------------------------------------------------------------
  1111. // Avia AJAX Portfolio
  1112. // -------------------------------------------------------------------------------------------
  1113. (function($)
  1114. {
  1115. "use strict";
  1116. $.avia_utilities = $.avia_utilities || {};
  1117. $.fn.avia_portfolio_preview = function(passed_options)
  1118. {
  1119. var win = $(window),
  1120. the_body = $('body'),
  1121. isMobile = $.avia_utilities.isMobile,
  1122. defaults =
  1123. {
  1124. open_in: '.portfolio-details-inner',
  1125. easing: 'easeOutQuint',
  1126. timing: 800,
  1127. transition: 'slide' // 'fade' or 'slide'
  1128. },
  1129. options = $.extend({}, defaults, passed_options);
  1130. return this.each(function()
  1131. {
  1132. var container = $(this),
  1133. portfolio_id = container.data('portfolio-id'),
  1134. target_wrap = $('.portfolio_preview_container[data-portfolio-id="' + portfolio_id + '"]'),
  1135. target_container = target_wrap.find(options.open_in),
  1136. items = container.find('.grid-entry'),
  1137. content_retrieved = {},
  1138. is_open = false,
  1139. animating = false,
  1140. index_open = false,
  1141. ajax_call = false,
  1142. methods,
  1143. controls,
  1144. loader = $.avia_utilities.loading();
  1145. methods =
  1146. {
  1147. load_item: function(e)
  1148. {
  1149. e.preventDefault();
  1150. var link = $(this),
  1151. post_container = link.parents('.post-entry:eq(0)'),
  1152. post_id = "ID_" + post_container.data('ajax-id'),
  1153. clickedIndex = items.index(post_container);
  1154. //check if current item is the clicked item or if we are currently animating
  1155. if(post_id === is_open || animating == true)
  1156. {
  1157. return false;
  1158. }
  1159. animating = true;
  1160. container.find('.active_portfolio_item').removeClass('active_portfolio_item');
  1161. post_container.addClass('active_portfolio_item');
  1162. loader.show();
  1163. methods.ajax_get_contents(post_id, clickedIndex);
  1164. },
  1165. scroll_top: function()
  1166. {
  1167. setTimeout(function()
  1168. {
  1169. var target_offset = target_wrap.offset().top - 175,
  1170. window_offset = win.scrollTop();
  1171. if(window_offset > target_offset || target_offset - window_offset > 100 )
  1172. {
  1173. $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target_offset }, options.timing, options.easing);
  1174. }
  1175. },10);
  1176. },
  1177. attach_item: function(post_id)
  1178. {
  1179. content_retrieved[post_id] = $(content_retrieved[post_id]).appendTo(target_container);
  1180. ajax_call = true;
  1181. },
  1182. remove_video: function()
  1183. {
  1184. var del = target_wrap.find('iframe, .avia-video').parents('.ajax_slide:not(.open_slide)');
  1185. if(del.length > 0)
  1186. {
  1187. del.remove();
  1188. content_retrieved["ID_" + del.data('slideId')] = undefined;
  1189. }
  1190. },
  1191. show_item: function(post_id, clickedIndex)
  1192. {
  1193. //check if current item is the clicked item or if we are currently animating
  1194. if(post_id === is_open)
  1195. {
  1196. return false;
  1197. }
  1198. animating = true;
  1199. loader.hide();
  1200. if(false === is_open)
  1201. {
  1202. target_wrap.addClass('open_container');
  1203. content_retrieved[post_id].addClass('open_slide');
  1204. methods.scroll_top();
  1205. target_wrap.css({display:'none'}).slideDown(options.timing, options.easing, function()
  1206. {
  1207. if(ajax_call)
  1208. {
  1209. activate_shortcode_scripts(content_retrieved[post_id]);
  1210. $.avia_utilities.avia_ajax_call(content_retrieved[post_id]);
  1211. the_body.trigger('av_resize_finished');
  1212. ajax_call = false;
  1213. }
  1214. methods.remove_video();
  1215. the_body.trigger('av_resize_finished');
  1216. });
  1217. index_open = clickedIndex;
  1218. is_open = post_id;
  1219. animating = false;
  1220. }
  1221. else
  1222. {
  1223. methods.scroll_top();
  1224. var initCSS = { zIndex:3 },
  1225. easing = options.easing;
  1226. if(index_open > clickedIndex) { initCSS.left = '-110%'; }
  1227. if(options.transition === 'fade'){ initCSS.left = '0%'; initCSS.opacity = 0; easing = 'easeOutQuad'; }
  1228. //fixate height for container during animation
  1229. target_container.height(target_container.height()); //outerHeight = border problems?
  1230. content_retrieved[post_id].css(initCSS).avia_animate({'left':"0%", opacity:1}, options.timing, easing);
  1231. content_retrieved[is_open].avia_animate({opacity:0}, options.timing, easing, function()
  1232. {
  1233. content_retrieved[is_open].attr({'style':""}).removeClass('open_slide');
  1234. content_retrieved[post_id].addClass('open_slide');
  1235. //+ 2 fixes border problem (slides move up and down 2 px on transition)
  1236. target_container.avia_animate({height: content_retrieved[post_id].outerHeight() + 2}, options.timing/2, options.easing, function()
  1237. {
  1238. target_container.attr({'style':""});
  1239. is_open = post_id;
  1240. index_open = clickedIndex;
  1241. animating = false;
  1242. methods.remove_video();
  1243. if(ajax_call)
  1244. {
  1245. the_body.trigger('av_resize_finished');
  1246. activate_shortcode_scripts(content_retrieved[post_id]);
  1247. $.avia_utilities.avia_ajax_call(content_retrieved[post_id]);
  1248. ajax_call = false;
  1249. }
  1250. });
  1251. });
  1252. }
  1253. },
  1254. ajax_get_contents: function(post_id, clickedIndex)
  1255. {
  1256. if(content_retrieved[post_id] !== undefined)
  1257. {
  1258. methods.show_item(post_id, clickedIndex);
  1259. return;
  1260. }
  1261. content_retrieved[post_id] = $('#avia-tmpl-portfolio-preview-' + post_id.replace(/ID_/,"")).html();
  1262. //this line is necessary to prevent w3 total cache from messing up the portfolio if inline js is compressed
  1263. content_retrieved[post_id] = content_retrieved[post_id].replace('/*<![CDATA[*/','').replace('*]]>','');
  1264. methods.attach_item(post_id);
  1265. $.avia_utilities.preload({container: content_retrieved[post_id] , single_callback: function(){ methods.show_item(post_id, clickedIndex); }});
  1266. },
  1267. add_controls: function()
  1268. {
  1269. controls = target_wrap.find('.ajax_controlls');
  1270. target_wrap.avia_keyboard_controls({27:'.avia_close', 37:'.ajax_previous', 39:'.ajax_next'});
  1271. //target_wrap.avia_swipe_trigger({prev:'.ajax_previous', next:'.ajax_next'});
  1272. items.each(function(){
  1273. var current = $(this), overlay;
  1274. current.addClass('no_combo').bind('click', function(event)
  1275. {
  1276. overlay = current.find('.slideshow_overlay');
  1277. if(overlay.length)
  1278. {
  1279. event.stopPropagation();
  1280. methods.load_item.apply(current.find('a:eq(0)'));
  1281. return false;
  1282. }
  1283. });
  1284. });
  1285. },
  1286. control_click: function()
  1287. {
  1288. var showItem,
  1289. activeID = container.find('.active_portfolio_item').data('ajax-id'),
  1290. active = container.find('.post-entry-'+activeID);
  1291. switch(this.hash)
  1292. {
  1293. case '#next':
  1294. showItem = active.nextAll('.post-entry:visible:eq(0)').find('a:eq(0)');
  1295. if(!showItem.length) { showItem = $('.post-entry:visible:eq(0)', container).find('a:eq(0)'); }
  1296. showItem.trigger('click');
  1297. break;
  1298. case '#prev':
  1299. showItem = active.prevAll('.post-entry:visible:eq(0)').find('a:eq(0)');
  1300. if(!showItem.length) { showItem = $('.post-entry:visible:last', container).find('a:eq(0)'); }
  1301. showItem.trigger('click');
  1302. break;
  1303. case '#close':
  1304. animating = true;
  1305. target_wrap.slideUp( options.timing, options.easing, function()
  1306. {
  1307. container.find('.active_portfolio_item').removeClass('active_portfolio_item');
  1308. content_retrieved[is_open].attr({'style':""}).removeClass('open_slide');
  1309. target_wrap.removeClass('open_container');
  1310. animating = is_open = index_open = false;
  1311. methods.remove_video();
  1312. the_body.trigger('av_resize_finished');
  1313. });
  1314. break;
  1315. }
  1316. return false;
  1317. },
  1318. resize_reset: function()
  1319. {
  1320. if(is_open === false)
  1321. {
  1322. target_container.html('');
  1323. content_retrieved = [];
  1324. }
  1325. }
  1326. };
  1327. methods.add_controls();
  1328. container.on("click", "a", methods.load_item);
  1329. controls.on("click", "a", methods.control_click);
  1330. if(jQuery.support.leadingWhitespace) { win.bind('debouncedresize', methods.resize_reset); }
  1331. });
  1332. };
  1333. }(jQuery));
  1334. // -------------------------------------------------------------------------------------------
  1335. // Fullscreen Slideshow
  1336. //
  1337. // extends avia slideshow script with a more sophisticated preloader and fixed size for slider
  1338. // -------------------------------------------------------------------------------------------
  1339. $.AviaFullscreenSlider = function(options, slider)
  1340. {
  1341. this.$slider = $( slider );
  1342. this.$inner = this.$slider.find('.avia-slideshow-inner');
  1343. this.$innerLi = this.$inner.find('>li');
  1344. this.$caption = this.$inner.find('.avia-slide-wrap .caption_container');
  1345. this.$win = $( window );
  1346. this.isMobile = $.avia_utilities.isMobile;
  1347. this.property = {};
  1348. this.scrollPos = "0";
  1349. this.transform3d= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
  1350. this.ticking = false;
  1351. if($.avia_utilities.supported.transition === undefined)
  1352. {
  1353. $.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
  1354. }
  1355. this._init( options );
  1356. }
  1357. $.AviaFullscreenSlider.defaults = {
  1358. //height of the slider in percent
  1359. height: 100,
  1360. //subtract elements from the height
  1361. subtract: '#wpadminbar, #header, #main>.title_container'
  1362. };
  1363. $.AviaFullscreenSlider.prototype =
  1364. {
  1365. _init: function( options )
  1366. {
  1367. var _self = this;
  1368. //set the default options
  1369. this.options = $.extend( true, {}, $.AviaFullscreenSlider.defaults, options );
  1370. if(this.$slider.data('slide_height')) this.options.height = this.$slider.data('slide_height');
  1371. //elements that get subtracted from the image height
  1372. this.$subtract = $(this.options.subtract);
  1373. // set the slideshow size
  1374. this._setSize();
  1375. // set resizing script on window resize
  1376. this.$win.on( 'debouncedresize', $.proxy( this._setSize, this) );
  1377. //parallax scroll if element if leaving viewport
  1378. setTimeout(function()
  1379. {
  1380. if(!_self.isMobile) //disable parallax scrolling on mobile
  1381. _self.$win.on( 'scroll', $.proxy( _self._on_scroll, _self) );
  1382. },100);
  1383. /**/
  1384. //activate the defaule slider
  1385. this.$slider.aviaSlider({bg_slider:true});
  1386. },
  1387. _on_scroll: function(e)
  1388. {
  1389. var _self = this;
  1390. if(!_self.ticking) {
  1391. _self.ticking = true;
  1392. window.requestAnimationFrame( $.proxy( _self._parallax_scroll, _self) );
  1393. }
  1394. },
  1395. _fetch_properties: function(slide_height)
  1396. {
  1397. this.property.offset = this.$slider.offset().top;
  1398. this.property.wh = this.$win.height();
  1399. this.property.height = slide_height || this.$slider.outerHeight();
  1400. //re-position the slider
  1401. this._parallax_scroll();
  1402. },
  1403. _setSize: function( )
  1404. {
  1405. if(!$.fn.avia_browser_height)
  1406. {
  1407. var viewport = this.$win.height(),
  1408. slide_height = Math.ceil( (viewport / 100) * this.options.height );
  1409. if(this.$subtract.length && this.options.height == 100)
  1410. {
  1411. this.$subtract.each(function()
  1412. {
  1413. slide_height -= this.offsetHeight - 0.5;
  1414. });
  1415. }
  1416. else
  1417. {
  1418. slide_height -= 1;
  1419. }
  1420. this.$slider.height(slide_height).removeClass('av-default-height-applied');
  1421. this.$inner.css('padding',0);
  1422. }
  1423. this._fetch_properties(slide_height);
  1424. },
  1425. _parallax_scroll: function(e)
  1426. {
  1427. if(this.isMobile) return; //disable parallax scrolling on mobile
  1428. var winTop = this.$win.scrollTop(),
  1429. winBottom = winTop + this.property.wh,
  1430. scrollPos = "0",
  1431. prop = {}, prop2 = {};
  1432. if(this.property.offset < winTop && winTop <= this.property.offset + this.property.height)
  1433. {
  1434. scrollPos = Math.round( (winTop - this.property.offset) * 0.3 );
  1435. }
  1436. if(this.scrollPos != scrollPos)
  1437. {
  1438. //slide background parallax
  1439. this.scrollPos = scrollPos;
  1440. //currently no 3d transform, because of browser quirks
  1441. //this.transform3d = false;
  1442. if(this.transform3d)
  1443. {
  1444. prop[$.avia_utilities.supported.transition+"transform"] = "translate3d(0px,"+ scrollPos +"px,0px)";
  1445. }
  1446. else
  1447. {
  1448. prop[$.avia_utilities.supported.transition+"transform"] = "translate(0px,"+ scrollPos +"px)";
  1449. }
  1450. this.$inner.css(prop);
  1451. //slider caption parallax
  1452. // prop2[$.avia_utilities.supported.transition+"transform"] = "translate(0px,-"+ ( scrollPos * 1) +"px)";
  1453. /*
  1454. prop2['opacity'] = Math.ceil((this.$slider.height() - (scrollPos * 2)) / 100)/ 10;
  1455. prop2['opacity'] = prop2['opacity'] < 0 ? 0 : prop2['opacity'];
  1456. this.$caption.css(prop2);
  1457. */
  1458. }
  1459. this.ticking = false;
  1460. }
  1461. };
  1462. $.fn.aviaFullscreenSlider = function( options )
  1463. {
  1464. return this.each(function()
  1465. {
  1466. var active = $.data( this, 'aviaFullscreenSlider' );
  1467. if(!active)
  1468. {
  1469. //make sure that the function doesnt get aplied a second time
  1470. $.data( this, 'aviaFullscreenSlider', 1 );
  1471. //create the preparations for fullscreen slider
  1472. new $.AviaFullscreenSlider( options, this );
  1473. }
  1474. });
  1475. }
  1476. // -------------------------------------------------------------------------------------------
  1477. // makes sure that the fixed container height is removed once the layerslider is loaded, so it adapts to the screen resolution
  1478. // -------------------------------------------------------------------------------------------
  1479. $.AviaParallaxElement = function(options, element)
  1480. {
  1481. this.$el = $( element ).addClass('active-parallax');
  1482. this.$win = $( window );
  1483. this.$body = $( 'body' );
  1484. this.$parent = this.$el.parent();
  1485. this.property = {};
  1486. this.isMobile = $.avia_utilities.isMobile;
  1487. this.ratio = this.$el.data('avia-parallax-ratio') || 0.5;
  1488. this.transform = document.documentElement.className.indexOf('avia_transform') !== -1 ? true : false;
  1489. this.transform3d= document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
  1490. this.ticking = false;
  1491. if($.avia_utilities.supported.transition === undefined)
  1492. {
  1493. $.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
  1494. }
  1495. this._init( options );
  1496. }
  1497. $.AviaParallaxElement.prototype = {
  1498. _init: function( options )
  1499. {
  1500. var _self = this;
  1501. if(_self.isMobile)
  1502. {
  1503. return; //disable parallax scrolling on mobile
  1504. }
  1505. //fetch window constants
  1506. setTimeout(function()
  1507. {
  1508. _self._fetch_properties();
  1509. },30);
  1510. this.$win.on("debouncedresize av-height-change", $.proxy( _self._fetch_properties, _self));
  1511. this.$body.on("av_resize_finished", $.proxy( _self._fetch_properties, _self));
  1512. //activate the scrolling
  1513. setTimeout(function()
  1514. {
  1515. _self.$win.on( 'scroll', $.proxy( _self._on_scroll, _self) );
  1516. },100);
  1517. },
  1518. _fetch_properties: function()
  1519. {
  1520. this.property.offset = this.$parent.offset().top;
  1521. this.property.wh = this.$win.height();
  1522. this.property.height = this.$parent.outerHeight();
  1523. //set the height of the element based on the windows height, offset ratio and parent height
  1524. this.$el.height(Math.ceil((this.property.wh * this.ratio) + this.property.height));
  1525. //re-position the element
  1526. this._parallax_scroll();
  1527. },
  1528. _on_scroll: function(e)
  1529. {
  1530. var _self = this;
  1531. if(!_self.ticking) {
  1532. _self.ticking = true;
  1533. window.requestAnimationFrame( $.proxy( _self._parallax_scroll, _self) );
  1534. }
  1535. },
  1536. _parallax_scroll: function(e)
  1537. {
  1538. var winTop = this.$win.scrollTop(),
  1539. winBottom = winTop + this.property.wh,
  1540. scrollPos = "0",
  1541. prop = {};
  1542. //shift element when it moves into viewport
  1543. if(this.property.offset < winBottom && winTop <= this.property.offset + this.property.height)
  1544. {
  1545. scrollPos = Math.ceil( (winBottom - this.property.offset) * this.ratio );
  1546. //parallax movement via backround position change, although
  1547. if(this.transform3d)
  1548. {
  1549. prop[$.avia_utilities.supported.transition+"transform"] = "translate3d(0px,"+ scrollPos +"px, 0px)";
  1550. }
  1551. else if(this.transform)
  1552. {
  1553. prop[$.avia_utilities.supported.transition+"transform"] = "translate(0px,"+ scrollPos +"px)";
  1554. }
  1555. else
  1556. {
  1557. prop["background-position"] = "0px "+ scrollPos +"px";
  1558. }
  1559. this.$el.css(prop);
  1560. }
  1561. this.ticking = false;
  1562. }
  1563. };
  1564. $.fn.avia_parallax = function(options)
  1565. {
  1566. return this.each(function()
  1567. {
  1568. var self = $.data( this, 'aviaParallax' );
  1569. if(!self)
  1570. {
  1571. self = $.data( this, 'aviaParallax', new $.AviaParallaxElement( options, this ) );
  1572. }
  1573. });
  1574. }
  1575. // -------------------------------------------------------------------------------------------
  1576. // Helper to allow fixed bgs on mobile
  1577. // -------------------------------------------------------------------------------------------
  1578. $.fn.avia_mobile_fixed = function(options)
  1579. {
  1580. var isMobile = $.avia_utilities.isMobile;
  1581. if(!isMobile) return;
  1582. return this.each(function()
  1583. {
  1584. var current = $(this).addClass('av-parallax-section'),
  1585. $background = current.attr('style'),
  1586. $attachment_class = current.data('section-bg-repeat'),
  1587. template = "";
  1588. if($attachment_class == 'stretch' || $attachment_class == 'no-repeat' )
  1589. {
  1590. $attachment_class = " avia-full-stretch";
  1591. }
  1592. else
  1593. {
  1594. $attachment_class = "";
  1595. }
  1596. template = "<div class='av-parallax " + $attachment_class + "' data-avia-parallax-ratio='0.0' style = '" + $background + "' ></div>";
  1597. current.prepend(template);
  1598. current.attr('style','');
  1599. });
  1600. }
  1601. // -------------------------------------------------------------------------------------------
  1602. // makes sure that the fixed container height is removed once the layerslider is loaded, so it adapts to the screen resolution
  1603. // -------------------------------------------------------------------------------------------
  1604. $.fn.layer_slider_height_helper = function(options)
  1605. {
  1606. return this.each(function()
  1607. {
  1608. var container = $(this),
  1609. first_div = container.find('>div:first'),
  1610. timeout = false,
  1611. counter = 0,
  1612. reset_size = function()
  1613. {
  1614. if(first_div.height() > 0 || counter > 5)
  1615. {
  1616. container.height('auto');
  1617. }
  1618. else
  1619. {
  1620. timeout = setTimeout(reset_size, 500);
  1621. counter++;
  1622. }
  1623. };
  1624. if(!first_div.length) return;
  1625. timeout = setTimeout(reset_size, 0);
  1626. });
  1627. }
  1628. // -------------------------------------------------------------------------------------------
  1629. // testimonial shortcode javascript
  1630. // -------------------------------------------------------------------------------------------
  1631. $.fn.avia_sc_testimonial = function(options)
  1632. {
  1633. return this.each(function()
  1634. {
  1635. var container = $(this), elements = container.find('.avia-testimonial');
  1636. //trigger displaying of thumbnails
  1637. container.on('avia_start_animation', function()
  1638. {
  1639. elements.each(function(i)
  1640. {
  1641. var element = $(this);
  1642. setTimeout(function(){ element.addClass('avia_start_animation') }, (i * 150));
  1643. });
  1644. });
  1645. });
  1646. }
  1647. // -------------------------------------------------------------------------------------------
  1648. // Progress bar shortcode javascript
  1649. // -------------------------------------------------------------------------------------------
  1650. $.fn.avia_sc_progressbar = function(options)
  1651. {
  1652. return this.each(function()
  1653. {
  1654. var container = $(this), elements = container.find('.progress');
  1655. //trigger displaying of thumbnails
  1656. container.on('avia_start_animation', function()
  1657. {
  1658. elements.each(function(i)
  1659. {
  1660. var element = $(this);
  1661. setTimeout(function(){ element.addClass('avia_start_animation') }, (i * 250));
  1662. });
  1663. });
  1664. });
  1665. }
  1666. // -------------------------------------------------------------------------------------------
  1667. // Iconlist shortcode javascript
  1668. // -------------------------------------------------------------------------------------------
  1669. $.fn.avia_sc_iconlist = function(options)
  1670. {
  1671. return this.each(function()
  1672. {
  1673. var iconlist = $(this), elements = iconlist.find('>li');
  1674. //trigger displaying of thumbnails
  1675. iconlist.on('avia_start_animation', function()
  1676. {
  1677. elements.each(function(i)
  1678. {
  1679. var element = $(this);
  1680. setTimeout(function(){ element.addClass('avia_start_animation') }, (i * 350));
  1681. });
  1682. });
  1683. });
  1684. }
  1685. // -------------------------------------------------------------------------------------------
  1686. // shortcode javascript for delayed animation even when non connected elements are used
  1687. // -------------------------------------------------------------------------------------------
  1688. $.fn.avia_sc_animation_delayed = function(options)
  1689. {
  1690. var global_timer = 0,
  1691. delay = options.delay || 50;
  1692. return this.each(function()
  1693. {
  1694. var elements = $(this);
  1695. //trigger displaying of thumbnails
  1696. elements.on('avia_start_animation', function()
  1697. {
  1698. var element = $(this);
  1699. global_timer ++;
  1700. setTimeout(function(){ element.addClass('avia_start_delayed_animation'); global_timer --; }, (global_timer * delay));
  1701. });
  1702. });
  1703. }
  1704. // -------------------------------------------------------------------------------------------
  1705. // Section Height Helper
  1706. // -------------------------------------------------------------------------------------------
  1707. $.fn.avia_browser_height = function()
  1708. {
  1709. if(!this.length) return;
  1710. var win = $(window),
  1711. html_el = $('html'),
  1712. subtract = $('#wpadminbar, #header.av_header_top:not(.html_header_transparency #header), #main>.title_container'),
  1713. css_block = $("<style type='text/css' id='av-browser-height'></style>").appendTo('head:first'),
  1714. sidebar_menu= $('.html_header_sidebar #top #header_main'),
  1715. full_slider = $('.html_header_sidebar .avia-fullscreen-slider.avia-builder-el-0.avia-builder-el-no-sibling').addClass('av-solo-full'),
  1716. calc_height = function()
  1717. {
  1718. var css = "",
  1719. wh100 = win.height(),
  1720. ww100 = win.width(),
  1721. wh100_mod = wh100,
  1722. whCover = (wh100 / 9) * 16,
  1723. wwCover = (ww100 / 16) * 9,
  1724. wh75 = Math.round( wh100 * 0.75 ),
  1725. wh50 = Math.round( wh100 * 0.5 ),
  1726. wh25 = Math.round( wh100 * 0.25 ),
  1727. solo = 0;
  1728. if(sidebar_menu.length) solo = sidebar_menu.height();
  1729. subtract.each(function(){ wh100_mod -= this.offsetHeight - 1; });
  1730. var whCoverMod = (wh100_mod / 9) * 16;
  1731. //fade in of section content with minimum height once the height has been calculated
  1732. css += ".avia-section.av-minimum-height .container{opacity: 1; }\n";
  1733. //various section heights (100-25% as well as 100% - header/adminbar in case its the first builder element)
  1734. css += ".av-minimum-height-100 .container, .avia-fullscreen-slider .avia-slideshow, #top.avia-blank .av-minimum-height-100 .container{height:"+wh100+"px;}\n";
  1735. css += ".av-minimum-height-75 .container {height:"+wh75+"px;}\n";
  1736. css += ".av-minimum-height-50 .container {height:"+wh50+"px;}\n";
  1737. css += ".av-minimum-height-25 .container {height:"+wh25+"px;}\n";
  1738. css += ".avia-builder-el-0.av-minimum-height-100 .container, .avia-builder-el-0.avia-fullscreen-slider .avia-slideshow{height:"+wh100_mod+"px;}\n";
  1739. css += "#top .av-solo-full .avia-slideshow {min-height:"+solo+"px;}\n";
  1740. //fullscreen video calculations
  1741. if(ww100/wh100 < 16/9)
  1742. {
  1743. 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";
  1744. }
  1745. else
  1746. {
  1747. 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";
  1748. }
  1749. if(ww100/wh100_mod < 16/9)
  1750. {
  1751. 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";
  1752. }
  1753. else
  1754. {
  1755. 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";
  1756. }
  1757. //ie8 needs different insert method
  1758. try{
  1759. css_block.text(css);
  1760. }
  1761. catch(err){
  1762. css_block.remove();
  1763. css_block = $("<style type='text/css' id='av-browser-height'>"+css+"</style>").appendTo('head:first');
  1764. }
  1765. setTimeout(function(){ win.trigger('av-height-change'); /*broadcast the height change*/ },100);
  1766. };
  1767. win.on( 'debouncedresize', calc_height);
  1768. calc_height();
  1769. }
  1770. // -------------------------------------------------------------------------------------------
  1771. // Video Section helper
  1772. // -------------------------------------------------------------------------------------------
  1773. $.fn.avia_video_section = function()
  1774. {
  1775. if(!this.length) return;
  1776. var elements = this.length, content = "",
  1777. win = $(window),
  1778. css_block = $("<style type='text/css' id='av-section-height'></style>").appendTo('head:first'),
  1779. calc_height = function(section, counter)
  1780. {
  1781. if(counter === 0) { content = "";}
  1782. var css = "",
  1783. the_id = '#' +section.attr('id'),
  1784. wh100 = section.height(),
  1785. ww100 = section.width(),
  1786. aspect = section.data('sectionVideoRatio').split(':'),
  1787. video_w = aspect[0],
  1788. video_h = aspect[1],
  1789. whCover = (wh100 / video_h ) * video_w,
  1790. wwCover = (ww100 / video_w ) * video_h;
  1791. //fullscreen video calculations
  1792. if(ww100/wh100 < video_w/video_h)
  1793. {
  1794. 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";
  1795. }
  1796. else
  1797. {
  1798. 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";
  1799. }
  1800. content = content + css;
  1801. if(elements == counter + 1)
  1802. {
  1803. //ie8 needs different insert method
  1804. try{
  1805. css_block.text(content);
  1806. }
  1807. catch(err){
  1808. css_block.remove();
  1809. css_block = $("<style type='text/css' id='av-section-height'>"+content+"</style>").appendTo('head:first');
  1810. }
  1811. }
  1812. };
  1813. return this.each(function(i)
  1814. {
  1815. var self = $(this);
  1816. win.on( 'debouncedresize', function(){ calc_height(self, i); });
  1817. calc_height(self, i);
  1818. });
  1819. }
  1820. // -------------------------------------------------------------------------------------------
  1821. // Gallery shortcode javascript
  1822. // -------------------------------------------------------------------------------------------
  1823. $.fn.avia_sc_gallery = function(options)
  1824. {
  1825. return this.each(function()
  1826. {
  1827. var gallery = $(this), images = gallery.find('img'), big_prev = gallery.find('.avia-gallery-big');
  1828. //trigger displaying of thumbnails
  1829. gallery.on('avia_start_animation', function()
  1830. {
  1831. images.each(function(i)
  1832. {
  1833. var image = $(this);
  1834. setTimeout(function(){ image.addClass('avia_start_animation') }, (i * 110));
  1835. });
  1836. });
  1837. if(gallery.hasClass('deactivate_avia_lazyload')) gallery.trigger('avia_start_animation');
  1838. //trigger thumbnail hover and big prev image change
  1839. if(big_prev.length)
  1840. {
  1841. gallery.on('mouseenter','.avia-gallery-thumb a', function()
  1842. {
  1843. var _self = this;
  1844. big_prev.attr('data-onclick', _self.getAttribute("data-onclick"));
  1845. big_prev.height(big_prev.height());
  1846. big_prev.attr('href', _self.href)
  1847. var newImg = _self.getAttribute("data-prev-img"),
  1848. oldImg = big_prev.find('img'),
  1849. oldImgSrc = oldImg.attr('src');
  1850. if(newImg != oldImgSrc)
  1851. {
  1852. var next_img = new Image();
  1853. next_img.src = newImg;
  1854. var $next = $(next_img);
  1855. if(big_prev.hasClass('avia-gallery-big-no-crop-thumb'))
  1856. {
  1857. $next.css({'height':big_prev.height(),'width':'auto'});
  1858. }
  1859. big_prev.stop().animate({opacity:0}, function()
  1860. {
  1861. $next.insertAfter(oldImg);
  1862. oldImg.remove();
  1863. big_prev.animate({opacity:1});
  1864. big_prev.attr('title',$(_self).attr('title'));
  1865. });
  1866. }
  1867. });
  1868. big_prev.on('click', function()
  1869. {
  1870. var imagelink = gallery.find('.avia-gallery-thumb a').eq(this.getAttribute("data-onclick") - 1);
  1871. if(imagelink && !imagelink.hasClass('aviaopeninbrowser'))
  1872. {
  1873. imagelink.trigger('click');
  1874. }
  1875. else if(imagelink)
  1876. {
  1877. var imgurl = imagelink.attr("href");
  1878. if(imagelink.hasClass('aviablank') && imgurl != '' )
  1879. {
  1880. window.open(imgurl, '_blank');
  1881. }
  1882. else if( imgurl != '' )
  1883. {
  1884. window.open(imgurl, '_self');
  1885. }
  1886. }
  1887. return false;
  1888. });
  1889. $(window).on("debouncedresize", function()
  1890. {
  1891. big_prev.height('auto');
  1892. });
  1893. }
  1894. });
  1895. }
  1896. // -------------------------------------------------------------------------------------------
  1897. // Toggle shortcode javascript
  1898. // -------------------------------------------------------------------------------------------
  1899. $.fn.avia_sc_toggle = function(options)
  1900. {
  1901. var defaults =
  1902. {
  1903. single: '.single_toggle',
  1904. heading: '.toggler',
  1905. content: '.toggle_wrap',
  1906. sortContainer:'.taglist'
  1907. };
  1908. var win = $(window),
  1909. options = $.extend(defaults, options);
  1910. return this.each(function()
  1911. {
  1912. var container = $(this).addClass('enable_toggles'),
  1913. toggles = $(options.single, container),
  1914. heading = $(options.heading, container),
  1915. allContent = $(options.content, container),
  1916. sortLinks = $(options.sortContainer + " a", container);
  1917. heading.each(function(i)
  1918. {
  1919. var thisheading = $(this), content = thisheading.next(options.content, container);
  1920. function scroll_to_viewport()
  1921. {
  1922. //check if toggle title is in viewport. if not scroll up
  1923. var el_offset = content.offset().top,
  1924. scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10);
  1925. if(win.scrollTop() > el_offset)
  1926. {
  1927. $('html:not(:animated),body:not(:animated)').animate({scrollTop: scoll_target},200);
  1928. }
  1929. }
  1930. if(content.css('visibility') != "hidden")
  1931. {
  1932. thisheading.addClass('activeTitle');
  1933. }
  1934. thisheading.on('click', function()
  1935. {
  1936. if(content.css('visibility') != "hidden")
  1937. {
  1938. content.slideUp(200, function()
  1939. {
  1940. content.removeClass('active_tc').attr({style:''});
  1941. win.trigger('av-height-change');
  1942. });
  1943. thisheading.removeClass('activeTitle');
  1944. }
  1945. else
  1946. {
  1947. if(container.is('.toggle_close_all'))
  1948. {
  1949. allContent.not(content).slideUp(200, function()
  1950. {
  1951. $(this).removeClass('active_tc').attr({style:''});
  1952. scroll_to_viewport();
  1953. });
  1954. heading.removeClass('activeTitle');
  1955. }
  1956. content.addClass('active_tc').slideDown(200,
  1957. function()
  1958. {
  1959. if(!container.is('.toggle_close_all'))
  1960. {
  1961. scroll_to_viewport();
  1962. }
  1963. win.trigger('av-height-change');
  1964. }
  1965. );
  1966. thisheading.addClass('activeTitle');
  1967. location.replace(thisheading.data('fake-id'));
  1968. }
  1969. });
  1970. });
  1971. sortLinks.click(function(e){
  1972. e.preventDefault();
  1973. var show = toggles.filter('[data-tags~="'+$(this).data('tag')+'"]'),
  1974. hide = toggles.not('[data-tags~="'+$(this).data('tag')+'"]');
  1975. sortLinks.removeClass('activeFilter');
  1976. $(this).addClass('activeFilter');
  1977. heading.filter('.activeTitle').trigger('click');
  1978. show.slideDown();
  1979. hide.slideUp();
  1980. });
  1981. function trigger_default_open(hash)
  1982. {
  1983. if(!hash && window.location.hash) hash = window.location.hash;
  1984. if(!hash) return;
  1985. var open = heading.filter('[data-fake-id="'+hash+'"]');
  1986. if(open.length)
  1987. {
  1988. if(!open.is('.activeTitle')) open.trigger('click');
  1989. window.scrollTo(0, container.offset().top - 70);
  1990. }
  1991. }
  1992. trigger_default_open(false);
  1993. $('a').on('click',function(){
  1994. var hash = $(this).attr('href');
  1995. if(typeof hash != "undefined" && hash)
  1996. {
  1997. hash = hash.replace(/^.*?#/,'');
  1998. trigger_default_open('#'+hash);
  1999. }
  2000. });
  2001. });
  2002. };
  2003. // -------------------------------------------------------------------------------------------
  2004. // Tab Shortcode
  2005. // -------------------------------------------------------------------------------------------
  2006. $.fn.avia_sc_tabs= function(options)
  2007. {
  2008. var defaults =
  2009. {
  2010. heading: '.tab',
  2011. content:'.tab_content',
  2012. active:'active_tab',
  2013. sidebar: false
  2014. };
  2015. var win = $(window)
  2016. options = $.extend(defaults, options);
  2017. return this.each(function()
  2018. {
  2019. var container = $(this),
  2020. tab_titles = $('<div class="tab_titles"></div>').prependTo(container),
  2021. tabs = $(options.heading, container),
  2022. content = $(options.content, container),
  2023. newtabs = false,
  2024. oldtabs = false;
  2025. newtabs = tabs.clone();
  2026. oldtabs = tabs.addClass('fullsize-tab');
  2027. tabs = newtabs;
  2028. tabs.prependTo(tab_titles).each(function(i)
  2029. {
  2030. var tab = $(this), the_oldtab = false;
  2031. if(newtabs) the_oldtab = oldtabs.filter(':eq('+i+')');
  2032. tab.addClass('tab_counter_'+i).bind('click', function()
  2033. {
  2034. open_content(tab, i, the_oldtab);
  2035. return false;
  2036. });
  2037. if(newtabs)
  2038. {
  2039. the_oldtab.bind('click', function()
  2040. {
  2041. open_content(the_oldtab, i, tab);
  2042. return false;
  2043. });
  2044. }
  2045. });
  2046. set_size();
  2047. trigger_default_open(false);
  2048. win.on("debouncedresize", set_size);
  2049. $('a').on('click',function(){
  2050. var hash = $(this).attr('href');
  2051. if(typeof hash != "undefined" && hash)
  2052. {
  2053. hash = hash.replace(/^.*?#/,'');
  2054. trigger_default_open('#'+hash);
  2055. }
  2056. });
  2057. function set_size()
  2058. {
  2059. if(!options.sidebar) return;
  2060. content.css({'min-height': tab_titles.outerHeight() + 1});
  2061. }
  2062. function open_content(tab, i, alternate_tab)
  2063. {
  2064. if(!tab.is('.'+options.active))
  2065. {
  2066. $('.'+options.active, container).removeClass(options.active);
  2067. $('.'+options.active+'_content', container).removeClass(options.active+'_content');
  2068. tab.addClass(options.active);
  2069. var new_loc = tab.data('fake-id');
  2070. if(typeof new_loc == 'string') location.replace(new_loc);
  2071. if(alternate_tab) alternate_tab.addClass(options.active);
  2072. var active_c = content.filter(':eq('+i+')').addClass(options.active+'_content');
  2073. if(typeof click_container != 'undefined' && click_container.length)
  2074. {
  2075. sidebar_shadow.height(active_c.outerHeight());
  2076. }
  2077. //check if tab title is in viewport. if not scroll up
  2078. var el_offset = active_c.offset().top,
  2079. scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10);
  2080. if(win.scrollTop() > el_offset)
  2081. {
  2082. $('html:not(:animated),body:not(:animated)').scrollTop(scoll_target);
  2083. }
  2084. }
  2085. }
  2086. function trigger_default_open(hash)
  2087. {
  2088. if(!hash && window.location.hash) hash = window.location.hash;
  2089. if(!hash) return;
  2090. var open = tabs.filter('[data-fake-id="'+hash+'"]');
  2091. if(open.length)
  2092. {
  2093. if(!open.is('.active_tab')) open.trigger('click');
  2094. window.scrollTo(0, container.offset().top - 70);
  2095. }
  2096. }
  2097. });
  2098. };
  2099. // -------------------------------------------------------------------------------------------
  2100. // Big Number animation shortcode javascript
  2101. // -------------------------------------------------------------------------------------------
  2102. (function($)
  2103. {
  2104. $.fn.avia_sc_animated_number = function(options)
  2105. {
  2106. var skipStep = false,
  2107. start_count = function(element, countTo, increment, current, fakeCountTo)
  2108. {
  2109. //calculate the new number
  2110. var newCount = current + increment;
  2111. //if the number is bigger than our final number set the number and finish
  2112. if(newCount >= fakeCountTo)
  2113. {
  2114. element.text(countTo); //exit
  2115. }
  2116. else
  2117. {
  2118. var prepend = "", addZeros = countTo.toString().length - newCount.toString().length
  2119. //if the number has less digits than the final number some zeros where omitted. add them to the front
  2120. for(var i = addZeros; i > 0; i--){ prepend += "0"; }
  2121. element.text(prepend + newCount);
  2122. window.requestAnimationFrame(function(){ start_count(element, countTo, increment, newCount, fakeCountTo) });
  2123. }
  2124. };
  2125. return this.each(function()
  2126. {
  2127. var number_container = $(this), elements = number_container.find('.avia-single-number'), countTimer = number_container.data('timer') || 3000;
  2128. //prepare elements
  2129. elements.each(function(i)
  2130. {
  2131. var element = $(this), text = element.text();
  2132. if(window.addEventListener) element.text( text.replace(/./g, "0")); /*https://github.com/AviaThemes/wp-themes/issues/812*/
  2133. });
  2134. //trigger number animation
  2135. number_container.addClass('number_prepared').on('avia_start_animation', function()
  2136. {
  2137. if(number_container.is('.avia_animation_done')) return;
  2138. number_container.addClass('avia_animation_done');
  2139. elements.each(function(i)
  2140. {
  2141. var element = $(this), countTo = element.data('number'), fakeCountTo = countTo, current = parseInt(element.text(),10), zeroOnly = /^0+$/.test(countTo), increment = 0;
  2142. //fallback for decimals like 00 or 000
  2143. if(zeroOnly && countTo !== 0) fakeCountTo = countTo.replace(/0/g, '9');
  2144. increment = Math.round( fakeCountTo * 32 / countTimer);
  2145. if(increment == 0 || increment % 10 == 0) increment += 1;
  2146. setTimeout(function(){ start_count(element, countTo, increment, current, fakeCountTo);}, 300);
  2147. });
  2148. });
  2149. });
  2150. }
  2151. })(jQuery);
  2152. // -------------------------------------------------------------------------------------------
  2153. // contact form ajax
  2154. // -------------------------------------------------------------------------------------------
  2155. (function($)
  2156. {
  2157. $.fn.avia_ajax_form = function(variables)
  2158. {
  2159. var defaults =
  2160. {
  2161. sendPath: 'send.php',
  2162. responseContainer: '.ajaxresponse'
  2163. };
  2164. var options = $.extend(defaults, variables);
  2165. return this.each(function()
  2166. {
  2167. var form = $(this),
  2168. form_sent = false,
  2169. send =
  2170. {
  2171. formElements: form.find('textarea, select, input[type=text], input[type=checkbox], input[type=hidden]'),
  2172. validationError:false,
  2173. button : form.find('input:submit'),
  2174. dataObj : {}
  2175. },
  2176. responseContainer = form.next(options.responseContainer+":eq(0)");
  2177. send.button.bind('click', checkElements);
  2178. //change type of email forms on mobile so the e-mail keyboard with @ sign is used
  2179. if($.avia_utilities.isMobile)
  2180. {
  2181. send.formElements.each(function(i)
  2182. {
  2183. var currentElement = $(this), is_email = currentElement.hasClass('is_email');
  2184. if(is_email) currentElement.attr('type','email');
  2185. });
  2186. }
  2187. function checkElements( e )
  2188. {
  2189. // reset validation var and send data
  2190. send.validationError = false;
  2191. send.datastring = 'ajax=true';
  2192. send.formElements.each(function(i)
  2193. {
  2194. var currentElement = $(this),
  2195. surroundingElement = currentElement.parent(),
  2196. value = currentElement.val(),
  2197. name = currentElement.attr('name'),
  2198. classes = currentElement.attr('class'),
  2199. nomatch = true;
  2200. if(currentElement.is(':checkbox'))
  2201. {
  2202. if(currentElement.is(':checked')) { value = true } else {value = ''}
  2203. }
  2204. send.dataObj[name] = encodeURIComponent(value);
  2205. if(classes && classes.match(/is_empty/))
  2206. {
  2207. if(value == '')
  2208. {
  2209. surroundingElement.removeClass("valid error ajax_alert").addClass("error");
  2210. send.validationError = true;
  2211. }
  2212. else
  2213. {
  2214. surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
  2215. }
  2216. nomatch = false;
  2217. }
  2218. if(classes && classes.match(/is_email/))
  2219. {
  2220. if(!value.match(/^[\w|\.|\-]+@\w[\w|\.|\-]*\.[a-zA-Z]{2,20}$/))
  2221. {
  2222. surroundingElement.removeClass("valid error ajax_alert").addClass("error");
  2223. send.validationError = true;
  2224. }
  2225. else
  2226. {
  2227. surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
  2228. }
  2229. nomatch = false;
  2230. }
  2231. if(classes && classes.match(/is_phone/))
  2232. {
  2233. if(!value.match(/^(\d|\s|\-|\/|\(|\)|\[|\]|e|x|t|ension|\.|\+|\_|\,|\:|\;){3,}$/))
  2234. {
  2235. surroundingElement.removeClass("valid error ajax_alert").addClass("error");
  2236. send.validationError = true;
  2237. }
  2238. else
  2239. {
  2240. surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
  2241. }
  2242. nomatch = false;
  2243. }
  2244. if(classes && classes.match(/is_number/))
  2245. {
  2246. if(!($.isNumeric(value)) || value == "")
  2247. {
  2248. surroundingElement.removeClass("valid error ajax_alert").addClass("error");
  2249. send.validationError = true;
  2250. }
  2251. else
  2252. {
  2253. surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
  2254. }
  2255. nomatch = false;
  2256. }
  2257. if(classes && classes.match(/captcha/))
  2258. {
  2259. var verifier = form.find("#" + name + "_verifier").val(),
  2260. lastVer = verifier.charAt(verifier.length-1),
  2261. finalVer = verifier.charAt(lastVer);
  2262. if(value != finalVer)
  2263. {
  2264. surroundingElement.removeClass("valid error ajax_alert").addClass("error");
  2265. send.validationError = true;
  2266. }
  2267. else
  2268. {
  2269. surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
  2270. }
  2271. nomatch = false;
  2272. }
  2273. if(nomatch && value != '')
  2274. {
  2275. surroundingElement.removeClass("valid error ajax_alert").addClass("valid");
  2276. }
  2277. });
  2278. if(send.validationError == false)
  2279. {
  2280. if(form.data('av-custom-send'))
  2281. {
  2282. mailchimp_send();
  2283. }
  2284. else
  2285. {
  2286. send_ajax_form();
  2287. }
  2288. }
  2289. return false;
  2290. }
  2291. function send_ajax_form()
  2292. {
  2293. if(form_sent){ return false; }
  2294. form_sent = true;
  2295. send.button.addClass('av-sending-button');
  2296. send.button.val(send.button.data('sending-label'));
  2297. var redirect_to = form.data('avia-redirect') || false,
  2298. action = form.attr('action');
  2299. responseContainer.load(action+' '+options.responseContainer, send.dataObj, function()
  2300. {
  2301. if(redirect_to && action != redirect_to)
  2302. {
  2303. form.attr('action', redirect_to);
  2304. location.href = redirect_to;
  2305. // form.submit();
  2306. }
  2307. else
  2308. {
  2309. responseContainer.removeClass('hidden').css({display:"block"});
  2310. form.slideUp(400, function(){responseContainer.slideDown(400, function(){ $('body').trigger('av_resize_finished'); }); send.formElements.val('');});
  2311. }
  2312. });
  2313. }
  2314. function mailchimp_send()
  2315. {
  2316. if(form_sent){ return false; }
  2317. form_sent = true;
  2318. var original_label = send.button.val();
  2319. send.button.addClass('av-sending-button');
  2320. send.button.val(send.button.data('sending-label'));
  2321. send.dataObj.ajax_mailchimp = true;
  2322. var redirect_to = form.data('avia-redirect') || false,
  2323. action = form.attr('action'),
  2324. error_msg_container = form.find('.av-form-error-container'),
  2325. form_id = form.data('avia-form-id');
  2326. $.ajax({
  2327. url: action,
  2328. type: "POST",
  2329. data:send.dataObj,
  2330. beforeSend: function()
  2331. {
  2332. if(error_msg_container.length)
  2333. {
  2334. error_msg_container.slideUp(400, function()
  2335. {
  2336. error_msg_container.remove();
  2337. $('body').trigger('av_resize_finished');
  2338. });
  2339. }
  2340. },
  2341. success: function(responseText)
  2342. {
  2343. var response = jQuery("<div>").append(jQuery.parseHTML(responseText)),
  2344. error = response.find('.av-form-error-container');
  2345. if(error.length)
  2346. {
  2347. form_sent = false;
  2348. form.prepend(error);
  2349. error.css({display:"none"}).slideDown(400, function()
  2350. {
  2351. $('body').trigger('av_resize_finished');
  2352. });
  2353. send.button.removeClass('av-sending-button');
  2354. send.button.val(original_label);
  2355. }
  2356. else
  2357. {
  2358. if(redirect_to && action != redirect_to)
  2359. {
  2360. form.attr('action', redirect_to);
  2361. location.href = redirect_to;
  2362. // form.submit();
  2363. }
  2364. else
  2365. {
  2366. var success_text = response.find(options.responseContainer + "_" + form_id);
  2367. responseContainer.html(success_text).removeClass('hidden').css({display:"block"});
  2368. form.slideUp(400, function()
  2369. {
  2370. responseContainer.slideDown(400, function()
  2371. {
  2372. $('body').trigger('av_resize_finished');
  2373. });
  2374. send.formElements.val('');
  2375. });
  2376. }
  2377. }
  2378. },
  2379. error: function()
  2380. {
  2381. },
  2382. complete: function()
  2383. {
  2384. }
  2385. });
  2386. }
  2387. });
  2388. };
  2389. })(jQuery);
  2390. // -------------------------------------------------------------------------------------------
  2391. // Aviaccordion Slideshow
  2392. //
  2393. // accordion slider script
  2394. // -------------------------------------------------------------------------------------------
  2395. $.AviaccordionSlider = function(options, slider)
  2396. {
  2397. this.$slider = $( slider );
  2398. this.$inner = this.$slider.find('.aviaccordion-inner');
  2399. this.$slides = this.$inner.find('.aviaccordion-slide');
  2400. this.$images = this.$inner.find('.aviaccordion-image');
  2401. this.$last = this.$slides.filter(':last');
  2402. this.$titles = this.$slider.find('.aviaccordion-preview');
  2403. this.$titlePos = this.$slider.find('.aviaccordion-preview-title-pos');
  2404. this.$titleWrap = this.$slider.find('.aviaccordion-preview-title-wrap');
  2405. this.$win = $( window );
  2406. if($.avia_utilities.supported.transition === undefined)
  2407. {
  2408. $.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
  2409. }
  2410. this.browserPrefix = $.avia_utilities.supported.transition;
  2411. this.cssActive = this.browserPrefix !== false ? true : false;
  2412. this.transform3d = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
  2413. this.isMobile = $.avia_utilities.isMobile;
  2414. this.property = this.browserPrefix + 'transform',
  2415. this.count = this.$slides.length;
  2416. this.open = false;
  2417. this.autoplay = false;
  2418. this.increaseTitle = this.$slider.is(".aviaccordion-title-on-hover");
  2419. // this.cssActive = false; //testing no css3 browser
  2420. this._init( options );
  2421. }
  2422. $.AviaccordionSlider.prototype =
  2423. {
  2424. _init: function( options )
  2425. {
  2426. var _self = this;
  2427. _self.options = $.extend({}, options, this.$slider.data());
  2428. $.avia_utilities.preload({container: this.$slider , single_callback: function(){ _self._kickOff(); }});
  2429. },
  2430. _kickOff: function()
  2431. {
  2432. var _self = this;
  2433. _self._calcMovement();
  2434. _self._bindEvents();
  2435. _self._showImages();
  2436. _self._autoplay();
  2437. },
  2438. _autoplay: function()
  2439. {
  2440. var _self = this;
  2441. if(_self.options.autoplay)
  2442. {
  2443. _self.autoplay = setInterval(function()
  2444. {
  2445. _self.open = _self.open === false ? 0 : _self.open + 1;
  2446. if(_self.open >= _self.count) _self.open = 0;
  2447. _self._move({}, _self.open);
  2448. }, _self.options.interval * 1000)
  2449. }
  2450. },
  2451. _showImages: function()
  2452. {
  2453. var _self = this, counter = 0, delay = 300, title_delay = this.count * delay;
  2454. if(this.cssActive)
  2455. {
  2456. setTimeout(function(){ _self.$slider.addClass('av-animation-active'); } , 10);
  2457. }
  2458. this.$images.each(function(i)
  2459. {
  2460. var current = $(this), timer = delay * (i + 1);
  2461. setTimeout(function()
  2462. {
  2463. current.avia_animate({opacity:1}, 400, function()
  2464. {
  2465. current.css($.avia_utilities.supported.transition + "transform", "none");
  2466. });
  2467. },timer);
  2468. });
  2469. if(_self.increaseTitle) title_delay = 0;
  2470. this.$titlePos.each(function(i)
  2471. {
  2472. var current = $(this), new_timer = title_delay + 100 * (i + 1);
  2473. setTimeout(function()
  2474. {
  2475. current.avia_animate({opacity:1}, 200, function()
  2476. {
  2477. current.css($.avia_utilities.supported.transition + "transform", "none");
  2478. });
  2479. },new_timer);
  2480. });
  2481. },
  2482. _bindEvents: function()
  2483. {
  2484. var trigger = this.isMobile ? "click" : "mouseenter";
  2485. this.$slider.on(trigger,'.aviaccordion-slide', $.proxy( this._move, this));
  2486. this.$slider.on('mouseleave','.aviaccordion-inner', $.proxy( this._move, this));
  2487. this.$win.on('debouncedresize', $.proxy( this._calcMovement, this));
  2488. this.$slider.on('av-prev av-next', $.proxy( this._moveTo, this));
  2489. if(this.isMobile)
  2490. {
  2491. this.$slider.avia_swipe_trigger({next: this.$slider, prev: this.$slider, event:{prev: 'av-prev', next: 'av-next'}});
  2492. }
  2493. },
  2494. _titleHeight: function()
  2495. {
  2496. var th = 0;
  2497. this.$titleWrap.css({'height':'auto'}).each(function()
  2498. {
  2499. var new_h = $(this).outerHeight();
  2500. if( new_h > th) th = new_h;
  2501. }).css({'height':th + 2});
  2502. },
  2503. _calcMovement: function(event, allow_repeat)
  2504. {
  2505. var _self = this,
  2506. containerWidth = this.$slider.width(),
  2507. defaultPos = this.$last.data('av-left'),
  2508. imgWidth = this.$images.filter(':last').width() || containerWidth,
  2509. imgWidthPercent = Math.floor((100 / containerWidth) * imgWidth),
  2510. allImageWidth = imgWidthPercent * _self.count,
  2511. modifier = 3, // 10 - _self.count,
  2512. tempMinLeft = 100 - imgWidthPercent,
  2513. minLeft = tempMinLeft > defaultPos / modifier ? tempMinLeft : 0,
  2514. oneLeft = minLeft / (_self.count -1 ),
  2515. titleWidth = imgWidth;
  2516. if(allImageWidth < 110 && allow_repeat !== false)
  2517. {
  2518. //set height if necessary
  2519. var slideHeight = this.$slider.height(),
  2520. maxHeight = (slideHeight / allImageWidth) * 110 ;
  2521. this.$slider.css({'max-height': maxHeight});
  2522. _self._calcMovement(event, false);
  2523. return;
  2524. }
  2525. //backup so the minimized slides dont get too small
  2526. if(oneLeft < 2) minLeft = 0;
  2527. this.$slides.each(function(i)
  2528. {
  2529. var current = $(this), newLeft = 0, newRight = 0, defaultLeft = current.data('av-left');
  2530. if( minLeft !== 0)
  2531. {
  2532. newLeft = oneLeft * i;
  2533. newRight = imgWidthPercent + newLeft - oneLeft;
  2534. }
  2535. else
  2536. {
  2537. newLeft = defaultLeft / Math.abs(modifier);
  2538. newRight = 100 - ((newLeft / i) * (_self.count - i));
  2539. }
  2540. if(i == 1 && _self.increaseTitle) { titleWidth = newRight + 1; }
  2541. if(_self.cssActive)
  2542. {
  2543. //if we are not animating based on the css left value but on css transform we need to subtract the left value
  2544. newLeft = newLeft - defaultLeft;
  2545. newRight = newRight - defaultLeft;
  2546. defaultLeft = 0;
  2547. }
  2548. current.data('av-calc-default', defaultLeft);
  2549. current.data('av-calc-left', newLeft);
  2550. current.data('av-calc-right', newRight);
  2551. });
  2552. if(_self.increaseTitle) { _self.$titles.css({width: titleWidth + "%"});}
  2553. },
  2554. _moveTo: function(event)
  2555. {
  2556. var direction = event.type == "av-next" ? 1 : -1,
  2557. nextSlide = this.open === false ? 0 : this.open + direction;
  2558. if(nextSlide >= 0 && nextSlide < this.$slides.length) this._move(event, nextSlide);
  2559. },
  2560. _move: function(event, direct_open)
  2561. {
  2562. var _self = this,
  2563. slide = event.currentTarget,
  2564. itemNo = typeof direct_open != "undefined" ? direct_open : this.$slides.index(slide);
  2565. this.open = itemNo;
  2566. if(_self.autoplay && typeof slide != "undefined") { clearInterval(_self.autoplay); _self.autoplay == false; }
  2567. this.$slides.removeClass('aviaccordion-active-slide').each(function(i)
  2568. {
  2569. var current = $(this),
  2570. dataSet = current.data(),
  2571. trans_val = i <= itemNo ? dataSet.avCalcLeft : dataSet.avCalcRight,
  2572. transition = {},
  2573. reset = event.type == 'mouseleave' ? 1 : 0,
  2574. active = itemNo === i ? _self.$titleWrap.eq(i) : false;
  2575. if(active) current.addClass('aviaccordion-active-slide');
  2576. if(reset)
  2577. {
  2578. trans_val = dataSet.avCalcDefault;
  2579. this.open = false;
  2580. }
  2581. if(_self.cssActive) //do a css3 animation
  2582. {
  2583. //move the slides
  2584. transition[_self.property] = _self.transform3d ? "translate3d(" + trans_val + "%, 0, 0)" : "translate(" + trans_val + "%,0)"; //3d or 2d transform?
  2585. current.css(transition);
  2586. }
  2587. else
  2588. {
  2589. transition.left = trans_val + "%";
  2590. current.stop().animate(transition, 700, 'easeOutQuint');
  2591. }
  2592. });
  2593. }
  2594. };
  2595. $.fn.aviaccordion = function( options )
  2596. {
  2597. return this.each(function()
  2598. {
  2599. var active = $.data( this, 'AviaccordionSlider' );
  2600. if(!active)
  2601. {
  2602. //make sure that the function doesnt get aplied a second time
  2603. $.data( this, 'AviaccordionSlider', 1 );
  2604. //create the preparations for fullscreen slider
  2605. new $.AviaccordionSlider( options, this );
  2606. }
  2607. });
  2608. }
  2609. // -------------------------------------------------------------------------------------------
  2610. // Aviaccordion Slideshow
  2611. //
  2612. // accordion slider script
  2613. // -------------------------------------------------------------------------------------------
  2614. $.AviaTextRotator = function(options, slider)
  2615. {
  2616. this.$win = $( window );
  2617. this.$slider = $( slider );
  2618. this.$inner = this.$slider.find('.av-rotator-text');
  2619. this.$slides = this.$inner.find('.av-rotator-text-single');
  2620. this.$current = this.$slides.eq(0);
  2621. this.open = 0;
  2622. this.count = this.$slides.length;
  2623. if($.avia_utilities.supported.transition === undefined)
  2624. {
  2625. $.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
  2626. }
  2627. this.browserPrefix = $.avia_utilities.supported.transition;
  2628. this.cssActive = this.browserPrefix !== false ? true : false;
  2629. this.property = this.browserPrefix + 'transform',
  2630. //this.cssActive = false; //testing no css3 browser
  2631. this._init( options );
  2632. }
  2633. $.AviaTextRotator.prototype =
  2634. {
  2635. _init: function( options )
  2636. {
  2637. var _self = this;
  2638. if(this.count <= 1) return;
  2639. _self.options = $.extend({}, options, this.$slider.data());
  2640. _self.$inner.addClass('av-rotation-active');
  2641. if(_self.options.fixwidth == 1) this.$inner.width(this.$current.width());
  2642. _self._autoplay();
  2643. },
  2644. _autoplay: function()
  2645. {
  2646. var _self = this;
  2647. _self.autoplay = setInterval(function()
  2648. {
  2649. _self.open = _self.open === false ? 0 : _self.open + 1;
  2650. if(_self.open >= _self.count) _self.open = 0;
  2651. _self._move({}, _self.open);
  2652. }, _self.options.interval * 1000)
  2653. },
  2654. _move: function(event)
  2655. {
  2656. var _self = this,
  2657. modifier = 30 * _self.options.animation,
  2658. fade_out = {opacity:0},
  2659. fade_start = {display:'inline', opacity:0},
  2660. fade_in = {opacity:1};
  2661. this.$next = _self.$slides.eq(this.open);
  2662. if(this.cssActive)
  2663. {
  2664. fade_out[_self.property] = "translate(0px," + modifier +"px)";
  2665. fade_start[_self.property] = "translate(0px," + (modifier * -1) +"px)";
  2666. fade_in[_self.property] = "translate(0px,0px)";
  2667. }
  2668. else
  2669. {
  2670. fade_out['top'] = modifier;
  2671. fade_start['top'] = (modifier * -1);
  2672. fade_in['top'] = 0;
  2673. }
  2674. _self.$current.avia_animate(fade_out, function()
  2675. {
  2676. _self.$current.css({display:'none'});
  2677. _self.$next.css(fade_start).avia_animate(fade_in, function()
  2678. {
  2679. _self.$current = _self.$slides.eq(_self.open);
  2680. });
  2681. });
  2682. }
  2683. };
  2684. $.fn.avia_textrotator = function( options )
  2685. {
  2686. return this.each(function()
  2687. {
  2688. var active = $.data( this, 'AviaTextRotator' );
  2689. if(!active)
  2690. {
  2691. //make sure that the function doesnt get aplied a second time
  2692. $.data( this, 'AviaTextRotator', 1 );
  2693. //create the preparations for fullscreen slider
  2694. new $.AviaTextRotator( options, this );
  2695. }
  2696. });
  2697. }
  2698. // -------------------------------------------------------------------------------------------
  2699. // HELPER FUNCTIONS
  2700. // -------------------------------------------------------------------------------------------
  2701. //waipoint script when something comes into viewport
  2702. $.fn.avia_waypoints = function(options_passed)
  2703. {
  2704. if(! $('html').is('.avia_transform')) return;
  2705. var defaults = { offset: 'bottom-in-view' , triggerOnce: true},
  2706. options = $.extend({}, defaults, options_passed),
  2707. isMobile = $.avia_utilities.isMobile;
  2708. return this.each(function()
  2709. {
  2710. var element = $(this);
  2711. setTimeout(function()
  2712. {
  2713. if(isMobile)
  2714. {
  2715. element.addClass('avia_start_animation').trigger('avia_start_animation');
  2716. }
  2717. else
  2718. {
  2719. element.waypoint(function(direction)
  2720. {
  2721. $(this.element).addClass('avia_start_animation').trigger('avia_start_animation');
  2722. }, options );
  2723. }
  2724. },100)
  2725. });
  2726. };
  2727. // window resize script
  2728. var $event = $.event, $special, resizeTimeout;
  2729. $special = $event.special.debouncedresize = {
  2730. setup: function() {
  2731. $( this ).on( "resize", $special.handler );
  2732. },
  2733. teardown: function() {
  2734. $( this ).off( "resize", $special.handler );
  2735. },
  2736. handler: function( event, execAsap ) {
  2737. // Save the context
  2738. var context = this,
  2739. args = arguments,
  2740. dispatch = function() {
  2741. // set correct event type
  2742. event.type = "debouncedresize";
  2743. $event.dispatch.apply( context, args );
  2744. };
  2745. if ( resizeTimeout ) {
  2746. clearTimeout( resizeTimeout );
  2747. }
  2748. execAsap ?
  2749. dispatch() :
  2750. resizeTimeout = setTimeout( dispatch, $special.threshold );
  2751. },
  2752. threshold: 150
  2753. };
  2754. $.easing['jswing'] = $.easing['swing'];
  2755. $.extend( $.easing,
  2756. {
  2757. def: 'easeOutQuad',
  2758. swing: function (x, t, b, c, d) { return $.easing[$.easing.def](x, t, b, c, d); },
  2759. easeInQuad: function (x, t, b, c, d) { return c*(t/=d)*t + b; },
  2760. easeOutQuad: function (x, t, b, c, d) { return -c *(t/=d)*(t-2) + b; },
  2761. 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; },
  2762. easeInCubic: function (x, t, b, c, d) { return c*(t/=d)*t*t + b; },
  2763. easeOutCubic: function (x, t, b, c, d) { return c*((t=t/d-1)*t*t + 1) + b; },
  2764. 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; },
  2765. easeInQuart: function (x, t, b, c, d) { return c*(t/=d)*t*t*t + b; },
  2766. easeOutQuart: function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b; },
  2767. 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; },
  2768. easeInQuint: function (x, t, b, c, d) { return c*(t/=d)*t*t*t*t + b; },
  2769. easeOutQuint: function (x, t, b, c, d) { return c*((t=t/d-1)*t*t*t*t + 1) + b; },
  2770. 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; },
  2771. easeInSine: function (x, t, b, c, d) { return -c * Math.cos(t/d * (Math.PI/2)) + c + b; },
  2772. easeOutSine: function (x, t, b, c, d) { return c * Math.sin(t/d * (Math.PI/2)) + b; },
  2773. easeInOutSine: function (x, t, b, c, d) { return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; },
  2774. easeInExpo: function (x, t, b, c, d) { return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; },
  2775. easeOutExpo: function (x, t, b, c, d) { return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; },
  2776. easeInOutExpo: function (x, t, b, c, d) {
  2777. if (t==0) return b;
  2778. if (t==d) return b+c;
  2779. if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
  2780. return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
  2781. },
  2782. easeInCirc: function (x, t, b, c, d) { return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; },
  2783. easeOutCirc: function (x, t, b, c, d) {return c * Math.sqrt(1 - (t=t/d-1)*t) + b; },
  2784. 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; },
  2785. easeInElastic: function (x, t, b, c, d) {
  2786. var s=1.70158;var p=0;var a=c;
  2787. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  2788. if (a < Math.abs(c)) { a=c; var s=p/4; }
  2789. else var s = p/(2*Math.PI) * Math.asin (c/a);
  2790. return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  2791. },
  2792. easeOutElastic: function (x, t, b, c, d) {
  2793. var s=1.70158;var p=0;var a=c;
  2794. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  2795. if (a < Math.abs(c)) { a=c; var s=p/4; }
  2796. else var s = p/(2*Math.PI) * Math.asin (c/a);
  2797. return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
  2798. },
  2799. easeInOutElastic: function (x, t, b, c, d) {
  2800. var s=1.70158;var p=0;var a=c;
  2801. if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
  2802. if (a < Math.abs(c)) { a=c; var s=p/4; }
  2803. else var s = p/(2*Math.PI) * Math.asin (c/a);
  2804. if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  2805. return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
  2806. },
  2807. easeInBack: function (x, t, b, c, d, s) {
  2808. if (s == undefined) s = 1.70158;
  2809. return c*(t/=d)*t*((s+1)*t - s) + b;
  2810. },
  2811. easeOutBack: function (x, t, b, c, d, s) {
  2812. if (s == undefined) s = 1.70158;
  2813. return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
  2814. },
  2815. easeInOutBack: function (x, t, b, c, d, s) {
  2816. if (s == undefined) s = 1.70158;
  2817. if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
  2818. return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
  2819. },
  2820. easeInBounce: function (x, t, b, c, d) {
  2821. return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
  2822. },
  2823. easeOutBounce: function (x, t, b, c, d) {
  2824. if ((t/=d) < (1/2.75)) {
  2825. return c*(7.5625*t*t) + b;
  2826. } else if (t < (2/2.75)) {
  2827. return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
  2828. } else if (t < (2.5/2.75)) {
  2829. return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
  2830. } else {
  2831. return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
  2832. }
  2833. },
  2834. easeInOutBounce: function (x, t, b, c, d) {
  2835. if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
  2836. return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
  2837. }
  2838. });
  2839. })( jQuery );
  2840. /*utility functions*/
  2841. (function($)
  2842. {
  2843. "use strict";
  2844. $.avia_utilities = $.avia_utilities || {};
  2845. /************************************************************************
  2846. gloabl loading function
  2847. *************************************************************************/
  2848. $.avia_utilities.loading = function(attach_to, delay){
  2849. var loader = {
  2850. active: false,
  2851. show: function()
  2852. {
  2853. if(loader.active === false)
  2854. {
  2855. loader.active = true;
  2856. loader.loading_item.css({display:'block', opacity:0});
  2857. }
  2858. loader.loading_item.stop().animate({opacity:0.7});
  2859. },
  2860. hide: function()
  2861. {
  2862. if(typeof delay === 'undefined'){ delay = 600; }
  2863. loader.loading_item.stop().delay( delay ).animate({opacity:0}, function()
  2864. {
  2865. loader.loading_item.css({display:'none'});
  2866. loader.active = false;
  2867. });
  2868. },
  2869. attach: function()
  2870. {
  2871. if(typeof attach_to === 'undefined'){ attach_to = 'body';}
  2872. loader.loading_item = $('<div class="avia_loading_icon"></div>').css({display:"none"}).appendTo(attach_to);
  2873. }
  2874. }
  2875. loader.attach();
  2876. return loader;
  2877. };
  2878. /************************************************************************
  2879. gloabl play/pause visualizer function
  2880. *************************************************************************/
  2881. $.avia_utilities.playpause = function(attach_to, delay){
  2882. var pp = {
  2883. active: false,
  2884. to1: "",
  2885. to2: "",
  2886. set: function(status)
  2887. {
  2888. pp.loading_item.removeClass('av-play av-pause');
  2889. pp.to1 = setTimeout(function(){ pp.loading_item.addClass('av-' + status); },10);
  2890. pp.to2 = setTimeout(function(){ pp.loading_item.removeClass('av-' + status); },1500);
  2891. },
  2892. attach: function()
  2893. {
  2894. if(typeof attach_to === 'undefined'){ attach_to = 'body';}
  2895. pp.loading_item = $('<div class="avia_playpause_icon"></div>').css({display:"none"}).appendTo(attach_to);
  2896. }
  2897. }
  2898. pp.attach();
  2899. return pp;
  2900. };
  2901. /************************************************************************
  2902. preload images, as soon as all are loaded trigger a special load ready event
  2903. *************************************************************************/
  2904. $.avia_utilities.preload = function(options_passed)
  2905. {
  2906. new $.AviaPreloader(options_passed);
  2907. }
  2908. $.AviaPreloader = function(options)
  2909. {
  2910. this.win = $(window);
  2911. this.defaults =
  2912. {
  2913. container: 'body',
  2914. maxLoops: 10,
  2915. trigger_single: true,
  2916. single_callback: function(){},
  2917. global_callback: function(){}
  2918. };
  2919. this.options = $.extend({}, this.defaults, options);
  2920. this.preload_images = 0;
  2921. this.load_images();
  2922. }
  2923. $.AviaPreloader.prototype =
  2924. {
  2925. load_images: function()
  2926. {
  2927. var _self = this;
  2928. if(typeof _self.options.container === 'string'){ _self.options.container = $(_self.options.container); }
  2929. _self.options.container.each(function()
  2930. {
  2931. var container = $(this);
  2932. container.images = container.find('img');
  2933. container.allImages = container.images;
  2934. _self.preload_images += container.images.length;
  2935. setTimeout(function(){ _self.checkImage(container); }, 10);
  2936. });
  2937. },
  2938. checkImage: function(container)
  2939. {
  2940. var _self = this;
  2941. container.images.each(function()
  2942. {
  2943. if(this.complete === true)
  2944. {
  2945. container.images = container.images.not(this);
  2946. _self.preload_images -= 1;
  2947. }
  2948. });
  2949. if(container.images.length && _self.options.maxLoops >= 0)
  2950. {
  2951. _self.options.maxLoops-=1;
  2952. setTimeout(function(){ _self.checkImage(container); }, 500);
  2953. }
  2954. else
  2955. {
  2956. _self.preload_images = _self.preload_images - container.images.length;
  2957. _self.trigger_loaded(container);
  2958. }
  2959. },
  2960. trigger_loaded: function(container)
  2961. {
  2962. var _self = this;
  2963. if(_self.options.trigger_single !== false)
  2964. {
  2965. _self.win.trigger('avia_images_loaded_single', [container]);
  2966. _self.options.single_callback.call(container);
  2967. }
  2968. if(_self.preload_images === 0)
  2969. {
  2970. _self.win.trigger('avia_images_loaded');
  2971. _self.options.global_callback.call();
  2972. }
  2973. }
  2974. }
  2975. /************************************************************************
  2976. CSS Easing transformation table
  2977. *************************************************************************/
  2978. /*
  2979. Easing transform table from jquery.animate-enhanced plugin
  2980. http://github.com/benbarnett/jQuery-Animate-Enhanced
  2981. */
  2982. $.avia_utilities.css_easings = {
  2983. linear: 'linear',
  2984. swing: 'ease-in-out',
  2985. bounce: 'cubic-bezier(0.0, 0.35, .5, 1.3)',
  2986. easeInQuad: 'cubic-bezier(0.550, 0.085, 0.680, 0.530)' ,
  2987. easeInCubic: 'cubic-bezier(0.550, 0.055, 0.675, 0.190)' ,
  2988. easeInQuart: 'cubic-bezier(0.895, 0.030, 0.685, 0.220)' ,
  2989. easeInQuint: 'cubic-bezier(0.755, 0.050, 0.855, 0.060)' ,
  2990. easeInSine: 'cubic-bezier(0.470, 0.000, 0.745, 0.715)' ,
  2991. easeInExpo: 'cubic-bezier(0.950, 0.050, 0.795, 0.035)' ,
  2992. easeInCirc: 'cubic-bezier(0.600, 0.040, 0.980, 0.335)' ,
  2993. easeInBack: 'cubic-bezier(0.600, -0.280, 0.735, 0.04)' ,
  2994. easeOutQuad: 'cubic-bezier(0.250, 0.460, 0.450, 0.940)' ,
  2995. easeOutCubic: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)' ,
  2996. easeOutQuart: 'cubic-bezier(0.165, 0.840, 0.440, 1.000)' ,
  2997. easeOutQuint: 'cubic-bezier(0.230, 1.000, 0.320, 1.000)' ,
  2998. easeOutSine: 'cubic-bezier(0.390, 0.575, 0.565, 1.000)' ,
  2999. easeOutExpo: 'cubic-bezier(0.190, 1.000, 0.220, 1.000)' ,
  3000. easeOutCirc: 'cubic-bezier(0.075, 0.820, 0.165, 1.000)' ,
  3001. easeOutBack: 'cubic-bezier(0.175, 0.885, 0.320, 1.275)' ,
  3002. easeInOutQuad: 'cubic-bezier(0.455, 0.030, 0.515, 0.955)' ,
  3003. easeInOutCubic: 'cubic-bezier(0.645, 0.045, 0.355, 1.000)' ,
  3004. easeInOutQuart: 'cubic-bezier(0.770, 0.000, 0.175, 1.000)' ,
  3005. easeInOutQuint: 'cubic-bezier(0.860, 0.000, 0.070, 1.000)' ,
  3006. easeInOutSine: 'cubic-bezier(0.445, 0.050, 0.550, 0.950)' ,
  3007. easeInOutExpo: 'cubic-bezier(1.000, 0.000, 0.000, 1.000)' ,
  3008. easeInOutCirc: 'cubic-bezier(0.785, 0.135, 0.150, 0.860)' ,
  3009. easeInOutBack: 'cubic-bezier(0.680, -0.550, 0.265, 1.55)' ,
  3010. easeInOutBounce:'cubic-bezier(0.580, -0.365, 0.490, 1.365)',
  3011. easeOutBounce: 'cubic-bezier(0.760, 0.085, 0.490, 1.365)'
  3012. };
  3013. /************************************************************************
  3014. check if a css feature is supported and save it to the supported array
  3015. *************************************************************************/
  3016. $.avia_utilities.supported = {};
  3017. $.avia_utilities.supports = (function()
  3018. {
  3019. var div = document.createElement('div'),
  3020. vendors = ['Khtml', 'Ms','Moz','Webkit']; // vendors = ['Khtml', 'Ms','Moz','Webkit','O'];
  3021. return function(prop, vendor_overwrite)
  3022. {
  3023. if ( div.style[prop] !== undefined ) { return ""; }
  3024. if (vendor_overwrite !== undefined) { vendors = vendor_overwrite; }
  3025. prop = prop.replace(/^[a-z]/, function(val)
  3026. {
  3027. return val.toUpperCase();
  3028. });
  3029. var len = vendors.length;
  3030. while(len--)
  3031. {
  3032. if ( div.style[vendors[len] + prop] !== undefined )
  3033. {
  3034. return "-" + vendors[len].toLowerCase() + "-";
  3035. }
  3036. }
  3037. return false;
  3038. };
  3039. }());
  3040. /************************************************************************
  3041. animation function
  3042. *************************************************************************/
  3043. $.fn.avia_animate = function(prop, speed, easing, callback)
  3044. {
  3045. if(typeof speed === 'function') {callback = speed; speed = false; }
  3046. if(typeof easing === 'function'){callback = easing; easing = false;}
  3047. if(typeof speed === 'string'){easing = speed; speed = false;}
  3048. if(callback === undefined || callback === false){ callback = function(){}; }
  3049. if(easing === undefined || easing === false) { easing = 'easeInQuad'; }
  3050. if(speed === undefined || speed === false) { speed = 400; }
  3051. if($.avia_utilities.supported.transition === undefined)
  3052. {
  3053. $.avia_utilities.supported.transition = $.avia_utilities.supports('transition');
  3054. }
  3055. if($.avia_utilities.supported.transition !== false )
  3056. {
  3057. var prefix = $.avia_utilities.supported.transition + 'transition',
  3058. cssRule = {},
  3059. cssProp = {},
  3060. thisStyle = document.body.style,
  3061. end = (thisStyle.WebkitTransition !== undefined) ? 'webkitTransitionEnd' : (thisStyle.OTransition !== undefined) ? 'oTransitionEnd' : 'transitionend';
  3062. //translate easing into css easing
  3063. easing = $.avia_utilities.css_easings[easing];
  3064. //create css transformation rule
  3065. cssRule[prefix] = 'all '+(speed/1000)+'s '+easing;
  3066. //add namespace to the transition end trigger
  3067. end = end + ".avia_animate";
  3068. //since jquery 1.10 the items passed need to be {} and not [] so make sure they are converted properly
  3069. for (var rule in prop)
  3070. {
  3071. if (prop.hasOwnProperty(rule)) { cssProp[rule] = prop[rule]; }
  3072. }
  3073. prop = cssProp;
  3074. this.each(function()
  3075. {
  3076. var element = $(this), css_difference = false, rule, current_css;
  3077. for (rule in prop)
  3078. {
  3079. if (prop.hasOwnProperty(rule))
  3080. {
  3081. current_css = element.css(rule);
  3082. if(prop[rule] != current_css && prop[rule] != current_css.replace(/px|%/g,""))
  3083. {
  3084. css_difference = true;
  3085. break;
  3086. }
  3087. }
  3088. }
  3089. if(css_difference)
  3090. {
  3091. var endTriggered = false;
  3092. element.on(end, function(event)
  3093. {
  3094. if(event.target != event.currentTarget) return false;
  3095. if(endTriggered == true) return false;
  3096. endTriggered = true;
  3097. cssRule[prefix] = "none";
  3098. element.off(end);
  3099. element.css(cssRule);
  3100. setTimeout(function(){ callback.call(element); });
  3101. });
  3102. //desktop safari fallback if we are in another tab to trigger the end event
  3103. setTimeout(function(){
  3104. if(!endTriggered && !avia_is_mobile && $('html').is('.avia-safari') ) {
  3105. element.trigger(end);
  3106. $.avia_utilities.log('Safari Fallback '+end+' trigger');
  3107. }
  3108. }, speed + 100);
  3109. setTimeout(function(){ element.css(cssRule);},10);
  3110. setTimeout(function(){ element.css(prop); },20);
  3111. }
  3112. else
  3113. {
  3114. setTimeout(function(){ callback.call(element); });
  3115. }
  3116. });
  3117. }
  3118. else // if css animation is not available use default JS animation
  3119. {
  3120. this.animate(prop, speed, easing, callback);
  3121. }
  3122. return this;
  3123. };
  3124. })( jQuery );
  3125. /* ======================================================================================================================================================
  3126. Avia Slideshow
  3127. ====================================================================================================================================================== */
  3128. (function($)
  3129. {
  3130. "use strict";
  3131. $.AviaSlider = function(options, slider)
  3132. {
  3133. var self = this;
  3134. this.$win = $( window );
  3135. this.$slider = $( slider );
  3136. this.isMobile = $.avia_utilities.isMobile;
  3137. this._prepareSlides(options);
  3138. //default preload images then init slideshow
  3139. $.avia_utilities.preload({container: this.$slider , single_callback: function(){ self._init( options ); }});
  3140. }
  3141. $.AviaSlider.defaults = {
  3142. //interval between autorotation switches
  3143. interval:5,
  3144. //autorotation active or not
  3145. autoplay:false,
  3146. //set if the loop will stop at the last/first slide or if the slides will loop infinite
  3147. //set to false for infinite loop, "last" to stop at the last slide or "first" to stop at the first slide
  3148. stopinfiniteloop: false,
  3149. //fade or slide animation
  3150. animation:'slide',
  3151. //transition speed when switching slide
  3152. transitionSpeed:900,
  3153. //easing method for the transition
  3154. easing:'easeInOutQuart',
  3155. //slide wrapper
  3156. wrapElement: '>ul',
  3157. //slide element
  3158. slideElement: '>li',
  3159. //pause if mouse cursor is above item
  3160. hoverpause: false,
  3161. //attach images as background
  3162. bg_slider: false,
  3163. //delay of miliseconds to wait before showing the next slide
  3164. show_slide_delay: 0,
  3165. //if slider animation is set to "fade" the fullfade property sets the crossfade behaviour
  3166. fullfade: false
  3167. };
  3168. $.AviaSlider.prototype =
  3169. {
  3170. _init: function( options )
  3171. {
  3172. // set slider options
  3173. this.options = this._setOptions(options);
  3174. //slidewrap
  3175. this.$sliderUl = this.$slider.find(this.options.wrapElement);
  3176. // slide elements
  3177. this.$slides = this.$sliderUl.find(this.options.slideElement);
  3178. // goto dots
  3179. this.gotoButtons = this.$slider.find('.avia-slideshow-dots a');
  3180. //perma caption
  3181. this.permaCaption = this.$slider.find('>.av-slideshow-caption');
  3182. // slide count
  3183. this.itemsCount = this.$slides.length;
  3184. // current image index
  3185. this.current = 0;
  3186. //loop count
  3187. this.loopCount = 0;
  3188. // control if the slicebox is animating
  3189. this.isAnimating = false;
  3190. // css browser prefix like -webkit-, -moz-
  3191. this.browserPrefix = $.avia_utilities.supports('transition');
  3192. // css3 animation?
  3193. this.cssActive = this.browserPrefix !== false ? true : false;
  3194. // css3D animation?
  3195. this.css3DActive = document.documentElement.className.indexOf('avia_transform3d') !== -1 ? true : false;
  3196. //store the aviaVideoApi object for the current slide if available
  3197. this.video = false;
  3198. //if we have a bg slider no images were preloaded yet. in that case start preloading and attaching images
  3199. if(this.options.bg_slider == true)
  3200. {
  3201. //create array that holds all image urls to preload
  3202. this.imageUrls = [];
  3203. //create a preloader icon to indicate loading
  3204. this.loader = $.avia_utilities.loading(this.$slider);
  3205. //preload the images ony by one
  3206. this._bgPreloadImages();
  3207. }
  3208. else //if it was a default slider all images are already loaded and we can start showing the slider
  3209. {
  3210. //kickoff the slider: bind functions, show first slide, if active start the autorotation timer
  3211. this._kickOff();
  3212. }
  3213. },
  3214. //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
  3215. _setOptions: function(options)
  3216. {
  3217. var newOptions = $.extend( true, {}, $.AviaSlider.defaults, options ),
  3218. htmlData = this.$slider.data(),
  3219. i = "";
  3220. //overwritte passed option set with any data properties on the html element
  3221. for (i in htmlData)
  3222. {
  3223. if (htmlData.hasOwnProperty(i))
  3224. {
  3225. if(typeof htmlData[i] === "string" || typeof htmlData[i] === "number" || typeof htmlData[i] === "boolean")
  3226. {
  3227. newOptions[i] = htmlData[i];
  3228. }
  3229. }
  3230. }
  3231. return newOptions;
  3232. },
  3233. _prepareSlides: function(options)
  3234. {
  3235. //if its a mobile device find all video slides that need to be altered
  3236. if(this.isMobile)
  3237. {
  3238. var alter = this.$slider.find('.av-mobile-fallback-image');
  3239. alter.each(function()
  3240. {
  3241. var current = $(this).removeClass('av-video-slide').data({'avia_video_events': true, 'video-ratio':0}),
  3242. fallback = current.data('mobile-img');
  3243. current.find('.av-click-overlay, .mejs-mediaelement, .mejs-container').remove();
  3244. if(!fallback)
  3245. {
  3246. var appendTo = current.find('.avia-slide-wrap');
  3247. $('<p class="av-fallback-message"><span>Please set a mobile device fallback image for this video in your wordpress backend</span></p>').appendTo(appendTo);
  3248. }
  3249. if(options && options.bg_slider)
  3250. {
  3251. current.data('img-url', fallback);
  3252. }
  3253. else
  3254. {
  3255. var image = $('<img src="'+fallback+'" alt="" title="" />');
  3256. current.find('.avia-slide-wrap').append(image);
  3257. }
  3258. });
  3259. }
  3260. },
  3261. //start preloading the background images
  3262. _bgPreloadImages : function(callback)
  3263. {
  3264. this._getImageURLS();
  3265. this._preloadSingle(0, function()
  3266. {
  3267. this._kickOff();
  3268. this._preloadNext(1);
  3269. });
  3270. },
  3271. //if we are using a background image slider, fetch the images from a data attribute and preload them one by one
  3272. _getImageURLS: function()
  3273. {
  3274. var _self = this;
  3275. //collect url strings of the images to preload
  3276. this.$slides.each(function(i)
  3277. {
  3278. _self.imageUrls[i] = [];
  3279. _self.imageUrls[i]['url'] = $(this).data("img-url");
  3280. //if no image is passed we can set the slide to loaded
  3281. if(typeof _self.imageUrls[i]['url'] == 'string')
  3282. {
  3283. _self.imageUrls[i]['status'] = false;
  3284. }
  3285. else
  3286. {
  3287. _self.imageUrls[i]['status'] = true;
  3288. }
  3289. });
  3290. },
  3291. _preloadSingle: function(key, callback)
  3292. {
  3293. var _self = this,
  3294. objImage = new Image();
  3295. if(typeof _self.imageUrls[key]['url'] == 'string')
  3296. {
  3297. $(objImage).bind('load error', function()
  3298. {
  3299. _self.imageUrls[key]['status'] = true;
  3300. _self.$slides.eq(key).css('background-image','url(' + _self.imageUrls[key]['url'] + ')');
  3301. if(typeof callback == 'function') callback.apply( _self, [objImage, key] );
  3302. });
  3303. objImage.src = _self.imageUrls[key]['url'];
  3304. }
  3305. else
  3306. {
  3307. if(typeof callback == 'function') callback.apply( _self, [objImage, key] );
  3308. }
  3309. },
  3310. _preloadNext: function(key)
  3311. {
  3312. if(typeof this.imageUrls[key] != "undefined")
  3313. {
  3314. this._preloadSingle(key, function()
  3315. {
  3316. this._preloadNext(key + 1);
  3317. });
  3318. }
  3319. },
  3320. //bind click events of slide controlls to the public functions
  3321. _bindEvents: function()
  3322. {
  3323. var self = this,
  3324. win = $( window );
  3325. this.$slider.on('click','.next-slide', $.proxy( this.next, this) );
  3326. this.$slider.on('click','.prev-slide', $.proxy( this.previous, this) );
  3327. this.$slider.on('click','.goto-slide', $.proxy( this.go2, this) );
  3328. if(this.options.hoverpause)
  3329. {
  3330. this.$slider.on('mouseenter', $.proxy( this.pause, this) );
  3331. this.$slider.on('mouseleave', $.proxy( this.resume, this) );
  3332. }
  3333. if(this.options.stopinfiniteloop && this.options.autoplay)
  3334. {
  3335. if(this.options.stopinfiniteloop == 'last')
  3336. {
  3337. this.$slider.on('avia_slider_last_slide', $.proxy(this._stopSlideshow, this) );
  3338. }
  3339. else if(this.options.stopinfiniteloop == 'first')
  3340. {
  3341. this.$slider.on('avia_slider_first_slide', $.proxy(this._stopSlideshow, this) );
  3342. }
  3343. }
  3344. win.on( 'debouncedresize.aviaSlider', $.proxy( this._setSize, this) );
  3345. //if its a desktop browser add arrow navigation, otherwise add touch nav
  3346. if(!this.isMobile)
  3347. {
  3348. this.$slider.avia_keyboard_controls();
  3349. }
  3350. else
  3351. {
  3352. this.$slider.avia_swipe_trigger();
  3353. }
  3354. self._attach_video_events();
  3355. },
  3356. //kickoff the slider by binding all functions to slides and buttons, show the first slide and start autoplay
  3357. _kickOff: function()
  3358. {
  3359. var self = this,
  3360. first_slide = self.$slides.eq(0),
  3361. video = first_slide.data('video-ratio');
  3362. // bind events to to the controll buttons
  3363. self._bindEvents();
  3364. this.$slider.removeClass('av-default-height-applied');
  3365. //show the first slide. if its a video set the correct size, otherwise make sure to remove the % padding
  3366. if(video)
  3367. {
  3368. self._setSize(true);
  3369. }
  3370. else
  3371. {
  3372. if(this.options.keep_pading != true)
  3373. {
  3374. self.$sliderUl.css('padding',0);
  3375. self.$win.trigger('av-height-change');
  3376. }
  3377. }
  3378. first_slide.css({visibility:'visible', opacity:0}).avia_animate({opacity:1}, function()
  3379. {
  3380. var current = $(this).addClass('active-slide');
  3381. if(self.permaCaption.length)
  3382. {
  3383. self.permaCaption.addClass('active-slide');
  3384. }
  3385. });
  3386. // start autoplay if active
  3387. if( self.options.autoplay )
  3388. {
  3389. self._startSlideshow();
  3390. }
  3391. },
  3392. //calculate which slide should be displayed next and call the executing transition function
  3393. _navigate : function( dir, pos ) {
  3394. if( this.isAnimating || this.itemsCount < 2 || !this.$slider.is(":visible") )
  3395. {
  3396. return false;
  3397. }
  3398. this.isAnimating = true;
  3399. // current item's index
  3400. this.prev = this.current;
  3401. // if position is passed
  3402. if( pos !== undefined )
  3403. {
  3404. this.current = pos;
  3405. dir = this.current > this.prev ? 'next' : 'prev';
  3406. }
  3407. // if not check the boundaries
  3408. else if( dir === 'next' )
  3409. {
  3410. this.current = this.current < this.itemsCount - 1 ? this.current + 1 : 0;
  3411. if( this.current === 0 && this.options.autoplay_stopper == 1 && this.options.autoplay )
  3412. {
  3413. this.isAnimating = false;
  3414. this.current = this.prev;
  3415. this._stopSlideshow();
  3416. return false;
  3417. }
  3418. }
  3419. else if( dir === 'prev' )
  3420. {
  3421. this.current = this.current > 0 ? this.current - 1 : this.itemsCount - 1;
  3422. }
  3423. //set goto button
  3424. this.gotoButtons.removeClass('active').eq(this.current).addClass('active');
  3425. //set slideshow size
  3426. this._setSize();
  3427. //if we are using a background slider make sure that the image is loaded. if not preload it, then show the slide
  3428. if(this.options.bg_slider == true)
  3429. {
  3430. if(this.imageUrls[this.current]['status'] == true )
  3431. {
  3432. this['_' + this.options.animation].call(this, dir);
  3433. }
  3434. else
  3435. {
  3436. this.loader.show();
  3437. this._preloadSingle(this.current, function()
  3438. {
  3439. this['_' + this.options.animation].call(this, dir);
  3440. this.loader.hide();
  3441. });
  3442. }
  3443. }
  3444. else //no background loader -> images are already loaded
  3445. {
  3446. //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
  3447. this['_' + this.options.animation].call(this, dir);
  3448. }
  3449. if(this.current == 0)
  3450. {
  3451. this.loopCount++;
  3452. this.$slider.trigger('avia_slider_first_slide');
  3453. }
  3454. else if(this.current == this.itemsCount - 1)
  3455. {
  3456. this.$slider.trigger('avia_slider_last_slide');
  3457. }
  3458. else
  3459. {
  3460. this.$slider.trigger('avia_slider_navigate_slide');
  3461. }
  3462. },
  3463. //if the next slide has a different height than the current change the slideshow height
  3464. _setSize: function(instant)
  3465. {
  3466. //if images are attached as bg images the slider has a fixed height
  3467. if(this.options.bg_slider == true) return;
  3468. var self = this,
  3469. slide = this.$slides.eq(this.current),
  3470. current = Math.floor(this.$sliderUl.height()),
  3471. ratio = slide.data('video-ratio'),
  3472. setTo = ratio ? this.$sliderUl.width() / ratio : Math.floor(slide.height()),
  3473. video_height = slide.data('video-height'), //forced video height %. needs to be set only once
  3474. video_toppos = slide.data('video-toppos'); //forced video top position
  3475. this.$sliderUl.height(current).css('padding',0); //make sure to set the slideheight to an actual value
  3476. if(setTo != current)
  3477. {
  3478. if(instant == true)
  3479. {
  3480. this.$sliderUl.css({height:setTo});
  3481. this.$win.trigger('av-height-change');
  3482. }
  3483. else
  3484. {
  3485. this.$sliderUl.avia_animate({height:setTo}, function()
  3486. {
  3487. self.$win.trigger('av-height-change');
  3488. });
  3489. }
  3490. }
  3491. if(video_height && video_height!= "set")
  3492. {
  3493. slide.find('iframe, embed, video, object, .av_youtube_frame').css({height: video_height + '%', top: video_toppos + '%'});
  3494. slide.data('video-height','set');
  3495. }
  3496. },
  3497. _slide: function(dir)
  3498. {
  3499. var sliderWidth = this.$slider.width(),
  3500. direction = dir === 'next' ? -1 : 1,
  3501. property = this.browserPrefix + 'transform',
  3502. reset = {}, transition = {}, transition2 = {},
  3503. trans_val = ( sliderWidth * direction * -1),
  3504. trans_val2 = ( sliderWidth * direction);
  3505. //do a css3 animation
  3506. if(this.cssActive)
  3507. {
  3508. property = this.browserPrefix + 'transform';
  3509. //do a translate 3d transformation if available, since it uses hardware acceleration
  3510. if(this.css3DActive)
  3511. {
  3512. reset[property] = "translate3d(" + trans_val + "px, 0, 0)";
  3513. transition[property] = "translate3d(" + trans_val2 + "px, 0, 0)";
  3514. transition2[property] = "translate3d(0,0,0)";
  3515. }
  3516. else //do a 2d transform. still faster than a position "left" change
  3517. {
  3518. reset[property] = "translate(" + trans_val + "px,0)";
  3519. transition[property] = "translate(" + trans_val2 + "px,0)";
  3520. transition2[property] = "translate(0,0)"; }
  3521. }
  3522. else
  3523. {
  3524. reset.left = trans_val;
  3525. transition.left = trans_val2;
  3526. transition2.left = 0;
  3527. }
  3528. this._slide_animate(reset, transition, transition2);
  3529. },
  3530. _slide_up: function(dir)
  3531. {
  3532. var sliderHeight = this.$slider.height(),
  3533. direction = dir === 'next' ? -1 : 1,
  3534. property = this.browserPrefix + 'transform',
  3535. reset = {}, transition = {}, transition2 = {},
  3536. trans_val = ( sliderHeight * direction * -1),
  3537. trans_val2 = ( sliderHeight * direction);
  3538. //do a css3 animation
  3539. if(this.cssActive)
  3540. {
  3541. property = this.browserPrefix + 'transform';
  3542. //do a translate 3d transformation if available, since it uses hardware acceleration
  3543. if(this.css3DActive)
  3544. {
  3545. reset[property] = "translate3d( 0," + trans_val + "px, 0)";
  3546. transition[property] = "translate3d( 0," + trans_val2 + "px, 0)";
  3547. transition2[property] = "translate3d(0,0,0)";
  3548. }
  3549. else //do a 2d transform. still faster than a position "left" change
  3550. {
  3551. reset[property] = "translate( 0," + trans_val + "px)";
  3552. transition[property] = "translate( 0," + trans_val2 + "px)";
  3553. transition2[property] = "translate(0,0)"; }
  3554. }
  3555. else
  3556. {
  3557. reset.top = trans_val;
  3558. transition.top = trans_val2;
  3559. transition2.top = 0;
  3560. }
  3561. this._slide_animate(reset, transition, transition2);
  3562. },
  3563. //slide animation: do a slide transition by css3 transform if possible. if not simply do a position left transition
  3564. _slide_animate: function( reset , transition , transition2 )
  3565. {
  3566. var self = this,
  3567. displaySlide = this.$slides.eq(this.current),
  3568. hideSlide = this.$slides.eq(this.prev);
  3569. hideSlide.trigger('pause');
  3570. if( !displaySlide.data('disableAutoplay') ) displaySlide.trigger('play');
  3571. displaySlide.css({visibility:'visible', zIndex:4, opacity:1, left:0, top:0});
  3572. displaySlide.css(reset);
  3573. hideSlide.avia_animate(transition, this.options.transitionSpeed, this.options.easing);
  3574. var after_slide = function()
  3575. {
  3576. self.isAnimating = false;
  3577. displaySlide.addClass('active-slide');
  3578. hideSlide.css({visibility:'hidden'}).removeClass('active-slide');
  3579. self.$slider.trigger('avia-transition-done');
  3580. }
  3581. if(self.options.show_slide_delay > 0)
  3582. {
  3583. setTimeout(function() { displaySlide.avia_animate(transition2, self.options.transitionSpeed, self.options.easing, after_slide); },self.options.show_slide_delay);
  3584. }
  3585. else
  3586. {
  3587. displaySlide.avia_animate(transition2, self.options.transitionSpeed, self.options.easing, after_slide);
  3588. }
  3589. },
  3590. //simple fade transition of the slideshow
  3591. _fade: function()
  3592. {
  3593. var self = this,
  3594. displaySlide = this.$slides.eq(this.current),
  3595. hideSlide = this.$slides.eq(this.prev),
  3596. properties = {visibility:'visible', zIndex:3, opacity:0},
  3597. fadeCallback = function()
  3598. {
  3599. self.isAnimating = false;
  3600. displaySlide.addClass('active-slide');
  3601. hideSlide.css({visibility:'hidden', zIndex:2}).removeClass('active-slide');
  3602. self.$slider.trigger('avia-transition-done');
  3603. };
  3604. hideSlide.trigger('pause');
  3605. if( !displaySlide.data('disableAutoplay') ) displaySlide.trigger('play');
  3606. if(self.options.fullfade == true)
  3607. {
  3608. hideSlide.avia_animate({opacity:0}, 200, 'linear', function()
  3609. {
  3610. displaySlide.css(properties).avia_animate({opacity:1}, self.options.transitionSpeed, 'linear',fadeCallback);
  3611. });
  3612. }
  3613. else
  3614. {
  3615. displaySlide.css(properties).avia_animate({opacity:1}, self.options.transitionSpeed/2, 'linear', function()
  3616. {
  3617. hideSlide.avia_animate({opacity:0}, 200, 'linear', fadeCallback);
  3618. });
  3619. }
  3620. },
  3621. /************************************************************************
  3622. Video functions
  3623. *************************************************************************/
  3624. //bind events to the video that tell the slider to autorotate once a video has been played
  3625. _attach_video_events: function()
  3626. {
  3627. var self = this, $html = $('html');
  3628. self.$slides.each(function(i)
  3629. {
  3630. var currentSlide = $(this),
  3631. caption = currentSlide.find('.caption_fullwidth, .av-click-overlay'),
  3632. mejs = currentSlide.find('.mejs-mediaelement');
  3633. if(currentSlide.data('avia_video_events') != true)
  3634. {
  3635. currentSlide.data('avia_video_events', true);
  3636. currentSlide.on('av-video-events-bound', { slide: currentSlide, wrap: mejs , iteration: i , self: self }, onReady);
  3637. currentSlide.on('av-video-ended', { slide: currentSlide , self: self}, onFinish);
  3638. currentSlide.on('av-video-play-executed', function(){ setTimeout(function(){ self.pause() }, 100); });
  3639. caption.on('click', { slide: currentSlide }, toggle);
  3640. // also if the player was loaded before the _bindEvents function was bound trigger it manually
  3641. if(currentSlide.is('.av-video-events-bound')) currentSlide.trigger('av-video-events-bound');
  3642. }
  3643. });
  3644. //helper functions
  3645. function onReady( event )
  3646. {
  3647. //autostart for first slide
  3648. if(event.data.iteration === 0)
  3649. {
  3650. event.data.wrap.css('opacity',0);
  3651. if(!event.data.self.isMobile && !event.data.slide.data('disableAutoplay')) { event.data.slide.trigger('play'); } 
  3652. setTimeout(function(){ event.data.wrap.avia_animate({opacity:1}, 400); }, 50);
  3653. }
  3654. else if ($html.is('.avia-msie') && !event.data.slide.is('.av-video-service-html5'))
  3655. {
  3656. /*
  3657. * Internet Explorer fires the ready event for external videos once they become visible
  3658. * as oposed to other browsers which always fire immediately.
  3659. */
  3660. if( !event.data.slide.data('disableAutoplay') ) event.data.slide.trigger('play');
  3661. }
  3662. }
  3663. function onFinish( event )
  3664. {
  3665. //if the video is not looped resume the slideshow
  3666. if(!event.data.slide.is('.av-single-slide') && !event.data.slide.is('.av-loop-video'))
  3667. {
  3668. event.data.slide.trigger('reset');
  3669. self._navigate( 'next' );
  3670. self.resume();
  3671. }
  3672. //safari 8 workaround for self hosted videos which wont loop by default
  3673. if(event.data.slide.is('.av-loop-video') && event.data.slide.is('.av-video-service-html5'))
  3674. {
  3675. if($html.is('.avia-safari-8'))
  3676. {
  3677. setTimeout(function(){ event.data.slide.trigger('play'); },1);
  3678. }
  3679. }
  3680. }
  3681. function toggle( event )
  3682. {
  3683. if(event.target.tagName != "A")
  3684. {
  3685. event.data.slide.trigger('toggle');
  3686. }
  3687. }
  3688. },
  3689. /************************************************************************
  3690. Slideshow control functions
  3691. *************************************************************************/
  3692. _timer: function(callback, delay, first)
  3693. {
  3694. var self = this, start, remaining = delay;
  3695. self.timerId = 0;
  3696. this.pause = function() {
  3697. window.clearTimeout(self.timerId);
  3698. remaining -= new Date() - start;
  3699. };
  3700. this.resume = function() {
  3701. start = new Date();
  3702. self.timerId = window.setTimeout(callback, remaining);
  3703. };
  3704. this.destroy = function()
  3705. {
  3706. window.clearTimeout(self.timerId);
  3707. };
  3708. this.resume(true);
  3709. },
  3710. //start autorotation
  3711. _startSlideshow: function()
  3712. {
  3713. var self = this;
  3714. this.isPlaying = true;
  3715. this.slideshow = new this._timer( function()
  3716. {
  3717. self._navigate( 'next' );
  3718. if ( self.options.autoplay )
  3719. {
  3720. self._startSlideshow();
  3721. }
  3722. }, (this.options.interval * 1000));
  3723. },
  3724. //stop autorotation
  3725. _stopSlideshow: function()
  3726. {
  3727. if ( this.options.autoplay ) {
  3728. this.slideshow.destroy();
  3729. this.isPlaying = false;
  3730. this.options.autoplay = false;
  3731. }
  3732. },
  3733. // public method: shows next image
  3734. next : function(e)
  3735. {
  3736. e.preventDefault();
  3737. this._stopSlideshow();
  3738. this._navigate( 'next' );
  3739. },
  3740. // public method: shows previous image
  3741. previous : function(e)
  3742. {
  3743. e.preventDefault();
  3744. this._stopSlideshow();
  3745. this._navigate( 'prev' );
  3746. },
  3747. // public method: goes to a specific image
  3748. go2 : function( pos )
  3749. {
  3750. //if we didnt pass a number directly lets asume someone clicked on a link that triggered the goto transition
  3751. if(isNaN(pos))
  3752. {
  3753. //in that case prevent the default link behavior and set the slide number to the links hash
  3754. pos.preventDefault();
  3755. pos = pos.currentTarget.hash.replace('#','');
  3756. }
  3757. pos -= 1;
  3758. if( pos === this.current || pos >= this.itemsCount || pos < 0 )
  3759. {
  3760. return false;
  3761. }
  3762. this._stopSlideshow();
  3763. this._navigate( false, pos );
  3764. },
  3765. // public method: starts the slideshow
  3766. // any call to next(), previous() or goto() will stop the slideshow autoplay
  3767. play : function()
  3768. {
  3769. if( !this.isPlaying )
  3770. {
  3771. this.isPlaying = true;
  3772. this._navigate( 'next' );
  3773. this.options.autoplay = true;
  3774. this._startSlideshow();
  3775. }
  3776. },
  3777. // public methos: pauses the slideshow
  3778. pause : function()
  3779. {
  3780. if( this.isPlaying )
  3781. {
  3782. this.slideshow.pause();
  3783. }
  3784. },
  3785. // publiccmethos: resumes the slideshow
  3786. resume : function()
  3787. {
  3788. if( this.isPlaying )
  3789. {
  3790. this.slideshow.resume();
  3791. }
  3792. },
  3793. // public methos: destroys the instance
  3794. destroy : function( callback )
  3795. {
  3796. this.slideshow.destroy( callback );
  3797. }
  3798. }
  3799. //simple wrapper to call the slideshow. makes sure that the slide data is not applied twice
  3800. $.fn.aviaSlider = function( options )
  3801. {
  3802. return this.each(function()
  3803. {
  3804. var self = $.data( this, 'aviaSlider' );
  3805. if(!self)
  3806. {
  3807. self = $.data( this, 'aviaSlider', new $.AviaSlider( options, this ) );
  3808. }
  3809. });
  3810. }
  3811. })( jQuery );
  3812. // -------------------------------------------------------------------------------------------
  3813. // keyboard controls
  3814. // -------------------------------------------------------------------------------------------
  3815. (function($)
  3816. {
  3817. "use strict";
  3818. /************************************************************************
  3819. keyboard arrow nav
  3820. *************************************************************************/
  3821. $.fn.avia_keyboard_controls = function(options_passed)
  3822. {
  3823. var defaults =
  3824. {
  3825. 37: '.prev-slide', // prev
  3826. 39: '.next-slide' // next
  3827. },
  3828. methods = {
  3829. mousebind: function(slider)
  3830. {
  3831. slider.hover(
  3832. function(){ slider.mouseover = true; },
  3833. function(){ slider.mouseover = false; }
  3834. );
  3835. },
  3836. keybind: function(slider)
  3837. {
  3838. $(document).keydown(function(e)
  3839. {
  3840. if(slider.mouseover && typeof slider.options[e.keyCode] !== 'undefined')
  3841. {
  3842. var item;
  3843. if(typeof slider.options[e.keyCode] === 'string')
  3844. {
  3845. item = slider.find(slider.options[e.keyCode]);
  3846. }
  3847. else
  3848. {
  3849. item = slider.options[e.keyCode];
  3850. }
  3851. if(item.length)
  3852. {
  3853. item.trigger('click', ['keypress']);
  3854. return false;
  3855. }
  3856. }
  3857. });
  3858. }
  3859. };
  3860. return this.each(function()
  3861. {
  3862. var slider = $(this);
  3863. slider.options = $.extend({}, defaults, options_passed);
  3864. slider.mouseover = false;
  3865. methods.mousebind(slider);
  3866. methods.keybind(slider);
  3867. });
  3868. };
  3869. /************************************************************************
  3870. swipe nav
  3871. *************************************************************************/
  3872. $.fn.avia_swipe_trigger = function(passed_options)
  3873. {
  3874. var win = $(window),
  3875. isMobile = $.avia_utilities.isMobile,
  3876. defaults =
  3877. {
  3878. prev: '.prev-slide',
  3879. next: '.next-slide',
  3880. event: {
  3881. prev: 'click',
  3882. next: 'click'
  3883. }
  3884. },
  3885. methods = {
  3886. activate_touch_control: function(slider)
  3887. {
  3888. var i, differenceX, differenceY;
  3889. slider.touchPos = {};
  3890. slider.hasMoved = false;
  3891. slider.on('touchstart', function(event)
  3892. {
  3893. slider.touchPos.X = event.originalEvent.touches[0].clientX;
  3894. slider.touchPos.Y = event.originalEvent.touches[0].clientY;
  3895. });
  3896. slider.on('touchend', function(event)
  3897. {
  3898. slider.touchPos = {};
  3899. if(slider.hasMoved) { event.preventDefault(); }
  3900. slider.hasMoved = false;
  3901. });
  3902. slider.on('touchmove', function(event)
  3903. {
  3904. if(!slider.touchPos.X)
  3905. {
  3906. slider.touchPos.X = event.originalEvent.touches[0].clientX;
  3907. slider.touchPos.Y = event.originalEvent.touches[0].clientY;
  3908. }
  3909. else
  3910. {
  3911. differenceX = event.originalEvent.touches[0].clientX - slider.touchPos.X;
  3912. differenceY = event.originalEvent.touches[0].clientY - slider.touchPos.Y;
  3913. //check if user is scrolling the window or moving the slider
  3914. if(Math.abs(differenceX) > Math.abs(differenceY))
  3915. {
  3916. event.preventDefault();
  3917. if(slider.touchPos !== event.originalEvent.touches[0].clientX)
  3918. {
  3919. if(Math.abs(differenceX) > 50)
  3920. {
  3921. i = differenceX > 0 ? 'prev' : 'next';
  3922. if(typeof slider.options[i] === 'string')
  3923. {
  3924. slider.find(slider.options[i]).trigger(slider.options.event[i], ['swipe']);
  3925. }
  3926. else
  3927. {
  3928. slider.options[i].trigger(slider.options.event[i], ['swipe']);
  3929. }
  3930. slider.hasMoved = true;
  3931. slider.touchPos = {};
  3932. return false;
  3933. }
  3934. }
  3935. }
  3936. }
  3937. });
  3938. }
  3939. };
  3940. return this.each(function()
  3941. {
  3942. if(isMobile)
  3943. {
  3944. var slider = $(this);
  3945. slider.options = $.extend({}, defaults, passed_options);
  3946. methods.activate_touch_control(slider);
  3947. }
  3948. });
  3949. };
  3950. }(jQuery));