Guest User

Untitled

a guest
Jan 22nd, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.77 KB | None | 0 0
  1. jQuery(function() {
  2. $('input[placeholder], textarea[placeholder]').placeholder();
  3. $(".phone-mask").mask("+7 999 999 99 99");
  4.  
  5. if ($("#map").length && $("#map").data('coord')) {
  6. google.maps.event.addDomListener(window, 'load', initialize);
  7. }
  8.  
  9. var nowTime = new Date();
  10.  
  11. var weekday = nowTime.getDay();
  12. weekday = weekday == 0 ? 7 : weekday;
  13. var day_offset = 60 * 60 * 24 - (((nowTime.valueOf() / 1000) % (60 * 60 * 24)) + (3600 * 4));
  14. var diffSecs = Math.floor(((7 - weekday) * 1000 * 60 * 60 * 24) + (day_offset * 1000));
  15.  
  16. dif(Math.floor(diffSecs / 1000));
  17.  
  18. $('.order-form').submit(function(e) {
  19. e.preventDefault();
  20.  
  21. var $form = $(this),
  22. ok = true,
  23. $name = $form.find('.fio'),
  24. $phone = $form.find('.phone'),
  25. $email = $form.find('.email');
  26.  
  27. if ($name.hasClass('required') && !$name.val()) {
  28. ok = false;
  29. $name.addClass("error");
  30. } else
  31. $name.removeClass("error");
  32.  
  33.  
  34. if (!/d{11}/.test($phone.val().replace(/D/g, ''))) {
  35. ok = false;
  36. $phone.addClass("error");
  37. } else
  38. $phone.removeClass("error");
  39.  
  40. if ($email.length > 0)
  41. if ($email.val().length > 0 || $email.hasClass('required')) {
  42. if (!checkEmail($email.val())) {
  43. ok = false;
  44. $email.addClass("error");
  45. } else
  46. $email.removeClass("error");
  47. }
  48.  
  49. if (ok) {
  50. $form.ajaxSubmit({
  51. success: function(response) {
  52. hideModal();
  53. showModal('.thanks-modal');
  54. $form.get(0).reset();
  55. if ($('body').data('metrika') && window['yaCounter'+$('body').data('metrika')]) window['yaCounter'+$('body').data('metrika')].reachGoal('request');
  56. if (window._gaq) _gaq.push(['_trackEvent','Form','Sent']);
  57. }
  58. });
  59. }
  60. });
  61. $('.send-btn').click(function(e) {
  62. e.preventDefault();
  63. $(this).closest('form').submit();
  64. return false;
  65. });
  66.  
  67.  
  68. $('.order-btn').click(function(e) {
  69. e.preventDefault();
  70. var mod = $('.modal.order-modal');
  71. if (mod.hasClass('open')) {
  72. hideModal(mod);
  73. mod.removeClass('open');
  74. } else {
  75. showModal(mod);
  76. mod.addClass('open');
  77. }
  78. });
  79.  
  80. $('.overlay, .modal .close-btn, .modal .modal-close-text').click(function(e) {
  81. e.preventDefault();
  82. hideModal('.modal');
  83. $('.modal').removeClass('open');
  84. });
  85.  
  86. $('.show-link').click(function () {
  87. var id = $(this).attr('id');
  88.  
  89. $('.b-show').slideUp();
  90. $('#'+id+'-data').slideDown();
  91. $('html:not(:animated),body:not(:animated)').animate({scrollTop: $('#b-all-our-shows').position().top+$('#b-all-our-shows').height()-80}, 500);
  92. return false;
  93. });
  94.  
  95.  
  96. var anchor = window.location.hash;
  97. if (anchor.indexOf('#shows')+1)
  98. $("html:not(:animated),body:not(:animated)").scrollTop($("#b-all-our-shows").offset().top-80);
  99.  
  100. if (anchor.indexOf('#why')+1)
  101. $("html:not(:animated),body:not(:animated)").scrollTop($("#b-why-we").offset().top-80);
  102.  
  103. if (anchor.indexOf('#how')+1)
  104. $("html:not(:animated),body:not(:animated)").scrollTop($("#b-how-buy-ticket").offset().top-80);
  105.  
  106. if (anchor.indexOf('#where')+1) {
  107. $("html:not(:animated),body:not(:animated)").scrollTop($(".bottom-priece").offset().top-80);
  108. }
  109.  
  110. });
  111.  
  112. function showModal(modal) {
  113. showModalTop(modal, 66);
  114. }
  115.  
  116. function showModalTop(modal, top) {
  117. modal = modal instanceof jQuery ? modal : jQuery(modal);
  118. modal.show();
  119. $(".overlay").show();
  120. }
  121.  
  122. function hideModal() {
  123. $(".modals > div").hide();
  124. $(".overlay").hide();
  125. }
  126. function dif(diffSecs) {
  127. var sec = Math.floor(diffSecs % 60);
  128. var mins = Math.floor(diffSecs / 60) % 60;
  129. var hours = Math.floor(diffSecs / 60 / 60) % 24;
  130. var days = Math.floor(diffSecs / 60 / 60 / 24);
  131.  
  132. var temp = convert(days, ['ĐƠĐộĐơứỂ', 'ĐƠĐơứỐ', 'ĐƠĐơĐộĐỰ']);
  133. $('.timer .days').html(temp[0]);
  134. $('.timer .days-text').html(temp[1]);
  135. var temp = convert(hours, ['ứẬĐồứẮ', 'ứẬĐồứẮĐồ', 'ứẬĐồứẮĐớĐỗ']);
  136. $('.timer .hours').html(temp[0] < 10 ? '0' + temp[0] : temp[0]);
  137. $('.timer .hours-text').html(temp[1]);
  138. var temp = convert(mins, ['ĐỬĐịĐơứẶứẰĐồ', 'ĐỬĐịĐơứẶứẰứỀ', 'ĐỬĐịĐơứẶứẰ']);
  139. $('.timer .mins').html(temp[0] < 10 ? '0' + temp[0] : temp[0]);
  140. $('.timer .mins-text').html(temp[1]);
  141. var temp = convert(sec, ['ứẮĐộĐỨứẶĐơĐƠĐồ', 'ứẮĐộĐỨứẶĐơĐƠứỀ', 'ứẮĐộĐỨứẶĐơĐƠ']);
  142. $('.timer .secs').html(temp[0] < 10 ? '0' + temp[0] : temp[0]);
  143. $('.timer .secs-text').html(temp[1]);
  144.  
  145. if (diffSecs > 0)
  146. {
  147. t = setTimeout(function('30') {
  148. dif(diffSecs - 1)
  149. }, 1000);
  150. }
  151. }
  152.  
  153. function convert(n, ar) {
  154. var o = n % 10;
  155. var l, g;
  156. switch (o) {
  157. case 1:
  158. l = 0;
  159. break;
  160. case 2:
  161. case 3:
  162. case 4:
  163. l = 1;
  164. break;
  165. default:
  166. l = 2;
  167. break;
  168. }
  169.  
  170. var g = n % 100;
  171. if (g == 10 || g == 11 || g == 12 || g == 13 || g == 14) {
  172. l = 2;
  173. }
  174. return [n, ar[l]];
  175. }
  176. function checkEmail(mail) {
  177. return /^[a-zĐồ-ứỐ0-9,!#$%&'*+/=?^_`{|}~-]+(.[a-zĐồ-ứỐ0-9,!#$%&'*+/=?^_`{|}~-]+)*@[a-zĐồ-ứỐ0-9-]+(.[a-z0-9-]+)*.([a-zứẠứẤ]{2,})$/.test(mail);
  178. }
  179.  
  180. var map;
  181.  
  182. function initialize() {
  183. var coords = $("#map").data('coord').split(',');
  184. var center = $("#map").data('center').split(',');
  185. var mapOptions = {
  186. zoom: 16,
  187. center: new google.maps.LatLng(center[0],center[1]),
  188. mapTypeId: google.maps.MapTypeId.ROADMAP
  189. };
  190. map = new google.maps.Map(document.getElementById('map'), mapOptions);
  191. marker = new google.maps.Marker({
  192. position: new google.maps.LatLng(coords[0],coords[1]),
  193. map: map
  194. });
  195. }
Add Comment
Please, Sign In to add comment