From 2b8efa0da5e16f5850abf642202b44f56cc609d0 Mon Sep 17 00:00:00 2001 From: Benjamin Jones Date: Wed, 6 Feb 2013 15:23:56 -0800 Subject: ruleset additions --- exampleData/ruleSets/trac/colors.json | 33 +++++++++++++++++++++++++++++++ exampleData/ruleSets/trac/navigation.json | 23 +++++++++++---------- exampleData/ruleSets/trac/structure.json | 19 ++++++++++++++++-- 3 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 exampleData/ruleSets/trac/colors.json (limited to 'exampleData/ruleSets') diff --git a/exampleData/ruleSets/trac/colors.json b/exampleData/ruleSets/trac/colors.json new file mode 100644 index 0000000..2e6a2cc --- /dev/null +++ b/exampleData/ruleSets/trac/colors.json @@ -0,0 +1,33 @@ +/* colorRules.json + * + * Simple rules for checking that the colors of specific elements are in a specific set. + * Test using exampleData/basic/testColorRules.html + */ + +{ 'name': "Color Guidelines" +, 'description': "Foreground/background color guidelines" +, 'rules': [ + //---------------------------------------------------------------- + { 'name': "Foreground check" + , 'description': "Foreground colors should be in a certain fixed set." + , 'rule': + function () { + var allow = "rgb(0, 0, 0) " + + "rgb(255, 255, 255) " + + "rgb(85, 85, 85) " + + "rgb(34, 34, 34) " + + "rgb(187, 0, 0) " + + "rgb(238, 238, 238) " + + "rgb(153, 153, 136) " + + "rgb(136, 136, 136) " + + "rgb(102, 102, 102) " + + "rgb(187, 187, 187)".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); + }); + } +] +} diff --git a/exampleData/ruleSets/trac/navigation.json b/exampleData/ruleSets/trac/navigation.json index bda8dab..f8329ab 100644 --- a/exampleData/ruleSets/trac/navigation.json +++ b/exampleData/ruleSets/trac/navigation.json @@ -3,6 +3,9 @@ * Author: Benjamin Jones * * Ruleset for checking the consistency of Trac navigation elements + * + * Note: the jQuery plugins .linksTo() and .idExists() haven't been + * written yet (1-31-2013). */ { 'name': "Trac Navigation Guidelines" @@ -14,8 +17,7 @@ , 'rule': function() { if ($5("a").linksTo("http://wiki.galois.com").length === 0) { - var elt = $("body"); - report("did not find a link back to homepage", elt); + report("did not find a link back to homepage", $("body")); } } }, @@ -24,9 +26,8 @@ , 'description': "Global navigation links should appear on every page" , 'rule': function() { - if (! $5("div").idExists("topbar")) { - var elt = $("body"); - report("could not find global navigation links", elt); + if (! $5("div#topbar")) { + report("could not find global navigation links", $("body")); } } }, @@ -35,9 +36,8 @@ , 'description': "Module level navigation links should appear on every page" , 'rule': function() { - if (! $5("div").idExists("mainnav")) { - var elt = $("body"); - report("could not find module navigation links", elt); + if ( $5("div#mainnav").length === 0 ) { + report("could not find module navigation links", $("body")); } } }, @@ -46,12 +46,11 @@ , 'description': "Local (context dependent) navigation links should appear on every page" , 'rule': function() { - if (! $5("div").idExists("ctxtnav")) { - var elt = $("body"); - report("could not find local (context dependent) navigation links", elt); + if (! $5("div#ctxtnav")) { + report("could not find local (context dependent) navigation links", $("body")); } } - }//, + } //-------------------------------------------- ] } diff --git a/exampleData/ruleSets/trac/structure.json b/exampleData/ruleSets/trac/structure.json index 1207241..c9931c1 100644 --- a/exampleData/ruleSets/trac/structure.json +++ b/exampleData/ruleSets/trac/structure.json @@ -3,6 +3,9 @@ * Author: Benjamin Jones * * Guidelines relating to structure (headings, layout, ...) of pages + * + * Note: the jQuery plugins .nonEmpty() .exists() and .cssIs() haven't + * been written yet (1-31-2013). */ { 'name': "Structure Guidelines" @@ -19,10 +22,22 @@ } }, //-------------------------------------------- - { 'name': "Fluid Layouts" - , 'description': "pages should not use a fluid layout" + { 'name': "Fluid DIV Layouts" + , 'description': "DIVs should not use a fluid layout" + , 'rule': + function() { + $5("body div").cssIs("layout", "fluid").each(function (i, elt) { + report("DIV layout should not be fluid", elt); + }); + }//, +//-------------------------------------------- + { 'name': "Fluid Body Layouts" + , 'description': "Body should not use a fluid layout" , 'rule': function() { + $5("body").cssIs("layout", "fluid").each(function (i, elt) { + report("BODY layout should not be fluid", elt); + }); }//, //-------------------------------------------- ] -- cgit v1.2.3