Skip to content

Commit

Permalink
Add focus to our modals. refs #207"
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmiller committed Jul 30, 2014
1 parent 3dc3912 commit 3fc4979
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
11 changes: 11 additions & 0 deletions opal/static/js/opal/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,14 @@ directives.directive('focusOnThis', function($timeout){
}
}
});

angular.module('ui.bootstrap.modal').directive('modalWindow', function ($timeout) {
return {
priority: 1,
link: function (scope, element, attrs) {
$timeout(function () {
element.find('[autofocus]').focus();
});
}
};
});
2 changes: 1 addition & 1 deletion opal/templates/add_episode_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h3>New record</h3>
<div class="control-group">
<label class="control-label">Name</label>
<div class="controls">
<input type="text" ng-model="editing.demographics.name">
<input type="text" ng-model="editing.demographics.name" autofocus>
</div>
</div>
<div class="control-group">
Expand Down
3 changes: 2 additions & 1 deletion opal/templates/hospital_number_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ <h3>Add Patient</h3>
<div class="col-sm-8">
<input class="form-control"
ng-model="model.hospitalNumber"
ng-keypress="$event.keyCode == 13 && findByHospitalNumber()">
ng-keypress="$event.keyCode == 13 && findByHospitalNumber()"
autofocus>
</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion opal/templates/save_filter_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ <h3>
<label for="name">Name</label>
<input type="text" class="form-control"
id="name" placeholder="Name for this search"
ng-model="model.name">
ng-model="model.name"
autofocus>
</div>
</form>

Expand Down

0 comments on commit 3fc4979

Please sign in to comment.