diff js/modules/app.js @ 65:8294f3d1efee

Startup dialog gains focus on open
author Atul Varma <avarma@mozilla.com>
date Sun, 25 Apr 2010 08:52:28 -0700
parents a196cc29fffb
children d0f5f87e0b0a
line wrap: on
line diff
--- a/js/modules/app.js	Sun Apr 25 08:45:26 2010 -0700
+++ b/js/modules/app.js	Sun Apr 25 08:52:28 2010 -0700
@@ -87,12 +87,6 @@
       return "";
     });
 
-  require("app/ui").whenStarted(
-    function maybeShowLoginForm() {
-      if (!require("app/login").get().isLoggedIn)
-        $("#login").fadeIn();
-    });
-
   exports.init = function init() {
   };
 };
@@ -218,7 +212,6 @@
 
 Require.modules["app/ui"] = function(exports, require) {
   var $ = require("jQuery");
-  var startupCallbacks = [];
 
   require("app/login").whenChanged(
     function changeUI(user) {
@@ -253,15 +246,8 @@
     });
 
   $("#header .menu li").click(
-    function openDialog(event) {
-      var name = this.getAttribute("data-dialog");
-      var dialog = $("#" + name);
-      if (dialog.length == 0)
-        throw new Error("dialog not found: " + name);
-      dialog.fadeIn(
-        function() {
-          dialog.find("input:first").focus();
-        });
+    function openDialogForMenuItem(event) {
+      openDialog(this.getAttribute("data-dialog"));
     });
 
   $(".dialog").click(
@@ -297,8 +283,14 @@
       });
   };
 
-  exports.whenStarted = function whenStarted(cb) {
-    startupCallbacks.push(cb);
+  function openDialog(name) {
+    var dialog = $("#" + name);
+    if (dialog.length == 0)
+      throw new Error("dialog not found: " + name);
+    dialog.fadeIn(
+      function() {
+        dialog.find("input:first").focus();
+      });
   };
 
   exports.init = function init(document) {
@@ -310,8 +302,8 @@
     require("app/ui/file-bug").init();
     require("app/ui/hash").init(document);
 
-    startupCallbacks.forEach(function(cb) { cb(); });
-    startupCallbacks.splice(0);
+    if (!require("app/login").get().isLoggedIn)
+      openDialog("login");
   };
 };