|
| 1 | + |
| 2 | +function copyClip(copyText){ |
| 3 | + var aux = document.createElement("input"); |
| 4 | + aux.setAttribute("value", copyText); |
| 5 | + document.body.appendChild(aux); |
| 6 | + aux.select(); |
| 7 | + document.execCommand("copy"); |
| 8 | + document.body.removeChild(aux); |
| 9 | +} |
| 10 | + |
| 11 | +(function ($) { |
| 12 | + |
| 13 | + "use strict"; |
| 14 | + |
| 15 | + |
| 16 | + $('html').addClass('oflow-hidden'); |
| 17 | + |
| 18 | + $(window).bind("load", function() { |
| 19 | + |
| 20 | + $('.navigation').stickySidebar({ |
| 21 | + containerSelector: 'section', |
| 22 | + topSpacing: 150, |
| 23 | + bottomSpacing: 0 |
| 24 | + }); |
| 25 | + |
| 26 | + |
| 27 | + $("#preloader").fadeOut(); |
| 28 | + $('html').removeClass('oflow-hidden'); |
| 29 | + }); |
| 30 | + |
| 31 | + |
| 32 | + $('.img-wrapper').each(function(){ |
| 33 | + |
| 34 | + var $this = $(this), |
| 35 | + text = $this.data('title'); |
| 36 | + |
| 37 | + if((text != null)){ |
| 38 | + $this.append('<h6 class="img-title">' + text + '</h6>'); |
| 39 | + } |
| 40 | + |
| 41 | + }); |
| 42 | + |
| 43 | + |
| 44 | + $('.click-copy').on('click', function(){ |
| 45 | + var $this = $(this), |
| 46 | + copyText = $this.text(); |
| 47 | + |
| 48 | + copyClip(copyText) |
| 49 | + $this.addClass('active').addClass('copied'); |
| 50 | + |
| 51 | + setTimeout(function(){ $this.removeClass('active'); },100); |
| 52 | + setTimeout(function(){ $this.removeClass('copied'); },800); |
| 53 | + }); |
| 54 | + |
| 55 | + |
| 56 | + $('.nav-title').on('click', function(){ |
| 57 | + $('.navigation-menu').toggleClass('active'); |
| 58 | + $('.navigation .nav-title').addClass('active'); |
| 59 | + }); |
| 60 | + |
| 61 | + |
| 62 | + // // PAGE LOADER |
| 63 | + $(window).on('load', function () { |
| 64 | + |
| 65 | + if (isExists(".loader-wrapper")) { |
| 66 | + $(".loader-wrapper").fadeOut("slow"); |
| 67 | + } |
| 68 | + |
| 69 | + }); |
| 70 | + |
| 71 | + |
| 72 | + // Dropdown functionality |
| 73 | + var winWidth = $(window).width(); |
| 74 | + var isTouchDevice = (winWidth < 767) ? true : false; |
| 75 | + menuDropdown(isTouchDevice); |
| 76 | + |
| 77 | + // Window resize event for dropdown menu |
| 78 | + $(window).on('resize', function () { |
| 79 | + |
| 80 | + winWidth = $(window).width(); |
| 81 | + isTouchDevice = (winWidth < 767) ? true : false; |
| 82 | + |
| 83 | + debounceFnForDropDown(isTouchDevice); |
| 84 | + }); |
| 85 | + |
| 86 | + |
| 87 | + // SMOOTH SCROLL ON THE SAME PAGE AFTER CLICKING A LINK |
| 88 | + smoothScroll(); |
| 89 | + |
| 90 | + |
| 91 | + // FIXED MENU ON SCROLL |
| 92 | + var $fixedMenu |
| 93 | + |
| 94 | + if (isExists('.fixed-on-scroll')) { |
| 95 | + $fixedMenu = $('.fixed-on-scroll'); |
| 96 | + fixedMenuOnScrollFn($fixedMenu); |
| 97 | + } |
| 98 | + |
| 99 | + |
| 100 | + // Enable counter on visible |
| 101 | + var a = 0; |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + // SCROLL EVENT |
| 108 | + $(window).on('scroll', function () { |
| 109 | + |
| 110 | + var winTop = $(window).scrollTop(), |
| 111 | + winMid = $(window).scrollTop() + 200; |
| 112 | + |
| 113 | + /*VISIBLE SELECTION*/ |
| 114 | + $('a[href^="#"]').removeClass('active'); |
| 115 | + $('article').each(function(){ |
| 116 | + var $this = $(this), |
| 117 | + elemBottom = $this.offset().top + $this.outerHeight(); |
| 118 | + if(($this.offset().top < winMid) && (elemBottom > winMid)){ |
| 119 | + var elem = 'a[href="#' + $this.attr('id') + '"]'; |
| 120 | + $(elem).addClass('active'); |
| 121 | + } |
| 122 | + }); |
| 123 | + |
| 124 | + /*FIXED MENU*/ |
| 125 | + if((winTop >= 60)) $('.navigation-fixed').addClass('fixed'); |
| 126 | + else $('.navigation-fixed').removeClass('fixed'); |
| 127 | + |
| 128 | + |
| 129 | + // FIXED MENU ON SCROLL |
| 130 | + if (typeof $fixedMenu != 'undefined') { |
| 131 | + fixedMenuOnScrollFn($fixedMenu); |
| 132 | + } |
| 133 | + |
| 134 | + // BACK TO TOP VISIBLE AFTER THE CENTER OF THE PAGE |
| 135 | + backToTop(); |
| 136 | + |
| 137 | + |
| 138 | + }); |
| 139 | + |
| 140 | + |
| 141 | + // Prevent fire an event if anchor is null |
| 142 | + $('a[href="#"]').on('click', function () { |
| 143 | + return false; |
| 144 | + }); |
| 145 | + |
| 146 | + // ENABLE MENU ICON FOR SMALLER DEVICE |
| 147 | + $('[data-menu-visible]').on('click', function (event) { |
| 148 | + |
| 149 | + var $this = $(this), |
| 150 | + visibleHeadArea = $this.data('menu-visible'); |
| 151 | + |
| 152 | + $('.nav-visible').not(visibleHeadArea).removeClass('visible'); |
| 153 | + |
| 154 | + $(visibleHeadArea).toggleClass('visible'); |
| 155 | + |
| 156 | + event.stopPropagation(); |
| 157 | + }); |
| 158 | + |
| 159 | + // BACK TO TOP VISIBLE AFTER THE CENTER OF THE PAGE |
| 160 | + backToTop(); |
| 161 | + |
| 162 | + $('#back-to-top').on('click', function (e) { |
| 163 | + e.preventDefault(); |
| 164 | + $('html,body').animate({ |
| 165 | + scrollTop: 0 |
| 166 | + }, 700); |
| 167 | + }); |
| 168 | + |
| 169 | +}) |
| 170 | +(jQuery); |
| 171 | + |
| 172 | + |
| 173 | +// FIXED MENU ON SCROLL |
| 174 | +function fixedMenuOnScrollFn($fixedElem) { |
| 175 | + |
| 176 | + var topWindow = $(window).scrollTop(); |
| 177 | + var fixedPosition = 500; |
| 178 | + |
| 179 | + if ((fixedPosition) < topWindow) { |
| 180 | + $fixedElem.addClass('fixed'); |
| 181 | + } else if ((fixedPosition) > topWindow) { |
| 182 | + $fixedElem.removeClass('fixed'); |
| 183 | + } |
| 184 | +} |
| 185 | + |
| 186 | +// DROPDOWN MENU FUNCTION |
| 187 | +function menuDropdown(isTouchDevice) { |
| 188 | + |
| 189 | + $('.main-menu li').removeClass('d-hover-effect'); |
| 190 | + |
| 191 | + if (isTouchDevice) { |
| 192 | + |
| 193 | + $('.main-menu a').unbind('click').on('click', function (e) { |
| 194 | + |
| 195 | + var listElem = $(this).parent(); |
| 196 | + |
| 197 | + $(listElem).toggleClass('d-hover-effect'); |
| 198 | + |
| 199 | + }); |
| 200 | + |
| 201 | + } else { |
| 202 | + |
| 203 | + var anchorElem = $('.main-menu li'); |
| 204 | + |
| 205 | + $(anchorElem).unbind('mouseenter').on('mouseenter', function (e) { |
| 206 | + $(this).addClass('d-hover-effect'); |
| 207 | + |
| 208 | + }).unbind('mouseleave').on('mouseleave', function (e) { |
| 209 | + $(this).removeClass('d-hover-effect'); |
| 210 | + |
| 211 | + }); |
| 212 | + } |
| 213 | + |
| 214 | +} |
| 215 | + |
| 216 | + |
| 217 | +// Debounce Function for Dropdown menu |
| 218 | +var debounceFnForDropDown = debounce(function (isTouchDevice) { |
| 219 | + menuDropdown(isTouchDevice); |
| 220 | +}, 50); |
| 221 | + |
| 222 | + |
| 223 | +function smoothScroll() { |
| 224 | + // Select all links with hashes |
| 225 | + $('a[href*="#"]') |
| 226 | + // Remove links that don't actually link to anything |
| 227 | + .not('[href="#"]') |
| 228 | + .not('[href="#bs-carousel"]') |
| 229 | + .not('[href="#0"]') |
| 230 | + .click(function (event) { |
| 231 | + // On-page links |
| 232 | + if ( |
| 233 | + location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') |
| 234 | + && |
| 235 | + location.hostname == this.hostname |
| 236 | + ) { |
| 237 | + // Figure out element to scroll to |
| 238 | + var target = $(this.hash); |
| 239 | + target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); |
| 240 | + // Does a scroll target exist? |
| 241 | + if (target.length) { |
| 242 | + // Only prevent default if animation is actually gonna happen |
| 243 | + event.preventDefault(); |
| 244 | + $('html, body').animate({ |
| 245 | + scrollTop: target.offset().top - 80 |
| 246 | + }, 500, function () { |
| 247 | + // Callback after animation |
| 248 | + // Must change focus! |
| 249 | + var $target = $(target); |
| 250 | + $target.focus(); |
| 251 | + |
| 252 | + }); |
| 253 | + } |
| 254 | + } |
| 255 | + }); |
| 256 | +} |
| 257 | + |
| 258 | + |
| 259 | +function backToTop() { |
| 260 | + var scrollTrigger = $(document).outerHeight() / 2; |
| 261 | + var scrollTop = $(window).scrollTop(); |
| 262 | + if (scrollTop > scrollTrigger) { |
| 263 | + $('#back-to-top').addClass('show'); |
| 264 | + } else { |
| 265 | + $('#back-to-top').removeClass('show'); |
| 266 | + } |
| 267 | +}; |
| 268 | + |
| 269 | +// Debounce Function for Dropdown menu |
| 270 | +var debounceFnForDropDown = debounce(function (isTouchDevice) { |
| 271 | + menuDropdown(isTouchDevice); |
| 272 | +}, 50); |
| 273 | + |
| 274 | +// Debounce Function |
| 275 | +function debounce(func, wait, immediate) { |
| 276 | + var timeout; |
| 277 | + return function () { |
| 278 | + var context = this, args = arguments; |
| 279 | + var later = function () { |
| 280 | + timeout = null; |
| 281 | + if (!immediate) func.apply(context, args); |
| 282 | + }; |
| 283 | + var callNow = immediate && !timeout; |
| 284 | + clearTimeout(timeout); |
| 285 | + timeout = setTimeout(later, wait); |
| 286 | + if (callNow) func.apply(context, args); |
| 287 | + }; |
| 288 | +} |
| 289 | + |
| 290 | + |
| 291 | +function isExists(elem) { |
| 292 | + if ($(elem).length > 0) { |
| 293 | + return true; |
| 294 | + } |
| 295 | + return false; |
| 296 | +} |
| 297 | + |
| 298 | + |
0 commit comments