Revision 7b5bca4a snf-astakos-app/astakos/im/static/im/js/common.js
b/snf-astakos-app/astakos/im/static/im/js/common.js | ||
---|---|---|
241 | 241 |
|
242 | 242 |
|
243 | 243 |
|
244 |
$('.auth_methods .canremove').click( function(e) { |
|
245 |
e.preventDefault(e); |
|
246 |
$(this).addClass('remove'); |
|
247 |
$(this).siblings('.dialog-wrap').slideDown('slow'); |
|
248 |
}) |
|
249 |
|
|
250 |
$('.auth_methods .no').click( function(e) { |
|
251 |
e.preventDefault(e); |
|
252 |
$(this).parents('.dialog-wrap').siblings('.canremove').removeClass('remove'); |
|
253 |
$(this).parents('.dialog-wrap').slideUp('slow'); |
|
254 |
}) |
|
244 |
|
|
255 | 245 |
|
256 | 246 |
|
257 | 247 |
setTimeout(function() { |
... | ... | |
263 | 253 |
} |
264 | 254 |
}, 100); |
265 | 255 |
|
266 |
|
|
267 |
/* complex form js */ |
|
268 |
|
|
269 |
// Intresting divs |
|
270 |
|
|
271 |
emailDiv = $('#id_email').parents('.form-row'); |
|
272 |
newEmailDiv = $('#id_new_email_address').parents('.form-row'); |
|
273 |
oldPasswordDiv = $('#id_old_password').parents('.form-row'); |
|
274 |
newPassword1Div = $('#id_new_password1').parents('.form-row'); |
|
275 |
newPassword2Div = $('#id_new_password2').parents('.form-row'); |
|
276 |
emailCheck = $('#id_change_email').parents('.form-row'); |
|
277 |
passwordCheck = $('#id_change_password').parents('.form-row'); |
|
278 |
authTokenDiv = $('#id_auth_token').parents('.form-row'); |
|
279 |
|
|
280 |
if ( newEmailDiv.length>0 ){ |
|
281 |
emailDiv.addClass('form-following'); |
|
282 |
} |
|
283 |
|
|
284 |
oldPasswordDiv.addClass('form-following'); |
|
285 |
|
|
286 |
|
|
287 |
// Intresting img spans |
|
288 |
|
|
289 |
emailDiv.find('span.extra-img').attr('id','email-span'); |
|
290 |
oldPasswordDiv.find('span.extra-img').attr('id','password-span'); |
|
291 |
authTokenDiv.find('span.extra-img').attr('id','token-span'); |
|
292 |
// Default hidden fields |
|
293 |
|
|
294 |
newEmailDiv.hide(); |
|
295 |
newPassword1Div.hide(); |
|
296 |
newPassword2Div.hide(); |
|
297 |
emailCheck.hide(); |
|
298 |
passwordCheck.hide(); |
|
299 |
|
|
300 |
|
|
301 |
|
|
302 |
newEmailDiv.addClass('email-span'); |
|
303 |
newPassword1Div.addClass('password-span'); |
|
304 |
newPassword2Div.addClass('password-span'); |
|
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 |
|
|
324 |
// Email, Password forms |
|
325 |
|
|
326 |
$('.form-following .extra-img').click(function(e){ |
|
327 |
|
|
328 |
$(this).parents('.form-row').toggleClass('open'); |
|
329 |
id = $(this).attr('id'); |
|
330 |
$('.form-row').each(function() { |
|
331 |
if( $(this).hasClass(id) ) { |
|
332 |
$(this).toggle(); |
|
333 |
} |
|
334 |
}); |
|
335 |
|
|
336 |
|
|
337 |
if ( !($(this).parents('.form-row').hasClass('open')) ){ |
|
338 |
$('.form-row').each(function() { |
|
339 |
if( $(this).hasClass(id) ) { |
|
340 |
console.info($(this).find('input[type="text"]')); |
|
341 |
$(this).find('input').val(''); |
|
342 |
$(this).removeClass('with-errors'); |
|
343 |
$(this).find('.form-error').hide(); |
|
344 |
} |
|
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(); } |
|
350 |
} |
|
351 |
}); |
|
352 |
|
|
353 |
// check uncheck checkbox |
|
354 |
$('#email-span').click(function(){ |
|
355 |
var $checkbox = $('input#id_change_email:checkbox'); |
|
356 |
$checkbox.attr('checked', !$checkbox.attr('checked')); |
|
357 |
}); |
|
358 |
|
|
359 |
// check uncheck checkbox |
|
360 |
$('#password-span').click(function(){ |
|
361 |
var $checkbox = $('input#id_change_password:checkbox'); |
|
362 |
$checkbox.attr('checked', !$checkbox.attr('checked')); |
|
363 |
}); |
|
364 |
|
|
365 |
// refresh token |
|
366 |
authTokenDiv.addClass('refresh'); |
|
367 |
$('#token-span').click(function(e){ |
|
368 |
renewToken(); |
|
369 |
}) |
|
370 |
|
|
371 |
|
|
372 |
|
|
373 |
/* end of complex form js */ |
|
256 |
|
|
374 | 257 |
|
375 | 258 |
|
376 | 259 |
|
Also available in: Unified diff