Skip to content

Commit

Permalink
release: 0.1.2
Browse files Browse the repository at this point in the history
* Optimized non-minified distribution output to remove comments and reduce file size
* Improved build process
* New docs that are much more readable
  • Loading branch information
azaslavsky committed Jan 3, 2015
1 parent fe10b93 commit 676c828
Show file tree
Hide file tree
Showing 12 changed files with 1,032 additions and 997 deletions.
106 changes: 60 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,79 +42,93 @@ myTextStack.snapshot();

<a name="TextStack"></a>
## API
**Members**

* [class: TextStack](#TextStack)
* [new TextStack(input, [opts])](#new_TextStack)
* [textStack.off()](#TextStack#off)
* [textStack.redo([e])](#TextStack#redo)
* [textStack.undo([e])](#TextStack#undo)
* [textStack.snapshot([force])](#TextStack#snapshot)
* [textStack.diff([a], [b], [omitWhitespace])](#TextStack#diff)
* [textStack.reset([clear])](#TextStack#reset)

<a name="new_TextStack"></a>
###new TextStack(input, [opts])
* [new TextStack(input, [opts])](#new_TextStack_new)
* _instance_
* [.off()](#TextStack#off)
* [.redo([e])](#TextStack#redo)
* [.undo([e])](#TextStack#undo)
* [.snapshot([force])](#TextStack#snapshot) ⇒ <code>boolean</code>
* [.diff([a], [b], [omitWhitespace])](#TextStack#diff) ⇒ <code>boolean</code>
* [.reset([clear])](#TextStack#reset)

<a name="new_TextStack_new"></a>

* * *
####new TextStack(input, [opts])
Create a new instance of TextStack

**Params**

- input `HTMLElement` - A DOM text input element (textarea, input type="text", etc)
- \[opts\] `Object` - A list of options
- \[idleDelay=1000\] `number` - Number of milleseconds for which user must be inactive before we save a snapshot
- \[omitWhitespace=false\] `boolean` - When diffing between two snapshots, whitespace will be omitted before comparing
- \[maxInterval=5000\] `number` - If no snapshot has occurred in this number of milleseconds, override the idleDelay and try to make one no matter what
- \[maxUndoStackSize=100\] `number` - Greatest number of snapshots that can be stored at a given time
- \[redoKeys\] `Array.<number>` - Array of keyCodes for keys that, when pressed together, fire a redo action (Default: Ctrl + Y)
- \[undoKeys\] `Array.<number>` - Array of keyCodes for keys that, when pressed together, fire an undo action (Default: Ctrl + Z)
| Param | Type | Description |
| ----- | ---- | ----------- |
| input | <code>HTMLElement</code> | A DOM text input element (textarea, input type="text", etc) |
| \[opts\] | <code>Object</code> | A list of options |
| \[opts.idleDelay=1000\] | <code>number</code> | Number of milleseconds for which user must be inactive before we save a snapshot |
| \[opts.omitWhitespace=false\] | <code>boolean</code> | When diffing between two snapshots, whitespace will be omitted before comparing |
| \[opts.maxInterval=5000\] | <code>number</code> | If no snapshot has occurred in this number of milleseconds, override the idleDelay and try to make one no matter what |
| \[opts.maxUndoStackSize=100\] | <code>number</code> | Greatest number of snapshots that can be stored at a given time |
| \[opts.redoKeys\] | <code>Array.&lt;number&gt;</code> | Array of keyCodes for keys that, when pressed together, fire a redo action (Default: Ctrl + Y) |
| \[opts.undoKeys\] | <code>Array.&lt;number&gt;</code> | Array of keyCodes for keys that, when pressed together, fire an undo action (Default: Ctrl + Z) |

<a name="TextStack#off"></a>
###textStack.off()

* * *
####textStack.off()
Remove the event listeners, so that we can delete this bad boy without any memory leaks

<a name="TextStack#redo"></a>
###textStack.redo([e])
Attempt a redo action

**Params**
* * *
####textStack.redo([e])
Attempt a redo action

- \[e\] `Event` - Event that triggered this function (optional)
| Param | Type | Description |
| ----- | ---- | ----------- |
| \[e\] | <code>Event</code> | Event that triggered this function (optional) |

<a name="TextStack#undo"></a>
###textStack.undo([e])
Attempt an undo action

**Params**
* * *
####textStack.undo([e])
Attempt an undo action

- \[e\] `Event` - Event that triggered this function (optional)
| Param | Type | Description |
| ----- | ---- | ----------- |
| \[e\] | <code>Event</code> | Event that triggered this function (optional) |

<a name="TextStack#snapshot"></a>
###textStack.snapshot([force])
Attempt to add a snapshot to the undoStack - returns false if the new snapshot matches the last available one

**Params**
* * *
####textStack.snapshot([force]) ⇒ <code>boolean</code>
Attempt to add a snapshot to the undoStack - returns false if the new snapshot matches the last available one

- \[force=false\] `boolean` - Forces the snapshot to be added to the stack, even if there is no difference between it and the previous snapshot
| Param | Type | Description |
| ----- | ---- | ----------- |
| \[force=false\] | <code>boolean</code> | Forces the snapshot to be added to the stack, even if there is no difference between it and the previous snapshot |

**Returns**: `boolean` - Whether or not the operation was successful
**Returns**: <code>boolean</code> - Whether or not the operation was successful
<a name="TextStack#diff"></a>
###textStack.diff([a], [b], [omitWhitespace])
Diff two strings, optionally omitting whitespace

**Params**
* * *
####textStack.diff([a], [b], [omitWhitespace]) ⇒ <code>boolean</code>
Diff two strings, optionally omitting whitespace

- \[a\] `string` - The first string to compare
- \[b\] `string` - The second string, against which the first will be compared
- \[omitWhitespace\] `boolean` - Do the comparison with or without whitespace included (ex: if true, "ab" === "a\n\n\nb")
| Param | Type | Description |
| ----- | ---- | ----------- |
| \[a\] | <code>string</code> | The first string to compare |
| \[b\] | <code>string</code> | The second string, against which the first will be compared |
| \[omitWhitespace\] | <code>boolean</code> | Do the comparison with or without whitespace included (ex: if true, "ab" === "a\n\n\nb") |

**Returns**: `boolean` - True means there is a difference, false means they are identical
**Returns**: <code>boolean</code> - True means there is a difference, false means they are identical
<a name="TextStack#reset"></a>
###textStack.reset([clear])
Reset the TextStack's histories, and optionally clear the text element

**Params**
* * *
####textStack.reset([clear])
Reset the TextStack's histories, and optionally clear the text element

- \[clear=false\] `boolean` - Whether or not we should clear the text element as well - be careful with this!
| Param | Type | Description |
| ----- | ---- | ----------- |
| \[clear=false\] | <code>boolean</code> | Whether or not we should clear the text element as well - be careful with this! |


## License
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": "textstack",
"version": "0.1.1",
"version": "0.1.2",
"description": "A simple undo history script for DOM text fields",
"main": "dist/textStack.js",
"license": "MIT",
Expand Down

0 comments on commit 676c828

Please sign in to comment.