Chromium Code Reviews| 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 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 var kMaxTestsPerGroup = 3; | 31 var kMaxTestsPerGroup = 3; |
| 32 | 32 |
| 33 ui.notifications.Stream = base.extends('ol', { | 33 ui.notifications.Stream = base.extends('ol', { |
| 34 init: function() | 34 init: function() |
| 35 { | 35 { |
| 36 this.className = 'notifications'; | 36 this.className = 'notifications'; |
| 37 }, | 37 }, |
| 38 add: function(notification) | 38 add: function(notification) |
| 39 { | 39 { |
| 40 var insertBefore = null; | 40 this.appendChild(notification); |
|
ojan
2014/06/14 18:42:11
Now that Notification doesn't have index, we would
| |
| 41 Array.prototype.some.call(this.children, function(existingNotification) { | |
| 42 if (existingNotification.index() < notification.index()) { | |
| 43 insertBefore = existingNotification; | |
| 44 return true; | |
| 45 } | |
| 46 }); | |
| 47 this.insertBefore(notification, insertBefore); | |
| 48 return notification; | 41 return notification; |
| 49 } | 42 } |
| 50 }); | 43 }); |
| 51 | 44 |
| 52 ui.notifications.Notification = base.extends('li', { | 45 ui.notifications.Notification = base.extends('li', { |
| 53 init: function() | 46 init: function() |
| 54 { | 47 { |
| 55 this._how = this.appendChild(document.createElement('div')); | 48 this._how = this.appendChild(document.createElement('div')); |
| 56 this._how.className = 'how'; | 49 this._how.className = 'how'; |
| 57 this._what = this.appendChild(document.createElement('div')); | 50 this._what = this.appendChild(document.createElement('div')); |
| 58 this._what.className = 'what'; | 51 this._what.className = 'what'; |
| 59 this._index = 0; | 52 this._index = 0; |
| 60 $(this).hide().fadeIn('fast'); | 53 $(this).hide().fadeIn('fast'); |
| 61 }, | 54 }, |
| 62 index: function() | |
| 63 { | |
| 64 return this._index; | |
| 65 }, | |
| 66 setIndex: function(index) | |
| 67 { | |
| 68 this._index = index; | |
| 69 }, | |
| 70 dismiss: function() | 55 dismiss: function() |
| 71 { | 56 { |
| 72 // FIXME: These fade in/out effects are lame. | 57 // FIXME: These fade in/out effects are lame. |
| 73 $(this).fadeOut(function() | 58 $(this).fadeOut(function() |
| 74 { | 59 { |
| 75 this.parentNode && this.parentNode.removeChild(this); | 60 this.parentNode && this.parentNode.removeChild(this); |
| 76 }); | 61 }); |
| 77 }, | 62 }, |
| 78 }); | 63 }); |
| 79 | 64 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 return this._revision == revision; | 114 return this._revision == revision; |
| 130 }, | 115 }, |
| 131 _addDetail: function(part, commitData, linkFunction) | 116 _addDetail: function(part, commitData, linkFunction) |
| 132 { | 117 { |
| 133 var content = commitData[part]; | 118 var content = commitData[part]; |
| 134 if (!content) | 119 if (!content) |
| 135 return; | 120 return; |
| 136 | 121 |
| 137 var span = this._details.appendChild(document.createElement('span')); | 122 var span = this._details.appendChild(document.createElement('span')); |
| 138 span.className = part; | 123 span.className = part; |
| 139 | 124 |
| 140 if (linkFunction) { | 125 if (linkFunction) { |
| 141 var parts = $.isArray(content) ? content : [content]; | 126 var parts = $.isArray(content) ? content : [content]; |
| 142 parts.forEach(function(item, index) { | 127 parts.forEach(function(item, index) { |
| 143 if (index > 0) | 128 if (index > 0) |
| 144 span.appendChild(document.createTextNode(', ')); | 129 span.appendChild(document.createTextNode(', ')); |
| 145 var link = ui.createLinkNode(linkFunction(item), item); | 130 var link = ui.createLinkNode(linkFunction(item), item); |
| 146 link.className = part + '-item'; | 131 link.className = part + '-item'; |
| 147 span.appendChild(link); | 132 span.appendChild(link); |
| 148 }); | 133 }); |
| 149 } else { | 134 } else { |
| 150 span.textContent = content; | 135 span.textContent = content; |
| 151 } | 136 } |
| 152 } | 137 } |
| 153 }); | 138 }); |
| 154 | 139 |
| 155 ui.notifications.Failure = base.extends(ui.notifications.Notification, { | 140 ui.notifications.Failure = base.extends(ui.notifications.Notification, { |
| 156 init: function() | 141 init: function() |
| 157 { | 142 { |
| 158 this._time = this._how.appendChild(new ui.RelativeTime()); | |
| 159 this._problem = this._what.appendChild(document.createElement('div')); | 143 this._problem = this._what.appendChild(document.createElement('div')); |
| 160 this._problem.className = 'problem'; | 144 this._problem.className = 'problem'; |
| 161 this._effects = this._problem.appendChild(document.createElement('ul')); | 145 this._effects = this._problem.appendChild(document.createElement('ul')); |
| 162 this._effects.className = 'effects'; | 146 this._effects.className = 'effects'; |
| 163 this._causes = this._what.appendChild(document.createElement('ul')); | 147 this._causes = this._what.appendChild(document.createElement('ul')); |
| 164 this._causes.className = 'causes'; | 148 this._causes.className = 'causes'; |
| 165 }, | 149 }, |
| 166 date: function() | |
| 167 { | |
| 168 return this._time.date; | |
| 169 } | |
| 170 }); | 150 }); |
| 171 | 151 |
| 172 ui.notifications.FailingTests = base.extends(ui.notifications.Failure, { | 152 ui.notifications.FailingTests = base.extends(ui.notifications.Failure, { |
| 173 init: function() { | 153 init: function() { |
| 174 // FIXME: Convert actions to a link from test! | 154 // FIXME: Convert actions to a link from test! |
| 175 this._problem.appendChild(new ui.actions.List([ | 155 this._problem.appendChild(new ui.actions.List([ |
| 176 new ui.actions.Examine().makeDefault(), | 156 new ui.actions.Examine().makeDefault(), |
| 177 new ui.actions.Rebaseline(), | 157 new ui.actions.Rebaseline(), |
| 178 ])); | 158 ])); |
| 179 this._testNameList = []; | 159 this._testNameList = []; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 $(this._causes).children().each(function() { | 219 $(this._causes).children().each(function() { |
| 240 if (this.hasRevision(commitData.revision)) | 220 if (this.hasRevision(commitData.revision)) |
| 241 return; | 221 return; |
| 242 $(this).detach(); | 222 $(this).detach(); |
| 243 }); | 223 }); |
| 244 }, | 224 }, |
| 245 addCommitData: function(commitData) | 225 addCommitData: function(commitData) |
| 246 { | 226 { |
| 247 if (this._commitDataPinned) | 227 if (this._commitDataPinned) |
| 248 return null; | 228 return null; |
| 249 var commitDataDate = new Date(commitData.time); | |
| 250 if (this._time.date > commitDataDate); { | |
|
ojan
2014/06/14 18:42:11
This looks like non-dead code, but we never call s
| |
| 251 this.setIndex(commitDataDate.getTime()); | |
| 252 this._time.setDate(commitDataDate); | |
| 253 } | |
| 254 return this._causes.appendChild(new ui.notifications.SuspiciousCommit(co mmitData)); | 229 return this._causes.appendChild(new ui.notifications.SuspiciousCommit(co mmitData)); |
| 255 } | 230 } |
| 256 }); | 231 }); |
| 257 | 232 |
| 258 ui.notifications.BuildersFailing = base.extends(ui.notifications.Failure, { | 233 ui.notifications.BuildersFailing = base.extends(ui.notifications.Failure, { |
| 259 init: function(message) | 234 init: function(message) |
| 260 { | 235 { |
| 261 if (message) | 236 if (message) |
| 262 this._problem.insertBefore(document.createTextNode(message + ':'), t his._problem.firstChild); | 237 this._problem.insertBefore(document.createTextNode(message + ':'), t his._problem.firstChild); |
| 263 }, | 238 }, |
| 264 setFailingBuilders: function(failuresList) | 239 setFailingBuilders: function(failuresList) |
| 265 { | 240 { |
| 266 $(this._effects).empty().append(Object.keys(failuresList).map(function(b uilderName) { | 241 $(this._effects).empty().append(Object.keys(failuresList).map(function(b uilderName) { |
| 267 var effect = document.createElement('li'); | 242 var effect = document.createElement('li'); |
| 268 effect.className = 'builder'; | 243 effect.className = 'builder'; |
| 269 effect.appendChild(new ui.failures.Builder(builderName, failuresList [builderName])); | 244 effect.appendChild(new ui.failures.Builder(builderName, failuresList [builderName])); |
| 270 return effect; | 245 return effect; |
| 271 })); | 246 })); |
| 272 } | 247 } |
| 273 }); | 248 }); |
| 274 | 249 |
| 275 })(); | 250 })(); |
| OLD | NEW |