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