1
0

scripts.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. jQuery( document ).ready(function($) {
  2. function loadScript(url, callback) {
  3. // Adding the script tag to the head as suggested before
  4. var head = document.getElementsByTagName('head')[0];
  5. var script = document.createElement('script');
  6. script.type = 'text/javascript';
  7. script.src = url;
  8. // Then bind the event to the callback function.
  9. // There are several events for cross browser compatibility.
  10. script.onreadystatechange = callback;
  11. script.onload = callback;
  12. // Fire the loading
  13. head.appendChild(script);
  14. }
  15. $("link[media=\"1\"]").attr("media", "all"); // load css async
  16. if(typeof $().Stickyfill == "undefined") {
  17. loadScript("/wp-content/themes/ams_2016/dist/stickyfill/stickyfill.min.js", function() {
  18. $('#nav').Stickyfill(); // NAV
  19. });
  20. } else {
  21. $('#nav').Stickyfill(); // NAV
  22. }
  23. $(document).on("click", "nav.navbar #ams-topnav[aria-expanded=\"true\"] a", function() {
  24. $('.navbar-toggler').click();
  25. });
  26. $(document).on('click', 'a.scroll-link[href^="#"]', function(e){
  27. e.preventDefault();
  28. $('html, body').animate({
  29. scrollTop: $( $.attr(this, 'href') ).offset().top
  30. }, 500);
  31. });
  32. /** TdA Carousel **/
  33. if(typeof $().slick == "undefined") {
  34. loadScript("/wp-content/themes/ams_2016/dist/slick/slick.min.js", function() {
  35. $('.owl-carousel').slick({
  36. dots: false,
  37. infinite: true,
  38. variableWidth: true,
  39. autoplay: true,
  40. lazyLoad: 'progressive',
  41. swipeToSlide: true,
  42. waitForAnimate: false,
  43. nextArrow: '<span class="icon-next" aria-hidden="true"><i class="fa fa-chevron-right" aria-hidden="true"></i></span>',
  44. prevArrow: '<span class="icon-prev" aria-hidden="true"><i class="fa fa-chevron-left" aria-hidden="true"></i></span>',
  45. });
  46. });
  47. } else {
  48. $('.owl-carousel').slick({
  49. dots: false,
  50. infinite: true,
  51. variableWidth: true,
  52. autoplay: true,
  53. lazyLoad: 'progressive',
  54. swipeToSlide: true,
  55. waitForAnimate: false,
  56. nextArrow: '<span class="icon-next" aria-hidden="true"><i class="fa fa-chevron-right" aria-hidden="true"></i></span>',
  57. prevArrow: '<span class="icon-prev" aria-hidden="true"><i class="fa fa-chevron-left" aria-hidden="true"></i></span>',
  58. });
  59. }
  60. });