Commit ae686605 authored by Geoffroy ARNOUD's avatar Geoffroy ARNOUD
Browse files

Added Select2 on embedded WAYF #K11

parent e3a51554
<?php // Copyright (c) 2019, SWITCH ?>
<?php // Copyright (c) 2019, SWITCH?>
<!-- Identity Provider Selection: Start -->
<h1><?php echo getLocalString('header'); ?></h1>
<form id="IdPList" name="IdPList" method="post" onSubmit="return checkForm()" action="<?php echo $actionURL ?>">
<form id="IdPList" name="IdPList" method="post" onSubmit="<?php echo printSubmitAction() ?>" action="<?php echo $actionURL ?>">
<div id="userInputArea">
<p class="promptMessage"><?php echo $promptMessage ?></p>
<div style="text-align: center">
<select name="user_idp" id="userIdPSelection">
<option value="-" <?php echo $defaultSelected ?>><?php echo getLocalString('select_idp') ?> ...</option>
<?php printDropDownList($IDProviders, $selectedIDP) ?>
<select name="user_idp" id="userIdPSelection" class="userIdPSelection" tabindex="0">
<?php
// If we use select2, we don't want IDP to be in DOM, but to use AJAX instead
if (!$useSelect2) {
echo '<option value="-" '.$defaultSelected.'>'.getLocalString('select_idp').' ...</option>';
printDropDownList($IDProviders, $selectedIDP);
}
?>
</select>
<input type="submit" name="Select" accesskey="s" value="<?php echo getLocalString('select_button') ?>">
</div>
<div style="text-align: left">
......@@ -26,7 +33,9 @@
</div>
</form>
<?php if (getLocalString('additional_info') != '') { ?>
<?php if (getLocalString('additional_info') != '') {
?>
<p><?php echo getLocalString('additional_info') ?></p>
<?php } ?>
<?php
} ?>
<!-- Identity Provider Selection: End -->
<?php // Copyright (c) 2019, SWITCH ?>
<?php // Copyright (c) 2019, SWITCH?>
<!-- EMBEDDED-WAYF-START -->
<script type="text/javascript"><!--
......@@ -147,6 +147,13 @@ var wayf_return_url = "https://my-app.switch.ch/aai/index.php?page=show_welcome"
// [Optional, default: false]
// var wayf_use_improved_drop_down_list = false;
// Whether or not use Select2 drop down
// Attention: setting this to true, overrides $useImprovedDropDownList param
// var wayf_use_select2 = false;
// Config to change the number of IdP fetched when using Select2 dropdown
// var wayf_select2_page_size = 100;
// If true the improved drop-down-list will not display IdP logos that
// have to be loaded from remote URLs. That way the web browser
// does not have to make requests to third party hosts.
......
......@@ -14,7 +14,6 @@
if ($useSelect2) {
echo '<link rel="stylesheet" href="'. $_SERVER['SCRIPT_NAME'] .'/select2.css" type="text/css" >'.PHP_EOL;
// echo '<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />'.PHP_EOL;
echo '<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>'.PHP_EOL;
echo '<script type="text/javascript" src="'.$javascriptURL .'/select2Functions.js"></script>'.PHP_EOL;
} elseif ($useImprovedDropDownList) {
......@@ -71,7 +70,6 @@
// Perform input validation on WAYF form for select2
function select2CheckForm() {
// FIXME : to be reviewed for select2 !!!
console.log("checkForm ", $('.userIdPSelection option:selected').text());
if (
document.IdPList.user_idp && (
......
<?php // Copyright (c) 2019, SWITCH ?>
<?php // Copyright (c) 2019, SWITCH?>
<!-- Identity Provider Selection: Start -->
<h1><?php echo getLocalString('permanent_select_header'); ?></h1>
<form id="IdPList" name="IdPList" method="post" onSubmit="<?php
if ($useSelect2) {
echo "return select2CheckForm()";
} else {
echo "return checkForm()";
}
?>" action="<?php echo $actionURL ?>">
<form id="IdPList" name="IdPList" method="post" onSubmit="<?php echo printSubmitAction() ?>" action="<?php echo $actionURL ?>">
<div id="userInputArea">
<p class="promptMessage"><?php echo getLocalString('permanent_cookie'); ?></p>
<p><?php echo getLocalString('select_idp'); ?></p>
......
......@@ -1116,3 +1116,13 @@ function isRunViaInclude()
{
return basename($_SERVER['SCRIPT_NAME']) != 'readMetadata.php';
}
function printSubmitAction()
{
global $useSelect2;
if ($useSelect2) {
return "return select2CheckForm()";
} else {
return "return checkForm()";
}
}
......@@ -5,13 +5,13 @@
// The API is compliant with select2 (https://select2.org/)
/*------------------------------------------------*/
// TODO : gérer la pré-sélection
$topLevelDir = dirname(__DIR__);
require('common.php');
require('idpApiObjects.php');
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
$repo = new IdpRepository($IDProviders, $IDPArray);
......
......@@ -291,6 +291,7 @@ function printEmbeddedWAYFScript()
global $langStrings, $language, $imageURL, $javascriptURL, $cssURL, $logoURL, $smallLogoURL, $federationURL;
global $selectedIDP, $IDProviders, $SAMLDomainCookieName, $redirectCookieName, $redirectStateCookieName;
global $customStrings;
global $apiURL, $developmentMode;
// Set values that are used in the java script
$loginWithString = getLocalString('login_with');
......
This diff is collapsed.
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