Version 1
[yaffs-website] / web / modules / contrib / superfish / js / superfish.js
diff --git a/web/modules/contrib/superfish/js/superfish.js b/web/modules/contrib/superfish/js/superfish.js
new file mode 100644 (file)
index 0000000..a99ec5d
--- /dev/null
@@ -0,0 +1,49 @@
+/**
+ * @file
+ * The Superfish Drupal Behavior to apply the Superfish jQuery plugin to lists.
+ */
+
+(function ($, Drupal, drupalSettings) {
+
+  'use strict';
+
+  /**
+   * jQuery Superfish plugin.
+   *
+   * @type {Drupal~behavior}
+   *
+   * @prop {Drupal~behaviorAttach} attach
+   *   Attaches the behavior to an applicable <ul> element.
+   */
+  Drupal.behaviors.superfish = {
+    attach: function (context, drupalSettings) {
+      // Take a look at each menu to apply Superfish to.
+      $.each(drupalSettings.superfish || {}, function (index, options) {
+        var $menu = $('ul#' + options.id, context);
+
+        // Check if we are to apply the Supersubs plug-in to it.
+        if (options.plugins || false) {
+          if (options.plugins.supersubs || false) {
+            $menu.supersubs(options.plugins.supersubs);
+          }
+        }
+
+        // Apply Superfish to the menu.
+        $menu.superfish(options.sf);
+
+        // Check if we are to apply any other plug-in to it.
+        if (options.plugins || false) {
+          if (options.plugins.touchscreen || false) {
+            $menu.sftouchscreen(options.plugins.touchscreen);
+          }
+          if (options.plugins.smallscreen || false) {
+            $menu.sfsmallscreen(options.plugins.smallscreen);
+          }
+          if (options.plugins.supposition || false) {
+            $menu.supposition();
+          }
+        }
+      });
+    }
+  };
+})(jQuery, Drupal, drupalSettings);