Classes
-
new Class()
A base class providing some helper methods for prototypal inheritance.
-
-
new Bounds()
A simple bounding rectangle class.
-
-
new Factory()
A factory for classes allowing them to be registered and created using a friendly name.
-
-
new Debugger( key )
A debug utility class that can be enabled across sessions using the given
key
by storing its state inlocalStorage
. -
-
new Throttle( [ idle ] )
A timer to throttle the execution of code.
-
Namespaces
-
is
Contains common type checking utility methods.
-
-
fn
Contains common function utility methods.
-
-
url
Contains common url utility methods.
-
-
str
Contains common string utility methods.
-
-
obj
Contains common object utility methods.
-
-
transition
Contains common utility methods and members for the CSS transition property.
-
Members
-
<static> $ :jQuery
A reference to the jQuery object the library is registered with.
-
Description
This is used internally for all jQuery operations to help work around issues where multiple jQuery libraries have been included in a single page.
Examples
<script src="jquery-1.12.4.js"></script> <script src="my-plugin.js"></script> <script src="jquery-2.2.4.js"></script> <script> jQuery(function($){ $(".selector").myPlugin(); // => This would throw a TypeError: $(...).myPlugin is not a function }); </script>
<script src="jquery-1.12.4.js"></script> <script src="my-plugin.js"></script> <script src="jquery-2.2.4.js"></script> <script> FooGallery.utils.$(function($){ $(".selector").myPlugin(); // => It works! }); </script>
Details
-
<static> version :string
The version of this library.
-
Details
Methods
-
<static> versionCompare( version1, version2 ) → {number}
Compares two version numbers.
-
Description
This method will compare two version numbers that conform to the basic MAJOR.MINOR.PATCH format returning the result as a simple number. This method will handle short version string comparisons e.g.
1.0
versus1.0.1
.Parameters
Name Type Description version1
string The first version to use in the comparison.
version2
string The second version to compare to the first.
Returns
Examples
console.log( FooGallery.utils.versionCompare( "0", "0" ) ); // => 0 console.log( FooGallery.utils.versionCompare( "0.0", "0" ) ); // => 0 console.log( FooGallery.utils.versionCompare( "0.0", "0.0.0" ) ); // => 0 console.log( FooGallery.utils.versionCompare( "0.1", "0.0.0" ) ); // => 1 console.log( FooGallery.utils.versionCompare( "0.1", "0.0.1" ) ); // => 1 console.log( FooGallery.utils.versionCompare( "1", "0.1" ) ); // => 1 console.log( FooGallery.utils.versionCompare( "1.10", "1.9" ) ); // => 1 console.log( FooGallery.utils.versionCompare( "1.9", "1.10" ) ); // => -1 console.log( FooGallery.utils.versionCompare( "1", "1.1" ) ); // => -1 console.log( FooGallery.utils.versionCompare( "1.0.9", "1.1" ) ); // => -1
console.log( FooGallery.utils.versionCompare( "not-a-version", "1.1" ) ); // => NaN console.log( FooGallery.utils.versionCompare( "1.1", "not-a-version" ) ); // => NaN console.log( FooGallery.utils.versionCompare( "not-a-version", "not-a-version" ) ); // => NaN
Details
-
<static> ready( callback )
Waits for the DOM to be accessible and then executes the supplied callback.
-
Parameters
Name Type Description callback
FooGallery.utils~readyCallback The function to execute once the DOM is accessible.
Examples
FooGallery.utils.ready(function($){ // do something });
Details
-
<static> uniqueId( $element [, prefix ] ) → {string}
Generate and apply a unique id for the given
$element
. -
Parameters
Name Type Attributes Default Description $element
jQuery The jQuery element object to retrieve an id from or generate an id for.
prefix
string <optional> "uid-" A prefix to append to the start of any generated ids.
Returns
Examples
// alias the FooGallery.utils namespace var _ = FooGallery.utils; // create some elements to test var $hasId = $("<span/>", {id: "exists"}); var $generatedId = $("<span/>"); var $generatedPrefixedId = $("<span/>"); console.log( _.uniqueId( $hasId ) ); // => "exists" console.log( $hasId.attr( "id" ) ); // => "exists" console.log( _.uniqueId( $generatedId ) ); // => "uid-1" console.log( $generatedId.attr( "id" ) ); // => "uid-1" console.log( _.uniqueId( $generatedPrefixedId, "plugin-" ) ); // => "plugin-2" console.log( $generatedPrefixedId.attr( "id" ) ); // => "plugin-2"
Details
-
<static> removeUniqueId( $element )
Remove the id from the given
$element
if it was set using the uniqueId method. -
Parameters
Name Type Description $element
jQuery The jQuery element object to remove a generated id from.
Examples
// alias the FooGallery.utils namespace var _ = FooGallery.utils; // create some elements to test var $hasId = $("<span/>", {id: "exists"}); var $generatedId = $("<span/>"); var $generatedPrefixedId = $("<span/>"); console.log( _.uniqueId( $hasId ) ); // => "exists" console.log( _.uniqueId( $generatedId ) ); // => "uid-1" console.log( _.uniqueId( $generatedPrefixedId, "plugin-" ) ); // => "plugin-2"
Details
-
<static> getViewportBounds( [ inflate ] ) → {FooGallery.utils.Bounds}
Gets the bounding rectangle of the current viewport.
-
Parameters
Name Type Attributes Description inflate
number <optional> An amount to inflate the bounds by. A positive number will expand the bounds outside of the visible viewport while a negative one would shrink it.
Returns
Details
-
<static> getElementBounds( element ) → {FooGallery.utils.Bounds}
Get the bounding rectangle for the supplied element.
-
Parameters
Name Type Description element
jQuery | HTMLElement | string The jQuery wrapper around the element, the element itself, or a CSS selector to retrieve the element with.
Returns
Details
-
<static> selectify( classes ) → {object|string}
Simple utility method to convert space delimited strings of CSS class names into a CSS selector.
-
Parameters
Name Type Description classes
string | Array.<string> | object A single space delimited string of CSS class names to convert or an array of them with each item being included in the selector using the OR (
,
) syntax as a separator. If an object is supplied the result will be an object with the same property names but the values converted to selectors.Returns
Details
Type Definitions
-
readyCallback( $ )
The callback for the FooGallery.utils.ready method.
-
Parameters
Name Type Description $
jQuery The instance of jQuery the plugin was registered with.
Details