PageRenderTime 55ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/assets/js/app.js

https://gitlab.com/Krisnasw/Ayobaca
JavaScript | 291 lines | 226 code | 32 blank | 33 comment | 21 complexity | 5384f520762069a9a658b487ee56310c MD5 | raw file
  1. /*
  2. * Template Name: Unify - Responsive Bootstrap Template
  3. * Version: 1.9
  4. * Author: @htmlstream
  5. * Website: http://htmlstream.com
  6. */
  7. var App = function () {
  8. //Fixed Header
  9. function handleHeader() {
  10. jQuery(window).scroll(function() {
  11. if (jQuery(window).scrollTop() > 100) {
  12. jQuery('.header-fixed .header-sticky').addClass('header-fixed-shrink');
  13. } else {
  14. jQuery('.header-fixed .header-sticky').removeClass('header-fixed-shrink');
  15. }
  16. });
  17. }
  18. //Header Mega Menu
  19. function handleMegaMenu() {
  20. jQuery(document).on('click', '.mega-menu .dropdown-menu', function(e) {
  21. e.stopPropagation();
  22. })
  23. }
  24. //Search Box (Header)
  25. function handleSearch() {
  26. jQuery('.search').on("click", function () {
  27. if(jQuery('.search-btn').hasClass('fa-search')){
  28. jQuery('.search-open').fadeIn(500);
  29. jQuery('.search-btn').removeClass('fa-search');
  30. jQuery('.search-btn').addClass('fa-times');
  31. } else {
  32. jQuery('.search-open').fadeOut(500);
  33. jQuery('.search-btn').addClass('fa-search');
  34. jQuery('.search-btn').removeClass('fa-times');
  35. }
  36. });
  37. }
  38. //Search Box v1 (Header v5)
  39. function handleSearchV1() {
  40. jQuery('.header-v5 .search-button').click(function () {
  41. jQuery('.header-v5 .search-open').slideDown();
  42. });
  43. jQuery('.header-v5 .search-close').click(function () {
  44. jQuery('.header-v5 .search-open').slideUp();
  45. });
  46. jQuery(window).scroll(function(){
  47. if(jQuery(this).scrollTop() > 1) jQuery('.header-v5 .search-open').fadeOut('fast');
  48. });
  49. }
  50. // Search Box v2 (Header v8)
  51. function handleSearchV2() {
  52. $(".blog-topbar .search-btn").on("click", function() {
  53. if (jQuery(".topbar-search-block").hasClass("topbar-search-visible")) {
  54. jQuery(".topbar-search-block").slideUp();
  55. jQuery(".topbar-search-block").removeClass("topbar-search-visible");
  56. } else {
  57. jQuery(".topbar-search-block").slideDown();
  58. jQuery(".topbar-search-block").addClass("topbar-search-visible");
  59. }
  60. });
  61. $(".blog-topbar .search-close").on("click", function() {
  62. jQuery(".topbar-search-block").slideUp();
  63. jQuery(".topbar-search-block").removeClass("topbar-search-visible");
  64. });
  65. jQuery(window).scroll(function() {
  66. jQuery(".topbar-search-block").slideUp();
  67. jQuery(".topbar-search-block").removeClass("topbar-search-visible");
  68. });
  69. }
  70. // TopBar (Header v8)
  71. function handleTopBar() {
  72. $(".topbar-toggler").on("click", function() {
  73. if (jQuery(".topbar-toggler").hasClass("topbar-list-visible")) {
  74. jQuery(".topbar-menu").slideUp();
  75. jQuery(this).removeClass("topbar-list-visible");
  76. } else {
  77. jQuery(".topbar-menu").slideDown();
  78. jQuery(this).addClass("topbar-list-visible");
  79. }
  80. });
  81. }
  82. // TopBar SubMenu (Header v8)
  83. function handleTopBarSubMenu() {
  84. $(".topbar-list > li").on("click", function(e) {
  85. if (jQuery(this).children("ul").hasClass("topbar-dropdown")) {
  86. if (jQuery(this).children("ul").hasClass("topbar-dropdown-visible")) {
  87. jQuery(this).children(".topbar-dropdown").slideUp();
  88. jQuery(this).children(".topbar-dropdown").removeClass("topbar-dropdown-visible");
  89. } else {
  90. jQuery(this).children(".topbar-dropdown").slideDown();
  91. jQuery(this).children(".topbar-dropdown").addClass("topbar-dropdown-visible");
  92. }
  93. }
  94. //e.preventDefault();
  95. });
  96. }
  97. //Sidebar Navigation Toggle
  98. function handleToggle() {
  99. jQuery('.list-toggle').on('click', function() {
  100. jQuery(this).toggleClass('active');
  101. });
  102. }
  103. //Equal Height Columns
  104. function handleEqualHeightColumns() {
  105. var EqualHeightColumns = function () {
  106. $(".equal-height-columns").each(function() {
  107. heights = [];
  108. $(".equal-height-column", this).each(function() {
  109. $(this).removeAttr("style");
  110. heights.push($(this).height()); // write column's heights to the array
  111. });
  112. $(".equal-height-column", this).height(Math.max.apply(Math, heights)); //find and set max
  113. });
  114. }
  115. EqualHeightColumns();
  116. $(window).resize(function() {
  117. EqualHeightColumns();
  118. });
  119. $(window).load(function() {
  120. EqualHeightColumns("img.equal-height-column");
  121. });
  122. }
  123. // Full Screen
  124. var handleFullscreen = function() {
  125. var WindowHeight = $(window).height();
  126. if ($(document.body).hasClass("promo-padding-top")) {
  127. HeaderHeight = $(".header").height();
  128. } else {
  129. HeaderHeight = 0;
  130. }
  131. $(".fullheight").css("height", WindowHeight - HeaderHeight);
  132. $(window).resize(function() {
  133. var WindowHeight = $(window).height();
  134. $(".fullheight").css("height", WindowHeight - HeaderHeight);
  135. });
  136. }
  137. // Align Middle
  138. var handleValignMiddle = function() {
  139. $(".valign__middle").each(function() {
  140. $(this).css("padding-top", $(this).parent().height() / 2 - $(this).height() / 2);
  141. });
  142. $(window).resize(function() {
  143. $(".valign__middle").each(function() {
  144. $(this).css("padding-top", $(this).parent().height() / 2 - $(this).height() / 2);
  145. });
  146. });
  147. }
  148. //Hover Selector
  149. function handleHoverSelector() {
  150. // $('.hoverSelector').on('hover', function(e) {
  151. // $('.hoverSelectorBlock', this).toggleClass('show');
  152. // e.stopPropagation();
  153. // });
  154. $('.hoverSelector').on('click', function(e) {
  155. if (jQuery(this).children('ul').hasClass('languages')) {
  156. if (jQuery(this).children('ul').hasClass('languages-visible')) {
  157. jQuery(this).children('.languages').slideUp();
  158. jQuery(this).children('.languages').removeClass('languages-visible');
  159. } else {
  160. jQuery(this).children('.languages').slideDown();
  161. jQuery(this).children('.languages').addClass('languages-visible');
  162. }
  163. }
  164. //e.preventDefault();
  165. });
  166. }
  167. //Bootstrap Tooltips and Popovers
  168. function handleBootstrap() {
  169. /*Bootstrap Carousel*/
  170. jQuery('.carousel').carousel({
  171. interval: 15000,
  172. pause: 'hover'
  173. });
  174. /*Tooltips*/
  175. jQuery('.tooltips').tooltip();
  176. jQuery('.tooltips-show').tooltip('show');
  177. jQuery('.tooltips-hide').tooltip('hide');
  178. jQuery('.tooltips-toggle').tooltip('toggle');
  179. jQuery('.tooltips-destroy').tooltip('destroy');
  180. /*Popovers*/
  181. jQuery('.popovers').popover();
  182. jQuery('.popovers-show').popover('show');
  183. jQuery('.popovers-hide').popover('hide');
  184. jQuery('.popovers-toggle').popover('toggle');
  185. jQuery('.popovers-destroy').popover('destroy');
  186. }
  187. return {
  188. init: function () {
  189. handleBootstrap();
  190. handleSearch();
  191. handleSearchV1();
  192. handleSearchV2();
  193. handleTopBar();
  194. handleTopBarSubMenu();
  195. handleToggle();
  196. handleHeader();
  197. handleMegaMenu();
  198. handleHoverSelector();
  199. handleFullscreen();
  200. handleValignMiddle();
  201. handleEqualHeightColumns();
  202. },
  203. //Counters
  204. initCounter: function () {
  205. jQuery('.counter').counterUp({
  206. delay: 10,
  207. time: 1000
  208. });
  209. },
  210. //Parallax Backgrounds
  211. initParallaxBg: function () {
  212. jQuery(window).load(function() {
  213. jQuery('.parallaxBg').parallax("50%", 0.2);
  214. jQuery('.parallaxBg1').parallax("50%", 0.4);
  215. });
  216. },
  217. //Scroll Bar
  218. initScrollBar: function () {
  219. jQuery('.mCustomScrollbar').mCustomScrollbar({
  220. theme:"minimal",
  221. scrollInertia: 200,
  222. scrollEasing: "linear"
  223. });
  224. },
  225. // Sidebar Menu Dropdown
  226. initSidebarMenuDropdown: function() {
  227. function SidebarMenuDropdown() {
  228. jQuery('.header-v7 .dropdown-toggle').on('click', function() {
  229. jQuery('.header-v7 .dropdown-menu').stop(true, false).slideUp();
  230. jQuery('.header-v7 .dropdown').removeClass('open');
  231. if (jQuery(this).siblings('.dropdown-menu').is(":hidden") == true) {
  232. jQuery(this).siblings('.dropdown-menu').stop(true, false).slideDown();
  233. jQuery(this).parents('.dropdown').addClass('open');
  234. }
  235. });
  236. }
  237. SidebarMenuDropdown();
  238. },
  239. //Animate Dropdown
  240. initAnimateDropdown: function() {
  241. function MenuMode() {
  242. jQuery('.dropdown').on('show.bs.dropdown', function() {
  243. jQuery(this).find('.dropdown-menu').first().stop(true, true).slideDown();
  244. });
  245. jQuery('.dropdown').on('hide.bs.dropdown', function() {
  246. jQuery(this).find('.dropdown-menu').first().stop(true, true).slideUp();
  247. });
  248. }
  249. jQuery(window).resize(function() {
  250. if (jQuery(window).width() > 768) {
  251. MenuMode();
  252. }
  253. });
  254. if (jQuery(window).width() > 768) {
  255. MenuMode();
  256. }
  257. },
  258. };
  259. }();