main.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. /*!
  2. //Description: //Core scripts to handle the entire theme// This file should be included in all pages
  3. !**/
  4. jQuery(document).ready(function() {
  5. //Tooltips Function
  6. //--------------------------------
  7. jQuery(function () {
  8. jQuery("[data-rel='tooltip']").tooltip()
  9. });
  10. // Popover Function
  11. //--------------------------------
  12. jQuery("[data-toggle=popover]").popover({html:true});
  13. //accordion Function
  14. //--------------------------------
  15. jQuery('.card-faqs-group .collapse').on('show.bs.collapse hide.bs.collapse', function(e) {
  16. var id = $(this).attr('id');
  17. var isShowing = e.type === 'show';
  18. jQuery('button[data-target="#' + id + '"]')
  19. .closest('.card')
  20. .toggleClass('accordion-active', isShowing)
  21. .find('.card-icon').html(isShowing ? '<i class="fal fa-angle-down"></i>' : '<i class="fal fa-angle-right"></i>');
  22. });
  23. jQuery('.block-footer .collapse').on('shown.bs.collapse', function(){
  24. jQuery(this).parent().find(".fa-angle-right").removeClass("fa-angle-right").addClass("fa-angle-down");
  25. }).on('hidden.bs.collapse', function(){
  26. jQuery(this).parent().find(".fa-angle-down").removeClass("fa-angle-down").addClass("fa-angle-right");
  27. });
  28. //Pricing Tables accordion Function
  29. //--------------------------------
  30. jQuery('.cros-pricing-container .PriceList-toggle').on('click', function () {
  31. jQuery('.cros-pricing-container .plan-features').collapse('toggle');
  32. });
  33. jQuery('select.location-switcher').on('change', function () {
  34. jQuery(':selected', this).tab('show');
  35. });
  36. /* toggle function */
  37. jQuery(".toggle").on("click",function(){
  38. var elm = $("#"+jQuery(this).data("toggle"));
  39. if(elm.is(":visible"))
  40. elm.addClass("d-none").removeClass("show");
  41. else
  42. elm.addClass("show").removeClass("d-none");
  43. return false;
  44. });
  45. /* Theme Swicther functions function */
  46. if(localStorage.getItem('cThemeMode'))
  47. {
  48. jQuery('body').addClass('dark-mode gray_logos');
  49. jQuery('.cThemeSwitcher').prop('checked', true);
  50. }
  51. jQuery('.cThemeSwitcher').click( function(){
  52. if (this.checked) {
  53. jQuery('body').addClass('dark-mode gray_logos');
  54. var cThemeMode = 'dark-mode gray_logos';
  55. } else if (!this.checked) {
  56. jQuery('body').removeClass('dark-mode gray_logos');
  57. var cThemeMode = '';
  58. }
  59. localStorage.setItem('cThemeMode', cThemeMode);
  60. });
  61. // Scroll Function for Sidebar
  62. jQuery(function () {
  63. function setHeight() {
  64. windowHeight = $(window).height();
  65. if (jQuery(window).width() < 991) {
  66. jQuery('.sidebar-scroll').css('max-height', windowHeight - 110);
  67. }
  68. else {
  69. if (jQuery(".navbar-side").hasClass("fixed")) {
  70. jQuery('.sidebar-scroll').css('max-height', windowHeight - 110);
  71. } else {
  72. jQuery('.sidebar-scroll').css('max-height', 5000);
  73. }
  74. }
  75. };
  76. setHeight();
  77. jQuery(window).resize(function() {
  78. setHeight();
  79. });
  80. jQuery('.sidebar-scroll').slimScroll({
  81. height: '100%',
  82. width: '100%',
  83. wheelStep: 20,
  84. size: '14px'
  85. });
  86. });
  87. /* toggle function for sidebar responsive */
  88. jQuery('#navbar-side-toggle').click(function() {
  89. jQuery(this).toggleClass('display');
  90. jQuery('#navbar-side').toggleClass('display');
  91. });
  92. jQuery('.panel-sidebar .truncate').each(function () {
  93. jQuery(this).attr('title', jQuery(this).text())
  94. .attr('data-toggle', 'tooltip')
  95. .attr('data-placement', 'bottom');
  96. });
  97. // For WHMCS only
  98. jQuery("#Secondary_Navbar-Account .dropdown-menu").addClass("dropdown-user");
  99. // Copyright removal
  100. jQuery("p:contains('Powered by')").remove();
  101. // Chekbox panel
  102. var panelSwitch = $('.panel-switch');
  103. panelSwitch.on('click', function (e) {
  104. if (!jQuery(this).is('a')) {
  105. var currCheck = $(this).find('input[type="checkbox"]');
  106. if (currCheck.is(':checked')) {
  107. panelSwitch.removeClass('checked');
  108. currCheck.prop('checked', false);
  109. } else {
  110. panelSwitch.addClass('checked');
  111. currCheck.prop('checked', true);
  112. }
  113. var that = $(this);
  114. setTimeout(function () {
  115. that.find('.loader').addClass('loading');
  116. }, 300);
  117. }
  118. });
  119. //back top top
  120. jQuery(window).scroll(function () {
  121. if (jQuery(this).scrollTop() > 50) {
  122. jQuery('#back-to-top').fadeIn();
  123. } else {
  124. jQuery('#back-to-top').fadeOut();
  125. }
  126. });
  127. // scroll body to 0px on click
  128. jQuery('#back-to-top').click(function () {
  129. jQuery('body,html').animate({
  130. scrollTop: 0
  131. }, 800);
  132. return false;
  133. });
  134. //for side menu simple search if you wish can impliment this option as per your choice
  135. jQuery(function() {
  136. jQuery('#input-items').on('keyup', function() {
  137. var rex = new RegExp($(this).val(), 'i');
  138. jQuery('.side-nav li').hide();
  139. jQuery('.side-nav li').filter(function() {
  140. return rex.test($(this).text());
  141. }).show();
  142. });
  143. });
  144. // enable side menu arrow
  145. jQuery(function() {
  146. jQuery('#side').crosMenu();
  147. })
  148. // Section Overlap functions
  149. jQuery('.section-overlap').each(function() {
  150. var $currentSection = $(this);
  151. var $nextSection = $currentSection.nextAll('div').first();
  152. if ($nextSection.length) {
  153. $nextSection.addClass('margin-up');
  154. }
  155. });
  156. $('.btn_loader').on('click', function(e) {
  157. var $this = $(this);
  158. if ($this.hasClass('loading')) {
  159. return; // Do nothing if already loading
  160. }
  161. $this.addClass('btn_loading disabled');
  162. $this.append('<span class="btn_loading_icon"><span class="spanner"><span></span><span></span><span></span><span></span></span></span>');
  163. // Simulate a delay or asynchronous action
  164. setTimeout(function() {
  165. $this.removeClass('btn_loading disabled');
  166. $this.find('.btn_loading_icon').remove();
  167. }, 3000); // Adjust the delay time as needed
  168. });
  169. jQuery(function() {
  170. jQuery('.page-scroll').bind('click', function(event) {
  171. var $anchor = jQuery(this);
  172. var offset = 100;
  173. if (window.innerWidth <= 768) {
  174. offset = 50;
  175. }
  176. jQuery('html, body').stop().animate({
  177. scrollTop: jQuery($anchor.attr('href')).offset().top - offset
  178. }, 1000, 'swing');
  179. event.preventDefault();
  180. });
  181. });
  182. $('.counter').each(function() {
  183. const el = this;
  184. if (isInViewport(el)) {
  185. startCounter(el);
  186. }
  187. });
  188. $(window).on('scroll', function() {
  189. $('.counter').each(function() {
  190. const el = this;
  191. if (isInViewport(el) && !$(el).hasClass('counted')) {
  192. startCounter(el);
  193. $(el).addClass('counted');
  194. }
  195. });
  196. });
  197. $('#enableSoundButton').on('click', function () {
  198. const container = $(this).closest('.banner-content-container');
  199. const video = $(this).closest('[class^="col-"]').find('.banner-bg-video')[0];
  200. if (video) {
  201. if (video.muted) {
  202. video.muted = false;
  203. video.play();
  204. $(this).find('.btn-text').text('Click to Mute');
  205. $(this).find('.fas').removeClass('fa-volume-mute').addClass('fa-volume-up');
  206. } else {
  207. video.muted = true;
  208. $(this).find('.btn-text').text('Click for Sound');
  209. $(this).find('.fas').removeClass('fa-volume-up').addClass('fa-volume-mute');
  210. }
  211. }
  212. });
  213. });
  214. // Custom function to handle smooth counter animation
  215. function startCounter(el) {
  216. const dataCount = $(el).attr('data-count');
  217. const regex = /(\d+)(\D*)/;
  218. const matches = dataCount.match(regex);
  219. const target = parseInt(matches[1], 10);
  220. const text = matches[2] || '';
  221. let count = 0;
  222. let step = target / 100;
  223. function animateCounter() {
  224. count += step;
  225. $(el).text(Math.round(count) + text);
  226. if (count < target) {
  227. requestAnimationFrame(animateCounter);
  228. } else {
  229. $(el).text(target + text);
  230. }
  231. }
  232. animateCounter();
  233. }
  234. // Function to check if element is in the viewport
  235. function isInViewport(el) {
  236. const rect = el.getBoundingClientRect();
  237. return rect.top >= 0 && rect.bottom <= window.innerHeight;
  238. }
  239. // side menu arrow function
  240. // Source https://github.com/onokumus/metisMenu
  241. ;(function ($, window, document, undefined) {
  242. var pluginName = "crosMenu",
  243. defaults = {
  244. toggle: true
  245. };
  246. function Plugin(element, options) {
  247. this.element = element;
  248. this.settings = $.extend({}, defaults, options);
  249. this._defaults = defaults;
  250. this._name = pluginName;
  251. this.init();
  252. }
  253. Plugin.prototype = {
  254. init: function () {
  255. var $this = $(this.element),
  256. $toggle = this.settings.toggle;
  257. $this.find('li.open').has('ul').children('ul').addClass('collapse show');
  258. $this.find('li').not('.open').has('ul').children('ul').addClass('collapse');
  259. $this.find('li').has('ul').children('a').on('click', function (e) {
  260. e.preventDefault();
  261. $(this).parent('li').toggleClass('open').children('ul').collapse('toggle');
  262. if ($toggle) {
  263. $(this).parent('li').siblings().removeClass('open').children('ul.show').collapse('hide');
  264. }
  265. });
  266. }
  267. };
  268. $.fn[ pluginName ] = function (options) {
  269. return this.each(function () {
  270. if (!$.data(this, "plugin_" + pluginName)) {
  271. $.data(this, "plugin_" + pluginName, new Plugin(this, options));
  272. }
  273. });
  274. };
  275. })(jQuery, window, document);
  276. // Loader
  277. jQuery(window).on('load', function () {
  278. jQuery('#overlay').fadeOut("slow");
  279. });
  280. // function collapse the navbar on scroll.
  281. var Apps = function () {
  282. return {
  283. init: function () {
  284. // init variables require in footer
  285. handleNavTopBar();
  286. },
  287. initNavTopBar: function (els) {
  288. if (window.matchMedia("(min-width: 992px)").matches) {
  289. var sbody = $('body').innerHeight();
  290. if (sbody > 1080) {
  291. //jQuery(window).scroll(function() {
  292. jQuery(window).on("load resize scroll",function(e){
  293. if (jQuery("body,html").scrollTop() > 50) {
  294. jQuery("body").addClass("top-nav-collapse");
  295. jQuery(".cros-navbar").addClass("navbar-fixed-top animated slideInDown");
  296. } else {
  297. jQuery("body").removeClass("top-nav-collapse");
  298. jQuery(".cros-navbar").removeClass("navbar-fixed-top animated slideInDown");
  299. }
  300. });
  301. }
  302. }
  303. },
  304. };
  305. }();
  306. /*!
  307. //end
  308. !**/