| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 treestatus.fetchTreeStatus(treestatus.urlByName(name), statusSpan); | 216 treestatus.fetchTreeStatus(treestatus.urlByName(name), statusSpan); |
| 217 }, | 217 }, |
| 218 init: function() | 218 init: function() |
| 219 { | 219 { |
| 220 this.className = 'treestatus'; | 220 this.className = 'treestatus'; |
| 221 this.addStatus('blink'); | 221 this.addStatus('blink'); |
| 222 this.addStatus('chromium'); | 222 this.addStatus('chromium'); |
| 223 }, | 223 }, |
| 224 }); | 224 }); |
| 225 | 225 |
| 226 ui.StatusArea = base.extends('div', { | |
| 227 init: function() | |
| 228 { | |
| 229 // This is a Singleton. | |
| 230 if (ui.StatusArea._instance) | |
| 231 return ui.StatusArea._instance; | |
| 232 ui.StatusArea._instance = this; | |
| 233 | |
| 234 var kMinimumStatusAreaHeightPx = 60; | |
| 235 var dragger = document.createElement('div'); | |
| 236 var initialY; | |
| 237 var initialHeight; | |
| 238 dragger.className = 'dragger'; | |
| 239 $(dragger).mousedown(function(e) { | |
| 240 initialY = e.pageY; | |
| 241 initialHeight = $(this).height(); | |
| 242 $(document.body).addClass('status-resizing'); | |
| 243 }.bind(this)); | |
| 244 $(document.body).mouseup(function(e) { | |
| 245 initialY = 0; | |
| 246 initialHeight = 0; | |
| 247 $(document.body).removeClass('status-resizing'); | |
| 248 }); | |
| 249 $(document.body).mousemove(function(e) { | |
| 250 if (initialY) { | |
| 251 var newHeight = initialHeight + initialY - e.pageY; | |
| 252 if (newHeight >= kMinimumStatusAreaHeightPx) | |
| 253 $(this).height(newHeight); | |
| 254 e.preventDefault(); | |
| 255 } | |
| 256 }.bind(this)); | |
| 257 this.appendChild(dragger); | |
| 258 | |
| 259 this.contents = document.createElement('div'); | |
| 260 this.contents.className = 'contents'; | |
| 261 this.appendChild(this.contents); | |
| 262 | |
| 263 this.className = 'status'; | |
| 264 document.body.appendChild(this); | |
| 265 this._currentId = 0; | |
| 266 this._unfinishedIds = {}; | |
| 267 | |
| 268 this.appendChild(new ui.actions.List([new ui.actions.Close()])); | |
| 269 $(this).bind('close', this.close.bind(this)); | |
| 270 | |
| 271 var processing = document.createElement('progress'); | |
| 272 processing.className = 'process-text'; | |
| 273 processing.textContent = 'Processing...'; | |
| 274 this.appendChild(processing); | |
| 275 }, | |
| 276 close: function() | |
| 277 { | |
| 278 this.style.visibility = 'hidden'; | |
| 279 Array.prototype.forEach.call(this.querySelectorAll('.status-content'), f
unction(node) { | |
| 280 node.parentNode.removeChild(node); | |
| 281 }); | |
| 282 }, | |
| 283 addMessage: function(id, message) | |
| 284 { | |
| 285 this.style.visibility = 'visible'; | |
| 286 $(this).addClass('processing'); | |
| 287 | |
| 288 var element = document.createElement('div'); | |
| 289 $(element).addClass('message').text(message); | |
| 290 | |
| 291 var content = this.querySelector('#' + id); | |
| 292 if (!content) { | |
| 293 content = document.createElement('div'); | |
| 294 content.id = id; | |
| 295 content.className = 'status-content'; | |
| 296 this.contents.appendChild(content); | |
| 297 } | |
| 298 | |
| 299 content.appendChild(element); | |
| 300 if (element.offsetTop < this.scrollTop || element.offsetTop + element.of
fsetHeight > this.scrollTop + this.offsetHeight) | |
| 301 this.scrollTop = element.offsetTop; | |
| 302 }, | |
| 303 // FIXME: It's unclear whether this code could live here or in a controller. | |
| 304 addFinalMessage: function(id, message) | |
| 305 { | |
| 306 this.addMessage(id, message); | |
| 307 | |
| 308 delete this._unfinishedIds[id]; | |
| 309 if (!Object.keys(this._unfinishedIds).length) | |
| 310 $(this).removeClass('processing'); | |
| 311 }, | |
| 312 newId: function() { | |
| 313 var id = 'status-content-' + ++this._currentId; | |
| 314 this._unfinishedIds[id] = 1; | |
| 315 return id; | |
| 316 } | |
| 317 }); | |
| 318 | |
| 319 ui.revisionDetails = base.extends('span', { | 226 ui.revisionDetails = base.extends('span', { |
| 320 // We only support 2 levels of visual escalation levels: warning and critica
l. | 227 // We only support 2 levels of visual escalation levels: warning and critica
l. |
| 321 warnRollRevisionSpanThreshold: 45, | 228 warnRollRevisionSpanThreshold: 45, |
| 322 criticalRollRevisionSpanThreshold: 80, | 229 criticalRollRevisionSpanThreshold: 80, |
| 323 classNameForUrgencyLevel: function(rollRevisionSpan) { | 230 classNameForUrgencyLevel: function(rollRevisionSpan) { |
| 324 if (rollRevisionSpan < this.criticalRollRevisionSpanThreshold) | 231 if (rollRevisionSpan < this.criticalRollRevisionSpanThreshold) |
| 325 return "warning"; | 232 return "warning"; |
| 326 return "critical"; | 233 return "critical"; |
| 327 }, | 234 }, |
| 328 updateUI: function(totRevision) { | 235 updateUI: function(totRevision) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 // We want this feature, but need to fetch the lastBlinkRollRevision via
the interwebs. | 313 // We want this feature, but need to fetch the lastBlinkRollRevision via
the interwebs. |
| 407 // Promise.all([checkout.lastBlinkRollRevision(), rollbot.fetchCurrentRo
ll()]).then(function(results) { | 314 // Promise.all([checkout.lastBlinkRollRevision(), rollbot.fetchCurrentRo
ll()]).then(function(results) { |
| 408 // theSpan.lastRolledRevision = results[0]; | 315 // theSpan.lastRolledRevision = results[0]; |
| 409 // theSpan.roll = results[1]; | 316 // theSpan.roll = results[1]; |
| 410 // theSpan.updateUI(totRevision); | 317 // theSpan.updateUI(totRevision); |
| 411 // }); | 318 // }); |
| 412 } | 319 } |
| 413 }); | 320 }); |
| 414 | 321 |
| 415 })(); | 322 })(); |
| OLD | NEW |