mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 08:33:24 +02:00
Added favicon resolving to URL input.
Added blur event after entering URL. Focus screen after entering URL.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
module.exports = function focusElementDirective($parse, $timeout) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attrs) {
|
||||
var model = $parse(attrs.focusElement)
|
||||
|
||||
scope.$watch(model, function (value) {
|
||||
if (value === true) {
|
||||
$timeout(function () {
|
||||
element[0].focus()
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
element.bind('blur', function () {
|
||||
scope.$apply(model.assign(scope, false))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
describe('focusElement', function () {
|
||||
|
||||
beforeEach(module('stf.focus-element'));
|
||||
|
||||
var scope, compile;
|
||||
|
||||
beforeEach(inject(function ($rootScope, $compile) {
|
||||
scope = $rootScope.$new();
|
||||
compile = $compile;
|
||||
}));
|
||||
|
||||
it('should ...', function () {
|
||||
|
||||
/*
|
||||
To test your directive, you need to create some html that would use your directive,
|
||||
send that through compile() then compare the results.
|
||||
|
||||
var element = compile('<div focus-element name="name">hi</div>')(scope);
|
||||
expect(element.text()).toBe('hello, world');
|
||||
*/
|
||||
|
||||
});
|
||||
});
|
||||
4
res/app/components/stf/common-ui/focus-element/index.js
Normal file
4
res/app/components/stf/common-ui/focus-element/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = angular.module('stf.focus-element', [
|
||||
|
||||
])
|
||||
.directive('focusElement', require('./focus-element-directive'))
|
||||
Reference in New Issue
Block a user