Skip to content

Commit 7c6bb40

Browse files
committed
Merge pull request #209 from stramel/development
Added accessibility classes to default inputs
2 parents d69ec9e + e146362 commit 7c6bb40

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/directives/decorators/bootstrap/default.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
<div class="form-group schema-form-{{form.type}} {{form.htmlClass}}"
22
ng-class="{'has-error': hasError(), 'has-success': hasSuccess(), 'has-feedback': form.feedback !== false }">
3-
<label class="control-label" ng-show="showTitle()">{{form.title}}</label>
3+
<label class="control-label" ng-class="{'sr-only': !showTitle()}" for="{{form.key.slice(-1)[0]}}">{{form.title}}</label>
44

55
<input ng-show="form.key"
66
type="{{form.type}}"
77
step="any"
88
sf-changed="form"
99
placeholder="{{form.placeholder}}"
1010
class="form-control {{form.fieldHtmlClass}}"
11+
id="{{form.key.slice(-1)[0]}}"
1112
ng-model-options="form.ngModelOptions"
1213
ng-model="$$value$$"
1314
ng-disabled="form.readonly"
1415
schema-validate="form"
15-
name="{{form.key.slice(-1)[0]}}">
16+
name="{{form.key.slice(-1)[0]}}"
17+
aria-describedby="{{form.key.slice(-1)[0] + 'Status'}}">
1618
<span ng-if="form.feedback !== false"
1719
class="form-control-feedback"
18-
ng-class="evalInScope(form.feedback) || {'glyphicon': true, 'glyphicon-ok': hasSuccess(), 'glyphicon-remove': hasError() }"></span>
20+
ng-class="evalInScope(form.feedback) || {'glyphicon': true, 'glyphicon-ok': hasSuccess(), 'glyphicon-remove': hasError() }"
21+
aria-hidden="true"></span>
22+
<span ng-if="hasError() || hasSuccess()"
23+
id="{{form.key.slice(-1)[0] + 'Status'}}"
24+
class="sr-only">{{ hasSuccess() ? '(success)' : '(error)' }}</span>
1925
<div class="help-block"
2026
ng-show="(hasError() && errorMessage(schemaError())) || form.description"
2127
ng-bind-html="(hasError() && errorMessage(schemaError())) || form.description"></div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="form-group">
2-
<label ng-show="showTitle()">{{form.title}}</label>
3-
<input ng-if="form.type !== 'textarea'" type="text" disabled class="form-control" value="{{$$value$$}}">
2+
<label ng-class="{'sr-only': !showTitle()}" for="{{form.key.slice(-1)[0]}}">{{form.title}}</label>
3+
<input ng-if="form.type !== 'textarea'" type="text" disabled class="form-control" id="{{form.key.slice(-1)[0]}}" value="{{$$value$$}}">
44
<textarea ng-if="form.type === 'textarea'" disabled class="form-control">{{$$value$$}}</textarea>
55
<div class="help-block" ng-show="form.description" ng-bind-html="form.description"></div>
66
</div>

src/directives/decorators/bootstrap/textarea.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<div class="form-group has-feedback {{form.htmlClass}} schema-form-textarea" ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
2-
<label ng-show="showTitle()">{{form.title}}</label>
2+
<label ng-class="{'sr-only': !showTitle()}" for="{{form.key.slice(-1)[0]}}">{{form.title}}</label>
33
<textarea class="form-control {{form.fieldHtmlClass}}"
4+
id="{{form.key.slice(-1)[0]}}"
45
sf-changed="form"
56
placeholder="{{form.placeholder}}"
67
ng-disabled="form.readonly"

test/directives/schema-form-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ describe('directive',function(){
779779
$rootScope.$apply();
780780

781781
tmpl.children().length.should.be.equal(2);
782-
tmpl.children().eq(0).children().eq(0).find('label').hasClass('ng-hide').should.be.true;
782+
tmpl.children().eq(0).children().eq(0).find('label').hasClass('sr-only').should.be.true;
783783
tmpl.children().eq(1).children().eq(0).find('label').hasClass('ng-hide').should.be.true;
784784
});
785785
});

0 commit comments

Comments
 (0)