aboutsummaryrefslogtreecommitdiff
path: root/exampleData/ruleSets/colorRules.json
diff options
context:
space:
mode:
Diffstat (limited to 'exampleData/ruleSets/colorRules.json')
-rw-r--r--exampleData/ruleSets/colorRules.json170
1 files changed, 79 insertions, 91 deletions
diff --git a/exampleData/ruleSets/colorRules.json b/exampleData/ruleSets/colorRules.json
index c2862e4..1cea5a0 100644
--- a/exampleData/ruleSets/colorRules.json
+++ b/exampleData/ruleSets/colorRules.json
@@ -1,99 +1,87 @@
/* colorRules.json
- * Author: Benjamin Jones <bjones@galois.com>
*
* Simple rules for checking that the colors of specific elements are in a specific set.
* Test using exampleData/basic/testColorRules.html
*/
-{ 'name': "Colors are in a specified set"
-, 'description': "All background and foreground colors used on a page should be in a specificed set"
+{ 'name': "Color Guidelines"
+, 'description': "Foreground/background color guidelines"
, 'rules': [
- { 'name': "Foregrounds"
- , 'description': "Foreground colors should be in the set:"+
- "'#0, #FFFFFF, #3D3D3D, #B4B4B4, #4E4E4E, #C2C2C2, #F7F7F7"
- , 'rule':
- function() { //----------------------------------------------
- var allowableColors = { '#0': 1, '#FFFFFF': 1, '#3D3D3D': 1,
- '#B4B4B4': 1, '#4E4E4E': 1, '#C2C2C2': 1,
- '#F7F7F7': 1 };
- fiveui.query(':visible').each(
- function(i, elt) {
- var color = $(elt).css('color');
- if (!(fiveui.color.color.colorToHex(color) in allowableColors)) {
- report('Disallowed FOREground color ' +
- fiveui.color.colorToHex(color) +
- ' appears', $(elt));
- }
- });
- } //---------------------------------------------------------
- },//==============================================================
- { 'name': "Backgrounds"
- , 'description': "Backgrounds colors are in the set:" +
- "#000000, #FFFFFF, #3D3D3D, #B4B4B4, #4E4E4E, #C2C2C2"
- , 'rule':
- function() { //----------------------------------------------
- var allowableColors = { '#0': 1, '#FFFFFF': 1,
- '#3D3D3D': 1, '#B4B4B4': 1, '#4E4E4E': 1,
- '#C2C2C2': 1 };
- fiveui.query(':visible').each(
- function(i, elt) {
- var color = $(elt).css('background-color');
- if (!(fiveui.color.colorToHex(color) in allowableColors)) {
- report('Disallowed BACKground color ' +
- fiveui.color.colorToHex(color) +
- ' appears', $(elt));
- }
- });
- } //---------------------------------------------------------
- },//==============================================================
- { 'name': "Content Area Color"
- , 'description': "Content Area Color should be #F7"
- , 'rule':
- //----------
- function() {
- var allowableColors = { '#F7F7F7': 1 };
- fiveui.query("#content").each(
- function(i, elt) {
- var color = $(elt).css('color');
- if (!(fiveui.color.colorToHex(color) in allowableColors)) {
- report('Invalid color '+fiveui.color.colorToHex(color) +
- ' in content area', $(elt));
- }
- });
- } //---------------------------------------------------------
- },//==============================================================
- { 'name': "Left Nav Color"
- , 'description': "Left Nav Color should be #C2 (#4E if active)"
- , 'rule':
- //----------
- function() {
- var allowableColors = { '#C2C2C2': 1 };
- fiveui.query("#nav-left").each(
- function(i, elt) {
- var color = $(elt).css('color');
- // if active then .. 4E
- if (!(fiveui.color.colorToHex(color) in allowableColors)) {
- report('Invalid color '+fiveui.color.colorToHex(color) +
- ' in left nav area', $(elt));
- }
- });
- } //---------------------------------------------------------
- },//==============================================================
- { 'name': "Header Color"
- , 'description': "Header Color should be #3D"
- , 'rule':
- //----------
- function() {
- var allowableColors = { '#3D3D3D': 1 };
- fiveui.query(":header").each(
- function(i, elt) {
- var color = $(elt).css('color');
- if (!(fiveui.color.colorToHex(color) in allowableColors)) {
- report('Invalid color '+fiveui.color.colorToHex(color) +
- ' in header', $(elt));
- }
- });
- } //---------------------------------------------------------
- } //==============================================================
- ]
+ //----------------------------------------------------------------
+ { 'name': "Foreground check"
+ , 'description': "Foreground colors should be in the set:"+
+ "#00 #FF #3D #F7 #C2 #B4 #4E #FFCB05 #7B8738"
+ , 'rule':
+ function () {
+ var allow = "#00 #FF #3D #F7 #C2 #B4 #4E #FFCB05 #7B8738".split(" ");
+ $5(":visible")
+ .cssIsNot("color", allow, fiveui.color.colorToHex)
+ .each(function (i, elt) {
+ var color = fiveui.color.colorToHex($(elt).css("color"));
+ report("foreground color: " + color, elt);
+ });
+ }
+ },
+ //----------------------------------------------------------------
+ { 'name': "Background check"
+ , 'description': "Backgrounds colors should be in the set:" +
+ "#00 #FF #3D #F7 #C2 #B4 #4E"
+ , 'rule':
+ function () {
+ var allow = "#00 #FF #3D #F7 #C2 #B4 #4E".split(" ");
+ $5(":visible")
+ .cssIsNot("background-color", allow, fiveui.color.colorToHex)
+ .each(function (i, elt) {
+ var color = fiveui.color.colorToHex($(elt).css("background-color"));
+ report("non-standard background color: " + color, elt);
+ });
+ }
+ },
+ //----------------------------------------------------------------
+ { 'name': "Content area color"
+ , 'description': "Background color should be: " +
+ "#F7"
+ , 'rule':
+ function () {
+ var allow = "#F7";
+ $5("#content")
+ .cssIsNot("background-color", allow, fiveui.color.colorToHex)
+ .each(function (i, elt) {
+ var color = fiveui.color.colorToHex($(elt).css("background-color"));
+ report("non-standard content background color: " + color, elt);
+ });
+ }
+ },
+ //----------------------------------------------------------------
+ { 'name': "Left navigation color"
+ , 'description': "Left navigation color should be: " +
+ "#C2"
+ , 'rule':
+ function () {
+ var allow = "#C2";
+ $5("#leftNav")
+ .cssIsNot("color", allow, fiveui.color.colorToHex)
+ .each(function (i, elt) {
+ var color = fiveui.color.colorToHex($(elt).css("color"));
+ report("non-standard left navigation color: " + color, elt);
+ });
+ }
+ },
+ //----------------------------------------------------------------
+ { 'name': "Header color check"
+ , 'description': "Header color should be: " +
+ "#3D"
+ , 'rule':
+ function () {
+ var allow = "#3D";
+ $5(":header")
+ .cssIsNot("color", allow, fiveui.color.colorToHex)
+ .each(function (i, elt) {
+ var color = fiveui.color.colorToHex($(elt).css("color"));
+ report("non-standard header color: " + color, elt);
+ });
+ }
+ }//,
+ //----------------------------------------------------------------
+]
}