diff --git a/browserid/static/dialog/controllers/page_controller.js b/browserid/static/dialog/controllers/page_controller.js index 12e2ac182edc8cb6e439e6ed584141ae44a7bef4..98c91520b6e987eac6a06b4c5a1f9682bdabefec 100644 --- a/browserid/static/dialog/controllers/page_controller.js +++ b/browserid/static/dialog/controllers/page_controller.js @@ -83,9 +83,7 @@ if (body) { var bodyHtml = $.View("//dialog/views/" + body, body_vars); target = $(target + " .contents"); - target.html(bodyHtml);//.hide().fadeIn(ANIMATION_TIME, function() { - target.find("input").eq(0).focus(); - //}); + target.html(bodyHtml).find("input").eq(0).focus(); } }, 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 ca66171fff628fc27a00f27bd52cb5b65efc294e..776f361a18d387795a9b1b0574e890ebec2d9ce1 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 @@ -37,7 +37,9 @@ steal.plugins("jquery").then("/dialog/controllers/page_controller", function() { "use strict"; - var controller, el; + var controller, el, + bodyTemplate = "testBodyTemplate.ejs", + waitTemplate = "wait.ejs"; module("PageController", { setup: function() { @@ -61,9 +63,9 @@ steal.plugins("jquery").then("/dialog/controllers/page_controller", function() { equal(html, "", "with no template specified, no text is loaded"); }); - test("page controller with body template renders in #formWrap > form", function() { + test("page controller with body template renders in #formWrap .contents", function() { controller = el.page({ - bodyTemplate: "wait.ejs", + bodyTemplate: bodyTemplate, bodyVars: { title: "Test title", message: "Test message" @@ -73,13 +75,17 @@ steal.plugins("jquery").then("/dialog/controllers/page_controller", function() { var html = el.find("#formWrap .contents").html(); ok(html.length, "with template specified, form text is loaded"); + + var input = el.find("input").eq(0); + ok(input.is(":focus"), "make sure the first input is focused"); + html = el.find("#wait .contents").html(); equal(html, "", "with body template specified, wait text is not loaded"); }); test("page controller with wait template renders in #wait .contents", function() { controller = el.page({ - waitTemplate: "wait.ejs", + waitTemplate: waitTemplate, waitVars: { title: "Test title", message: "Test message" diff --git a/browserid/static/dialog/test/qunit/qunit.js b/browserid/static/dialog/test/qunit/qunit.js index 56ba798c52779ea972cd3f667e81ee3b3cf58ca3..435935bdb970b11177eb07a37efc7aaa60a63e99 100644 --- a/browserid/static/dialog/test/qunit/qunit.js +++ b/browserid/static/dialog/test/qunit/qunit.js @@ -10,6 +10,7 @@ steal("/dialog/resources/browserid.js", "jquery/controller/view", "jquery/view/ejs", "funcunit/qunit") + .views('testBodyTemplate.ejs') .views('wait.ejs') .then("browserid_unit_test") .then("controllers/page_controller_unit_test") diff --git a/browserid/static/dialog/views/testBodyTemplate.ejs b/browserid/static/dialog/views/testBodyTemplate.ejs new file mode 100644 index 0000000000000000000000000000000000000000..77a06e46bbf5acedeb0fbb140b6f289c40389a8b --- /dev/null +++ b/browserid/static/dialog/views/testBodyTemplate.ejs @@ -0,0 +1,2 @@ +<input type="text" value="" /> +