275 |
275 |
newPassword2Div = $('#id_new_password2').parents('.form-row');
|
276 |
276 |
emailCheck = $('#id_change_email').parents('.form-row');
|
277 |
277 |
passwordCheck = $('#id_change_password').parents('.form-row');
|
|
278 |
authTokenDiv = $('#id_auth_token').parents('.form-row');
|
278 |
279 |
|
279 |
280 |
if ( newEmailDiv.length>0 ){
|
280 |
281 |
emailDiv.addClass('form-following');
|
... | ... | |
287 |
288 |
|
288 |
289 |
emailDiv.find('span.extra-img').attr('id','email-span');
|
289 |
290 |
oldPasswordDiv.find('span.extra-img').attr('id','password-span');
|
290 |
|
|
|
291 |
authTokenDiv.find('span.extra-img').attr('id','token-span');
|
291 |
292 |
// Default hidden fields
|
292 |
293 |
|
293 |
294 |
newEmailDiv.hide();
|
... | ... | |
302 |
303 |
newPassword1Div.addClass('password-span');
|
303 |
304 |
newPassword2Div.addClass('password-span');
|
304 |
305 |
|
|
306 |
// If errors show fields
|
|
307 |
|
|
308 |
|
|
309 |
if ($('input#id_change_password:checkbox').attr('checked')) {
|
|
310 |
oldPasswordDiv.find('input').focus();
|
|
311 |
newPassword1Div.show();
|
|
312 |
newPassword2Div.show();
|
|
313 |
$('.form-following #password-span').parents('.form-row').addClass('open');
|
|
314 |
};
|
|
315 |
|
|
316 |
|
|
317 |
|
|
318 |
if ($('input#id_change_password:checkbox').attr('checked')) {
|
|
319 |
newEmailDiv.show();
|
|
320 |
|
|
321 |
$('.form-following #email-span').parents('.form-row').addClass('open');
|
|
322 |
};
|
|
323 |
|
305 |
324 |
// Email, Password forms
|
306 |
325 |
|
307 |
326 |
$('.form-following .extra-img').click(function(e){
|
|
327 |
|
308 |
328 |
$(this).parents('.form-row').toggleClass('open');
|
309 |
329 |
id = $(this).attr('id');
|
310 |
330 |
$('.form-row').each(function() {
|
... | ... | |
313 |
333 |
}
|
314 |
334 |
});
|
315 |
335 |
|
|
336 |
|
316 |
337 |
if ( !($(this).parents('.form-row').hasClass('open')) ){
|
317 |
338 |
$('.form-row').each(function() {
|
318 |
339 |
if( $(this).hasClass(id) ) {
|
319 |
340 |
console.info($(this).find('input[type="text"]'));
|
320 |
341 |
$(this).find('input').val('');
|
|
342 |
$(this).removeClass('with-errors');
|
|
343 |
$(this).find('.form-error').hide();
|
321 |
344 |
}
|
322 |
345 |
});
|
|
346 |
} else {
|
|
347 |
// focus on first input
|
|
348 |
if ( id == 'email-span') { newEmailDiv.find('input').focus(); }
|
|
349 |
if ( id == 'password-span') { oldPasswordDiv.find('input').focus(); }
|
323 |
350 |
}
|
324 |
351 |
});
|
325 |
352 |
|
326 |
|
|
|
353 |
// check uncheck checkbox
|
327 |
354 |
$('#email-span').click(function(){
|
328 |
355 |
var $checkbox = $('input#id_change_email:checkbox');
|
329 |
356 |
$checkbox.attr('checked', !$checkbox.attr('checked'));
|
330 |
357 |
});
|
331 |
358 |
|
332 |
|
|
|
359 |
// check uncheck checkbox
|
333 |
360 |
$('#password-span').click(function(){
|
334 |
361 |
var $checkbox = $('input#id_change_password:checkbox');
|
335 |
362 |
$checkbox.attr('checked', !$checkbox.attr('checked'));
|
336 |
363 |
});
|
337 |
364 |
|
|
365 |
// refresh token
|
|
366 |
authTokenDiv.addClass('refresh');
|
|
367 |
$('#token-span').click(function(e){
|
|
368 |
renewToken();
|
|
369 |
})
|
|
370 |
|
|
371 |
|
|
372 |
|
338 |
373 |
/* end of complex form js */
|
339 |
374 |
|
340 |
375 |
|