comparison 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
comparison
equal deleted inserted replaced
64:a196cc29fffb 65:8294f3d1efee
83 require("app/login").setPasswordProvider( 83 require("app/login").setPasswordProvider(
84 function maybeGetCachedPasswordFromForm(username) { 84 function maybeGetCachedPasswordFromForm(username) {
85 if (cachedUsername == username) 85 if (cachedUsername == username)
86 return cachedPassword; 86 return cachedPassword;
87 return ""; 87 return "";
88 });
89
90 require("app/ui").whenStarted(
91 function maybeShowLoginForm() {
92 if (!require("app/login").get().isLoggedIn)
93 $("#login").fadeIn();
94 }); 88 });
95 89
96 exports.init = function init() { 90 exports.init = function init() {
97 }; 91 };
98 }; 92 };
216 }; 210 };
217 }; 211 };
218 212
219 Require.modules["app/ui"] = function(exports, require) { 213 Require.modules["app/ui"] = function(exports, require) {
220 var $ = require("jQuery"); 214 var $ = require("jQuery");
221 var startupCallbacks = [];
222 215
223 require("app/login").whenChanged( 216 require("app/login").whenChanged(
224 function changeUI(user) { 217 function changeUI(user) {
225 var show = { 218 var show = {
226 "no-login": false, 219 "no-login": false,
251 query.hide(); 244 query.hide();
252 } 245 }
253 }); 246 });
254 247
255 $("#header .menu li").click( 248 $("#header .menu li").click(
256 function openDialog(event) { 249 function openDialogForMenuItem(event) {
257 var name = this.getAttribute("data-dialog"); 250 openDialog(this.getAttribute("data-dialog"));
258 var dialog = $("#" + name);
259 if (dialog.length == 0)
260 throw new Error("dialog not found: " + name);
261 dialog.fadeIn(
262 function() {
263 dialog.find("input:first").focus();
264 });
265 }); 251 });
266 252
267 $(".dialog").click( 253 $(".dialog").click(
268 function dismissDialogOnOutsideClick(event) { 254 function dismissDialogOnOutsideClick(event) {
269 if (event.target == this) 255 if (event.target == this)
295 $("#header .title").text(title); 281 $("#header .title").text(title);
296 } 282 }
297 }); 283 });
298 }; 284 };
299 285
300 exports.whenStarted = function whenStarted(cb) { 286 function openDialog(name) {
301 startupCallbacks.push(cb); 287 var dialog = $("#" + name);
288 if (dialog.length == 0)
289 throw new Error("dialog not found: " + name);
290 dialog.fadeIn(
291 function() {
292 dialog.find("input:first").focus();
293 });
302 }; 294 };
303 295
304 exports.init = function init(document) { 296 exports.init = function init(document) {
305 setupDocumentTitleChanger(document); 297 setupDocumentTitleChanger(document);
306 298
308 require("app/ui/login-form").init(); 300 require("app/ui/login-form").init();
309 require("app/ui/find-user").init(); 301 require("app/ui/find-user").init();
310 require("app/ui/file-bug").init(); 302 require("app/ui/file-bug").init();
311 require("app/ui/hash").init(document); 303 require("app/ui/hash").init(document);
312 304
313 startupCallbacks.forEach(function(cb) { cb(); }); 305 if (!require("app/login").get().isLoggedIn)
314 startupCallbacks.splice(0); 306 openDialog("login");
315 }; 307 };
316 }; 308 };
317 309
318 Require.modules["app/ui/hash"] = function(exports, require) { 310 Require.modules["app/ui/hash"] = function(exports, require) {
319 function usernameFromHash(location) { 311 function usernameFromHash(location) {