bug 12081

-Always login field labels, until text is present in input field

-Focus username field on load

status 12081: resolved fixed
This commit is contained in:
Brian Federle 2011-12-09 11:07:39 -08:00
parent 10593528ca
commit 91bb0cfeea
2 changed files with 22 additions and 9 deletions

View File

@ -242,6 +242,7 @@ body.login {
position: absolute;
margin-left: 11px;
margin-top: 12px;
cursor: text;
}
.login .fields .field label.error {

View File

@ -26,23 +26,35 @@
$form.validate();
// Form label behavior
$inputs.bind('focus blur', function(event) {
$inputs.bind('keydown keyup focus blur', function(event) {
var $target = $(event.target);
var $label = $form.find('label').filter(function() {
return $(this).attr('for') == $target.attr('name') && !$(this).hasClass('error');
return $(this).attr('for') == $target.attr('name');
});
var isEmpty = !$target.val();
var isFocus = event.type == 'focus';
var isBlur = event.type == 'blur';
if (isFocus) {
if (event.type == 'keydown') {
$label.hide();
} else if (isBlur && isEmpty) {
$label.show();
return true;
} else {
if (!$target.val()) {
$label.show();
} else {
$label.hide();
}
}
return true;
});
$inputs.focus().blur();
// Labels cause related input to be focused
$login.find('label').click(function() {
var $input = $inputs.filter('[name=' + $(this).attr('for') + ']');
$input.focus();
});
$inputs.filter(':first').focus();
// Login action
$login.find('input[type=submit]').click(function() {