Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions scripts/ddbasic.login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(function($) {
"use strict";

$(document).ready(function() {
// Focus on username form field when entering login form.
$('#user-login-form #edit-name').focus();

// Focus on username form field when clicking login tab.
$('.topbar-link-user').bind('click', function(event) {
$('#user-login-form #edit-name').focus();
});

// Unfocus login form when user wants to scroll with key buttons (i.e. clicks the up or down button).
$('#user-login-form').bind('keydown', function(event) {
var keymap = {
up: 38,
down: 40
};

// Only unfocus if we press the up or down key.
if (keymap.up == event.which || keymap.down == event.which) {
document.activeElement.blur();
}
});
});
}(jQuery));
4 changes: 4 additions & 0 deletions template.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ function ddbasic_form_alter(&$form, &$form_state, $form_id) {
$form['pass']['#field_prefix'] = '<i class="icon-lock"></i>';
$form['pass']['#attributes']['placeholder'] = t('Pincode is 4 digits');

// Add JavaScript that will place focus in the login box, when the Login
// is clicked.
drupal_add_js(drupal_get_path('theme', 'ddbasic') . '/scripts/ddbasic.login.js', 'file');

unset($form['links']);

// Temporary hack to get rid of open id links.
Expand Down