mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 16:13:24 +02:00
Added text-focus-select directive for text inputs so it selects automatically the text when clicked.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
module.exports = angular.module('stf.text-focus-select', [
|
||||
|
||||
])
|
||||
.directive('textFocusSelect', require('./text-focus-select-directive'))
|
||||
@@ -0,0 +1,11 @@
|
||||
module.exports = function textFocusSelectDirective() {
|
||||
return {
|
||||
restrict: 'AC',
|
||||
link: function (scope, element) {
|
||||
// TODO: try with focus event
|
||||
element.bind('click', function () {
|
||||
this.select()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
describe('textFocusSelect', function () {
|
||||
|
||||
beforeEach(module('stf.text-focus-select'));
|
||||
|
||||
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 text-focus-select name="name">hi</div>')(scope);
|
||||
expect(element.text()).toBe('hello, world');
|
||||
*/
|
||||
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user