Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / video_embed_field / js / video-embed-field.lazyLoad.js
diff --git a/web/modules/contrib/video_embed_field/js/video-embed-field.lazyLoad.js b/web/modules/contrib/video_embed_field/js/video-embed-field.lazyLoad.js
new file mode 100644 (file)
index 0000000..b222920
--- /dev/null
@@ -0,0 +1,17 @@
+/**
+ * @file
+ * The video_embed_field lazy loading videos.
+ */
+
+(function($) {
+  Drupal.behaviors.video_embed_field_lazyLoad = {
+    attach: function (context, settings) {
+      $('.video-embed-field-lazy', context).once().click(function(e) {
+        // Swap the lightweight image for the heavy JavaScript.
+        e.preventDefault();
+        var $el = $(this);
+        $el.html($el.data('video-embed-field-lazy'));
+      });
+    }
+  };
+})(jQuery);