Mercurial > bugzilla-dashboard
annotate js/main.js @ 41:7a1162b1b7e7
Added app module
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Sat, 24 Apr 2010 17:56:20 -0700 |
parents | 1cf0cdbc18cc |
children | 0a1c7fec0af2 |
rev | line source |
---|---|
36
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
1 $(window).ready( |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
2 function() { |
37 | 3 const BASE_TITLE = document.title; |
4 | |
41 | 5 var require = Require.build(); |
6 | |
7 require("app/login").whenChanged( | |
8 function changeTitle(user) { | |
9 var title = BASE_TITLE; | |
10 | |
11 if (user.isLoggedIn) | |
12 title = user.username + "'s " + BASE_TITLE; | |
37 | 13 |
41 | 14 if (document.title != title) { |
15 document.title = title; | |
16 $("#header .title").text(title); | |
17 } | |
18 }); | |
37 | 19 |
41 | 20 require("app/login").whenChanged( |
21 function changeUI(user) { | |
22 if (user.isLoggedIn) { | |
23 $(".requires-no-login").hide(); | |
24 $(".requires-login").show(); | |
25 if (user.isAuthenticated) { | |
26 $(".requires-auth-login").show(); | |
27 } else { | |
28 $(".requires-auth-login").hide(); | |
29 } | |
37 | 30 } else { |
41 | 31 $(".requires-no-login").show(); |
32 $(".requires-login").hide(); | |
37 | 33 $(".requires-auth-login").hide(); |
34 } | |
41 | 35 }); |
37 | 36 |
37 $("#header .menu li").click( | |
41 | 38 function openDialog(event) { |
37 | 39 var dialog = $("#" + this.title); |
40 if (dialog.length == 0) | |
41 throw new Error("dialog not found: " + this.title); | |
42 dialog.fadeIn(); | |
43 }); | |
44 | |
41 | 45 $(".dialog").click( |
46 function dismissDialogOnOutsideClick(event) { | |
47 if (event.target == this) | |
48 $(this).fadeOut(); | |
49 }); | |
50 | |
37 | 51 $("#login-form").submit( |
52 function(event) { | |
53 event.preventDefault(); | |
41 | 54 require("app/login").set($("#login-username").val(), |
55 $("#login-password").val()); | |
56 $("#login").fadeOut(); | |
37 | 57 }); |
58 | |
41 | 59 require("app/login").set($("#login-username").val(), |
60 $("#login-password").val()); | |
61 if (!require("app/login").isLoggedIn()) | |
62 $("#login").fadeIn(); | |
36
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
63 }); |