|
@@ -1,10 +1,10 @@
|
|
|
|
|
|
-* Runs a waterfall of promises: calls each task, passing the result
|
|
|
-* from the previous one as an argument. The first task is run with an empty array.
|
|
|
-*
|
|
|
-* @param {array} methods of Promises to run waterfall on
|
|
|
-* @return {Promise} of the final task
|
|
|
-*/
|
|
|
+ * Runs a waterfall of promises: calls each task, passing the result
|
|
|
+ * from the previous one as an argument. The first task is run with an empty array.
|
|
|
+ *
|
|
|
+ * @param {array} methods of Promises to run waterfall on
|
|
|
+ * @return {Promise} of the final task
|
|
|
+ */
|
|
|
function promiseWaterfall(methods) {
|
|
|
const [resolvedPromise, ...tasks] = methods;
|
|
|
const finalTaskPromise = tasks.reduce(function (prevTaskPromise, task) {
|
|
@@ -15,13 +15,13 @@ function promiseWaterfall(methods) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-* Toggles a class on a DOM element
|
|
|
-* This is how we roll $('.element').toggleClass in a non-jQuery world
|
|
|
-*
|
|
|
-* @param {String} el selector
|
|
|
-* @param {String} className to toggle
|
|
|
-* @return {String}
|
|
|
-*/
|
|
|
+ * Toggles a class on a DOM element
|
|
|
+ * This is how we roll $('.element').toggleClass in a non-jQuery world
|
|
|
+ *
|
|
|
+ * @param {String} el selector
|
|
|
+ * @param {String} className to toggle
|
|
|
+ * @return {String}
|
|
|
+ */
|
|
|
function toggleClass(el, className) {
|
|
|
if (el.classList) {
|
|
|
el.classList.toggle(className);
|
|
@@ -39,12 +39,12 @@ function toggleClass(el, className) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-* Adds a class to a DOM element
|
|
|
-*
|
|
|
-* @param {String} el selector
|
|
|
-* @param {String} className to add
|
|
|
-* @return {String}
|
|
|
-*/
|
|
|
+ * Adds a class to a DOM element
|
|
|
+ *
|
|
|
+ * @param {String} el selector
|
|
|
+ * @param {String} className to add
|
|
|
+ * @return {String}
|
|
|
+ */
|
|
|
function addClass(el, className) {
|
|
|
if (el.classList) {
|
|
|
el.classList.add(className);
|
|
@@ -54,12 +54,12 @@ function addClass(el, className) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-* Removes a class to a DOM element
|
|
|
-*
|
|
|
-* @param {String} el selector
|
|
|
-* @param {String} className to remove
|
|
|
-* @return {String}
|
|
|
-*/
|
|
|
+ * Removes a class to a DOM element
|
|
|
+ *
|
|
|
+ * @param {String} el selector
|
|
|
+ * @param {String} className to remove
|
|
|
+ * @return {String}
|
|
|
+ */
|
|
|
function removeClass(el, className) {
|
|
|
if (el.classList) {
|
|
|
el.classList.remove(className);
|
|
@@ -69,14 +69,14 @@ function removeClass(el, className) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-* Adds multiple listeners to to a DOM element
|
|
|
-* Equvalent to jQuery’s `$form.on('drag dragstart dragend dragover dragenter dragleave drop')`.
|
|
|
-*
|
|
|
-* @param {String} el selector
|
|
|
-* @param {String} events to add, like `drag dragstart dragend dragover dragenter dragleave drop`
|
|
|
-* @param {requestCallback} cb
|
|
|
-* @return {String}
|
|
|
-*/
|
|
|
+ * Adds multiple listeners to to a DOM element
|
|
|
+ * Equvalent to jQuery’s `$form.on('drag dragstart dragend dragover dragenter dragleave drop')`.
|
|
|
+ *
|
|
|
+ * @param {String} el selector
|
|
|
+ * @param {String} events to add, like `drag dragstart dragend dragover dragenter dragleave drop`
|
|
|
+ * @param {requestCallback} cb
|
|
|
+ * @return {String}
|
|
|
+ */
|
|
|
function addListenerMulti(el, events, cb) {
|
|
|
const eventsArray = events.split(' ');
|
|
|
for (let event in eventsArray) {
|