Skip to content
Snippets Groups Projects
Commit 3e646a2f authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2505649 by tarekdj, tohesi: Update jquery.once to 2.1.1

parent c583a577
No related branches found
No related tags found
No related merge requests found
/*!
* jQuery Once v2.0.2 - http://github.com/robloach/jquery-once
* jQuery Once v2.1.1 - http://github.com/robloach/jquery-once
* @license MIT, GPL-2.0
* http://opensource.org/licenses/MIT
* http://opensource.org/licenses/GPL-2.0
......@@ -15,35 +15,38 @@
* @see {@link http://github.com/umdjs/umd}
*/
(function (factory) {
"use strict";
if (typeof exports === "object") {
'use strict';
if (typeof exports === 'object') {
// CommonJS
factory(require("jquery"));
} else if (typeof define === "function" && define.amd) {
factory(require('jquery'));
} else if (typeof define === 'function' && define.amd) {
// AMD
define(["jquery"], factory);
/* globals define */
define(['jquery'], factory);
} else {
// Global object
/* globals jQuery */
factory(jQuery);
}
}(function ($) {
"use strict";
'use strict';
/**
* Ensures that the given ID is valid, returning "once" if one is not given.
* Ensures that the given ID is valid, returning 'once' if one is not given.
*
* @param {string} [id=once]
* A string representing the ID to check. Defaults to `"once"`.
* A string representing the ID to check. Defaults to `'once'`.
*
* @returns The valid ID name.
*
* @throws Error when an ID is provided, but not a string.
* @private
*/
var checkId = function(id) {
id = id || "once";
if (typeof id !== "string") {
throw new Error("The jQuery Once id parameter must be a string");
var checkId = function (id) {
id = id || 'once';
if (typeof id !== 'string') {
throw new Error('The jQuery Once id parameter must be a string');
}
return id;
};
......@@ -53,7 +56,7 @@
*
* @param {string} [id=once]
* The data ID used to determine whether the given elements have already
* been processed or not. Defaults to `"once"`.
* been processed or not. Defaults to `'once'`.
*
* @returns jQuery collection of elements that have now run once by
* the given ID.
......@@ -61,21 +64,21 @@
* @example
* ``` javascript
* // The following will change the color of each paragraph to red, just once
* // for the "changecolor" key.
* // for the 'changecolor' key.
* $('p').once('changecolor').css('color', 'red');
*
* // .once() will return a set of elements that yet to have the once ID
* // associated with them. You can return to the original collection set by
* // using .end().
* $('p')
* .once("changecolorblue")
* .css("color", "blue")
* .once('changecolorblue')
* .css('color', 'blue')
* .end()
* .css("color", "red");
* .css('color', 'red');
*
* // To execute a function on the once set, you can use jQuery's each().
* $('div.calendar').once().each(function() {
* // Since there is no once ID provided here, the key will be "once".
* $('div.calendar').once().each(function () {
* // Since there is no once ID provided here, the key will be 'once'.
* });
* ```
*
......@@ -88,10 +91,10 @@
*/
$.fn.once = function (id) {
// Build the jQuery Once data name from the provided ID.
var name = "jquery-once-" + checkId(id);
var name = 'jquery-once-' + checkId(id);
// Find elements that don't have the jQuery Once data applied to them yet.
return this.filter(function() {
return this.filter(function () {
return $(this).data(name) !== true;
}).data(name, true);
};
......@@ -103,19 +106,19 @@
* A 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. Defaults to `"once"`.
* originally passed to the once() function. Defaults to `'once'`.
*
* @returns jQuery collection of elements that were acted upon to remove their
* once data.
*
* @example
* ``` javascript
* // Remove once data with the "changecolor" ID. The result set is the
* // Remove once data with the 'changecolor' ID. The result set is the
* // elements that had their once data removed.
* $('p').removeOnce("changecolor").css("color", "");
* $('p').removeOnce('changecolor').css('color', '');
*
* // Any jQuery function can be performed on the result set.
* $("div.calendar").removeOnce().each(function() {
* $('div.calendar').removeOnce().each(function () {
* // Remove the calendar behavior.
* });
* ```
......@@ -128,7 +131,7 @@
*/
$.fn.removeOnce = function (id) {
// Filter through the elements to find the once'd elements.
return this.findOnce(id).removeData("jquery-once-" + checkId(id));
return this.findOnce(id).removeData('jquery-once-' + checkId(id));
};
/**
......@@ -138,21 +141,21 @@
* A 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. Defaults to "once".
* was originally passed to the once() function. Defaults to 'once'.
*
* @returns jQuery collection of elements that have been run once.
*
* @example
* ``` javascript
* // Find all elements that have been changecolor'ed once.
* $('p').findOnce('changecolor').each(function() {
* $('p').findOnce('changecolor').each(function () {
* // This function is called for all elements that has already once'd.
* });
*
* // Find all elements that have been acted on with the default "once" key.
* $('p').findOnce().each(function() {
* // Find all elements that have been acted on with the default 'once' key.
* $('p').findOnce().each(function () {
* // This function is called for all elements that have been acted on with
* // a "once" action.
* // a 'once' action.
* });
* ```
*
......@@ -164,9 +167,9 @@
*/
$.fn.findOnce = function (id) {
// Filter the elements by which do have the data.
var name = "jquery-once-" + checkId(id);
var name = 'jquery-once-' + checkId(id);
return this.filter(function() {
return this.filter(function () {
return $(this).data(name) === true;
});
};
......
/*!
* jQuery Once v2.0.2 - http://github.com/robloach/jquery-once
* jQuery Once v2.1.1 - http://github.com/robloach/jquery-once
* @license MIT, GPL-2.0
* http://opensource.org/licenses/MIT
* http://opensource.org/licenses/GPL-2.0
......
{"version":3,"file":"jquery.once.min.js","sources":["jquery.once.js"],"names":["factory","exports","require","define","amd","jQuery","$","checkId","id","Error","fn","once","name","this","filter","data","removeOnce","findOnce","removeData"],"mappings":";;;;;;CAgBC,SAAUA,GACT,YACA,UAAWC,WAAY,SAAU,CAE/BD,EAAQE,QAAQ,eACX,UAAWC,UAAW,YAAcA,OAAOC,IAAK,CAErDD,QAAQ,UAAWH,OACd,CAELA,EAAQK,WAEV,SAAUC,GACV,YAaA,IAAIC,GAAU,SAASC,GACrBA,EAAKA,GAAM,MACX,UAAWA,KAAO,SAAU,CAC1B,KAAM,IAAIC,OAAM,iDAElB,MAAOD,GAyCTF,GAAEI,GAAGC,KAAO,SAAUH,GAEpB,GAAII,GAAO,eAAiBL,EAAQC,EAGpC,OAAOK,MAAKC,OAAO,WACjB,MAAOR,GAAEO,MAAME,KAAKH,KAAU,OAC7BG,KAAKH,EAAM,MAiChBN,GAAEI,GAAGM,WAAa,SAAUR,GAE1B,MAAOK,MAAKI,SAAST,GAAIU,WAAW,eAAiBX,EAAQC,IAkC/DF,GAAEI,GAAGO,SAAW,SAAUT,GAExB,GAAII,GAAO,eAAiBL,EAAQC,EAEpC,OAAOK,MAAKC,OAAO,WACjB,MAAOR,GAAEO,MAAME,KAAKH,KAAU"}
\ No newline at end of file
{"version":3,"file":"jquery.once.min.js","sources":["jquery.once.js"],"names":["factory","exports","require","define","amd","jQuery","$","checkId","id","Error","fn","once","name","this","filter","data","removeOnce","findOnce","removeData"],"mappings":";;;;;;CAgBC,SAAUA,GACT,YAEA,UAAWC,WAAY,SAAU,CAE/BD,EAAQE,QAAQ,eACX,UAAWC,UAAW,YAAcA,OAAOC,IAAK,CAGrDD,QAAQ,UAAWH,OACd,CAGLA,EAAQK,WAEV,SAAUC,GACV,YAaA,IAAIC,GAAU,SAAUC,GACtBA,EAAKA,GAAM,MACX,UAAWA,KAAO,SAAU,CAC1B,KAAM,IAAIC,OAAM,iDAElB,MAAOD,GAyCTF,GAAEI,GAAGC,KAAO,SAAUH,GAEpB,GAAII,GAAO,eAAiBL,EAAQC,EAGpC,OAAOK,MAAKC,OAAO,WACjB,MAAOR,GAAEO,MAAME,KAAKH,KAAU,OAC7BG,KAAKH,EAAM,MAiChBN,GAAEI,GAAGM,WAAa,SAAUR,GAE1B,MAAOK,MAAKI,SAAST,GAAIU,WAAW,eAAiBX,EAAQC,IAkC/DF,GAAEI,GAAGO,SAAW,SAAUT,GAExB,GAAII,GAAO,eAAiBL,EAAQC,EAEpC,OAAOK,MAAKC,OAAO,WACjB,MAAOR,GAAEO,MAAME,KAAKH,KAAU"}
\ No newline at end of file
......@@ -400,10 +400,10 @@ jquery.joyride:
jquery.once:
remote: https://github.com/RobLoach/jquery-once
version: "2.0.2"
version: "2.1.1"
license:
name: GNU-GPL-2.0-or-later
url: https://github.com/RobLoach/jquery-once/blob/2.0.2/LICENSE.md
url: https://github.com/RobLoach/jquery-once/blob/2.1.1/LICENSE.md
gpl-compatible: true
js:
assets/vendor/jquery-once/jquery.once.min.js: { weight: -19, minified: true }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment