diff --git a/browserid/static/dialog/controllers/page_controller.js b/browserid/static/dialog/controllers/page_controller.js index 98c91520b6e987eac6a06b4c5a1f9682bdabefec..0c621d11c7ecb9cb755021566468693be5f38f06 100644 --- a/browserid/static/dialog/controllers/page_controller.js +++ b/browserid/static/dialog/controllers/page_controller.js @@ -89,12 +89,17 @@ renderDialog: function(body, body_vars) { this.renderTemplates("#formWrap", body, body_vars); - $("#wait").stop().fadeOut(250); + $("#wait").stop().fadeOut(ANIMATION_TIME); }, renderWait: function(body, body_vars) { this.renderTemplates("#wait", body, body_vars); - $("#wait").stop().css('opacity', 1).hide().fadeIn(250); + $("#wait").stop().css('opacity', 1).hide().fadeIn(ANIMATION_TIME); + }, + + renderError: function(error_vars) { + this.renderTemplates("#error", "wait.ejs", error_vars); + $("#error").stop().css('opacity', 1).hide().fadeIn(ANIMATION_TIME); }, onSubmit: function(event) { @@ -135,14 +140,7 @@ * two fields, message, description. */ errorDialog: function(info) { - $("form").hide(); - - $("#error_dialog .title").text(info.message); - $("#error_dialog .content").text(info.description); - - $("body").removeClass("authenticated").addClass("error"); - - $("#error_dialog").fadeIn(ANIMATION_TIME); + this.renderError({title: info.message, message: info.description}); }, /** diff --git a/browserid/static/dialog/qunit.html b/browserid/static/dialog/qunit.html index 962facb3ddbab496a049edbc6f87d34661cb318c..108cc60fd8fbc23e0105384c865a527e58e19b92 100644 --- a/browserid/static/dialog/qunit.html +++ b/browserid/static/dialog/qunit.html @@ -13,13 +13,19 @@ <h2 id="qunit-userAgent"></h2> <div id="test-content"> <div id="page_controller"> + <div id="formWrap"> - <div class="contents"></div> + <div class="contents"></div> </div> <div id="wait"> - <div class="contents"></div> + <div class="contents"></div> + </div> + + <div id="error"> + <div class="contents"></div> </div> + </div> </div> <ol id="qunit-tests"></ol> diff --git a/browserid/static/dialog/test/qunit/controllers/page_controller_unit_test.js b/browserid/static/dialog/test/qunit/controllers/page_controller_unit_test.js index 776f361a18d387795a9b1b0574e890ebec2d9ce1..92ed30efcfb848c7a7a5ce79fb0913374b1fdc14 100644 --- a/browserid/static/dialog/test/qunit/controllers/page_controller_unit_test.js +++ b/browserid/static/dialog/test/qunit/controllers/page_controller_unit_test.js @@ -49,6 +49,7 @@ steal.plugins("jquery").then("/dialog/controllers/page_controller", function() { teardown: function() { el.find("#formWrap .contents").html(""); el.find("#wait .contents").html(""); + el.find("#error .contents").html(""); controller.destroy(); } }); @@ -99,5 +100,23 @@ steal.plugins("jquery").then("/dialog/controllers/page_controller", function() { ok(html.length, "with wait template specified, wait text is loaded"); }); + test("renderError does what it is meant to", function() { + controller = el.page({ + waitTemplate: waitTemplate, + waitVars: { + title: "Test title", + message: "Test message" + } + }).controller(); + + el.page("renderError", { + title: "error title", + message: "error message" + }); + + var html = el.find("#error .contents").html(); + ok(html.length, "with error template specified, error text is loaded"); + }); + }); diff --git a/browserid/views/dialog.ejs b/browserid/views/dialog.ejs index 36f990e6d0c89cd44c4184ac51c7a2e77c68b499..4bde9a26a0106b5e5f6664f4f357ef107b42cfc3 100644 --- a/browserid/views/dialog.ejs +++ b/browserid/views/dialog.ejs @@ -56,8 +56,6 @@ <section id="error"> <div class="table"> <div class="vertical contents"> - <h2 class="title"></h2> - <p class="content"></p> </div> </div> </section>