X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fthemes%2Fcontrib%2Fbootstrap%2Fjs%2Ftheme.js;fp=web%2Fthemes%2Fcontrib%2Fbootstrap%2Fjs%2Ftheme.js;h=2f52c70ea3a31d416b4509e696b6b9f61e6b73ce;hp=7e3de0a9c7c06ddf0a5b818b33a5521c87e1d7d4;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/themes/contrib/bootstrap/js/theme.js b/web/themes/contrib/bootstrap/js/theme.js index 7e3de0a9c..2f52c70ea 100644 --- a/web/themes/contrib/bootstrap/js/theme.js +++ b/web/themes/contrib/bootstrap/js/theme.js @@ -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 ''; } @@ -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'] }); }, /** @@ -75,13 +75,19 @@ * @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 '' + label + ''; }, @@ -110,7 +116,7 @@ * @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')); }, /** @@ -124,7 +130,7 @@ * @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')); }, /** @@ -138,7 +144,7 @@ * @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')); }, /** @@ -152,7 +158,7 @@ * @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')); }, /** @@ -171,4 +177,4 @@ }); -})(window.jQuery, window.Drupal, window.Drupal.bootstrap); +})(window.jQuery, window.Drupal, window.Drupal.bootstrap, window.Attributes);