/* * SimpleModal login Form * http://www.ericmmartin.com/projects/simplemodal/ * http://code.google.com/p/simplemodal/ * * Copyright (c) 2010 Eric Martin - http://ericmmartin.com * * Licensed under the MIT license: * http://www.opensource.org/licenses/mit-license.php * * Revision: $Id: login.js 243 2010-03-15 14:23:14Z emartin24 $ * */ jQuery(function ($) { //message //init //open //show //close //error //validate //validateEmail //showError var login = { message: null, init: function () { $('#login-form input.login, #login-form a.login').click(function (e) { //here //alert('sdf'); e.preventDefault(); // load the login form using ajax $.get("https://www.payeroll.ie/jlogin.php", function(data){ // create a modal dialog with the data $(data).modal({ closeHTML: "x", position: ["15%",], overlayId: 'login-overlay', containerId: 'login-container', onOpen: login.open, onShow: login.show, onClose: login.close }); }); }); }, open: function (dialog) { // add padding to the buttons in firefox/mozilla if ($.browser.mozilla) { $('#login-container .login-button').css({ 'padding-bottom': '2px' }); } // input field font size if ($.browser.safari) { $('#login-container .login-input').css({ 'font-size': '.9em' }); } // determine height var h = 140; var title = $('#login-container .login-title').html(); $('#login-container .login-title').html('Loading...'); dialog.overlay.fadeIn(200, function () { dialog.container.fadeIn(200, function () { dialog.data.fadeIn(200, function () { $('#login-container .login-content').animate({ height: h }, function () { $('#login-container .login-title').html(title); $('#login-container form').fadeIn(200, function () { $('#login-container #login-email').focus(); // fix png's for IE 6 if ($.browser.msie && $.browser.version < 7) { $('#login-container .login-button').each(function () { if ($(this).css('backgroundImage').match(/^url[("']+(.*\.png)[)"']+$/i)) { var src = RegExp.$1; $(this).css({ backgroundImage: 'none', filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + src + '", sizingMethod="crop")' }); } }); } }); }); }); }); }); }, show: function (dialog) { $('#login-container .login-send').click(function (e) { e.preventDefault(); // validate form if (login.validate()) { var msg = $('#login-container .login-message'); msg.fadeOut(function () { msg.removeClass('login-error').empty(); }); $('#login-container .login-title').html('Sending...'); $('#login-container form').fadeOut(200); $('#login-container .login-content').animate({ height: '80px' }, function () { $('#login-container .login-loading').fadeIn(200, function () { $.ajax({ url: 'https://www.payeroll.ie/jlogin.php', data: $('#login-container form').serialize() + '&action=send', type: 'post', cache: false, dataType: 'html', success: function (data) { $('#login-container .login-loading').fadeOut(200, function () { $('#login-container .login-title').html(data); msg.html(data).fadeIn(200); // $.ajaxSetup({ // complete: function (xhr) { // var redirect = xhr.getResponseHeader('Redirect'); // if (redirect) alert(redirect); //if(redirect) window.location = redirect; // } // }); //$.modal.close(); //window.location="https://www.securehut.com/payerollie/login.php?sessid="; }); }, error: login.error }); }); }); } else { if ($('#login-container .login-message:visible').length > 0) { var msg = $('#login-container .login-message div'); msg.fadeOut(200, function () { msg.empty(); login.showError(); msg.fadeIn(200); }); } else { $('#login-container .login-message').animate({ height: '30px' }, login.showError); } } }); }, close: function (dialog) { $('#login-container .login-message').fadeOut(); $('#login-container .login-title').html('Processing...'); $('#login-container form').fadeOut(200); $('#login-container .login-content').animate({ height: 40 }, function () { dialog.data.fadeOut(200, function () { dialog.container.fadeOut(200, function () { dialog.overlay.fadeOut(200, function () { $.modal.close(); }); }); }); }); }, error: function (xhr) { alert(xhr.statusText); }, validate: function () { login.message = ''; var email = $('#login-container #login-email').val(); if (!email) { login.message += 'Email is required. '; } else { if (!login.validateEmail(email)) { login.message += 'Email is invalid. '; } } if (!$('#login-container #login-password').val()) { login.password += 'Password is required.'; } if (login.message.length > 0) { return false; } else { return true; } }, validateEmail: function (email) { var at = email.lastIndexOf("@"); // Make sure the at (@) sybmol exists and // it is not the first or last character if (at < 1 || (at + 1) === email.length) return false; // Make sure there aren't multiple periods together if (/(\.{2,})/.test(email)) return false; // Break up the local and domain portions var local = email.substring(0, at); var domain = email.substring(at + 1); // Check lengths if (local.length < 1 || local.length > 64 || domain.length < 4 || domain.length > 255) return false; // Make sure local and domain don't start with or end with a period if (/(^\.|\.$)/.test(local) || /(^\.|\.$)/.test(domain)) return false; // Check for quoted-string addresses // Since almost anything is allowed in a quoted-string address, // we're just going to let them go through if (!/^"(.+)"$/.test(local)) { // It's a dot-string address...check for valid characters if (!/^[-a-zA-Z0-9!#$%*\/?|^{}`~&'+=_\.]*$/.test(local)) return false; } // Make sure domain contains only valid characters and at least one period if (!/^[-a-zA-Z0-9\.]*$/.test(domain) || domain.indexOf(".") === -1) return false; return true; }, showError: function () { $('#login-container .login-message') .html($('
').append(login.message)) .fadeIn(200); } }; login.init(); });