main.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. ;(function () {
  2. 'use strict';
  3. var isMobile = {
  4. Android: function() {
  5. return navigator.userAgent.match(/Android/i);
  6. },
  7. BlackBerry: function() {
  8. return navigator.userAgent.match(/BlackBerry/i);
  9. },
  10. iOS: function() {
  11. return navigator.userAgent.match(/iPhone|iPad|iPod/i);
  12. },
  13. Opera: function() {
  14. return navigator.userAgent.match(/Opera Mini/i);
  15. },
  16. Windows: function() {
  17. return navigator.userAgent.match(/IEMobile/i);
  18. },
  19. any: function() {
  20. return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
  21. }
  22. };
  23. var mobileMenuOutsideClick = function() {
  24. $(document).click(function (e) {
  25. var container = $("#bida-offcanvas, .js-bida-nav-toggle");
  26. if (!container.is(e.target) && container.has(e.target).length === 0) {
  27. if ( $('body').hasClass('offcanvas') ) {
  28. $('body').removeClass('offcanvas');
  29. $('.js-bida-nav-toggle').removeClass('active');
  30. }
  31. }
  32. });
  33. };
  34. var offcanvasMenu = function() {
  35. $('#page').prepend('<div id="bida-offcanvas" />');
  36. $('#page').prepend('<a href="#" class="js-bida-nav-toggle bida-nav-toggle bida-nav-white"><i></i></a>');
  37. var clone1 = $('.menu-1 > ul').clone();
  38. $('#bida-offcanvas').append(clone1);
  39. var clone2 = $('.menu-2 > ul').clone();
  40. $('#bida-offcanvas').append(clone2);
  41. $('#bida-offcanvas .has-dropdown').addClass('offcanvas-has-dropdown');
  42. $('#bida-offcanvas')
  43. .find('li')
  44. .removeClass('has-dropdown');
  45. // Hover dropdown menu on mobile
  46. $('.offcanvas-has-dropdown').mouseenter(function(){
  47. var $this = $(this);
  48. $this
  49. .addClass('active')
  50. .find('ul')
  51. .slideDown(500, 'easeOutExpo');
  52. }).mouseleave(function(){
  53. var $this = $(this);
  54. $this
  55. .removeClass('active')
  56. .find('ul')
  57. .slideUp(500, 'easeOutExpo');
  58. });
  59. $(window).resize(function(){
  60. if ( $('body').hasClass('offcanvas') ) {
  61. $('body').removeClass('offcanvas');
  62. $('.js-bida-nav-toggle').removeClass('active');
  63. }
  64. });
  65. };
  66. var burgerMenu = function() {
  67. $('body').on('click', '.js-bida-nav-toggle', function(event){
  68. var $this = $(this);
  69. if ( $('body').hasClass('overflow offcanvas') ) {
  70. $('body').removeClass('overflow offcanvas');
  71. } else {
  72. $('body').addClass('overflow offcanvas');
  73. }
  74. $this.toggleClass('active');
  75. event.preventDefault();
  76. });
  77. };
  78. var fullHeight = function() {
  79. if ( !isMobile.any() ) {
  80. $('.js-fullheight').css('height', $(window).height());
  81. $(window).resize(function(){
  82. $('.js-fullheight').css('height', $(window).height());
  83. });
  84. }
  85. };
  86. var contentWayPoint = function() {
  87. var i = 0;
  88. $('.animate-box').waypoint( function( direction ) {
  89. if( direction === 'down' && !$(this.element).hasClass('animated-fast') ) {
  90. i++;
  91. $(this.element).addClass('item-animate');
  92. setTimeout(function(){
  93. $('body .animate-box.item-animate').each(function(k){
  94. var el = $(this);
  95. setTimeout( function () {
  96. var effect = el.data('animate-effect');
  97. if ( effect === 'fadeIn') {
  98. el.addClass('fadeIn animated-fast');
  99. } else if ( effect === 'fadeInLeft') {
  100. el.addClass('fadeInLeft animated-fast');
  101. } else if ( effect === 'fadeInRight') {
  102. el.addClass('fadeInRight animated-fast');
  103. } else {
  104. el.addClass('fadeInUp animated-fast');
  105. }
  106. el.removeClass('item-animate');
  107. }, k * 200, 'easeInOutExpo' );
  108. });
  109. }, 100);
  110. }
  111. } , { offset: '85%' } );
  112. };
  113. var dropdown = function() {
  114. $('.has-dropdown').mouseenter(function(){
  115. var $this = $(this);
  116. $this
  117. .find('.dropdown')
  118. .css('display', 'block')
  119. .addClass('animated-fast fadeInUpMenu');
  120. }).mouseleave(function(){
  121. var $this = $(this);
  122. $this
  123. .find('.dropdown')
  124. .css('display', 'none')
  125. .removeClass('animated-fast fadeInUpMenu');
  126. });
  127. };
  128. var goToTop = function() {
  129. $('.js-gotop').on('click', function(event){
  130. event.preventDefault();
  131. $('html, body').animate({
  132. scrollTop: $('html').offset().top
  133. }, 500, 'easeInOutExpo');
  134. return false;
  135. });
  136. $(window).scroll(function(){
  137. var $win = $(window);
  138. if ($win.scrollTop() > 200) {
  139. $('.js-top').addClass('active');
  140. } else {
  141. $('.js-top').removeClass('active');
  142. }
  143. });
  144. };
  145. // Loading page
  146. var loaderPage = function() {
  147. $(".bida-loader").fadeOut("slow");
  148. };
  149. var counterWayPoint = function() {
  150. if ($('#bida-counter').length > 0 ) {
  151. $('#bida-counter').waypoint( function( direction ) {
  152. if( direction === 'down' && !$(this.element).hasClass('animated') ) {
  153. setTimeout( counter , 400);
  154. $(this.element).addClass('animated');
  155. }
  156. } , { offset: '90%' } );
  157. }
  158. };
  159. var sliderMain = function() {
  160. $('#bida-hero .flexslider').flexslider({
  161. animation: "fade",
  162. slideshowSpeed: 5000,
  163. directionNav: true,
  164. start: function(){
  165. setTimeout(function(){
  166. $('.slider-text').removeClass('animated fadeInUp');
  167. $('.flex-active-slide').find('.slider-text').addClass('animated fadeInUp');
  168. }, 500);
  169. },
  170. before: function(){
  171. setTimeout(function(){
  172. $('.slider-text').removeClass('animated fadeInUp');
  173. $('.flex-active-slide').find('.slider-text').addClass('animated fadeInUp');
  174. }, 500);
  175. }
  176. });
  177. $('#bida-hero .flexslider .slides > li').css('height', $(window).height());
  178. $(window).resize(function(){
  179. $('#bida-hero .flexslider .slides > li').css('height', $(window).height());
  180. });
  181. };
  182. $(function(){
  183. mobileMenuOutsideClick();
  184. offcanvasMenu();
  185. burgerMenu();
  186. contentWayPoint();
  187. sliderMain();
  188. dropdown();
  189. goToTop();
  190. loaderPage();
  191. counterWayPoint();
  192. fullHeight();
  193. });
  194. }());