$( function() { php.messages.entro = function (msg, params){ // alert ("My messages CallBack func: " + msg); document.location='/admin/'; } php.messages.entrocp = function (msg, params){ // alert ("Attenzione " + msg + " ! Sara' necessario effettuare il login in alto a destra nel pannello cliente. Stiamo lavorando alla nuova interfaccia del pannello di controllo ..."); document.location='/cp/'; } php.messages.entromd = function (msg, params){ alert ("Attenzione " + msg + " ! Questo pannello di controllo e' in fase di sviluppo."); document.location='/md/'; } //alert('test'); php.errors.defaultCallBack = function (msg, params) { $.localFlash(msg, 'error'); if (msg.indexOf('password')!=-1 ) { //$("#password").effect("shake", { times:5,distance:1,direction:'top' }, 70); //$('#passwordfield').focus(); $('#password').effect('highlight', {}, 1000); } if (msg.indexOf('username')!=-1 ) { //$("#username").effect("shake", { times:5,distance:2,direction:'top' }, 70); //$('#username').focus(); $('#username').effect('highlight', {}, 1000); } } php.messages.defaultCallBack = function (msg, params) { $.localFlash(msg, 'notice'); } $.localFlash = function( message, type ) { if( type.toLowerCase() == 'notice' ) { $('#Flash').removeClass('flash_notice_error'); $('#Flash').addClass('flash_notice'); } else { $('#Flash').removeClass('flash_notice'); $('#Flash').addClass('flash_notice_error'); } $('#Flash').html(message); $('#Flash').show(); $('#Flash').unbind('click'); $('#Flash').bind('click', function() { $(this).fadeOut(); }); $('html, body').animate({scrollTop:0}, 'slow'); } // bind to the form's submit event and cancel legacy submit // $('#signupForm').submit(function() { $('#loginPage').bind('submit', function(event) { event.preventDefault(); if( $('#username').attr('value') == '' ) { $.localFlash('Inserire lo username.', 'error'); //$("#username").effect("shake", { times:5,distance:2,direction:'top' }, 70); // $('#username').focus(); $('#username').effect('highlight', {}, 1000); return false; } if( $('#password').attr('value') == '' ) { $.localFlash('Inserire la password', 'error'); //$("#password").effect("shake", { times:5,distance:7,direction:'top' }, 70); $('#password').effect('highlight', {}, 1000); //$('#passwordfield').focus(); return false; } //$.localFlash('Processing login, please wait.', 'notice'); $.php( $('#loginPage').attr('action'), $('#loginPage').serialize() ); //return false; }); });