diff --git a/resources/static/dialog/controllers/add_email.js b/resources/static/dialog/controllers/add_email.js index 8711e69d1c9506c5478ae89a6e62fd312c8a31f5..c9a8c638ca85ddc7f7566fb1c80e8dd90fa85d89 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 94839750354a5f6a2e3c9d3ac60bf19232ab21f8..a955170a02bc17f24994a7dc9b72602efaecdc95 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 3c951706d90c0620e26766482d11a019b12ead1a..de7cb0e13e81f8dbdbb76525cd8de9a7ac68dad2 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 bbc085c17f3b189844e9c4ba61d21df3713a2a41..b18696f31079038a463fff7341c767e4901a2ab8 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() {