aboutsummaryrefslogtreecommitdiff
path: root/exampleData
diff options
context:
space:
mode:
authorGravatar Benjamin Jones <bjones@galois.com>2013-06-13 15:21:37 -0700
committerGravatar Benjamin Jones <bjones@galois.com>2013-06-13 15:21:37 -0700
commit296ca3e5a2166965df546e1db4250366403a7d47 (patch)
tree2cbb84f625ad11cab26a46d77cc2bbbf64cab83a /exampleData
parentc7b493dcc46ac800ace472a580d5430a1b0c2e41 (diff)
converted basicUIRules.json rulesets to new format
Diffstat (limited to 'exampleData')
-rw-r--r--exampleData/ruleSets/basic/basicUIRules.json6
-rw-r--r--exampleData/ruleSets/basic/emptyHeadings.js13
-rw-r--r--exampleData/ruleSets/basic/emptyHrefs.js12
-rw-r--r--exampleData/ruleSets/basic/labelFields.js23
4 files changed, 54 insertions, 0 deletions
diff --git a/exampleData/ruleSets/basic/basicUIRules.json b/exampleData/ruleSets/basic/basicUIRules.json
new file mode 100644
index 0000000..bfa755d
--- /dev/null
+++ b/exampleData/ruleSets/basic/basicUIRules.json
@@ -0,0 +1,6 @@
+{ "name": "Basic HTML guidelines"
+, "description": "A selection of simple HTML guidelines for improved usability and consistency"
+, "rules": [ "labelFields.js",
+ "emptyHeadings.js",
+ "emptyHrefs.js" ]
+}
diff --git a/exampleData/ruleSets/basic/emptyHeadings.js b/exampleData/ruleSets/basic/emptyHeadings.js
new file mode 100644
index 0000000..4d2db46
--- /dev/null
+++ b/exampleData/ruleSets/basic/emptyHeadings.js
@@ -0,0 +1,13 @@
+exports.name = "Don't use empty headings";
+exports.description = 'Empty headings confuse layout';
+exports.rule =
+ function() {
+ var that = this;
+ fiveui.query(':header').each(
+ function(i, elt) {
+ if ($(elt).text() == '') {
+ that.report('Heading is empty', elt);
+ }
+ }
+ );
+ };
diff --git a/exampleData/ruleSets/basic/emptyHrefs.js b/exampleData/ruleSets/basic/emptyHrefs.js
new file mode 100644
index 0000000..a333842
--- /dev/null
+++ b/exampleData/ruleSets/basic/emptyHrefs.js
@@ -0,0 +1,12 @@
+exports.name': "Don't use empty hrefs."
+exports.description': "Links with no text can't generally be used."
+exports.rule =
+ function() {
+ var that = this;
+ fiveui.query('a').each(
+ function(i, elt) {
+ if ($(elt).text() == '' && elt.title == '') {
+ that.report('Link has no text', elt);
+ }
+ });
+ };
diff --git a/exampleData/ruleSets/basic/labelFields.js b/exampleData/ruleSets/basic/labelFields.js
new file mode 100644
index 0000000..e93c370
--- /dev/null
+++ b/exampleData/ruleSets/basic/labelFields.js
@@ -0,0 +1,23 @@
+exports.name = 'All input fields have exactly one label.';
+exports.description = '<p>Screen readers rely on HTML attributes to identify the purpose '
+ + "of form widgets on-screen. These tools use label tags with 'for' "
+ + 'attributes that specify the id of the form element they pertain to. '
+ + 'Some of the components of this web page do not have those labels.</p>';
+
+exports.rule = function() {
+ var that = this;
+ fiveui.query(':input').each(
+ function(i, elt) {
+ if (elt.id) {
+ var $label = fiveui.query("label[for='" + elt.id + "']");
+
+ if (1 < $label.size()) {
+ that.report('Form element has too many labels', elt);
+ }
+
+ if (0 == $label.size()) {
+ that.report('Form element has no label', elt);
+ }
+ }
+ });
+}