From 9486d273d1b01c91728d61774e514fc0a9d4f6b3 Mon Sep 17 00:00:00 2001 From: Shane Tomlinson <stomlinson@mozilla.com> Date: Wed, 14 Mar 2012 13:37:34 +0000 Subject: [PATCH] Adding the TOS/PP to the Add Email screen. issue #1316 --- resources/static/dialog/controllers/add_email.js | 8 ++++++-- resources/static/dialog/resources/state.js | 5 +++++ resources/static/dialog/views/add_email.ejs | 14 ++++++++++++++ .../static/test/cases/controllers/add_email.js | 14 +++++++++++--- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/resources/static/dialog/controllers/add_email.js b/resources/static/dialog/controllers/add_email.js index 8711e69d1..c9a8c638c 100644 --- a/resources/static/dialog/controllers/add_email.js +++ b/resources/static/dialog/controllers/add_email.js @@ -32,9 +32,13 @@ BrowserID.Modules.AddEmail = (function() { var Module = bid.Modules.PageModule.extend({ start: function(options) { - var self=this; + var self=this, + templateData = helpers.extend({}, options, { + privacy_url: options.privacyURL || null, + tos_url: options.tosURL || null + }); - self.renderDialog("add_email", options); + self.renderDialog("add_email", templateData); self.click("#cancel", cancelAddEmail); Module.sc.start.call(self, options); diff --git a/resources/static/dialog/resources/state.js b/resources/static/dialog/resources/state.js index 948397503..a955170a0 100644 --- a/resources/static/dialog/resources/state.js +++ b/resources/static/dialog/resources/state.js @@ -253,6 +253,11 @@ BrowserID.State = (function() { }); subscribe("add_email", function(msg, info) { + info = helpers.extend(info || {}, { + privacyURL: self.privacyURL, + tosURL: self.tosURL + }); + startState("doAddEmail", info); }); diff --git a/resources/static/dialog/views/add_email.ejs b/resources/static/dialog/views/add_email.ejs index 3c951706d..de7cb0e13 100644 --- a/resources/static/dialog/views/add_email.ejs +++ b/resources/static/dialog/views/add_email.ejs @@ -30,8 +30,22 @@ </ul> <div class="submit cf"> + <% if (privacy_url && tos_url) { %> + <p class="tospp"> + <%= format( + gettext('By clicking %s, you confirm that you accept this site\'s <a %s>Terms of Use</a> and <a %s>Privacy Policy</a>.'), + [ gettext('add'), + format(' href="%s" target="_new"', [tos_url]), + format(' href="%s" target="_new"', [privacy_url]) + ]) %> + </p> + <p> + <% } %> <button id="addNewEmail"><%= gettext('add') %></button> <a href="#" id="cancel"><%= gettext('cancel') %></a> + <% if (privacy_url && tos_url) { %> + </p> + <% } %> </div> </div> diff --git a/resources/static/test/cases/controllers/add_email.js b/resources/static/test/cases/controllers/add_email.js index bbc085c17..b18696f31 100644 --- a/resources/static/test/cases/controllers/add_email.js +++ b/resources/static/test/cases/controllers/add_email.js @@ -11,7 +11,6 @@ bid = BrowserID, user = bid.User, xhr = bid.Mocks.xhr, - //provisioning = bid.Mocks.Provisioning, modules = bid.Modules, testHelpers = bid.TestHelpers, register = testHelpers.register; @@ -38,13 +37,22 @@ function createController(options) { controller = modules.AddEmail.create(); - controller.start(options); + controller.start(options || {}); } + test("privacyURL and tosURL specified - show TOS/PP", function() { + equal($(".tospp").length, 0, "tospp has not yet been added to the DOM"); + createController({ + privacyURL: "http://testuser.com/priv.html", + tosURL: "http://testuser.com/tos.html", + }); + + equal($(".tospp").length, 1, "tospp has been added to the DOM"); + }); + test("addEmail with specified email address - fill in email", function() { createController({ email: "testuser@testuser.com" }); ok($("#newEmail").val(), "testuser@testuser.com", "email prepopulated"); - }); asyncTest("addEmail with valid unknown secondary email", function() { -- GitLab