mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-05-13 01:16:53 +02:00
Renames show-error & autofocus directives to conform to naming conventions. Fixes: https://github.com/meanjs/mean/issues/1233
29 lines
594 B
JavaScript
29 lines
594 B
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
// Focus the element on page load
|
|
// Unless the user is on a small device, because this could obscure the page with a keyboard
|
|
|
|
angular.module('core')
|
|
.directive('autofocus', autofocus);
|
|
|
|
autofocus.$inject = ['$timeout', '$window'];
|
|
|
|
function autofocus($timeout, $window) {
|
|
var directive = {
|
|
restrict: 'A',
|
|
link: link
|
|
};
|
|
|
|
return directive;
|
|
|
|
function link(scope, element, attrs) {
|
|
if ($window.innerWidth >= 800) {
|
|
$timeout(function() {
|
|
element[0].focus();
|
|
}, 100);
|
|
}
|
|
}
|
|
}
|
|
}());
|