summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Loach <robloach@gmail.com>2014-10-07 14:09:51 -0400
committerRob Loach <robloach@gmail.com>2014-10-07 14:09:51 -0400
commita13bee763493c608722ea4ff53269fecb8b6d68b (patch)
tree77a13a2452bb46423d9dd6bca4a15c4170334264
parent80d3a483234a1969f5e44882e4fa26489dd79910 (diff)
downloadjquery-once-a13bee763493c608722ea4ff53269fecb8b6d68b.zip
jquery-once-a13bee763493c608722ea4ff53269fecb8b6d68b.tar.gz
jquery-once-a13bee763493c608722ea4ff53269fecb8b6d68b.tar.bz2
Update documentation
-rw-r--r--.npmignore1
-rw-r--r--README.md6
-rw-r--r--jquery.once.js14
-rw-r--r--package.json3
4 files changed, 13 insertions, 11 deletions
diff --git a/.npmignore b/.npmignore
index c101763..6924651 100644
--- a/.npmignore
+++ b/.npmignore
@@ -10,6 +10,7 @@ build/
components/
bower_components/
node_modules/
+out/
# Private Files
.env
diff --git a/README.md b/README.md
index a1bbdf1..915aeda 100644
--- a/README.md
+++ b/README.md
@@ -60,6 +60,8 @@ be used to ensure that a function is only applied once to an element.
### `.once()`
+Filter elements by whether they have not yet been processed.
+
``` javascript
$('div.calendar').once('calendar').each(function() {
// This function is only executed once for each div, even if this
@@ -73,7 +75,7 @@ $('div.calendar').once('calendar').click(function() {
});
```
-It also works without supplying a name:
+It is also possible to use `.once()` without supplying a name:
``` javascript
$('div.calendar').once().each(function() {
@@ -180,5 +182,3 @@ These amazing people have contributed code to this project:
[Become a contributor!](https://github.com/RobLoach/jquery-once/blob/master/CONTRIBUTING.md#files)
<!-- /BACKERS -->
-
-
diff --git a/jquery.once.js b/jquery.once.js
index 222aef4..054ceb4 100644
--- a/jquery.once.js
+++ b/jquery.once.js
@@ -21,16 +21,17 @@
var cache = {}, uuid = 0;
/**
- * Filters elements by whether they have not yet been processed.
+ * Filter elements by whether they have not yet been processed.
*
* @param {string} [id]
- * (Optional) If this is a string, then it will be the data ID used
- * to determine whether it has already been processed or not.
+ * (Optional) The data id used to determine whether the given elements have
+ * already been processed or not.
*
- * When the id is not passed, it becomes a unique identifier, depicted as a
- * number. The element's data ID will then be represented in the form of
+ * When id is not provided, it becomes a unique identifier, depicted as a
+ * number. The element's data id will then be represented in the form of
* "jquery-once-#".
- * @returns jQuery element collection of elements that have now run once.
+ * @returns jQuery element collection of elements that have now run once by
+ * the given id.
*
* @example
* // Change the color to green only once.
@@ -112,6 +113,7 @@
$.fn.findOnce = function (id) {
// Filter the elements by which do have the data.
var name = 'jquery-once-' + id;
+
return this.filter(function() {
return $(this).data(name) === true;
});
diff --git a/package.json b/package.json
index d54e57a..711f8e6 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,6 @@
"daviddev": true,
"gittip": "robloach"
},
- "repo": "RobLoach/jquery-once",
"homepage": "https://github.com/RobLoach/jquery-once",
"author": "Rob Loach (http://github.com/robloach)",
"maintainers": [
@@ -61,4 +60,4 @@
"release": "grunt release",
"jsdoc": "npm install jsdoc && node_modules/.bin/jsdoc jquery.once.js"
}
-} \ No newline at end of file
+}