From bbf10bdd14fdfdf3891c6225e57b24b9bc82a1ba Mon Sep 17 00:00:00 2001 From: Nick Martin Date: Wed, 13 Jun 2012 22:56:56 -0700 Subject: [PATCH] Make the login buttons template detect and react to which accounts packages are enabled. --- packages/login-buttons/login-buttons.css | 6 ++-- packages/login-buttons/login-buttons.html | 11 ++++-- packages/login-buttons/login-buttons.js | 43 ++++++++++++++--------- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/packages/login-buttons/login-buttons.css b/packages/login-buttons/login-buttons.css index a094373e78..e708d0f9c2 100644 --- a/packages/login-buttons/login-buttons.css +++ b/packages/login-buttons/login-buttons.css @@ -1,10 +1,12 @@ -.login-header-email { + +#login-buttons .login-header { float: left; padding: 2px 7px; margin: 5px 0px 5px 5px; } -.login-button { + +#login-buttons .login-button { float:left; cursor: pointer; diff --git a/packages/login-buttons/login-buttons.html b/packages/login-buttons/login-buttons.html index a779187fdf..f41550f645 100644 --- a/packages/login-buttons/login-buttons.html +++ b/packages/login-buttons/login-buttons.html @@ -1,11 +1,16 @@ diff --git a/packages/login-buttons/login-buttons.js b/packages/login-buttons/login-buttons.js index a15a87ea39..226dd716b3 100644 --- a/packages/login-buttons/login-buttons.js +++ b/packages/login-buttons/login-buttons.js @@ -1,21 +1,7 @@ (function () { - Template.login_buttons.userEmail = function () { - var user = Meteor.user(); - if (!user || !user.emails || !user.emails[0]) - return ''; - return user.emails[0]; - }; - - Template.login_buttons.userName = function () { - var user = Meteor.user(); - if (!user || !user.name) - return ''; - return user.name; - }; - Template.login_buttons.events = { - 'click #login-buttons-fb-login': function () { + 'click #login-buttons-Facebook': function () { try { Meteor.loginWithFacebook(); } catch (e) { @@ -26,7 +12,7 @@ } }, - 'click #login-buttons-google-login': function () { + 'click #login-buttons-Google': function () { try { Meteor.loginWithGoogle(); } catch (e) { @@ -42,4 +28,29 @@ } }; + Template.login_buttons.services = function () { + var ret = []; + if (Meteor.accounts.facebook) + ret.push({name: 'Facebook'}); + if (Meteor.accounts.google) + ret.push({name: 'Google'}); + + return ret; + }; + + Template.login_buttons.userEmail = function () { + var user = Meteor.user(); + if (!user || !user.emails || !user.emails[0]) + return ''; + return user.emails[0]; + }; + + Template.login_buttons.userName = function () { + var user = Meteor.user(); + if (!user || !user.name) + return ''; + return user.name; + }; + + })();