Split directives into separate files

This commit is contained in:
Kevin Gisi
2015-06-08 04:13:55 -04:00
parent e0794b1f08
commit 7ef98ff7e2
12 changed files with 319 additions and 198 deletions

View File

@@ -0,0 +1,24 @@
'use strict';
angular
.module('habitrpg')
.directive('taskFocus', taskFocus);
taskFocus.$inject = ['$timeout'];
/**
* Directive that places focus on the element it is applied to when the
* expression it binds to evaluates to true.
*/
function taskFocus($timeout) {
return function(scope, elem, attrs) {
scope.$watch(attrs.taskFocus, function(newVal) {
if (newVal) {
$timeout(function() {
elem[0].focus();
}, 0, false);
}
});
}
}