PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/assets/js/enter.js

https://gitlab.com/iz9/de-coffee.landing.reborn
JavaScript | 211 lines | 124 code | 40 blank | 47 comment | 12 complexity | 1531c5f1eaa0ae61d5f2d950b9503b74 MD5 | raw file
  1. /**
  2. * Created by angry_bird on 26.06.2016.
  3. */
  4. var $ = require('jquery');
  5. var fullPageModule = require('./fullPageModule/fullPageModule');
  6. var multyLanguageModule = require('./multiLanguageModule/multyLanguageModule');
  7. $(document).ready(function () {
  8. var browserLangId = 1;
  9. function browserLangDetect() {
  10. var lang = navigator.language;
  11. if (lang == "uk" || lang == "ru") browserLangId = 2
  12. else browserLangId = 1
  13. }
  14. browserLangDetect();
  15. multyLanguageModule(browserLangId);
  16. var fullPageId = $('#fullpage');
  17. fullPageModule(fullPageId);
  18. $('.w-preload').addClass('fadeOut').css('z-index', -1);
  19. setTimeout(function () {
  20. }, 3000);
  21. if(browserLangId == 1){
  22. langBackgroundFunc('.c-welcomeImg', 'url(../img/de_coffe_welcome.png)');
  23. langBackgroundFunc('.c-miniLogo', 'url(../img/De_coffe_EN.png)');
  24. langBackgroundFunc('.c-logo', 'url(../img/De_coffe_EN.png)');
  25. langBackgroundFunc('.c-quickstartImg', 'url(../img/de_coffe_welcome.png)');
  26. langBackgroundHoverFunc('.c-quickstartButton__snack', 'url(../img/fancy.png)', 'url(../img/fancy_active.png)');
  27. langBackgroundHoverFunc('.c-quickstartButton__customer', 'url(../img/find.png)', 'url(../img/find_active.png)');
  28. }
  29. if(browserLangId == 2){
  30. langBackgroundFunc('.c-welcomeImg', 'url(../img/de_coffe_welcome_u.png)');
  31. langBackgroundFunc('.c-miniLogo', 'url(../img/De_coffe.png)');
  32. langBackgroundFunc('.c-logo', 'url(../img/De_coffe.png)');
  33. langBackgroundFunc('.c-quickstartImg', 'url(../img/de_coffe_welcome_u.png)');
  34. langBackgroundHoverFunc('.c-quickstartButton__snack', 'url(../img/fancy_u.png)', 'url(../img/fancy_active_u.png)');
  35. langBackgroundHoverFunc('.c-quickstartButton__customer', 'url(../img/find_u.png)', 'url(../img/find_active_u.png)');
  36. }
  37. //Event listeners
  38. //language Dropdown
  39. var allOptions = $("#optionsList").children('li:not(.init)');
  40. console.log(allOptions);
  41. $("#optionsList").on("click", '.init', function () {
  42. console.log('clicked list');
  43. if ($('#optionsList').children()[2].style.display == 'list-item') {
  44. $(this).closest("#optionsList").children('li:not(.init)').slideUp();
  45. $('.c-language__select_triangle').removeClass('triangle-rotate');
  46. } else {
  47. $(this).closest("#optionsList").children('li:not(.init)').slideDown();
  48. $('.c-language__select_triangle').addClass('triangle-rotate');
  49. }
  50. });
  51. $("#optionsList").on("click", "li:not(.init)", function () {
  52. allOptions.removeClass('selected');
  53. $(this).addClass('selected');
  54. $("#optionsList").children('.init').html($(this).html());
  55. $('.c-language__select_triangle').removeClass('triangle-rotate');
  56. allOptions.slideUp();
  57. });
  58. //popups
  59. $('.js-providerOpenTrigger').click(function () {
  60. openPopup('.c-contentProvider', '.c-popupProvider', '.s-forProvider')
  61. });
  62. $('.js-providerCloseTrigger').click(function () {
  63. closePopup('.c-contentProvider', '.c-popupProvider', '.s-forProvider')
  64. });
  65. $('.js-manOpenTrigger').click(function () {
  66. openPopup('.c-contentMan', '.c-popupMan', '.s-forCustomer')
  67. });
  68. $('.js-manCloseTrigger').click(function () {
  69. closePopup('.c-contentMan', '.c-popupMan', '.s-forCustomer')
  70. });
  71. //popups finish
  72. //sections navigation
  73. $('.c-logo').click(function () {
  74. $.fn.fullpage.moveSectionDown()
  75. });
  76. $('.js-miniLogo').click(function () {
  77. $.fn.fullpage.moveSectionDown()
  78. });
  79. $('.js-miniLogoLast').click(function () {
  80. $.fn.fullpage.moveTo(2)
  81. });
  82. $('.c-welcomeImg').click(function () {
  83. $.fn.fullpage.moveSectionDown()
  84. });
  85. //sections navigation
  86. //animations
  87. $('.c-logo').hover(function () {
  88. toggleAnimation(this, 'bounce')
  89. });
  90. $('.c-quickstartButton').hover(function () {
  91. toggleAnimation(this, 'rubberBand')
  92. });
  93. $('.c-welcomeImg').hover(function () {
  94. toggleAnimation(this, 'pulse')
  95. });
  96. //animations finish
  97. //Event listeners finish
  98. //functions
  99. /**
  100. *Функция открывает попап и скрывает секцию контента,
  101. к которому этот попап относится + анимация
  102. * @param content - класс или идентификатор блока контента (String)
  103. вида '.contentBlockClassName' || '#contentBlockId'
  104. * @param popup - класс или идентификатор попапа (String)
  105. вида '.popupClassName' || '#popupId'
  106. * @param parentSection - класс или идентификатор родительской секции (String)
  107. вида '.parentSectionClassName' || '#parentSectionId'
  108. */
  109. function openPopup(content, popup, parentSection) {
  110. $(content)
  111. .addClass('no-opacity')
  112. .removeClass('slideInDown')
  113. .addClass('slideOutUp');
  114. $(popup)
  115. .removeClass('no-opacity')
  116. .css('z-index', 4)
  117. .removeClass('slideOutUp')
  118. .addClass('slideInDown');
  119. $(parentSection + ' .c-miniLogo').css('opacity', 0)
  120. }
  121. /**
  122. *Функция скрывает попап и открывает секцию контента
  123. к которому этот попап относится + анимация
  124. * @param content - класс или идентификатор блока контента (String)
  125. вида '.contentBlockClassName' || '#contentBlockId'
  126. * @param popup - класс или идентификатор попапа (String)
  127. вида '.popupClassName' || '#popupId'
  128. * @param parentSection - класс или идентификатор родительской секции (String)
  129. вида '.parentSectionClassName' || '#parentSectionId'
  130. */
  131. function closePopup(content, popup, parentSection) {
  132. $(popup)
  133. .addClass('no-opacity')
  134. .css('z-index', 0)
  135. .removeClass('slideInDown')
  136. .addClass('slideOutUp');
  137. $(content)
  138. .removeClass('slideOutUp')
  139. .addClass('slideInDown')
  140. .removeClass('no-opacity');
  141. $(parentSection + ' .c-miniLogo').css('opacity', 1)
  142. }
  143. /**
  144. *Функция задает элементу класс с анимацией при ховере
  145. * @param element - блок который будет анимироваться (String)
  146. * @param animationName - название класса анимации (String)
  147. */
  148. function toggleAnimation(element, animationName){
  149. $(element).toggleClass(animationName)
  150. }
  151. /**
  152. *
  153. *
  154. */
  155. function langBackgroundFunc(elem, bgi){
  156. $(elem).css('backgroundImage', bgi);
  157. }
  158. function langBackgroundHoverFunc(elem, bgi, hoverBgi) {
  159. $(elem).hover(function () {
  160. $(this).css('backgroundImage', hoverBgi)
  161. },
  162. function () {
  163. $(this).css('backgroundImage', bgi)
  164. })
  165. }
  166. });
  167. /*
  168. $(window).load(function() {
  169. /!** код будет запущен когда страница будет полностью загружена, включая все фреймы, объекты и изображения **!/
  170. $('.w-preload').addClass('fadeOut').css('z-index', -1);
  171. });*/