mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Encapsulate directive functions in anonymous functions - avoid the global namespace
This commit is contained in:
@@ -1,24 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('habitrpg')
|
||||
.directive('taskFocus', taskFocus);
|
||||
(function(){
|
||||
angular
|
||||
.module('habitrpg')
|
||||
.directive('taskFocus', taskFocus);
|
||||
|
||||
taskFocus.$inject = ['$timeout'];
|
||||
taskFocus.$inject = ['$timeout'];
|
||||
|
||||
/**
|
||||
* Directive that places focus on the element it is applied to when the
|
||||
* expression it binds to evaluates to true.
|
||||
*/
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
});
|
||||
function taskFocus($timeout) {
|
||||
return function(scope, elem, attrs) {
|
||||
scope.$watch(attrs.taskFocus, function(newVal) {
|
||||
if (newVal) {
|
||||
$timeout(function() {
|
||||
elem[0].focus();
|
||||
}, 0, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}());
|
||||
|
||||
Reference in New Issue
Block a user