Skip to content
This repository was archived by the owner on Feb 14, 2018. It is now read-only.

new function #9

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
36 changes: 29 additions & 7 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# jQuery - fieldSelection

A jQuery plugin to get'n'set the caret/selection.
A jQuery plugin to get'n'set the caret/selection.

## Description

Expand All @@ -14,21 +14,43 @@ support the easy DOM 3.0 methods.

First public release: `getSelection` and `replaceSelection` basically works.

Check my [blog](http://blog.0xab.cd) or the
[fieldSelection](http://laboratorium.0xab.cd/jquery/fieldselection/) page
for further updates.

## Requirements

[jQuery](http://jquery.com) (tested with version 1.0.2+)

## Usage sample

```html
<script type="text/javascript" src="jquery-fieldselection.js"></script>

```

```js
//Get Selected text
var selectedText = $('#id_textarea').getSelection();

//Replacing selection
$('#id_textarea').replaceSelection('new text here');

```

getSelection return sample:
```json
{start: 162, end: 171, length: 9, text: "Selected text here"}
```

## Gratitude

Thankyou to [localhost](https://github.com/localhost) a person who started this plugin.

## License

<pre>
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2006 Alex Brem <alex@0xab.cd>
Copyright (C) 2017 Nikolas Leite
2006 Alex Brem <alex@0xab.cd>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
Expand All @@ -45,4 +67,4 @@ as the name is changed.
> the extent permitted by applicable law. You can redistribute it
> and/or modify it under the terms of the Do What The Fuck You Want
> To Public License, Version 2, as published by Sam Hocevar. See
> [http://sam.zoy.org/wtfpl/COPYING](http://sam.zoy.org/wtfpl/COPYING) for more details.
> [http://sam.zoy.org/wtfpl/COPYING](http://sam.zoy.org/wtfpl/COPYING) for more details.
7 changes: 4 additions & 3 deletions jquery-fieldselection.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* jQuery plugin: fieldSelection - v0.1.1 - last change: 2006-12-16
* (c) 2006 Alex Brem <alex@0xab.cd> - http://blog.0xab.cd
* jQuery plugin: fieldSelection - v1.0.0 - last change: 2017/12/05
* Sustained by Nikolas Leite - https://github.com/nikolasmagno
* Started by (c) 2006 Alex Brem <alex@0xab.cd> - http://blog.0xab.cd
*/

(function() {
Expand Down Expand Up @@ -46,7 +47,7 @@

replaceSelection: function() {

var e = (typeof this.id == 'function') ? this.get(0) : this;
var e = (this.jquery) ? this[0] : this;
var text = arguments[0] || '';

return (
Expand Down
7 changes: 4 additions & 3 deletions jquery-fieldselection.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading