Guest User

Untitled

a guest
Aug 21st, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.09 KB | None | 0 0
  1. jQuery(document).ready(function($) {
  2.  
  3. function wp_travel_set_equal_height() {
  4. var base_height = 0;
  5. $('.wp-travel-feature-slide-content').css({ 'height': 'auto' });
  6. var winWidth = window.innerWidth;
  7. if (winWidth > 992) {
  8.  
  9. $('.wp-travel-feature-slide-content').each(function() {
  10. if ($(this).height() > base_height) {
  11. base_height = $(this).height();
  12. }
  13. });
  14. if (base_height > 0) {
  15. $('.trip-headline-wrapper .left-plot').height(base_height); // Adding Padding of right plot.
  16. $('.trip-headline-wrapper .right-plot').height(base_height);
  17. }
  18. }
  19. }
  20. wp_travel_set_equal_height();
  21.  
  22. $('.wp-travel-gallery').magnificPopup({
  23. delegate: 'a', // child items selector, by clicking on it popup will open
  24. type: 'image',
  25. // other options
  26. gallery: {
  27. enabled: true
  28. }
  29. });
  30.  
  31. $('.wp-travel-send-enquiries').magnificPopup({
  32. type: 'inline',
  33. preloader: false,
  34. focus: '#wp-travel-enquiry-name',
  35. midClick: true
  36. });
  37.  
  38. $('#wp-travel-tab-wrapper').easyResponsiveTabs({
  39.  
  40. });
  41.  
  42. if (window.location.hash) {
  43. var hash = window.location.hash.substring(1); //Puts hash in variable, and removes the # character
  44.  
  45. // var match = hash.match(/wp-travel-/);
  46. // if (!match) {
  47. // hash = 'wp-travel-' + hash;
  48. // }
  49.  
  50. if ($("ul.resp-tabs-list > li." + hash).hasClass('wp-travel-ert')) {
  51. lis = $("ul.resp-tabs-list > li");
  52. lis.removeClass("resp-tab-active");
  53. $("ul.resp-tabs-list > li." + hash).addClass("resp-tab-active");
  54. tab_cont = $('.tab-list-content');
  55. tab_cont.removeClass('resp-tab-content-active').hide();
  56. $('#' + hash + '.tab-list-content').addClass('resp-tab-content-active').show();
  57. }
  58.  
  59. if ($('.wp-travel-tab-wrapper').length) {
  60. var winWidth = $(window).width();
  61. var tabHeight = $('.wp-travel-tab-wrapper').offset().top;
  62. if (winWidth < 767) {
  63. var tabHeight = $('.resp-accordion.resp-tab-active').offset().top;
  64. }
  65. $('html, body').animate({
  66. scrollTop: (tabHeight)
  67. }, 1200);
  68. }
  69. }
  70.  
  71. // $('ul.resp-tabs-list > li').on('click', function() {
  72. // // window.location.hash = '';
  73. // // history.pushState("", document.title, window.location.pathname);
  74. // });
  75.  
  76. // Rating script starts.
  77. $('.rate_label').hover(function() {
  78. var rateLabel = $(this).attr('data-id');
  79. $('.rate_label').removeClass('dashicons-star-filled');
  80.  
  81. rate(rateLabel);
  82. },
  83. function() {
  84. var ratedLabel = $('#wp_travel_rate_val').val();
  85.  
  86. $('.rate_label').removeClass('dashicons-star-filled').addClass('dashicons-star-empty');
  87. if (ratedLabel > 0) {
  88. rate(ratedLabel);
  89. }
  90. });
  91.  
  92. function rate(rateLabel) {
  93. for (var i = 0; i < rateLabel; i++) {
  94. $('.rate_label:eq( ' + i + ' )').addClass('dashicons-star-filled').removeClass('dashicons-star-empty ');
  95. }
  96.  
  97. for (j = 4; j >= i; j--) {
  98. $('.rate_label:eq( ' + j + ' )').addClass('dashicons-star-empty');
  99. }
  100. }
  101.  
  102. // click
  103. $('.rate_label').click(function(e) {
  104. e.preventDefault();
  105. $('#wp_travel_rate_val').val($(this).attr('data-id'));
  106. });
  107. // Rating script ends.
  108. //
  109.  
  110. $(document).on('click', '.wp-travel-count-info', function(e) {
  111. e.preventDefault();
  112. $(".wp-travel-review").trigger("click");
  113. });
  114.  
  115. $(document).on('click', '.top-view-gallery', function(e) {
  116. e.preventDefault();
  117. $(".wp-travel-tab-gallery-contnet").trigger("click");
  118. });
  119.  
  120. $(document).on('click', '.wp-travel-count-info, .top-view-gallery', function(e) {
  121. e.preventDefault();
  122. var winWidth = $(window).width();
  123. var tabHeight = $('.wp-travel-tab-wrapper').offset().top;
  124. if (winWidth < 767) {
  125. var tabHeight = $('.resp-accordion.resp-tab-active').offset().top;
  126. }
  127. $('html, body').animate({
  128. scrollTop: (tabHeight)
  129. }, 1200);
  130.  
  131. });
  132.  
  133. // Scroll and resize event
  134. // $(window).on("scroll", function(e) {
  135.  
  136. // var tabWrapper = $('.wp-travel-tab-wrapper');
  137. // var tabMenu = $('ul.wp-travel.tab-list');
  138.  
  139. // var tabWrapperTopOffset = tabWrapper.offset().top;
  140. // var tabWrapperHeight = tabWrapper.height();
  141. // var tabMenuHeight = tabMenu.height();
  142.  
  143. // var winScrollTop = $(window).scrollTop();
  144. // if (winScrollTop < (tabWrapperTopOffset + tabWrapperHeight) && winScrollTop >= tabWrapperTopOffset) {
  145. // tabMenu.addClass('custom-container fixed');
  146. // tabWrapper.css({ 'padding-top': tabMenuHeight });
  147. // } else {
  148. // tabMenu.removeClass('custom-container fixed');
  149. // tabWrapper.css({ 'padding-top': 0 });
  150. // }
  151.  
  152. // });
  153. $(window).on("resize", function(e) {
  154. wp_travel_set_equal_height();
  155. });
  156.  
  157. // Open All And Close All accordion.
  158. $('.open-all-link').click(function(e) {
  159. e.preventDefault();
  160. $('.panel-title a').removeClass('collapsed').attr({ 'aria-expanded': 'true' });
  161. $('.panel-collapse').addClass('in');
  162. // $(this).hide();
  163. $('.close-all-link').show();
  164. $('.panel-collapse').css('height', 'auto');
  165. });
  166. $('.close-all-link').click(function(e) {
  167. e.preventDefault();
  168. $('.panel-title a').addClass('collapsed').attr({ 'aria-expanded': 'false' });
  169. $('.panel-collapse').removeClass('in');
  170. // $(this).hide();
  171. $('.open-all-link').show();
  172. });
  173.  
  174. // Enquiry Submission.
  175.  
  176. $('#wp-travel-enquiries').submit(function(e) {
  177.  
  178. e.preventDefault();
  179.  
  180. //Remove any previous errors.
  181. $('.enquiry-response').remove();
  182.  
  183. var formData = {
  184. 'wp_travel_enquiry_name': $('#wp-travel-enquiry-name').val(),
  185. 'wp_travel_enquiry_email': $('#wp-travel-enquiry-email').val(),
  186. 'wp_travel_enquiry_query': $('#wp-travel-enquiry-query').val(),
  187. 'action': 'wp_travel_save_user_enquiry',
  188. 'nonce': wp_travel_frontend_vars.nonce,
  189. 'post_id': $('#wp-travel-enquiry-post-id').val(),
  190. };
  191. var text_processing = $('#wp_travel_label_processing').val();
  192. var text_submit_enquiry = $('#wp_travel_label_submit_enquiry').val();
  193. $.ajax({
  194. type: "POST",
  195. url: wp_travel_frontend_vars.ajaxUrl,
  196. data: formData,
  197. beforeSend: function() {
  198. $('#wp-travel-enquiry-submit').addClass('loading-bar loading-bar-striped active').val(text_processing).attr('disabled', 'disabled');
  199. },
  200. success: function(data) {
  201.  
  202. if (false == data.success) {
  203. var message = '<span class="enquiry-response enquiry-error-msg">' + data.data.message + '</span>';
  204. $('#wp-travel-enquiries').append(message);
  205. } else {
  206. if (true == data.success) {
  207.  
  208. var message = '<span class="enquiry-response enquiry-success-msg">' + data.data.message + '</span>';
  209. $('#wp-travel-enquiries').append(message);
  210.  
  211. setTimeout(function() {
  212. jQuery('#wp-travel-send-enquiries').magnificPopup('close')
  213. }, '3000');
  214.  
  215. }
  216. }
  217.  
  218. $('#wp-travel-enquiry-submit').removeClass('loading-bar loading-bar-striped active').val(text_submit_enquiry).removeAttr('disabled', 'disabled');
  219. //Reset Form Fields.
  220. $('#wp-travel-enquiry-name').val('');
  221. $('#wp-travel-enquiry-email').val('');
  222. $('#wp-travel-enquiry-query').val('');
  223.  
  224. return false;
  225. }
  226. });
  227.  
  228. });
  229.  
  230. jQuery('.wp-travel-booking-row').hide();
  231. jQuery('.show-booking-row').click(function(event) {
  232. event.preventDefault();
  233. jQuery(this).parent('.action').siblings('.wp-travel-booking-row').toggle('fast').addClass('animate');
  234. jQuery(this).text(function(i, text) {
  235. return text === wp_travel_frontend_vars.text_array.pricing_select ? wp_travel_frontend_vars.text_array.pricing_close : wp_travel_frontend_vars.text_array.pricing_select;
  236. })
  237. });
  238.  
  239. jQuery('.wp-travel-pricing-dates').each(function() {
  240. var availabledate = jQuery(this).data('available-dates');
  241. if (availabledate) {
  242. jQuery(this).datepicker({
  243. language: wp_travel_frontend_vars.locale,
  244. inline: true,
  245. autoClose: true,
  246. minDate: new Date(),
  247. onRenderCell: function(date, cellType) {
  248. if (cellType == 'day') {
  249. availabledate = availabledate.map(function(d) {
  250. return (new Date(d)).toLocaleDateString("en-US");
  251. });
  252. // availabledate = availabledate.map((d) => (new Date(d)).toLocaleDateString("en-US"));
  253. isDisabled = !availabledate.includes(date.toLocaleDateString("en-US"));
  254. return {
  255. disabled: isDisabled
  256. }
  257. }
  258. },
  259. });
  260.  
  261. } else {
  262. jQuery(this).datepicker({
  263. language: wp_travel_frontend_vars.locale,
  264. inline: true,
  265. minDate: new Date(),
  266. autoClose: true,
  267. });
  268. }
  269.  
  270. })
  271.  
  272. $(document).ready(function($) {
  273.  
  274. if (typeof parsley == "function") {
  275.  
  276. $('input').parsley();
  277.  
  278. }
  279.  
  280. // $('.add-to-cart-btn').click(function(event) {
  281. // event.preventDefault();
  282. // // Validate all input fields.
  283. // var isValid = true;
  284. // var parent = '#' + $(this).data('parent-id');
  285. // console.log(parent);
  286. // $(parent + ' input').each(function() {
  287. // if ($(this).parsley().validate() !== true) isValid = false;
  288. // });
  289. // if (isValid) {
  290. // pathname = $(this).attr('href');
  291. // query_string = '?';
  292. // var check_query_string = pathname.match(/\?/);
  293. // if (check_query_string) {
  294. // query_string = '&';
  295. // }
  296. // $(parent + ' input').each(function() {
  297. // filterby = $(this).attr('name');
  298. // filterby_val = $(this).val();
  299. // query_string += filterby + '=' + filterby_val + '&';
  300. // })
  301. // redirect_url = pathname + query_string;
  302. // redirect_url = redirect_url.replace(/&+$/, '');
  303. // location.href = redirect_url;
  304. // }
  305. // });
  306.  
  307. });
  308.  
  309. jQuery(document).ready(function($) {
  310. $('.login-page .message a').click(function(e) {
  311. e.preventDefault();
  312. $('.login-page form.login-form,.login-page form.register-form').animate({ height: "toggle", opacity: "toggle" }, "slow");
  313. });
  314. });
  315.  
  316. $('.dashboard-tab').easyResponsiveTabs({
  317. type: 'vertical',
  318. width: 'auto',
  319. fit: true,
  320. tabidentify: 'ver_1', // The tab groups identifier
  321. activetab_bg: '#fff', // background color for active tabs in this group
  322. inactive_bg: '#F5F5F5', // background color for inactive tabs in this group
  323. active_border_color: '#c1c1c1', // border color for active tabs heads in this group
  324. active_content_border_color: '#5AB1D0' // border color for active tabs contect in this group so that it matches the tab head border
  325. });
  326.  
  327. $('.dashtab-nav').click(function(e) {
  328.  
  329. e.preventDefault();
  330. var tab = $(this).data('tabtitle');
  331.  
  332. $('#' + tab).click();
  333.  
  334. });
  335.  
  336. $('#wp-travel-dsh-change-pass-switch').change(function(e) {
  337.  
  338. $('#wp-travel-dsh-change-pass').slideToggle();
  339.  
  340. });
  341.  
  342. });
Add Comment
Please, Sign In to add comment