Mercurial > bugzilla-dashboard
comparison js/modules/app.js @ 63:88b856b1353b
added file-bug dialog
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Sun, 25 Apr 2010 08:30:50 -0700 |
parents | 68b4c80e884f |
children | a196cc29fffb |
comparison
equal
deleted
inserted
replaced
62:68b4c80e884f | 63:88b856b1353b |
---|---|
89 | 89 |
90 require("app/ui").whenStarted( | 90 require("app/ui").whenStarted( |
91 function maybeShowLoginForm() { | 91 function maybeShowLoginForm() { |
92 if (!require("app/login").get().isLoggedIn) | 92 if (!require("app/login").get().isLoggedIn) |
93 $("#login").fadeIn(); | 93 $("#login").fadeIn(); |
94 }); | |
95 | |
96 exports.init = function init() { | |
97 }; | |
98 }; | |
99 | |
100 Require.modules["app/ui/file-bug"] = function(exports, require) { | |
101 const EM_DASH = "\u2014"; | |
102 | |
103 var $ = require("jQuery"); | |
104 var cache = require("cache"); | |
105 var bugzilla = require("app/bugzilla-auth").Bugzilla; | |
106 var window = require("window"); | |
107 var config = cache.get("configuration"); | |
108 var needToFetchConfig = config ? false : true; | |
109 var categories; | |
110 var queuedRespond; | |
111 | |
112 function buildCategories() { | |
113 categories = []; | |
114 for (product in config.product) | |
115 for (component in config.product[product].component) | |
116 categories.push(product + EM_DASH + component); | |
117 } | |
118 | |
119 function fetchConfig() { | |
120 bugzilla.ajax({url: "/configuration", | |
121 data: {flags: 0}, | |
122 success: function(result) { | |
123 config = result; | |
124 cache.set("configuration", result); | |
125 if (queuedRespond) | |
126 queuedRespond(); | |
127 }}); | |
128 } | |
129 | |
130 var categoryOptions = { | |
131 minLength: 2, | |
132 source: function(request, response) { | |
133 function respond() { | |
134 queuedRespond = null; | |
135 | |
136 var suggs = []; | |
137 var terms = request.term.split(" "); | |
138 | |
139 if (!categories) | |
140 buildCategories(); | |
141 | |
142 categories.forEach( | |
143 function(category) { | |
144 for (var i = 0; i < terms.length; i++) | |
145 if (!category.match(terms[i], "i")) | |
146 return; | |
147 suggs.push(category); | |
148 }); | |
149 | |
150 response(suggs); | |
151 }; | |
152 | |
153 if (!config) { | |
154 queuedRespond = respond; | |
155 if (needToFetchConfig) { | |
156 needToFetchConfig = false; | |
157 fetchConfig(); | |
158 } | |
159 } else | |
160 respond(); | |
161 } | |
162 }; | |
163 | |
164 $("input#category").autocomplete(categoryOptions); | |
165 $("#file-bug").submit( | |
166 function(event) { | |
167 event.preventDefault(); | |
168 var parts = $("input#category").val().split(EM_DASH); | |
169 window.open(bugzilla.BASE_UI_URL + "/enter_bug.cgi?" + | |
170 "product=" + escape(parts[0]) + "&" + | |
171 "component=" + escape(parts[1])); | |
94 }); | 172 }); |
95 | 173 |
96 exports.init = function init() { | 174 exports.init = function init() { |
97 }; | 175 }; |
98 }; | 176 }; |
217 setupDocumentTitleChanger(document); | 295 setupDocumentTitleChanger(document); |
218 | 296 |
219 require("app/ui/dashboard").init(); | 297 require("app/ui/dashboard").init(); |
220 require("app/ui/login-form").init(); | 298 require("app/ui/login-form").init(); |
221 require("app/ui/find-user").init(); | 299 require("app/ui/find-user").init(); |
300 require("app/ui/file-bug").init(); | |
222 require("app/ui/hash").init(document); | 301 require("app/ui/hash").init(document); |
223 | 302 |
224 startupCallbacks.forEach(function(cb) { cb(); }); | 303 startupCallbacks.forEach(function(cb) { cb(); }); |
225 startupCallbacks.splice(0); | 304 startupCallbacks.splice(0); |
226 }; | 305 }; |