Created
October 5, 2017 09:48
-
-
Save Brachamul/3e53d65b9a21f8a9210e718ef648e777 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// bootstrapify the default django-allauth forms | |
$('form p').replaceWith(function() { return '<div>' + this.innerHTML + '</div>'; }); | |
$('form input').each(function(index){ | |
$input = $(this) | |
var t = $input.attr('type') | |
if (t == 'text' || t == 'email' || t == 'password' || typeof t == 'undefined' ) { | |
$input.addClass('form-control') | |
$input.closest('div').addClass('form-group') | |
} | |
if (t == 'radio' || t == 'checkbox' ) { | |
var $label = $input.siblings('label') | |
$label.text(' ' + $label.text().slice(0, -1)) | |
$input.addClass('form-check-input') | |
$label.addClass('form-check-label') | |
$input.closest('div').addClass('form-check') | |
$input.prependTo($label) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment