Members
-
<readonly> isAttached :boolean
Whether or not the items' elements are appended to the template.
-
Details
-
<readonly> isCreated :boolean
Whether or not the items' elements are created and can be used.
-
Details
-
<readonly> isLoading :boolean
Whether or not the items' image is currently loading.
-
Details
-
<readonly> isLoaded :boolean
Whether or not the items' image has been loaded.
-
Details
-
<readonly> isError :boolean
Whether or not the items' image threw an error while loading.
-
Details
-
<nullable> $el :jQuery
-
Details
-
<nullable> $inner :jQuery
-
Details
-
<nullable> $anchor :jQuery
-
Details
-
<nullable> $image :jQuery
-
Details
-
<nullable> $caption :jQuery
-
Details
-
id :string
-
Details
-
href :string
-
Details
-
src :string
-
Details
-
srcset :string
-
Details
-
width :number
-
Details
-
height :number
-
Details
-
title :string
-
Details
-
description :string
-
Details
-
attrItem :FooGallery.Item~Attributes
-
Details
-
tags :Array.<string>
-
Details
-
<nullable> maxWidth :FooGallery.Item~maxWidthCallback
-
Details
-
tmpl :FooGallery.Template
The template that created this component.
-
Details
Methods
-
destroy()
Destroy the item preparing it for garbage collection.
-
Details
-
parse( element ) → {boolean}
Parse the supplied element updating the current items' properties.
-
Parameters
Name Type Description elementjQuery | HTMLElement | string The element to parse.
Returns
Fires
Details
-
create() → {boolean}
Create the items' DOM elements and populate the corresponding properties.
-
Returns
Fires
Details
-
append() → {boolean}
Append the item to the current template.
-
Returns
Fires
Details
-
detach() → {boolean}
Detach the item from the current template preserving its' data and events.
-
Returns
Details
-
load() → {Promise.<FooGallery.Item>}
Load the items' $image.
-
Returns
Details
-
fix() → {FooGallery.Item}
Attempts to set a inline width and height on the $image to prevent layout jumps.
-
Returns
Details
-
unfix() → {FooGallery.Item}
Removes any inline width and height values set on the $image.
-
Returns
Details
-
getThumbUrl( [ refresh ] ) → {string}
Inspect the
srcandsrcsetproperties to determine which url to load for the thumb. -
Parameters
Name Type Attributes Default Description refreshboolean <optional> false Whether or not to force refreshing of the cached value.
Returns
Details
-
scrollTo()
Scroll the item into the center of the viewport.
-
Details
-
bounds() → {FooGallery.utils.Bounds}
Get the bounds for the item.
-
Returns
Details
-
intersects( bounds ) → {boolean}
Checks if the item bounds intersects the supplied bounds.
-
Parameters
Name Type Description boundsFooGallery.utils.Bounds The bounds to check.
Returns
Details
-
<static> extend( [ definition ] ) → {function}
Creates a new class that inherits from this one which in turn allows itself to be extended.
-
Description
Parameters
Name Type Attributes Description definitionObject <optional> An object containing any methods to implement/override.
Returns
Examples
The below shows an example of how to implement inheritance using this method.
// create a base Person class var Person = FooGallery.utils.Class.extend({ construct: function(isDancing){ this.dancing = isDancing; }, dance: function(){ return this.dancing; } }); var Ninja = Person.extend({ construct: function(){ // Call the inherited version of construct() this._super( false ); }, dance: function(){ // Call the inherited version of dance() return this._super(); }, swingSword: function(){ return true; } }); var p = new Person(true); console.log( p.dance() ); // => true var n = new Ninja(); console.log( n.dance() ); // => false console.log( n.swingSword() ); // => true console.log( p instanceof Person && p.constructor === Person && p instanceof FooGallery.utils.Class && n instanceof Ninja && n.constructor === Ninja && n instanceof Person && n instanceof FooGallery.utils.Class ); // => trueDetails
-
<static> override( name, fn )
Overrides a single method on this class.
-
Description
This is a helper method for overriding a single function of a FooGallery.utils.Class or one of its child classes. This uses the FooGallery.utils.fn.addOrOverride method internally and simply provides the correct prototype.
Parameters
Name Type Description namestring The name of the function to override.
fnfunction The new function to override with, the
_supermethod will be made available within this function.Examples
The below example wraps the
Person.prototype.dancemethod with a new one that inverts the result. Note the override applies even to instances of the class that are already created.var Person = FooGallery.utils.Class.extend({ construct: function(isDancing){ this.dancing = isDancing; }, dance: function(){ return this.dancing; } }); var p = new Person(true); console.log( p.dance() ); // => true Person.override("dance", function(){ // Call the original version of dance() return !this._super(); }); console.log( p.dance() ); // => falseDetails
Type Definitions
-
maxWidthCallback( item ) → {number}
Called when setting an items' image size to prevent layout jumps.
-
Parameters
Name Type Description itemFooGallery.Item The item to determine the maxWidth for.
Returns
Examples
An example of the default behavior this callback replaces would look like the below.
{ "maxWidth": function(item){ return item.$image.outerWidth(); } }Details
-
Options
A simple object containing an items' default values.
-
Properties
Name Type Attributes Default Description idstring <optional>
<nullable>The
data-idattribute for the outer element.hrefstring <optional>
<nullable>The
hrefattribute for the anchor element.srcstring <optional>
<nullable>The
srcattribute for the image element.srcsetstring <optional>
<nullable>The
srcsetattribute for the image element.widthnumber <optional> 0 The width of the image.
heightnumber <optional> 0 The height of the image.
titlestring <optional>
<nullable>The title for the image.
descriptionstring <optional>
<nullable>The description for the image.
tagsArray.<string> <optional> [] The
data-tagsattribute for the outer element.maxWidthFooGallery.Item~maxWidthCallback <optional>
<nullable>Called when setting an items' image size. If not supplied the images outer width is used.
attrFooGallery.Item~Attributes <optional> Additional attributes to apply to the items' elements.
Details
-
CSSClasses
A simple object containing the CSS classes used by an item.
-
Properties
Name Type Attributes Default Description elemstring <optional> "fg-item" The CSS class for the outer containing
divelement of an item.innerstring <optional> "fg-item-inner" The CSS class for the inner containing
divelement of an item.anchorstring <optional> "fg-thumb" The CSS class for the
aelement of an item.imagestring <optional> "fg-image" The CSS class for the
imgelement of an item.loadingstring <optional> "fg-idle" The CSS class applied to an item that is waiting to be loaded.
loadingstring <optional> "fg-loading" The CSS class applied to an item while it is loading.
loadedstring <optional> "fg-loaded" The CSS class applied to an item once it is loaded.
errorstring <optional> "fg-error" The CSS class applied to an item if it throws an error while loading.
captionobject <optional> A simple object containing the CSS classes used by an items' caption.
Name Type Attributes Default Description elemstring <optional> "fg-caption" The CSS class for the outer containing
divelement of a caption.innerstring <optional> "fg-caption-inner" The CSS class for the inner containing
divelement of a caption.titlestring <optional> "fg-caption-title" The CSS class for the title
divelement of a caption.descriptionstring <optional> "fg-caption-desc" The CSS class for the description
divelement of a caption.Details
-
Attributes
A simple object used to store any additional attributes to apply to an items' elements.
-
Properties
Name Type Attributes Default Description elemobject <optional> {} The attributes to apply to the items' outer
<div/>element.innerobject <optional> {} The attributes to apply to the items' inner element.
anchorobject <optional> {} The attributes to apply to the items' anchor element.
imageobject <optional> {} The attributes to apply to the items' image element.
captionobject <optional> A simple object used to store any additional attributes to apply to an items' caption elements.
Name Type Attributes Default Description elemobject <optional> {} The attributes to apply to the captions' outer
<div/>element.innerobject <optional> {} The attributes to apply to the captions' inner element.
titleobject <optional> {} The attributes to apply to the captions' title element.
descriptionobject <optional> {} The attributes to apply to the captions' description element.
Details