|
(function($){ |
|
$.support.placeholder = ('placeholder' in document.createElement('input')); |
|
})(jQuery); |
|
|
|
$(function(){ |
|
var username, reCookie, |
|
cookieName = 'msdcuser', |
|
cookie = document.cookie, |
|
$username = $('#username'), |
|
$password = $('#password'), |
|
$rememberMe = $('#remember-me'), |
|
$forgotForm = $('#forgot-ui-form'), |
|
$form = $('#login-ui-form').on('submit', |
|
function(){ |
|
var cookieInfo = [ // 90 days ... |
|
'path=/', 'max-age=' + 86400 * 90, |
|
]; |
|
if (!$.support.placeholder) { |
|
$form.find('[placeholder]').each(function() { |
|
if (($input = $(this)).val() === $input.attr("placeholder")) { |
|
$input.val(''); |
|
} |
|
}); |
|
} |
|
if (!$username.val() || !$password.val()) { |
|
return false; |
|
} else if ($rememberMe[0].checked) { |
|
cookieInfo.unshift(cookieName + '=' + $username.val()); |
|
document.cookie = cookieInfo.join(';'); |
|
} |
|
return true; |
|
} |
|
), |
|
$uiLogin = $('#login-ui').on('click', '#forgot-password', function(){ |
|
$form.hide('slow', function(){ |
|
$forgotForm.show(); |
|
}); |
|
}).on('click', '.go-back', function(){ |
|
$forgotForm.hide('fast', function(){ |
|
$form.show(); |
|
}); |
|
}); |
|
|
|
if (!$.support.placeholder) { |
|
var $input; // IE 8/9 placeholder fix. |
|
$form.find("[placeholder]").focus(function(){ |
|
if (($input = $(this)).val() === $input.attr('placeholder')) $input.val(''); |
|
}).blur(function(){ |
|
if (($input = $(this)) === '') $input.val($input.attr('placeholder')); |
|
}).blur(); |
|
} |
|
|
|
if (cookie) { |
|
reCookie = new RegExp('(' + cookieName + '=(.+?(?=(;|$))))'); |
|
username = reCookie.exec(cookie); |
|
if (username && username.length > 2) { |
|
$username.val(username[2]); |
|
} |
|
} |
|
|
|
if ($(window).height() < $form[0].getBoundingClientRect().bottom) { |
|
$('body').css('overflow-y', 'visible'); |
|
} |
|
|
|
if ((/localhost|127\.0\.0\.1/).test(location)) { |
|
$form[0].action = 'portal.html'; |
|
} |
|
}); |