Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / themes / contrib / bootstrap / js / theme.js
index 7e3de0a9c7c06ddf0a5b818b33a5521c87e1d7d4..2f52c70ea3a31d416b4509e696b6b9f61e6b73ce 100644 (file)
@@ -2,7 +2,7 @@
  * @file
  * Theme hooks for the Drupal Bootstrap base theme.
  */
-(function ($, Drupal, Bootstrap) {
+(function ($, Drupal, Bootstrap, Attributes) {
 
   /**
    * Fallback for theming an icon if the Icon API module is not installed.
@@ -24,7 +24,7 @@
        */
       icon: function (bundle, icon, attributes) {
         if (!Drupal.icon.bundles[bundle]) return '';
-        attributes = Attributes(attributes).addClass('icon').set('aria-hidden', 'true');
+        attributes = Attributes.create(attributes).addClass('icon').set('aria-hidden', 'true');
         icon = Drupal.icon.bundles[bundle](icon, attributes);
         return '<span' + attributes + '></span>';
       }
@@ -54,7 +54,7 @@
      * @returns {string}
      */
     ajaxThrobber: function () {
-      return Drupal.theme.bootstrapIcon('refresh', {'class': ['ajax-throbber', 'glyphicon-spin'] });
+      return Drupal.theme('bootstrapIcon', 'refresh', {'class': ['ajax-throbber', 'glyphicon-spin'] });
     },
 
     /**
      * @returns {string}
      */
     button: function (attributes) {
-      attributes = Attributes(attributes).addClass('btn');
+      attributes = Attributes.create(attributes).addClass('btn');
       var context = attributes.get('context', 'default');
       var label = attributes.get('value', '');
       attributes.remove('context').remove('value');
       if (!attributes.hasClass(['btn-default', 'btn-primary', 'btn-success', 'btn-info', 'btn-warning', 'btn-danger', 'btn-link'])) {
         attributes.addClass('btn-' + Bootstrap.checkPlain(context));
       }
+
+      // Attempt to, intelligently, provide a default button "type".
+      if (!attributes.exists('type')) {
+        attributes.set('type', attributes.hasClass('form-submit') ? 'submit' : 'button');
+      }
+
       return '<button' + attributes + '>' + label + '</button>';
     },
 
      * @returns {string}
      */
     'btn-block': function (attributes) {
-      return Drupal.theme('button', Attributes(attributes).addClass('btn-block'));
+      return Drupal.theme('button', Attributes.create(attributes).addClass('btn-block'));
     },
 
     /**
      * @returns {string}
      */
     'btn-lg': function (attributes) {
-      return Drupal.theme('button', Attributes(attributes).addClass('btn-lg'));
+      return Drupal.theme('button', Attributes.create(attributes).addClass('btn-lg'));
     },
 
     /**
      * @returns {string}
      */
     'btn-sm': function (attributes) {
-      return Drupal.theme('button', Attributes(attributes).addClass('btn-sm'));
+      return Drupal.theme('button', Attributes.create(attributes).addClass('btn-sm'));
     },
 
     /**
      * @returns {string}
      */
     'btn-xs': function (attributes) {
-      return Drupal.theme('button', Attributes(attributes).addClass('btn-xs'));
+      return Drupal.theme('button', Attributes.create(attributes).addClass('btn-xs'));
     },
 
     /**
 
   });
 
-})(window.jQuery, window.Drupal, window.Drupal.bootstrap);
+})(window.jQuery, window.Drupal, window.Drupal.bootstrap, window.Attributes);