logintoboggan.unifiedlogin.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. (function ($) {
  2. Drupal.behaviors.unifiedLogin = {
  3. attach: function (context) {
  4. // Attach behaviors to the links so that they show/hide forms appropriately.
  5. $('.toboggan-unified #register-link').click(function() {
  6. $(this).addClass('lt-active').blur();
  7. $('.toboggan-unified #login-link').removeClass('lt-active');
  8. $('.toboggan-unified #register-form').show();
  9. $('.toboggan-unified #login-form').hide();
  10. $.ajax({
  11. url: "/user/register",
  12. success: function(data) {
  13. var title = data.match("<title>(.*?)</title>")[1];
  14. $('html head').find('title').text(title);
  15. $('h1.title').text(title.substring(0,title.indexOf('|')));
  16. },
  17. });
  18. return false;
  19. });
  20. $('.toboggan-unified #login-link').click(function() {
  21. $(this).addClass('lt-active').blur();
  22. $('.toboggan-unified #register-link').removeClass('lt-active');
  23. $('.toboggan-unified #login-form').show();
  24. $('.toboggan-unified #register-form').hide();
  25. $.ajax({
  26. url: "/user/login",
  27. success: function(data) {
  28. var title = data.match("<title>(.*?)</title>")[1];
  29. $('html head').find('title').text(title);
  30. $('h1.title').text(title.substring(0,title.indexOf('|')));
  31. },
  32. });
  33. return false;
  34. });
  35. switch(Drupal.settings.LoginToboggan.unifiedLoginActiveForm) {
  36. case 'register':
  37. $('.toboggan-unified #register-link').click();
  38. break;
  39. case 'login':
  40. default:
  41. $('.toboggan-unified #login-link').click();
  42. break;
  43. }
  44. }
  45. };
  46. })(jQuery);