Commit 12c6b8e4 authored by Kevin Paxman's avatar Kevin Paxman Committed by Kevin Paxman
Browse files

ISTWCMS-3682: move button-adding into JS (since it requires JS to work) and make minor improvements

parent d853a39f
!function(l,i){i.behaviors.uwFdsuThemeRespUserLogin={attach:function(i,n){l("#user-login-form").css("display","none"),l("#local-login-link").click(function(){l("#user-login-form").css("display","block"),l("#local-login-link").css("display","none"),l("#adfs-login-link").css("display","none"),l("#edit-submit").val("Log In Locally")}),l("#adfs-login-link").click(function(){l("#edit-simplesamlphp-auth-login-link")[0].click()})}}}(jQuery,Drupal);
!function(l,i){i.behaviors.uwFdsuThemeRespUserLogin={attach:function(i,n){l("#edit-simplesamlphp-auth-login-link").length&&(l("#user-login-form").css("display","none"),l("#user-login-form").after('<button id="adfs-login-link" class="button--primary">Log in via ADFS</button> &nbsp; <button id="local-login-link" class="button--medium">Log in locally</button>'),l("#edit-submit").val("Log in locally"),l("#local-login-link").click(function(){l("#user-login-form").css("display","block"),l("#local-login-link").css("display","none"),l("#adfs-login-link").css("display","none"),l("#edit-name").focus()}),l("#adfs-login-link").click(function(){l("#edit-simplesamlphp-auth-login-link")[0].click()}))}}}(jQuery,Drupal);
(function ($, Drupal) {
Drupal.behaviors.uwFdsuThemeRespUserLogin = {
attach: function (context, settings) {
$('#user-login-form').css('display', 'none');
$('#local-login-link').click(function () {
$('#user-login-form').css('display', 'block');
$('#local-login-link').css('display', 'none');
$('#adfs-login-link').css('display', 'none');
$('#edit-submit').val('Log In Locally');
});
$('#adfs-login-link').click(function () {
$('#edit-simplesamlphp-auth-login-link')[0].click();
});
// Don't do anything if SimpleSAML isn't enabled.
if ($('#edit-simplesamlphp-auth-login-link').length)
{
// Hide the normal login form.
$('#user-login-form').css('display', 'none');
// Add buttons (using JS because they don't work without JS)
$('#user-login-form').after('<button id="adfs-login-link" class="button--primary">Log in via ADFS</button> &nbsp; <button id="local-login-link" class="button--medium">Log in locally</button>');
// Update the existing login form's link text.
$('#edit-submit').val('Log in locally');
// If the local login link is clicked, show the normal login form and hide the buttons.
// Be nice to the user, and put focus on the name field so they can just start typing.
$('#local-login-link').click(function () {
$('#user-login-form').css('display', 'block');
$('#local-login-link').css('display', 'none');
$('#adfs-login-link').css('display', 'none');
$('#edit-name').focus();
});
// If the ADFS login link is clicked, click on the original log in with ADFS link.
$('#adfs-login-link').click(function () {
$('#edit-simplesamlphp-auth-login-link')[0].click();
});
}
}
};
})(jQuery, Drupal);
{#
/**
* @file
* Theme override for a 'form' element.
*
* Available variables
* - attributes: A list of HTML attributes for the wrapper element.
* - children: The child elements of the form.
*
* @see template_preprocess_form()
*/
#}
<form{{ attributes }}>
{{ children }}
</form>
<button id="adfs-login-link" class="button--primary">Log In Via ADFS</button>
<button id="local-login-link">Log In Locally</button>
......@@ -24,32 +24,6 @@ require_once dirname(__FILE__) . '/includes/navigation.inc';
require_once dirname(__FILE__) . '/includes/taxonomy.inc';
require_once dirname(__FILE__) . '/includes/views.inc';
/**
* Implements hook_theme_suggestions_form_alter().
*
* Add suggestion for forms.
*/
function uw_fdsu_theme_resp_theme_suggestions_form_alter(array &$suggestions, array $variables) {
// form--user-login-form.html.twig.
$suggestions[] = 'form__' . str_replace('-', '_', $variables['element']['#id']);
}
/**
* Implements hook_theme().
*
* Custom twig for forms.
*/
function uw_fdsu_theme_resp_theme($existing, $type, $theme, $path) {
return [
'form__user-login-form' => [
'#theme' => 'form--user-login-form',
'render element' => 'form',
],
];
}
/**
* Implements hook_preprocess_HOOK().
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment