Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | var Login = function() { |
| 2 | |||
| 3 | var handleLogin = function() { |
||
| 4 | |||
| 5 | $('.login-form').validate({ |
||
| 6 | errorElement: 'span', //default input error message container |
||
| 7 | errorClass: 'help-block', // default input error message class |
||
| 8 | focusInvalid: false, // do not focus the last invalid input |
||
| 9 | rules: { |
||
| 10 | username: { |
||
| 11 | required: true |
||
| 12 | }, |
||
| 13 | password: { |
||
| 14 | required: true |
||
| 15 | }, |
||
| 16 | remember: { |
||
| 17 | required: false |
||
| 18 | } |
||
| 19 | }, |
||
| 20 | |||
| 21 | messages: { |
||
| 22 | username: { |
||
| 23 | required: "Username is required." |
||
| 24 | }, |
||
| 25 | password: { |
||
| 26 | required: "Password is required." |
||
| 27 | } |
||
| 28 | }, |
||
| 29 | |||
| 30 | invalidHandler: function(event, validator) { //display error alert on form submit |
||
| 31 | $('.alert-danger', $('.login-form')).show(); |
||
| 32 | }, |
||
| 33 | |||
| 34 | highlight: function(element) { // hightlight error inputs |
||
| 35 | $(element) |
||
| 36 | .closest('.form-group').addClass('has-error'); // set error class to the control group |
||
| 37 | }, |
||
| 38 | |||
| 39 | success: function(label) { |
||
| 40 | label.closest('.form-group').removeClass('has-error'); |
||
| 41 | label.remove(); |
||
| 42 | }, |
||
| 43 | |||
| 44 | errorPlacement: function(error, element) { |
||
| 45 | error.insertAfter(element.closest('.input-icon')); |
||
| 46 | }, |
||
| 47 | |||
| 48 | submitHandler: function(form) { |
||
| 49 | form.submit(); // form validation success, call ajax form submit |
||
| 50 | } |
||
| 51 | }); |
||
| 52 | |||
| 53 | $('.login-form input').keypress(function(e) { |
||
| 54 | if (e.which == 13) { |
||
| 55 | if ($('.login-form').validate().form()) { |
||
| 56 | $('.login-form').submit(); //form validation success, call ajax form submit |
||
| 57 | } |
||
| 58 | return false; |
||
| 59 | } |
||
| 60 | }); |
||
| 61 | |||
| 62 | $('.forget-form input').keypress(function(e) { |
||
| 63 | if (e.which == 13) { |
||
| 64 | if ($('.forget-form').validate().form()) { |
||
| 65 | $('.forget-form').submit(); |
||
| 66 | } |
||
| 67 | return false; |
||
| 68 | } |
||
| 69 | }); |
||
| 70 | |||
| 71 | $('#forget-password').click(function(){ |
||
| 72 | $('.login-form').hide(); |
||
| 73 | $('.forget-form').show(); |
||
| 74 | }); |
||
| 75 | |||
| 76 | $('#back-btn').click(function(){ |
||
| 77 | $('.login-form').show(); |
||
| 78 | $('.forget-form').hide(); |
||
| 79 | }); |
||
| 80 | } |
||
| 81 | |||
| 82 | |||
| 83 | |||
| 84 | |||
| 85 | return { |
||
| 86 | //main function to initiate the module |
||
| 87 | init: function() { |
||
| 88 | |||
| 89 | handleLogin(); |
||
| 90 | |||
| 91 | // init background slide images |
||
| 92 | $('.login-bg').backstretch([ |
||
| 93 | "../assets/pages/img/login/bg1.jpg", |
||
| 94 | "../assets/pages/img/login/bg2.jpg", |
||
| 95 | "../assets/pages/img/login/bg3.jpg" |
||
| 96 | ], { |
||
| 97 | fade: 1000, |
||
| 98 | duration: 8000 |
||
| 99 | } |
||
| 100 | ); |
||
| 101 | |||
| 102 | $('.forget-form').hide(); |
||
| 103 | |||
| 104 | } |
||
| 105 | |||
| 106 | }; |
||
| 107 | |||
| 108 | }(); |
||
| 109 | |||
| 110 | jQuery(document).ready(function() { |
||
| 111 | Login.init(); |
||
| 112 | }); |