mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
rename website/client to website/client-old
This commit is contained in:
26
website/client-old/js/directives/focus-element.directive.js
Normal file
26
website/client-old/js/directives/focus-element.directive.js
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
(function(){
|
||||
angular
|
||||
.module('habitrpg')
|
||||
.directive('focusElement', focusElement);
|
||||
|
||||
focusElement.$inject = ['$timeout'];
|
||||
|
||||
/**
|
||||
* Directive that places focus on the element it is applied to when the
|
||||
* expression it binds to evaluates to true.
|
||||
*/
|
||||
|
||||
function focusElement($timeout) {
|
||||
return function($scope, elem, attrs) {
|
||||
$scope.$watch(attrs.focusElement, function(newVal) {
|
||||
if (newVal) {
|
||||
$timeout(function() {
|
||||
elem[0].focus();
|
||||
}, 0, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}());
|
||||
Reference in New Issue
Block a user