mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Editable: use execCommand to selectAll, if supported
This commit is contained in:
parent
121b134db9
commit
691c539ca6
2
dist/js/widgets/widget-editable.min.js
vendored
2
dist/js/widgets/widget-editable.min.js
vendored
File diff suppressed because one or more lines are too long
@ -27,20 +27,25 @@
|
||||
|
||||
selectAll: function( cell ) {
|
||||
setTimeout( function() {
|
||||
// select all text in contenteditable
|
||||
// see http://stackoverflow.com/a/6150060/145346
|
||||
var range, selection;
|
||||
if ( document.body.createTextRange ) {
|
||||
range = document.body.createTextRange();
|
||||
range.moveToElementText( cell );
|
||||
range.select();
|
||||
} else if ( window.getSelection ) {
|
||||
selection = window.getSelection();
|
||||
range = document.createRange();
|
||||
range.selectNodeContents( cell );
|
||||
selection.removeAllRanges();
|
||||
selection.addRange( range );
|
||||
if ( document.queryCommandSupported( 'SelectAll' ) ) {
|
||||
document.execCommand( 'selectAll', false, null );
|
||||
} else {
|
||||
// select all text in contenteditable
|
||||
// see http://stackoverflow.com/a/6150060/145346
|
||||
var range, selection;
|
||||
if ( document.body.createTextRange ) {
|
||||
range = document.body.createTextRange();
|
||||
range.moveToElementText( cell );
|
||||
range.select();
|
||||
} else if ( window.getSelection ) {
|
||||
selection = window.getSelection();
|
||||
range = document.createRange();
|
||||
range.selectNodeContents( cell );
|
||||
selection.removeAllRanges();
|
||||
selection.addRange( range );
|
||||
}
|
||||
}
|
||||
// need delay of at least 100ms or last contenteditable will get refocused
|
||||
}, 100 );
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user