mirror of
https://github.com/openstf/stf
synced 2025-10-06 03:50:04 +02:00
Added text-focus-select directive for text inputs so it selects automatically the text when clicked.
This commit is contained in:
parent
f9fd3fd4bc
commit
fb2e522945
8 changed files with 48 additions and 6 deletions
|
@ -9,5 +9,6 @@ module.exports = angular.module('stf/common-ui', [
|
|||
require('./tooltips').name,
|
||||
//require('./tree').name,
|
||||
require('./modals').name,
|
||||
require('./include-cached').name
|
||||
require('./include-cached').name,
|
||||
require('./text-focus-select').name
|
||||
])
|
||||
|
|
|
@ -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');
|
||||
*/
|
||||
|
||||
});
|
||||
});
|
|
@ -4,7 +4,7 @@
|
|||
span(translate) Clipboard
|
||||
.widget-content.padded
|
||||
.input-group.form-inline
|
||||
textarea(rows='1', ng-model='control.clipboardContent', msd-elastic).form-control.clipboard-textarea
|
||||
textarea(rows='1', ng-model='control.clipboardContent', msd-elastic, text-focus-select).form-control.clipboard-textarea
|
||||
span.input-group-btn
|
||||
button.btn.btn-primary-outline(ng-click='control.getClipboardContent()', tooltip='{{ "Get clipboard contents" | translate }}')
|
||||
i.fa.fa-refresh
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
form
|
||||
.input-group
|
||||
input.form-control(type='text', placeholder='http://...', autocomplete='off', ng-model='textURL',
|
||||
typeahead='url for url in urlHistory | filter:$viewValue').form-control
|
||||
typeahead='url for url in urlHistory | filter:$viewValue', text-focus-select).form-control
|
||||
|
||||
.input-group-btn
|
||||
button(ng-click='openURL()', ng-disabled='!textURL', translate).btn.btn-primary-outline Open
|
||||
//button(type='button', ng-disabled='!hasHistory()').btn.btn-primary-outline.dropdown-toggle
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
.widget-content.padded
|
||||
|
||||
.input-group.form-inline
|
||||
input(type=text, ng-model='command', ng-enter='run(command)').form-control.shell-input
|
||||
input(type=text, ng-model='command', ng-enter='run(command)', text-focus-select).form-control.shell-input
|
||||
span.input-group-btn
|
||||
// , tooltip='{{"Run Command"|translate}}'
|
||||
button.btn.btn-primary-outline(ng-click='run(command)', ng-disabled='!command')
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
input(type='search', results='5', autosave='deviceFilter'
|
||||
name='deviceFilter', ng-model='deviceFilter', ng-change='applyFilter(deviceFilter)',
|
||||
ng-model-options='{debounce: 150}'
|
||||
autocorrect='off', autocapitalize='off', spellcheck='false').form-control.input-sm.device-search.pull-right
|
||||
autocorrect='off', autocapitalize='off', spellcheck='false',
|
||||
text-focus-select).form-control.input-sm.device-search.pull-right
|
||||
.clear-filtering-buttons
|
||||
|
||||
device-list-icons(tracker='tracker', sort='sort', filter='filter')
|
||||
|
@ -36,7 +37,8 @@
|
|||
name='deviceFilter', ng-model='deviceFilter', ng-change='applyFilter(deviceFilter)',
|
||||
ng-model-options='{debounce: 150}'
|
||||
autocorrect='off', autocapitalize='off', spellcheck='false'
|
||||
list='searchFields', multiple).form-control.input-sm.device-search.pull-right
|
||||
list='searchFields', multiple,
|
||||
text-focus-select).form-control.input-sm.device-search.pull-right
|
||||
|
||||
span.pull-right
|
||||
.btn-group(dropdown).pull-right
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue