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 element
jQuery | 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
src
andsrcset
properties to determine which url to load for the thumb. -
Parameters
Name Type Attributes Default Description refresh
boolean <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 bounds
FooGallery.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 definition
Object <optional> An object containing any methods to implement/override.
Returns
Examples
// 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 ); // => true
Details
-
<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 name
string The name of the function to override.
fn
function The new function to override with, the
_super
method will be made available within this function.Examples
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() ); // => false
Details
Type Definitions
-
maxWidthCallback( item ) → {number}
Called when setting an items' image size to prevent layout jumps.
-
Parameters
Name Type Description item
FooGallery.Item The item to determine the maxWidth for.
Returns
Examples
{ "maxWidth": function(item){ return item.$image.outerWidth(); } }
Details
-
Options
A simple object containing an items' default values.
-
Properties
Name Type Attributes Default Description id
string <optional>
<nullable>The
data-id
attribute for the outer element.href
string <optional>
<nullable>The
href
attribute for the anchor element.src
string <optional>
<nullable>The
src
attribute for the image element.srcset
string <optional>
<nullable>The
srcset
attribute for the image element.width
number <optional> 0 The width of the image.
height
number <optional> 0 The height of the image.
title
string <optional>
<nullable>The title for the image.
description
string <optional>
<nullable>The description for the image.
tags
Array.<string> <optional> [] The
data-tags
attribute for the outer element.maxWidth
FooGallery.Item~maxWidthCallback <optional>
<nullable>Called when setting an items' image size. If not supplied the images outer width is used.
attr
FooGallery.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 elem
string <optional> "fg-item" The CSS class for the outer containing
div
element of an item.inner
string <optional> "fg-item-inner" The CSS class for the inner containing
div
element of an item.anchor
string <optional> "fg-thumb" The CSS class for the
a
element of an item.image
string <optional> "fg-image" The CSS class for the
img
element of an item.loading
string <optional> "fg-idle" The CSS class applied to an item that is waiting to be loaded.
loading
string <optional> "fg-loading" The CSS class applied to an item while it is loading.
loaded
string <optional> "fg-loaded" The CSS class applied to an item once it is loaded.
error
string <optional> "fg-error" The CSS class applied to an item if it throws an error while loading.
caption
object <optional> A simple object containing the CSS classes used by an items' caption.
Name Type Attributes Default Description elem
string <optional> "fg-caption" The CSS class for the outer containing
div
element of a caption.inner
string <optional> "fg-caption-inner" The CSS class for the inner containing
div
element of a caption.title
string <optional> "fg-caption-title" The CSS class for the title
div
element of a caption.description
string <optional> "fg-caption-desc" The CSS class for the description
div
element 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 elem
object <optional> {} The attributes to apply to the items' outer
<div/>
element.inner
object <optional> {} The attributes to apply to the items' inner element.
anchor
object <optional> {} The attributes to apply to the items' anchor element.
image
object <optional> {} The attributes to apply to the items' image element.
caption
object <optional> A simple object used to store any additional attributes to apply to an items' caption elements.
Name Type Attributes Default Description elem
object <optional> {} The attributes to apply to the captions' outer
<div/>
element.inner
object <optional> {} The attributes to apply to the captions' inner element.
title
object <optional> {} The attributes to apply to the captions' title element.
description
object <optional> {} The attributes to apply to the captions' description element.
Details