salmancreation

main js

Sep 27th, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.90 KB | None | 0 0
  1. (function ($) {
  2. const app = {
  3. init: () => {
  4.  
  5. $(document).on('click', '.installer-btn', app.handleInstaller);
  6. app.handleOfferBanner();
  7.  
  8. $(document).on('click', '.spacial_offer .close_bar', app.handleOfferBanner);
  9.  
  10. },
  11.  
  12. handleInstaller: () => {
  13. var url = $('#install-website').val();
  14.  
  15. if (app.isValidUrl(url)) {
  16. url = url + '/wp-admin/plugin-install.php?tab=plugin-information&plugin=wp-dark-mode';
  17.  
  18. window.open(url);
  19. } else {
  20. $('#install-website').addClass('invalid');
  21. }
  22. },
  23.  
  24. isValidUrl: (str) => {
  25. var pattern = new RegExp('^(https?:\\/\\/)?' + // protocol
  26. '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name
  27. '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
  28. '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
  29. '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
  30. '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
  31. return !!pattern.test(str);
  32. },
  33.  
  34. handleOfferBanner: () => {
  35. if($('.top_bar.spacial_offer').is(":visible")){
  36. $('body').addClass('offer-active');
  37. }else{
  38. $('body').removeClass('offer-active');
  39. }
  40. }
  41.  
  42. };
  43.  
  44. $(document).ready(app.init);
  45. })(jQuery);
  46.  
  47.  
  48. (function ($) {
  49. "use strict";
  50.  
  51. $(document).ready(function () {
  52.  
  53. // testimonial slider landing page
  54. $("#testimonial_slider").owlCarousel({
  55. autoplay: true,
  56. items: 1,
  57. loop: true,
  58. nav: false,
  59. dot: true
  60. });
  61.  
  62.  
  63. // WOW js initalization
  64. new WOW().init();
  65.  
  66. });
  67.  
  68. // sticky menu
  69. $(window).on('scroll', function () {
  70. if ($(this).scrollTop() > 36) {
  71. $('.navbar').addClass('sticky');
  72. } else {
  73. $('.navbar').removeClass('sticky');
  74. }
  75. });
  76.  
  77. // resize post height controller
  78. $(function () {
  79. function reSizeArea(e) {
  80. var arr = $.makeArray(e);
  81. var ah = $.map(arr, function (h) {
  82. return $(h).height();
  83. });
  84. var mh = Math.max.apply($(this).height(), ah);
  85. e.height(mh);
  86. }
  87.  
  88. reSizeArea($('.single_quote > blockquote'));
  89. if ($(window).width() > 1024) {
  90. reSizeArea($('.table_head'));
  91. reSizeArea($('.packages'));
  92. }
  93. });
  94.  
  95. // pricing page FAQ section
  96. $(function () {
  97. $('dd').filter(':nth-child(n+4)').addClass('hide');
  98. $('dl').on('click', 'dt', function () {
  99. $('dt').removeClass('open')
  100. $(this).addClass('open')
  101. .next()
  102. .slideDown(300)
  103. .siblings('dd')
  104. .slideUp(300);
  105. });
  106. });
  107.  
  108. // Pricing table plan changing annual and life time
  109. $(function () {
  110. $('.basic_plan_lifetime, .pro_plan_lifetime, .ultimate_plan_lifetime').addClass('hide');
  111. $('#change_plan').on('click', () => {
  112.  
  113. $('#change_plan').toggleClass('clicked');
  114. $('.annual, .lifetime').toggleClass('active')
  115. $('.basic_plan_lifetime, .pro_plan_lifetime, .ultimate_plan_lifetime, .basic_plan, .pro_plan, .ultimate_plan').toggleClass('hide');
  116. })
  117. $('.plan').on('mouseover', function () {
  118. $('.plan').removeClass('active');
  119. $(this).addClass('active')
  120. })
  121. });
  122.  
  123. // Mobile menu and top bar customization
  124. $(function () {
  125. $('#main_menu').prepend("<span class='close_menu'></span>");
  126. var getProBtn = $('.pro_account > ul > li');
  127. $(".navbar-toggler").on('click', () => {
  128. $("#main_menu").addClass('open_menu')
  129. if ($(window).width() > 576) {
  130. $('#main_menu > #navBar').append(getProBtn);
  131. }
  132. })
  133. $(".close_menu").on('click', () => {
  134. $("#main_menu").removeClass('open_menu')
  135. if ($(window).width() > 576) {
  136. $('.pro_account > ul').append(getProBtn);
  137. }
  138. })
  139.  
  140. if ($(window).width() < 576) {
  141. $('#main_menu > #navBar').append(getProBtn);
  142. $(getProBtn).clone()
  143. .insertBefore('.banner-content > .btn')
  144. .children().text("get pro plugin");
  145. }
  146.  
  147. $('.top_bar').prepend("<span class='close_bar'></span>");
  148. $(".close_bar").on('click', () => {
  149. $('.top_bar').css('display', 'none');
  150. })
  151.  
  152. })
  153.  
  154. // Banner image mode changing
  155. $(() => {
  156. $('.dark_btn').on('click', () => {
  157. $('.dark_btn').addClass('active');
  158. $('.light_btn').removeClass('active');
  159. $('.dark_demo').css('display', 'block');
  160. $('.light_demo').css('display', 'none');
  161. })
  162. $('.light_btn').on('click', () => {
  163. $('.light_btn').addClass('active');
  164. $('.dark_btn').removeClass('active');
  165. $('.light_demo').css('display', 'block');
  166. $('.dark_demo').css('display', 'none');
  167. })
  168.  
  169. setInterval(() => {
  170. if ($('.dark_btn').hasClass('active')) {
  171. $('.light_btn').addClass('active');
  172. $('.dark_btn').removeClass('active');
  173. $('.light_demo').css('display', 'block');
  174. $('.dark_demo').css('display', 'none');
  175. } else {
  176. $('.dark_btn').addClass('active');
  177. $('.light_btn').removeClass('active');
  178. $('.dark_demo').css('display', 'block');
  179. $('.light_demo').css('display', 'none');
  180. }
  181.  
  182. }, 3000);
  183. });
  184.  
  185.  
  186. $(window).on('load', function () {
  187. // jQuery twentytwenty image compare
  188. $("#image_compare").twentytwenty();
  189. });
  190.  
  191.  
  192.  
  193.  
  194.  
  195. })(jQuery);
  196.  
  197.  
  198. // top bar coung down timer
  199. (function () {
  200. const lastDate = document.getElementById('offer_limit').getAttribute('data-limit');
  201. // Set the date we're counting down to Y M D
  202. let countDownDate = new Date(lastDate).getTime();
  203. // Update the count down every 1 second
  204. let counter = setInterval(function () {
  205. // Get today's date and time
  206. let now = new Date().getTime();
  207. // Find the distance between now and the count down date
  208. let distance = countDownDate - now;
  209. // Formate single digit to double digit
  210. // const FormatMe = (n) => (n < 10) ? '0' + n : n;
  211. // Time calculations for days, hours, minutes and seconds
  212. let days = Math.floor(distance / (1000 * 60 * 60 * 24));
  213. let hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  214. let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  215. let seconds = Math.floor((distance % (1000 * 60)) / 1000);
  216. // Output the result in an element with id="offer_limit"
  217. document.getElementById("offer_limit").innerHTML = `
  218. <ul>
  219. <li>${days} <span>Days</span></li>
  220. <li>${hours} <span>Hours</span></li>
  221. <li>${minutes} <span>Minutes</span></li>
  222. <li>${seconds} <span>Seconds</span></li>
  223. </ul>
  224. `;
  225. // If the count down is over, write some text
  226. if (distance < 0) {
  227. clearInterval(counter);
  228. // document.getElementById("offer_limit").innerHTML = "EXPIRED";
  229. document.querySelector('.top_bar').style.display = "none";
  230. }
  231. }, 1000);
  232.  
  233. $(window).on('load resize orientationchange', function () {
  234. var navbar_height = $('.navbar').height();
  235. console.log(navbar_height);
  236. $('.header.header-banner').css('padding-top', 0 + navbar_height);
  237. });
  238.  
  239.  
  240. })();
  241.  
Add Comment
Please, Sign In to add comment