Mercurial > bugzilla-dashboard
diff js/modules/app.js @ 89:ee0a4597c067
Added a really basic error log that gets populated when the wrong username/pass is entered. Also, the username/password prompt for login now emphasizes the fact that it is a bugzilla login.
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Mon, 26 Apr 2010 17:45:02 -0700 |
parents | 03bf0a1b85da |
children | d48599d7a9ae |
line wrap: on
line diff
--- a/js/modules/app.js Mon Apr 26 16:41:32 2010 -0700 +++ b/js/modules/app.js Mon Apr 26 17:45:02 2010 -0700 @@ -54,7 +54,43 @@ }; }; +Require.modules["errors"] = function(exports, require) { + var $ = require("jQuery"); + + var errors = $("#errors"); + var messages = $("#templates .errors"); + var lastError = null; + + exports.log = function log(name) { + var message = messages.find("." + name); + if (!message.length) { + exports.log("unknown-error"); + return; + } + if (lastError == message.get(0)) + return; + lastError = message.get(0); + + message = message.clone(); + errors.append(message); + if (errors.children().length == 1) + errors.fadeIn(); + else + message.fadeIn(); + }; +}; + Require.modules["app/bugzilla-auth"] = function(exports, require) { + function onLoad(event) { + var xhr = event.target; + console.log("load", xhr); + } + + function onError(event) { + var xhr = event.target; + require("errors").log("bugzilla-api-error"); + } + exports.create = function(Bugzilla) { function AuthenticatedBugzilla() { this.ajax = function ajax(options) { @@ -67,7 +103,12 @@ options.data.password = user.password; } - return Bugzilla.ajax.call(this, options); + var xhr = Bugzilla.ajax.call(this, options); + + xhr.addEventListener("load", onLoad, false); + xhr.addEventListener("error", onError, false); + + return xhr; }; }