summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--HISTORY.md4
-rw-r--r--jquery.once.coffee92
-rw-r--r--jquery.once.js127
-rw-r--r--jquery.once.js.map4
-rw-r--r--jquery.once.litcoffee132
-rw-r--r--package.json6
6 files changed, 193 insertions, 172 deletions
diff --git a/HISTORY.md b/HISTORY.md
index 4ed742d..ba10609 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -1,7 +1,7 @@
# History
-## v2.0.0-alpha.10 November 2, 2014
-- Switch to [CoffeeScript](http://coffeescript.org)
+## v2.0.0-alpha.10 November 3, 2014
+- Switch source to [CoffeeScript](http://coffeescript.org)
## v2.0.0-alpha.9 October 16, 2014
- `id` parameter of `.once()` now a required parameter
diff --git a/jquery.once.coffee b/jquery.once.coffee
new file mode 100644
index 0000000..0741abf
--- /dev/null
+++ b/jquery.once.coffee
@@ -0,0 +1,92 @@
+###
+# jQuery Once `2.0.0-alpha.10`
+# http://github.com/robloach/jquery-once
+#
+# Act on jQuery elements only once.
+#
+# - [MIT](http://www.opensource.org/licenses/mit-license.php)
+# - [GPL-2.0](http://www.gnu.org/licenses/gpl.html)
+###
+
+###
+# Universal Module Definition
+#
+# [jQuery](http://jquery.com) is a dependency, so we wrap the code with a
+# [UMD](https://github.com/umdjs/umd) pattern in order to allow loading jQuery,
+# and jQuery Once, using [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD),
+# [CommonJS](http://en.wikipedia.org/wiki/CommonJS), or as a global variable.
+###
+((umd) ->
+ # CommonJS
+ return umd require "jquery" if typeof exports is "object"
+ # AMD
+ return define ["jquery"], umd if typeof define is "function" and define.amd
+ # Global
+ umd jQuery
+) ($) ->
+
+ ###
+ # Filter elements by whether they have not yet been processed.
+ #
+ # @param {string} id - The data id used to determine whether the given
+ # elements have already been processed or not.
+ #
+ # @return jQuery element collection of elements that have now run once by the
+ # given id.
+ #
+ # @example
+ # // Change the color of the text to green.
+ # $('p').once('changecolor').css('color', 'green');
+ ###
+ $.fn.once = (id) ->
+ # The id parameter is required.
+ throw new Error("An ID is required when calling jQuery.once()") unless id
+
+ # Build the name for the data identifier.
+ name = "jquery-once-" + id
+
+ # Filter the elements by which do not have the data yet.
+ @filter ->
+ $(this).data(name) isnt true
+ .data name, true
+
+ ###
+ # Removes the once data from the given elements, based on the given ID.
+ #
+ # @param {string} id - A required string representing the name of the data id
+ # which should be used when filtering the elements. This only filters elements
+ # that have already been processed by the once function. The id should be the
+ # same id that was originally passed to the `.once()` function.
+ #
+ # @return jQuery element collection that had their `once` data removed.
+ # @example
+ # // Remove the once
+ # $('p').removeOnce('changecolor').each(function() {
+ # // This function is run for each element that had its once data removed.
+ # });
+ ###
+ $.fn.removeOnce = (id) ->
+ # Filter through the elements to find the once'd elements.
+ @findOnce(id).removeData "jquery-once-" + id
+
+ ###
+ # Filters elements that have already been processed once.
+ #
+ # @param {string} id - A required string representing the name of the data id
+ # which should be used when filtering the elements. This only filters elements
+ # that have already been processed by the once function. The id should be the
+ # same id that was originally passed to the `.once()` function.
+ #
+ # @return jQuery element collection of elements that have been run once.
+ #
+ # @example
+ # // Remove the once
+ # $('p').findOnce('changecolor').each(function() {
+ # // This function is run for each element that has already been run once.
+ # });
+ ###
+ $.fn.findOnce = (id) ->
+ # Filter the elements by which do have the data.
+ name = "jquery-once-" + id
+ @filter ->
+ $(this).data(name) is true
diff --git a/jquery.once.js b/jquery.once.js
index a547c1a..d946eb3 100644
--- a/jquery.once.js
+++ b/jquery.once.js
@@ -1,38 +1,99 @@
// Generated by CoffeeScript 1.8.0
-(function() {
- (function(factory) {
- if (typeof exports === "object") {
- factory(require("jquery"));
- } else if (typeof define === "function" && define.amd) {
- define(["jquery"], factory);
- } else {
- factory(jQuery);
+
+/*
+ * jQuery Once `2.0.0-alpha.10`
+ * http://github.com/robloach/jquery-once
+ *
+ * Act on jQuery elements only once.
+ *
+ * - [MIT](http://www.opensource.org/licenses/mit-license.php)
+ * - [GPL-2.0](http://www.gnu.org/licenses/gpl.html)
+ */
+
+/*
+ * Universal Module Definition
+ *
+ * [jQuery](http://jquery.com) is a dependency, so we wrap the code with a
+ * [UMD](https://github.com/umdjs/umd) pattern in order to allow loading jQuery,
+ * and jQuery Once, using [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD),
+ * [CommonJS](http://en.wikipedia.org/wiki/CommonJS), or as a global variable.
+ */
+(function(umd) {
+ if (typeof exports === "object") {
+ return umd(require("jquery"));
+ }
+ if (typeof define === "function" && define.amd) {
+ return define(["jquery"], umd);
+ }
+ return umd(jQuery);
+})(function($) {
+
+ /*
+ * Filter elements by whether they have not yet been processed.
+ *
+ * @param {string} id - The data id used to determine whether the given
+ * elements have already been processed or not.
+ *
+ * @return jQuery element collection of elements that have now run once by the
+ * given id.
+ *
+ * @example
+ * // Change the color of the text to green.
+ * $('p').once('changecolor').css('color', 'green');
+ */
+ $.fn.once = function(id) {
+ var name;
+ if (!id) {
+ throw new Error("An ID is required when calling jQuery.once()");
}
- })(function($) {
- var uuid;
- uuid = 0;
- $.fn.once = function(id) {
- var name;
- if (!id) {
- throw new Error("An ID is required when calling jQuery.once()");
- }
- name = "jquery-once-" + id;
- return this.filter(function() {
- return $(this).data(name) !== true;
- }).data(name, true);
- };
- $.fn.removeOnce = function(id) {
- return this.findOnce(id).removeData("jquery-once-" + id);
- };
- $.fn.findOnce = function(id) {
- var name;
- name = "jquery-once-" + id;
- return this.filter(function() {
- return $(this).data(name) === true;
- });
- };
- });
+ name = "jquery-once-" + id;
+ return this.filter(function() {
+ return $(this).data(name) !== true;
+ }).data(name, true);
+ };
+
+ /*
+ * Removes the once data from the given elements, based on the given ID.
+ *
+ * @param {string} id - A required string representing the name of the data id
+ * which should be used when filtering the elements. This only filters elements
+ * that have already been processed by the once function. The id should be the
+ * same id that was originally passed to the `.once()` function.
+ *
+ * @return jQuery element collection that had their `once` data removed.
+ * @example
+ * // Remove the once
+ * $('p').removeOnce('changecolor').each(function() {
+ * // This function is run for each element that had its once data removed.
+ * });
+ */
+ $.fn.removeOnce = function(id) {
+ return this.findOnce(id).removeData("jquery-once-" + id);
+ };
-}).call(this);
+ /*
+ * Filters elements that have already been processed once.
+ *
+ * @param {string} id - A required string representing the name of the data id
+ * which should be used when filtering the elements. This only filters elements
+ * that have already been processed by the once function. The id should be the
+ * same id that was originally passed to the `.once()` function.
+ *
+ * @return jQuery element collection of elements that have been run once.
+ *
+ * @example
+ * // Remove the once
+ * $('p').findOnce('changecolor').each(function() {
+ * // This function is run for each element that has already been run once.
+ * });
+ */
+ return $.fn.findOnce = function(id) {
+ var name;
+ name = "jquery-once-" + id;
+ return this.filter(function() {
+ return $(this).data(name) === true;
+ });
+ };
+});
//# sourceMappingURL=jquery.once.js.map
diff --git a/jquery.once.js.map b/jquery.once.js.map
index bc71b56..2e51832 100644
--- a/jquery.once.js.map
+++ b/jquery.once.js.map
@@ -3,8 +3,8 @@
"file": "jquery.once.js",
"sourceRoot": "",
"sources": [
- "jquery.once.litcoffee"
+ "jquery.once.coffee"
],
"names": [],
- "mappings": ";AAaI;AAAA,EAAA,CAAC,SAAC,OAAD,GAAA;AACC,IAAA,IAAG,MAAA,CAAA,OAAA,KAAkB,QAArB;AACE,MAAA,OAAA,CAAQ,OAAA,CAAQ,QAAR,CAAR,CAAA,CADF;KAAA,MAEK,IAAG,MAAA,CAAA,MAAA,KAAiB,UAAjB,IAAgC,MAAM,CAAC,GAA1C;AACH,MAAA,MAAA,CAAO,CAAC,QAAD,CAAP,EAAmB,OAAnB,CAAA,CADG;KAAA,MAAA;AAGH,MAAA,OAAA,CAAQ,MAAR,CAAA,CAHG;KAHN;EAAA,CAAD,CAAA,CAQE,SAAC,CAAD,GAAA;AACA,QAAA,IAAA;AAAA,IAAA,IAAA,GAAO,CAAP,CAAA;AAAA,IA0BA,CAAC,CAAC,EAAE,CAAC,IAAL,GAAY,SAAC,EAAD,GAAA;AAEV,UAAA,IAAA;AAAA,MAAA,IAAmE,CAAA,EAAnE;AAAA,cAAU,IAAA,KAAA,CAAM,8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KAAA;AAAA,EAaA,CAAC,CAAC,EAAE,CAAC,IAAL,GAAY,SAAC,EAAD,GAAA;AAEV,QAAA,IAAA;AAAA,IAAA,IAAA,CAAA,EAAA;AAAA,YAAU,IAAA,KAAA,CAAM,8CAAN,CAAV,CAAA;KAAA;AAAA,IAGA,IAAA,GAAO,cAAA,GAAiB,EAHxB,CAAA;WAMA,IAAC,CAAA,MAAD,CAAQ,SAAA,GAAA;aACN,CAAA,CAAE,IAAF,CAAO,CAAC,IAAR,CAAa,IAAb,CAAA,KAAwB,KADlB;IAAA,CAAR,CAEA,CAAC,IAFD,CAEM,IAFN,EAEY,IAFZ,EARU;EAAA,CAbZ,CAAA;AAyBA;AAAA;;;;;;;;;;;;;;KAzBA;AAAA,EAwCA,CAAC,CAAC,EAAE,CAAC,UAAL,GAAkB,SAAC,EAAD,GAAA;WAEhB,IAAC,CAAA,QAAD,CAAU,EAAV,CAAa,CAAC,UAAd,CAAyB,cAAA,GAAiB,EAA1C,EAFgB;EAAA,CAxClB,CAAA;AA4CA;AAAA;;;;;;;;;;;;;;;KA5CA;SA4DA,CAAC,CAAC,EAAE,CAAC,QAAL,GAAgB,SAAC,EAAD,GAAA;AAEd,QAAA,IAAA;AAAA,IAAA,IAAA,GAAO,cAAA,GAAiB,EAAxB,CAAA;WACA,IAAC,CAAA,MAAD,CAAQ,SAAA,GAAA;aACN,CAAA,CAAE,IAAF,CAAO,CAAC,IAAR,CAAa,IAAb,CAAA,KAAsB,KADhB;IAAA,CAAR,EAHc;EAAA,EA9DhB;AAAA,CAPF,CAlBA,CAAA"
} \ No newline at end of file
diff --git a/jquery.once.litcoffee b/jquery.once.litcoffee
deleted file mode 100644
index 43bf8ea..0000000
--- a/jquery.once.litcoffee
+++ /dev/null
@@ -1,132 +0,0 @@
-# [jQuery Once](http://github.com/robloach/jquery-once)
-
-Act on jQuery elements only once.
-
-
-## API
-
-* [Universal Module Definition](#universal-module-definition)
-* [`once()`](#once)
-* [`findOnce()`](#findonce)
-* [`removeOnce()`](#removeonce)
-
-
-## Universal Module Definition
-
-[jQuery](http://jquery.com) is a dependency, so we wrap the code with a
-[UMD](https://github.com/umdjs/umd) pattern in order to allow loading jQuery,
-and jQuery Once, using [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD),
-[CommonJS](http://en.wikipedia.org/wiki/CommonJS), or as a global variable.
-
- ((factory) ->
- if typeof exports is "object"
- factory require("jquery")
- else if typeof define is "function" and define.amd
- define ["jquery"], factory
- else
- factory jQuery
- return
- ) ($) ->
- uuid = 0
-
-
-## `.once()`
-
-Filter elements by whether they have not yet been processed.
-
-### Parameters
-
-* `id` The data id used to determine whether the given elements have already
-been processed or not.
-
-### Returns
-
-jQuery element collection of elements that have now run once by
-the given id.
-
-### Example
-
-``` javascript
-// Change the color of the text to green.
-$('p').once('changecolor').css('color', 'green');
-```
-
-### Source
-
- $.fn.once = (id) ->
- # The id parameter is required.
- throw new Error("An ID is required when calling jQuery.once()") if not id
-
- # Build the name for the data identifier.
- name = "jquery-once-" + id
-
- # Filter the elements by which do not have the data yet.
- @filter ->
- $(this).data(name) isnt true
- .data name, true
-
-
-## `.removeOnce()`
-
-Removes the once data from the given elements, based on the given ID.
-
-### Parameters
-
-* `id` *string* A required string representing the name of the data id which
-should be used when filtering the elements. This only filters elements that
-have already been processed by the once function. The id should be the same id
-that was originally passed to the `.once()` function.
-
-### Returns
-
-jQuery element collection that had their `once` data removed.
-
-### Example
-
-``` javascript
-// Remove the once
-$('p').removeOnce('changecolor').each(function() {
- // This function is run for each element that had its once data removed.
-});
-```
-
-### Source
-
- $.fn.removeOnce = (id) ->
- # Filter through the elements to find the once'd elements.
- @findOnce(id).removeData "jquery-once-" + id
-
-
-## `.findOnce()`
-
-Filters elements that have already been processed once.
-
-### Parameters
-
-* `id` *string* A required string representing the name of the data id which
-should be used when filtering the elements. This only filters elements that have
-already been processed by the once function. The id should be the same id that
-was originally passed to the `.once()` function.
-
-### Returns
-
-jQuery element collection of elements that have been run once.
-
-### Example
-
-``` javascript
-// Remove the once
-$('p').findOnce('changecolor').each(function() {
- // This function is run for each element that has already been run once.
-});
-```
-
-### Source
-
- $.fn.findOnce = (id) ->
- # Filter the elements by which do have the data.
- name = "jquery-once-" + id
- @filter ->
- $(this).data(name) is true
-
- return
diff --git a/package.json b/package.json
index bcbe91e..ce4ef32 100644
--- a/package.json
+++ b/package.json
@@ -58,12 +58,12 @@
"qunitjs": "~1.15.0"
},
"scripts": {
- "compile": "./node_modules/.bin/coffee -m -c *.litcoffee",
- "coffeelint": "./node_modules/.bin/coffeelint *.litcoffee",
+ "compile": "./node_modules/.bin/coffee -m -c -b *.coffee",
+ "coffeelint": "./node_modules/.bin/coffeelint *.coffee",
"test": "npm run-script coffeelint && npm run-script compile && npm run-script qunit",
"projectz": "./node_modules/.bin/projectz compile",
"release": "npm run-script test && npm run-script uglify && npm run-script projectz",
"uglify": "grunt uglify",
"qunit": "grunt qunit"
}
-} \ No newline at end of file
+}