Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 function getElement(e) | |
| 2 { | |
| 3 if (typeof e == "string") | |
| 4 e = document.getElementById(e); | |
| 5 return e; | |
| 6 } | |
| 7 | |
| 8 function isBoxOfColor(givenColor) | |
| 9 { | |
| 10 return function(e, quiet) | |
| 11 { | |
| 12 e = getElement(e); | |
| 13 var color = window.getComputedStyle(e).backgroundColor; | |
| 14 if (color == givenColor) | |
| 15 return true; | |
| 16 if (!quiet) | |
| 17 testFailed('Box had backgroundColor: ' + color); | |
| 18 return false; | |
| 19 } | |
| 20 } | |
| 21 | |
| 22 function elementCenter(e) | |
|
tdresser
2014/03/14 14:24:51
Where is this used?
Zeeshan Qureshi
2014/03/14 14:52:21
Oh I was using this in another CL and decided to s
| |
| 23 { | |
| 24 e = getElement(e); | |
| 25 return { | |
| 26 x: e.offsetLeft + e.offsetWidth / 2, | |
| 27 y: e.offsetTop + e.offsetHeight / 2 | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 // Generate methods | |
|
tdresser
2014/03/14 14:24:51
Could switch to "boxShouldBeOfColor," which would
Zeeshan Qureshi
2014/03/14 14:52:21
I'm not quite following this, wouldn't the test ou
| |
| 32 window.isBoxDefault = isBoxOfColor("rgb(0, 0, 255)"); | |
| 33 window.isBoxHovered = isBoxOfColor("rgb(255, 0, 0)"); | |
| 34 window.isBoxActive = isBoxOfColor("rgb(0, 255, 0)"); | |
| 35 window.isBoxHoverActive = isBoxOfColor("rgb(255, 255, 0)"); | |
|
tdresser
2014/03/14 14:24:51
How about "isBoxHoveredAndActive"?
Zeeshan Qureshi
2014/03/14 14:52:21
That sounds better.
| |
| OLD | NEW |