root / snf-astakos-app / astakos / im / static / im / js / auth_methods.js @ 51d734ea
History | View | Annotate | Download (4.7 kB)
1 |
$(document).ready(function() { |
---|---|
2 |
|
3 |
|
4 |
$('.auth_methods .canremove').click( function(e) { |
5 |
e.preventDefault(e); |
6 |
$(this).parent('li').addClass('remove'); |
7 |
$(this).siblings('.details').hide(); |
8 |
$(this).siblings('.dialog-wrap').slideDown('slow'); |
9 |
|
10 |
}); |
11 |
|
12 |
$('.auth_methods .no').click( function(e) { |
13 |
e.preventDefault(e); |
14 |
$(this).parents('li').removeClass('remove'); |
15 |
$(this).parents('.dialog-wrap').slideUp('slow'); |
16 |
}); |
17 |
|
18 |
$('.auth_methods .canremove').hover( |
19 |
function () {
|
20 |
$(this).siblings('span.details').hide(); |
21 |
}, |
22 |
function () {
|
23 |
$(this).siblings('span.details').show(); |
24 |
}); |
25 |
|
26 |
/* complex form js */
|
27 |
|
28 |
// Intresting divs
|
29 |
|
30 |
emailDiv = $('#id_email').parents('.form-row'); |
31 |
newEmailDiv = $('#id_new_email_address').parents('.form-row'); |
32 |
oldPasswordDiv = $('#id_old_password').parents('.form-row'); |
33 |
newPassword1Div = $('#id_new_password1').parents('.form-row'); |
34 |
newPassword2Div = $('#id_new_password2').parents('.form-row'); |
35 |
emailCheck = $('#id_change_email').parents('.form-row'); |
36 |
passwordCheck = $('#id_change_password').parents('.form-row'); |
37 |
authTokenDiv = $('#id_auth_token').parents('.form-row'); |
38 |
|
39 |
if ( newEmailDiv.length>0 ){ |
40 |
emailDiv.addClass('form-following');
|
41 |
} |
42 |
|
43 |
oldPasswordDiv.addClass('form-following');
|
44 |
|
45 |
|
46 |
// Intresting img spans
|
47 |
|
48 |
emailDiv.find('span.extra-img').attr('id','email-span'); |
49 |
oldPasswordDiv.find('span.extra-img').attr('id','password-span'); |
50 |
authTokenDiv.find('span.extra-img').attr('id','token-span'); |
51 |
// Default hidden fields
|
52 |
|
53 |
|
54 |
emailCheck.hide(); |
55 |
passwordCheck.hide(); |
56 |
|
57 |
|
58 |
|
59 |
newEmailDiv.addClass('email-span');
|
60 |
newPassword1Div.addClass('password-span');
|
61 |
newPassword2Div.addClass('password-span');
|
62 |
|
63 |
$('.password-span').wrapAll('<div class="hidden-form-rows">'); |
64 |
$('.email-span').wrapAll('<div class="hidden-form-rows">'); |
65 |
|
66 |
// If errors show fields
|
67 |
|
68 |
|
69 |
if ($('input#id_change_password:checkbox').attr('checked')) { |
70 |
oldPasswordDiv.find('input').focus();
|
71 |
$('.form-following #password-span').parents('.form-row').next('.hidden-form-rows').show(); |
72 |
|
73 |
$('.form-following #password-span').parents('.form-row').addClass('open'); |
74 |
}; |
75 |
|
76 |
|
77 |
|
78 |
if ($('input#id_change_email:checkbox').attr('checked')) { |
79 |
|
80 |
$('.form-following #email-span').parents('.form-row').next('.hidden-form-rows').show(); |
81 |
$('.form-following #email-span').parents('.form-row').addClass('open'); |
82 |
}; |
83 |
|
84 |
// Email, Password forms
|
85 |
|
86 |
$('.form-following .extra-img').click(function(e){ |
87 |
var h = $('.form-row').first().outerHeight(); |
88 |
$('.form-row').css('height', h); |
89 |
$(this).parents('.form-row').toggleClass('open'); |
90 |
$(this).parents('.form-row').next('.hidden-form-rows').slideToggle('slow'); |
91 |
|
92 |
id = $(this).attr('id'); |
93 |
|
94 |
|
95 |
|
96 |
if ( !($(this).parents('.form-row').hasClass('open')) ){ |
97 |
$('.form-row').each(function() { |
98 |
if( $(this).hasClass(id) ) { |
99 |
console.info($(this).find('input[type="text"]')); |
100 |
$(this).find('input').val(''); |
101 |
$(this).removeClass('with-errors'); |
102 |
$(this).find('.form-error').hide(); |
103 |
} |
104 |
}); |
105 |
$(this).parents('.form-row').removeClass('with-errors'); |
106 |
$(this).parents('.form-row').find('.form-error').hide(); |
107 |
|
108 |
} else {
|
109 |
// focus on first input
|
110 |
if ( id == 'email-span') { newEmailDiv.find('input').focus(); } |
111 |
if ( id == 'password-span') { oldPasswordDiv.find('input').focus(); } |
112 |
} |
113 |
|
114 |
|
115 |
}); |
116 |
|
117 |
// check uncheck checkbox
|
118 |
$('#email-span').click(function(){ |
119 |
var $checkbox = $('input#id_change_email:checkbox'); |
120 |
$checkbox.attr('checked', !$checkbox.attr('checked')); |
121 |
}); |
122 |
|
123 |
// check uncheck checkbox
|
124 |
$('#password-span').click(function(){ |
125 |
var $checkbox = $('input#id_change_password:checkbox'); |
126 |
$checkbox.attr('checked', !$checkbox.attr('checked')); |
127 |
}); |
128 |
|
129 |
// refresh token
|
130 |
authTokenDiv.addClass('refresh');
|
131 |
authTokenDiv.append('<a id="token-confirm" class="submit" href="#">Confirm token change</a>');
|
132 |
|
133 |
$('#token-span').click(function(e){ |
134 |
$(this).parents('.form-row').toggleClass('open'); |
135 |
$(this).siblings('span.info').find('span').hide(); |
136 |
//placeTokenConfirm();
|
137 |
$('#token-confirm').toggle(); |
138 |
return false; |
139 |
}); |
140 |
|
141 |
$('#token-confirm').click(function(e){ |
142 |
e.preventDefault(); |
143 |
renewToken(); |
144 |
$(this).hide(); |
145 |
}) |
146 |
|
147 |
$('#token-span').hover( |
148 |
function () {
|
149 |
if (!$(this).parents('.form-row').hasClass('open')){ |
150 |
$(this).siblings('span.info').find('span').show(); |
151 |
} |
152 |
|
153 |
}, |
154 |
function () {
|
155 |
$(this).siblings('span.info').find('span').hide(); |
156 |
}); |
157 |
|
158 |
/* end of complex form js */
|
159 |
|
160 |
|
161 |
|
162 |
}); |
163 |
|