Browse Source

Scripts will be reloaded (ajax) if not working yet

Moritz Schmidt 8 năm trước cách đây
mục cha
commit
f38236144f
4 tập tin đã thay đổi với 68 bổ sung23 xóa
  1. 50 13
      dist/scripts.js
  2. 7 0
      dist/stickyfill/stickyfill.min.js
  3. 0 0
      dist/tether/tether.min.js
  4. 11 10
      functions.php

+ 50 - 13
dist/scripts.js

@@ -1,7 +1,29 @@
 jQuery( document ).ready(function($) {
+  function loadScript(url, callback) {
+    // Adding the script tag to the head as suggested before
+    var head = document.getElementsByTagName('head')[0];
+    var script = document.createElement('script');
+    script.type = 'text/javascript';
+    script.src = url;
+
+    // Then bind the event to the callback function.
+    // There are several events for cross browser compatibility.
+    script.onreadystatechange = callback;
+    script.onload = callback;
+
+    // Fire the loading
+    head.appendChild(script);
+  }
+
   $("link[media=\"1\"]").attr("media", "all"); // load css async
 
-  $('#nav').Stickyfill(); // NAV
+  if(typeof $().Stickyfill == "undefined") {
+    loadScript("/wp-content/themes/ams_2016/dist/stickyfill/stickyfill.min.js", function() {
+      $('#nav').Stickyfill(); // NAV
+    });
+  } else {
+    $('#nav').Stickyfill(); // NAV
+  }
 
   $(document).on("click", "nav.navbar #ams-topnav[aria-expanded=\"true\"] a", function() {
     $('.navbar-toggler').click();
@@ -17,16 +39,31 @@ jQuery( document ).ready(function($) {
 
   /** TdA Carousel **/
 
-  $('.owl-carousel').slick({
-      dots: false,
-      infinite: true,
-      variableWidth: true,
-      autoplay: true,
-      lazyLoad: 'progressive',
-      swipeToSlide: true,
-      waitForAnimate: false,
-      nextArrow: '<span class="icon-next" aria-hidden="true"><i class="fa fa-chevron-right" aria-hidden="true"></i></span>',
-      prevArrow: '<span class="icon-prev" aria-hidden="true"><i class="fa fa-chevron-left" aria-hidden="true"></i></span>',
-  });
-
+  if(typeof $().slick == "undefined") {
+    loadScript("/wp-content/themes/ams_2016/dist/slick/slick.min.js", function() {
+      $('.owl-carousel').slick({
+          dots: false,
+          infinite: true,
+          variableWidth: true,
+          autoplay: true,
+          lazyLoad: 'progressive',
+          swipeToSlide: true,
+          waitForAnimate: false,
+          nextArrow: '<span class="icon-next" aria-hidden="true"><i class="fa fa-chevron-right" aria-hidden="true"></i></span>',
+          prevArrow: '<span class="icon-prev" aria-hidden="true"><i class="fa fa-chevron-left" aria-hidden="true"></i></span>',
+      });
+    });
+  } else {
+    $('.owl-carousel').slick({
+        dots: false,
+        infinite: true,
+        variableWidth: true,
+        autoplay: true,
+        lazyLoad: 'progressive',
+        swipeToSlide: true,
+        waitForAnimate: false,
+        nextArrow: '<span class="icon-next" aria-hidden="true"><i class="fa fa-chevron-right" aria-hidden="true"></i></span>',
+        prevArrow: '<span class="icon-prev" aria-hidden="true"><i class="fa fa-chevron-left" aria-hidden="true"></i></span>',
+    });
+  }
 });

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 7 - 0
dist/stickyfill/stickyfill.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
dist/tether/tether.min.js


+ 11 - 10
functions.php

@@ -22,9 +22,10 @@ function ams_enqueue_scripts() {
   wp_deregister_script( 'jquery' );
   wp_register_script( 'jquery', includes_url( '/js/jquery/jquery.js' ), false, NULL, true ); // push jquery to the bottom
   wp_enqueue_script( 'jquery' );
+  wp_enqueue_script('tether', get_template_directory_uri() . '/dist/tether/tether.min.js', array("jquery"), '1.4.0', true);
   wp_enqueue_script('bootstrap', get_template_directory_uri() . '/dist/bootstrap/bootstrap.js', array("jquery"), '4.0.0-3', true);
-  wp_enqueue_script('stickyfill', get_template_directory_uri() . '/dist/stickyfill/stickyfill.js', array("jquery"), '1.1.4', true);
-  wp_enqueue_script('slick', get_template_directory_uri() . '/dist/slick/slick.js', array("jquery"), '1.6.0', true);
+  wp_enqueue_script('stickyfill', get_template_directory_uri() . '/dist/stickyfill/stickyfill.min.js', array("jquery"), '1.1.4', true);
+  wp_enqueue_script('slick', get_template_directory_uri() . '/dist/slick/slick.min.js', array("jquery"), '1.6.0', true);
   wp_enqueue_script('scripts', get_template_directory_uri() . '/dist/scripts.js', array("jquery"), '1.0.0', true);
 }
 
@@ -224,7 +225,7 @@ $tdaSlider = array(
     "tag-der-architektur-2015-43.jpg"
   ),
     "TdA2014" => array(
-    "url" => "https://ams.mmnx.de/wp-content/uploads/2016/11/",
+    "url" => "http://www.architekturmachtschule.de/wp-content/uploads/2016/11/",
     "tag-der-architektur-2014-14.jpg",
     "tag-der-architektur-2014-27.jpg",
     "tag-der-architektur-2014-41.jpg",
@@ -280,7 +281,7 @@ $tdaSlider = array(
     "tag-der-architektur-2014-53.jpg"
     ),
   "TdA2013" => array(
-    "url" => "https://ams.mmnx.de/wp-content/uploads/2016/11/",
+    "url" => "http://www.architekturmachtschule.de/wp-content/uploads/2016/11/",
     "tag-der-architektur-2013-01.jpg",
     "tag-der-architektur-2013-02.jpg",
     "tag-der-architektur-2013-03.jpg",
@@ -357,7 +358,7 @@ $tdaSlider = array(
     "tag-der-architektur-2013-74.jpg"
     ),
   "TdA2012" => array(
-    "url" => "https://ams.mmnx.de/wp-content/uploads/2016/11/",
+    "url" => "http://www.architekturmachtschule.de/wp-content/uploads/2016/11/",
     "tag-der-architektur-2012-01.jpg",
     "tag-der-architektur-2012-02.jpg",
     "tag-der-architektur-2012-03.jpg",
@@ -416,7 +417,7 @@ $tdaSlider = array(
     "tag-der-architektur-2012-56.jpg"
     ),
   "TdA2011" => array(
-    "url" => "https://ams.mmnx.de/wp-content/uploads/2016/11/",
+    "url" => "http://www.architekturmachtschule.de/wp-content/uploads/2016/11/",
     "tag-der-architektur-2011-01.jpg",
     "tag-der-architektur-2011-02.jpg",
     "tag-der-architektur-2011-03.jpg",
@@ -463,7 +464,7 @@ $tdaSlider = array(
     "tag-der-architektur-2011-44.jpg"
     ),
   "TdA2010" => array(
-    "url" => "https://ams.mmnx.de/wp-content/uploads/2016/11/",
+    "url" => "http://www.architekturmachtschule.de/wp-content/uploads/2016/11/",
     "tag-der-architektur-2010-02.jpg",
     "tag-der-architektur-2010-03.jpg",
     "tag-der-architektur-2010-04.jpg",
@@ -544,7 +545,7 @@ $tdaSlider = array(
     "tag-der-architektur-2010-79.jpg"
     ),
   "PH2008" => array(
-    "url" => "https://ams.mmnx.de/wp-content/uploads/2016/11/",
+    "url" => "http://www.architekturmachtschule.de/wp-content/uploads/2016/11/",
     "koop-ph-heidelberg-2008-01.jpg",
     "koop-ph-heidelberg-2008-02.jpg",
     "koop-ph-heidelberg-2008-03.jpg",
@@ -564,7 +565,7 @@ $tdaSlider = array(
     "koop-ph-heidelberg-2008-17.jpg"
     ),
   "LF2010" => array(
-    "url" => "https://ams.mmnx.de/wp-content/uploads/2016/11/",
+    "url" => "http://www.architekturmachtschule.de/wp-content/uploads/2016/11/",
     "lehrerfortbildung-2010-01.jpg",
     "lehrerfortbildung-2010-02.jpg",
     "lehrerfortbildung-2010-03.jpg",
@@ -584,7 +585,7 @@ $tdaSlider = array(
     "lehrerfortbildung-2010-19.jpg"
     ),
   "LF2011" => array(
-    "url" => "https://ams.mmnx.de/wp-content/uploads/2016/11/",
+    "url" => "http://www.architekturmachtschule.de/wp-content/uploads/2016/11/",
     "lehrerfortbildung-2011-01.jpg",
     "lehrerfortbildung-2011-02.jpg",
     "lehrerfortbildung-2011-03.jpg",

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác