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