* @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.
*/
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>';
}
* @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);