From d5ec6fdcb5daff56791131c587ac03613e0c2a7b Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 14 Mar 2013 12:09:27 +0100 Subject: [PATCH] [FIX] auth_openid: add data-modes attribute on
  • tags to be compatible with auth_signup module. show()/hide() elements explicitly instead of setting a specific class for this job. bzr revid: chs@openerp.com-20130314110927-rvb21ii1lbfpmmna --- addons/auth_openid/static/src/css/openid.css | 9 ------ .../auth_openid/static/src/js/auth_openid.js | 21 +++++++++---- .../static/src/xml/auth_openid.xml | 31 ++++++++++++------- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/addons/auth_openid/static/src/css/openid.css b/addons/auth_openid/static/src/css/openid.css index ab01ffd2f60..dc3ffcf4a20 100644 --- a/addons/auth_openid/static/src/css/openid.css +++ b/addons/auth_openid/static/src/css/openid.css @@ -8,11 +8,6 @@ padding-left: 20px; } -.auth_choice { - position: static; - display: none; -} - .openid_providers { padding: 0; list-style: none; @@ -50,7 +45,3 @@ .openid_providers a[title="Yahoo!"] { background-image: url(../img/yahoo.png); } .openid_providers a[title="Launchpad"] { background-image: url(../img/launchpad.png); } - -li.auth_choice.selected { - display: table-row; -} diff --git a/addons/auth_openid/static/src/js/auth_openid.js b/addons/auth_openid/static/src/js/auth_openid.js index f8615481a40..c8e2c710350 100644 --- a/addons/auth_openid/static/src/js/auth_openid.js +++ b/addons/auth_openid/static/src/js/auth_openid.js @@ -14,6 +14,16 @@ instance.web.Login = instance.web.Login.extend({ self.$openid_selected_input = $(); self.$openid_selected_provider = null; + + // Hook auth_signup events. noop if module is not installed. + self.on('change:login_mode', self, function() { + var mode = self.get('login_mode') || 'default'; + if (mode !== 'default') { + return; + } + self.do_openid_select(self.$openid_selected_button, self.$openid_selected_provider, true); + }); + var openIdProvider = null; if (self.has_local_storage && self.remember_credentials) { @@ -21,12 +31,10 @@ instance.web.Login = instance.web.Login.extend({ } if (openIdProvider) { - $openid_selected_provider = openIdProvider; + self.$openid_selected_provider = openIdProvider; self.do_openid_select('a[href="#' + openIdProvider + '"]', openIdProvider, true); - if (self.has_local_storage && self.remember_credentials) { - self.$openid_selected_input.find('input').val(localStorage.getItem('openid-login')); - } + self.$openid_selected_input.find('input').val(localStorage.getItem('openid-login') || ''); } else { self.do_openid_select('a[data-url=""]', 'login,password', true); @@ -49,11 +57,12 @@ instance.web.Login = instance.web.Login.extend({ do_openid_select: function (button, provider, noautosubmit) { var self = this; + self.$('li[data-provider]').hide(); self.$openid_selected_button.add(self.$openid_selected_input).removeClass('selected'); self.$openid_selected_button = self.$el.find(button).addClass('selected'); var input = _(provider.split(',')).map(function(p) { return 'li[data-provider="'+p+'"]'; }).join(','); - self.$openid_selected_input = self.$el.find(input).addClass('selected'); + self.$openid_selected_input = self.$el.find(input).show().addClass('selected'); self.$openid_selected_input.find('input:first').focus(); self.$openid_selected_provider = (self.$openid_selected_button.attr('href') || '').substr(1); @@ -62,7 +71,7 @@ instance.web.Login = instance.web.Login.extend({ localStorage.setItem('openid-provider', self.$openid_selected_provider); } - if (!noautosubmit && self.$openid_selected_input.length == 0) { + if (!noautosubmit && self.$openid_selected_input.length === 0) { self.$el.find('form').submit(); } diff --git a/addons/auth_openid/static/src/xml/auth_openid.xml b/addons/auth_openid/static/src/xml/auth_openid.xml index 6a40439a012..9802b8adda5 100644 --- a/addons/auth_openid/static/src/xml/auth_openid.xml +++ b/addons/auth_openid/static/src/xml/auth_openid.xml @@ -4,7 +4,7 @@ -
      +
      • Password
      • Google
      • Google
      • @@ -14,34 +14,43 @@ - -
      • + +
      • Google Apps Domain
      • -
      • +
      • -
      • +
      • Username
      • -
      • +
      • -
      • +
      • OpenID URL
      • -
      • +
      • - + + this.each(function() { + var $i = $(this); + $i.add($i.prev()).attr('data-provider', 'password'); + }); + + this.each(function() { var $i = $(this), - dp = $i.find('input').attr('name'); - $i.add($i.prev()).attr('class', 'auth_choice').attr('data-provider', dp); + dp = $i.find('input').attr('name'), + $p = $i.prev(); + // $p may not be the correct label when auth_signup is installed. + while(($p.attr('data-modes') || 'default') !== 'default') { $p = $p.prev(); } + $i.add($p).attr('data-provider', dp); });