Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,18 @@ $('input[name="example"]').textrange('setcursor', 5);

### 'replace'

You can use this method to replace the selection with given text.
You can use this method to replace the selection with given text.

```javascript
$('input[name="example"]').textrange('replace', 'some text');
```

There is also an `insert` alias for `replace` if you're using this method to insert text at the cursor location. They work the same way.

### 'get-nofocus', 'set-nofocus', 'setcursor-nofocus', 'replace-nofocus', 'insert-nofocus'

You can add the suffix '-nofocus' to any of the method names to perform the corresponding operation without setting focus on the target element.

## Minified Version
A minified version of this plugin can be generated using UglifyJS during your build process or via CLI tools:

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-textrange",
"version": "1.3.3",
"version": "1.3.4",
"main": "jquery-textrange.js",
"dependencies": {
"jquery": ">=1.3"
Expand Down
7 changes: 5 additions & 2 deletions jquery-textrange.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,11 @@
return this;
}

// Focus on the element before operating upon it.
if (document.activeElement !== this[0]) {
// Focus on the element before operating upon it,
// unless the specified method ends in '-nofocus'
if (method.slice(-8)==='-nofocus') {
method = method.slice(0,-8); //strip the -nofocus suffix and bypass focus()
} else if (document.activeElement !== this[0]) {
this[0].focus();
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-textrange",
"version": "1.3.3",
"version": "1.3.4",
"description": "A jQuery plugin for getting, setting and replacing the selected text in input fields and textareas.",
"main": "jquery-textrange.js",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion textrange.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"substring",
"substr"
],
"version": "1.3.3",
"version": "1.3.4",
"author": {
"name": "Daniel Imhoff",
"email": "dwieeb@gmail.com",
Expand Down