Merge pull request #4887 from TheHollidayInn/focus-textarea-on-pm

Added focus directive to focus textarea for a private message model box
This commit is contained in:
Alys
2015-04-04 01:45:30 +10:00
2 changed files with 16 additions and 3 deletions

View File

@@ -183,3 +183,16 @@ habitrpg
" </div>\n" + " </div>\n" +
"</div>\n"); "</div>\n");
}]); }]);
habitrpg.directive('focusMe', function($timeout, $parse) {
return {
link: function(scope, element, attrs) {
var model = $parse(attrs.focusMe);
scope.$watch(model, function(value) {
$timeout(function() {
element[0].focus();
});
});
}
};
});

View File

@@ -46,7 +46,7 @@ script(type='text/ng-template', id='modals/private-message.html')
.modal-header .modal-header
h4=env.t('pmHeading', {name: "{{profile.profile.name}}"}) h4=env.t('pmHeading', {name: "{{profile.profile.name}}"})
.modal-body .modal-body
textarea.form-control(type='text',rows='5',ui-keydown='{"meta-enter":"sendPrivateMessage(profile._id, _message)"}',ng-model='_message') textarea.form-control(type='text',rows='5',ui-keydown='{"meta-enter":"sendPrivateMessage(profile._id, _message)"}',ng-model='_message', focus-me)
.modal-footer .modal-footer
button.btn.btn-primary(ng-click='sendPrivateMessage(profile._id, _message)')=env.t("send") button.btn.btn-primary(ng-click='sendPrivateMessage(profile._id, _message)')=env.t("send")
button.btn.btn-default(ng-click='$close()')=env.t('cancel') button.btn.btn-default(ng-click='$close()')=env.t('cancel')