Skip to content
Snippets Groups Projects
Commit 825729f6 authored by Olav Morken's avatar Olav Morken
Browse files

Add autofocus helper script with support from default template. Also change

previous autofocus implementations to use this script.


git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@646 44740490-163a-0410-bde0-09ae8108e29a
parent e89cd8bf
No related branches found
No related tags found
No related merge requests found
<?php <?php
$this->data['icon'] = 'debug.png'; $this->data['icon'] = 'debug.png';
$this->data['autofocus'] = 'sendlink';
$this->includeAtTemplateBase('includes/header.php'); $this->includeAtTemplateBase('includes/header.php');
?> ?>
...@@ -14,9 +15,6 @@ ...@@ -14,9 +15,6 @@
<pre style="overflow: scroll; border: 1px solid #eee"><?php echo $this->data['message']; ?></pre> <pre style="overflow: scroll; border: 1px solid #eee"><?php echo $this->data['message']; ?></pre>
<p>[ <a id="sendlink" href="<?php echo htmlentities($this->data['url']); ?>">send SAML message</a> ]</p> <p>[ <a id="sendlink" href="<?php echo htmlentities($this->data['url']); ?>">send SAML message</a> ]</p>
<script type="text/javascript">
document.getElementById('sendlink').focus();
</script>
<h2>Debug mode</h2> <h2>Debug mode</h2>
......
...@@ -12,8 +12,18 @@ if(array_key_exists('header', $this->data)) { ...@@ -12,8 +12,18 @@ if(array_key_exists('header', $this->data)) {
<link rel="stylesheet" type="text/css" href="/<?php echo $this->data['baseurlpath']; ?>resources/default.css" /> <link rel="stylesheet" type="text/css" href="/<?php echo $this->data['baseurlpath']; ?>resources/default.css" />
<link rel="icon" type="image/icon" href="/<?php echo $this->data['baseurlpath']; ?>resources/icons/favicon.ico" /> <link rel="icon" type="image/icon" href="/<?php echo $this->data['baseurlpath']; ?>resources/icons/favicon.ico" />
<script type="text/javascript" src="/<?php echo $this->data['baseurlpath']; ?>resources/script.js" />
</head> </head>
<body> <?php
$onLoad = '';
if(array_key_exists('autofocus', $this->data)) {
$onLoad .= 'SimpleSAML_focus(\'' . $this->data['autofocus'] . '\');';
}
if($onLoad !== '') {
$onLoad = ' onload="' . $onLoad . '"';
}
?>
<body<?php echo $onLoad; ?>>
<div id="wrap"> <div id="wrap">
......
<?php <?php
if (!array_key_exists('icon', $this->data)) $this->data['icon'] = 'lock.png'; if (!array_key_exists('icon', $this->data)) $this->data['icon'] = 'lock.png';
$this->data['autofocus'] = 'username';
$this->includeAtTemplateBase('includes/header.php'); $this->includeAtTemplateBase('includes/header.php');
?> ?>
<script type="text/javascript">
function focusit() {
document.getElementById('username').focus();
}
window.onload = focusit;
</script>
<div id="content"> <div id="content">
<?php if (isset($this->data['error'])) { ?> <?php if (isset($this->data['error'])) { ?>
......
<?php <?php
$this->data['icon'] = 'debug.png'; $this->data['icon'] = 'debug.png';
$this->data['autofocus'] = 'sendbutton';
$this->includeAtTemplateBase('includes/header.php'); $this->includeAtTemplateBase('includes/header.php');
?> ?>
...@@ -19,10 +20,6 @@ ...@@ -19,10 +20,6 @@
<input type="submit" value="Submit the response to the service" id="sendbutton" /> <input type="submit" value="Submit the response to the service" id="sendbutton" />
</form> </form>
<script type="text/javascript">
document.getElementById('sendbutton').focus();
</script>
<h2>Debug mode</h2> <h2>Debug mode</h2>
<p>As you are in debug mode you are lucky to see the content of the response you are sending:</p> <p>As you are in debug mode you are lucky to see the content of the response you are sending:</p>
......
/**
* Set focus to the element with the given id.
*
* @param id The id of the element which should receive focus.
*/
function SimpleSAML_focus(id) {
element = document.getElementById(id);
if(element != null) {
element.focus();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment