Mercurial > bugzilla-dashboard
comparison js/modules/app.js @ 68:6f5b5b404066
added a refresh button.
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Sun, 25 Apr 2010 10:58:25 -0700 |
parents | d0f5f87e0b0a |
children | 4ec651cc606e |
comparison
equal
deleted
inserted
replaced
67:d0f5f87e0b0a | 68:6f5b5b404066 |
---|---|
55 } | 55 } |
56 | 56 |
57 return this.__proto__.ajax.call(this, options); | 57 return this.__proto__.ajax.call(this, options); |
58 }, | 58 }, |
59 __proto__: require("bugzilla") | 59 __proto__: require("bugzilla") |
60 }; | |
61 }; | |
62 | |
63 Require.modules["app/commands"] = function(exports, require) { | |
64 var commands = {}; | |
65 | |
66 exports.get = function get(name) { | |
67 if (!(name in commands)) | |
68 throw new Error("command not found: " + name); | |
69 return commands[name]; | |
70 }; | |
71 | |
72 exports.register = function(options) { | |
73 if (options.name in commands) | |
74 throw new Error("command already registered: " + options.name); | |
75 commands[options.name] = options; | |
60 }; | 76 }; |
61 }; | 77 }; |
62 | 78 |
63 Require.modules["app/ui/login-form"] = function(exports, require) { | 79 Require.modules["app/ui/login-form"] = function(exports, require) { |
64 var $ = require("jQuery"); | 80 var $ = require("jQuery"); |
244 query.hide(); | 260 query.hide(); |
245 } | 261 } |
246 }); | 262 }); |
247 | 263 |
248 $("#header .menu li").click( | 264 $("#header .menu li").click( |
249 function openDialogForMenuItem(event) { | 265 function onMenuItemClick(event) { |
250 openDialog(this.getAttribute("data-dialog")); | 266 if (this.hasAttribute("data-command")) { |
267 var cmdName = this.getAttribute("data-command"); | |
268 require("app/commands").get(cmdName).execute(); | |
269 } else | |
270 openDialog(this.getAttribute("data-dialog")); | |
251 }); | 271 }); |
252 | 272 |
253 $(".dialog").click( | 273 $(".dialog").click( |
254 function dismissDialogOnOutsideClick(event) { | 274 function dismissDialogOnOutsideClick(event) { |
255 if (event.target == this) | 275 if (event.target == this) |
529 email2_type: "not_equals", | 549 email2_type: "not_equals", |
530 email2_assigned_to: 1, | 550 email2_assigned_to: 1, |
531 email2_reporter: 1}); | 551 email2_reporter: 1}); |
532 }; | 552 }; |
533 | 553 |
554 var refreshCommand = { | |
555 name: "refresh-dashboard", | |
556 execute: function execute() { | |
557 var user = require("app/login").get(); | |
558 if (user.isLoggedIn) | |
559 update(user.username); | |
560 } | |
561 }; | |
562 | |
534 exports.init = function init() { | 563 exports.init = function init() { |
564 require("app/commands").register(refreshCommand); | |
535 require("app/login").whenChanged( | 565 require("app/login").whenChanged( |
536 function changeSearchCriteria(user) { | 566 function changeSearchCriteria(user) { |
537 if (user.isLoggedIn) { | 567 if (user.isLoggedIn) { |
538 update(user.username); | 568 update(user.username); |
539 } | 569 } |