main.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. $(function()
  2. {
  3. 'use strict';
  4. handleMainMenu();
  5. handleResponsiveSidebar();
  6. handleAccordionMenu();
  7. handleTooltips();
  8. handleFloatingLabels();
  9. handlePackageSwitcher();
  10. checkBoxes($('body'));
  11. var animation_offset_px = 200;
  12. if (typeof onGetAnimationOffsetPx === 'function')
  13. {
  14. animation_offset_px = onGetAnimationOffsetPx();
  15. }
  16. handlePageAnimations(animation_offset_px);
  17. if ($('body').hasClass('page-scrollspy'))
  18. {
  19. handleScrollSpySidebar();
  20. }
  21. $('.reponsive-image-types > li > a').on('click', function(e)
  22. {
  23. e.preventDefault();
  24. var imageType = $(this).data('type');
  25. var imagePreview = $('.responsive-image .browser');
  26. imagePreview.removeClass('desktop-size tablet-size mobile-size').addClass(imageType);
  27. $(this).closest('ul').find('li').removeClass('active');
  28. $(this).parent().addClass('active');
  29. imagePreview.find('.control-panel').removeClass('animated');
  30. setTimeout(function()
  31. {
  32. imagePreview.find('.control-panel').addClass('animated');
  33. }, 1000);
  34. });
  35. $('.play').on('click', function() {
  36. var $controlPanel = $(this).parent();
  37. $(this).closest('.responsive-image').find('.animated').removeClass('animated').parent();
  38. $controlPanel.removeClass('animated');
  39. setTimeout(function()
  40. {
  41. $controlPanel.addClass('animated');
  42. }, 10);
  43. });
  44. //Change the browser to mobile phone in the Control Panel feature subapge
  45. if ($(window).width() < 768) {
  46. $('.repsonsive-image-multiple .browser').removeClass('tablet-size desktop-size').addClass('mobile-size');
  47. }
  48. $(window).resize(function()
  49. {
  50. if ($(window).width() < 768) {
  51. $('.repsonsive-image-multiple .browser').removeClass('tablet-size desktop-size').addClass('mobile-size');
  52. }
  53. });
  54. $('.tabs-responsive .dropdown').on('show.bs.dropdown', function () {
  55. $('.tabs-responsive, .tabs-responsive .nav').css( "overflow", "inherit" );
  56. });
  57. $('.tabs-responsive .dropdown').on('hide.bs.dropdown', function () {
  58. $('.tabs-responsive, .tabs-responsive .nav').removeAttr('style')
  59. });
  60. });
  61. var handleTooltips = function()
  62. {
  63. "use strict";
  64. $('[data-toggle="tooltip"]').tooltip();
  65. };
  66. var handleMainMenu = function()
  67. {
  68. "use strict";
  69. var mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
  70. var menuList = $('.page-navbar .navbar-main > li');
  71. // Disable floating menu on mobile phones
  72. if (!mobile) {
  73. navfloat();
  74. //close dropdown on hover
  75. menuList.on('mouseover', function()
  76. {
  77. if(!$(this).hasClass('open')) {
  78. $(this).closest('.nav').find('.open').removeClass('open');
  79. }
  80. });
  81. }
  82. else {
  83. $('html').addClass('mobile');
  84. }
  85. // Show navigation menu on button click
  86. $('.navbar-toggle').on('click', function()
  87. {
  88. var btn = $(this);
  89. var target = $('body');
  90. if (!target.hasClass('navbar-open'))
  91. {
  92. btn.addClass('active');
  93. target.addClass('navbar-open');
  94. }
  95. else
  96. {
  97. target.addClass('navbar-closing');
  98. setTimeout(function()
  99. {
  100. target.addClass('navbar-bgfade');
  101. }, 400);
  102. setTimeout(function()
  103. {
  104. btn.removeClass('active');
  105. target.removeClass('navbar-open navbar-closing navbar-bgfade');
  106. }, 800);
  107. }
  108. });
  109. // Floating menu function
  110. function navfloat()
  111. {
  112. var pageNav = $('.page-navbar');
  113. var prevScroll = '0';
  114. var curDir = 'down';
  115. var prevDir = 'up';
  116. var fixedSidebar = $('.main-sidebar-scrollspy');
  117. $(window).scroll(function ()
  118. {
  119. if($(this).scrollTop() > 100 && (!pageNav.hasClass('navbar-hidden') && !pageNav.hasClass('navbar-fixed')))
  120. {
  121. pageNav.addClass('navbar-hidden');
  122. }
  123. else if ($(this).scrollTop() < 100 && (!pageNav.hasClass('navbar-fixed') && pageNav.hasClass('navbar-hidden')))
  124. {
  125. pageNav.removeClass('navbar-hidden');
  126. }
  127. if ($(this).scrollTop() > 300)
  128. {
  129. if (!pageNav.hasClass('navbar-fixed'))
  130. {
  131. pageNav.addClass('navbar-fixed');
  132. }
  133. if ($(this).scrollTop() >= prevScroll)
  134. {
  135. curDir = 'down';
  136. if (curDir !== prevDir)
  137. {
  138. prevDir = curDir;
  139. pageNav.removeClass('navbar-visible').addClass('navbar-hidden');
  140. fixedSidebar.removeClass('main-sidebar-floating-nav');
  141. }
  142. }
  143. else
  144. {
  145. curDir = 'up';
  146. if (curDir !== prevDir)
  147. {
  148. pageNav.removeClass('navbar-hidden').addClass('navbar-visible');
  149. fixedSidebar.addClass('main-sidebar-floating-nav');
  150. prevDir = curDir;
  151. }
  152. }
  153. prevScroll = $(this).scrollTop();
  154. }
  155. if (pageNav.hasClass('navbar-fixed') && $(this).scrollTop() <= 10)
  156. {
  157. pageNav.removeClass('navbar-fixed navbar-visible');
  158. fixedSidebar.removeClass('main-sidebar-floating-nav');
  159. }
  160. });
  161. }
  162. };
  163. var handleScrollSpySidebar = function()
  164. {
  165. "use strict";
  166. $('.page-scrollspy').scrollspy({ target: '.main-sidebar-scrollspy' });
  167. $('.main-sidebar-scrollspy .nav-sidebar').affix({
  168. offset: {
  169. top: $('.page-main').offset().top,
  170. bottom: $('body').height() - ($('.page-main').height() + $('.page-main').offset().top) + 80,
  171. }
  172. });
  173. console.log($('body').height() - ($('.page-main').height() + $('.page-main').offset().top) + 60);
  174. $('.main-sidebar-scrollspy .nav > li > a').on('click', function(e)
  175. {
  176. e.preventDefault();
  177. $('html, body').animate({
  178. scrollTop: $(this.hash).offset().top
  179. }, 250);
  180. });
  181. };
  182. var handleResponsiveSidebar = function()
  183. {
  184. "use strict";
  185. $('.nav-responsive .btn').on('click', function()
  186. {
  187. var target = $('.nav-responsive');
  188. if (!target.hasClass('open'))
  189. {
  190. target.addClass('open');
  191. $('html, body').animate({
  192. scrollTop: target.offset().top
  193. }, 250);
  194. }
  195. else
  196. {
  197. target.removeClass('open');
  198. }
  199. });
  200. $('.nav-responsive > .nav-sidebar a').on('click', function()
  201. {
  202. $(this).closest('.nav-responsive').removeClass('open');
  203. });
  204. $(document).on('click','.nav-responsive.open > .nav-sidebar > .dropdown > a', function(e)
  205. {
  206. e.preventDefault();
  207. $(this).parent().addClass('active');
  208. });
  209. $(document).mouseup(function (e)
  210. {
  211. var target = $('.nav-responsive');
  212. if (!target.is(e.target) && target.has(e.target).length === 0)
  213. {
  214. target.removeClass('open');
  215. }
  216. });
  217. };
  218. var handleFloatingLabels = function()
  219. {
  220. "use strict";
  221. $('.floatlabel').floatlabel();
  222. };
  223. var handleAccordionMenu = function()
  224. {
  225. "use strict";
  226. $('.accordion .accordion-title').on('click', function ()
  227. {
  228. var currLi = $(this).closest('li');
  229. if (!currLi.hasClass('open'))
  230. {
  231. $('.accordion .collapse.in').collapse('hide');
  232. $('.accordion li').removeClass('open');
  233. currLi.find('.collapse').collapse('toggle');
  234. currLi.closest('li').addClass('open');
  235. /*
  236. currLi.on('shown.bs.collapse', function () {
  237. $('html, body').animate({
  238. scrollTop: currLi.offset().top - 60
  239. }, 250);
  240. });
  241. */
  242. }
  243. else
  244. {
  245. $('.accordion li').removeClass('open');
  246. currLi.find('.collapse').collapse('toggle');
  247. }
  248. });
  249. };
  250. var handlePackageSwitcher = function()
  251. {
  252. "use strict";
  253. var switcher = $('.packages-switcher');
  254. switcher.on('click', function()
  255. {
  256. if($(this).hasClass('monthly'))
  257. {
  258. $(this).removeClass('monthly');
  259. $('.package').each(function()
  260. {
  261. $(this).find('.package-price > span').html($(this).find('.package-price').data('hourly'));
  262. });
  263. }
  264. else
  265. {
  266. $(this).addClass('monthly');
  267. $('.package').each(function()
  268. {
  269. $(this).find('.package-price > span').html($(this).find('.package-price').data('monthly'));
  270. });
  271. }
  272. });
  273. };
  274. var handlePageAnimations = function(offset)
  275. {
  276. "use strict";
  277. var wow = new WOW(
  278. {
  279. boxClass: 'animate',
  280. animateClass: 'animated',
  281. offset: offset,
  282. mobile: false,
  283. live: true
  284. });
  285. wow.init();
  286. };
  287. var checkBoxes = function (container)
  288. {
  289. "use strict";
  290. container.find('input:not(.switch-checkbox)').icheck({
  291. checkboxClass: 'checkbox-styled',
  292. radioClass: 'radio-styled',
  293. increaseArea: '20%'
  294. });
  295. };
  296. // For responsive tabs scrolling
  297. $(function() {
  298. "use strict";
  299. function e() {
  300. c.classList.remove("disabled"), n.classList.remove("disabled"), l.scrollLeft <= 0 && c.classList.add("disabled"), l.scrollLeft + l.clientWidth + 5 >= l.scrollWidth && n.classList.add("disabled")
  301. }
  302. function t(e) {
  303. l.scrollLeft += e
  304. }
  305. var n = document.querySelector(".btn-next"),
  306. c = document.querySelector(".btn-prev"),
  307. l = document.querySelector(".tabs-responsive > .tabs-container > .nav-tabs"),
  308. i = 40;
  309. if (l !== null)
  310. {
  311. l.addEventListener("scroll", e), e(), n.addEventListener("click", t.bind(null, i)), n.addEventListener("tap", t.bind(null, i)), c.addEventListener("click", t.bind(null, -i)), c.addEventListener("tap", t.bind(null, -i))
  312. }
  313. }(),
  314. function() {
  315. "use strict";
  316. var e = document.querySelectorAll('[href=""]');
  317. Array.prototype.forEach.call(e, function(e) {
  318. e.addEventListener("click", function(e) {
  319. e.preventDefault()
  320. })
  321. })
  322. });
  323. h=1;