foo-utils v1.0.0
FooUtils
Contains common utility methods and classes used in our plugins.
Usage
Either use the foo-utils.js or foo-utils.min.js files in the dist/ directory with the default namespace FooUtils or if you want to embed this as part of another package you can rename the namespace and file as part of a copy/concat/uglify task by using something like the below.
copy: {
main: {
src: './node_modules/foo-utils/dist/foo-utils.js',
dest: 'compiled/my-api-utils.js',
options: {
process: function (content, srcpath) {
return content.replace(/FooUtils/g, "MyApi.utils");
}
}
}
},The above simply regex replaces all occurrences of FooUtils to MyApi.utils within the JavaScript files and then renames the file to my-api-utils.js. As this is a simple regex replace the namespace MyApi must exist prior to the my-api-utils.js file being included in the page.
This package does expose a custom grunt task called foo-utils that can be used to perform the above and it requires just two options to be set; namespace and dest.
"foo-utils": {
options: {
namespace: "MyApi.utils",
dest: "./dist/my-api-utils.js"
}
},Ideally the above would be used as a step in a larger build process that would include the my-api-utils.js file as part of its own concat or uglify tasks resulting in a single file so any include order namespace issues are no longer a problem.
Changelog
1.0.0
There are considerable changes for this version as I included babel in the build and performed a cleanup of old/unused methods.
- Breaking Change: Removed the
FooUtils.uniqueIdandFooUtils.removeUniqueIdmethods as they were no longer being used in any of our plugins. - Breaking Change: Removed the
FooUtils.scrollParentmethod as it was no longer being used due to issues in some browsers. - Breaking Change: Removed the
FooUtils.srcmethod as it was no longer being used in any of our plugins. - Breaking Change: Removed the
FooUtils.versionComparemethod as it was only being used by the lib when it registered itself and that was changed in version 0.2.0. - Breaking Change: Removed the
FooUtils.animationnamespace and moved theFooUtils.animation.requestFrameandFooUtils.animation.cancelFramemethods to the baseFooUtilsnamespace asFooUtils.requestFrameandFooUtils.cancelFrame. - Breaking Change: Removed the
FooUtils.transition.transitionendandFooUtils.transition.supportedproperties as all supported browsers now have support for thetransitionendevent and browser detection is no longer required. - Breaking Change: Updated the signature of the
FooUtils.transition.start(element, triggerFn, propertyName, timeout)method to provide better functionality now that all supported browsers support thetransitionendevent. - Breaking Change: Removed the
FooUtils.Boundsobject as its functionality can be better implemented using anIntersectionObserver. - Breaking Change: Removed the
FooUtils.fn.whenmethod and replaced it withFooUtils.fn.allandFooUtils.fn.allSettledto match the signatures of the standardPromiseapi. - Breaking Change: Updated the signatures of the
FooUtils.fn.resolveWithandFooUtils.fn.rejectWithmethods to better match those provided by jQuery. The first parameter is now thethisArgwithin any callbacks. - Breaking Change: Changed the
FooUtils.Class.basesmethod toFooUtils.Class.getBaseClasses. - Breaking Change: Removed the
FooUtils.fn.checkandFooUtils.fn.fetchmethods as they were no longer being used in any of our plugins. - Breaking Change: Removed the
FooUtils.Factoryclass, use the newFooUtils.ClassRegistryclass instead. - Added new
FooUtils.ClassRegistryclass to replace the previousFooUtils.Factoryclass. - Added new
FooUtils.transition.disable(element, modifyFn)method to help with working with transitions. This method temporarily disables all transitions on an element, executes the callback to modify the element, and then enables all transitions again once modifications are complete. - Added new
FooUtils.transition.modify(element, modifyFn [, immediate [, propertyName]])method to help with working with transitions. Theimmediateparameter changes how themodifyFnis used;trueis applied immediately with no transition,falseis applied immediately but waits for the transition to end. - Added new
FooUtils.fn.allmethod to match the functionality provided by thePromise.allmethod. - Added new
FooUtils.fn.allSettledmethod to match the functionality provided by thePromise.allSettledmethod. - Added new
FooUtils.fn.resolvemethod to match the functionality provided by thePromise.resolvemethod and the previousFooUtils.fn.resolveWithmethod. - Added new
FooUtils.fn.rejectmethod to match the functionality provided by thePromise.rejectmethod and the previousFooUtils.fn.rejectWithmethod.
0.2.2
- Added new
FooUtils.inArraymethod to test if a value exists in an array. Essentially a wrapper around the nativeindexOfmethod on an array, but it checks if the haystack is an actual array.
0.2.1
- Breaking Change: Removed the
FooUtils.Debuggerclass, it's usefulness had come to an end, and it was reporting as a cookie in Chrome because it checked on the existence of localStorage as the script was parsed. - Breaking Change: Removed the default instance of the
FooUtils.FullscreenAPIclass which was exposed asFooUtils.fullscreenas not all projects need it and initializing it by default was unnecessary overhead.
0.2.0
- Breaking Change: Changed how the lib registers itself to the global. Previously it would only register itself if it didn't exist, or the existing version was older. The version check is no longer performed.
- Added new
FooUtils.findmethod to pluck a single value from an array or object. - Added new
FooUtils.eachmethod to iterate over arrays or objects. - Added new
FooUtils.Event.parsemethod that splits an event name into its type and namespace. - Updated the
FooUtils.transition.duration,FooUtils.animation.durationandFooUtils.animation.iterationsmethods to handle multiple values. - Updated the
FooUtils.EventClassto expose various internal members publicly. This class now exposes aneventsobject as well as aaddListenerandremoveListenermethods. - Updated the
FooUtils.fn.whenmethod to handle values that are not promises passed in as part of the array. - Updated the
FooUtils.str.formatmethod to use the newFooUtils.eachmethod internally. - Updated the
FooUtils.str.fromandFooUtils.str.untilmethods by simply removing unnecessary parameter checks. - Updated the
devDependenciesin thepackage.json. - Updated various comments across the library to give better intellisense.
0.1.9
- Added new
FooUtils.Class.basesmethod to return an array of all inherited classes.
0.1.8
- Added new
FooUtils.str.kebabmethod for formatting strings to kebab case (this-is-kebab).
0.1.7
- Fixed issue with transitions/animations not firing on newly appended elements.
0.1.6
- Fixed inconsistent results across browsers when using the
FooUtils.url.partsmethod. - Added new
FooUtils.animationnamespace containing various properties and methods to help with CSS animations. - Added new
FooUtils.FullscreenAPIclass, exposed as theFooUtils.fullscreeninstance, to provide a cross browser fullscreen API. - Added new
FooUtils.Timerclass to provide a simple event based timer.
0.1.5
- Fixed issue with the
FooUtils.EventClass'sonandoffmethods when using an object with space separated event names.
0.1.4
- Updated the
FooUtils.EventClassandFooUtils.Eventclasses to handle namespaced events. - Updated the
FooUtils.EventClass'sonandoffmethods to accept an object containing event type to handler mappings.
0.1.3
- Fixed context issue with
FooUtils.fn.debounce.
0.1.2
- Updated
FooUtils.scrollParent( element, axis, def )to explicitly test foroverflow:scrolloroverflow:autorather than just notoverflow:hidden.
0.1.1
- Updated
FooUtils.scrollParent( element, axis, def )to exclude<html/>from the result as its scroll events are raised on thedocument.
0.1.0
Start of changelog. Older versions have no breaking changes.
- Breaking Change: Removed
FooUtils.Throttleclass, replaced with two methodsFooUtils.fn.debounce( fn, time )andFooUtils.fn.throttle( fn, time ). - Added new
FooUtils.EventClassbase class andFooUtils.Eventclasses to allow objects to be subscribed to and emit events through the supplied.on( eventName, callback [, thisArg] ),.off( eventName [, callback] )and.trigger( eventName, args )methods. - Added new
FooUtils.selectify( classes )method. - Added new
FooUtils.src( src, srcset, srcWidth, srcHeight, renderWidth, renderHeight, devicePixelRatio )method. - Added new
FooUtils.scrollParent( element, axis, def )method.
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
