Members
-
<nullable> masonry :Masonry
The current Masonry instance for the template.
-
Description
This value is
null
until after thepre-init.foogallery
event has been raised.Details
-
cls :FooGallery.MasonryTemplate~CSSClasses
The CSS classes for the Masonry template.
-
Details
-
sel :FooGallery.MasonryTemplate~CSSSelectors
The CSS selectors for the Masonry template.
-
Details
-
$el :jQuery
The jQuery object for the template container.
-
Details
-
opt :FooGallery~Options
The options for the template.
-
Details
-
template :object
Any custom options for the template.
-
Details
-
id :string
The ID for the template.
-
Details
-
createdSelf :boolean
Whether or not the template created its' own container element.
-
Details
-
il8n :FooGallery~il8n
The il8n strings for the template.
-
Details
-
items :FooGallery.Items
The item manager for the template.
-
Details
-
<nullable> pages :FooGallery.Paging
The page manager for the template.
-
Details
-
state :FooGallery.State
The state manager for the template.
-
Details
Methods
-
<protected> create() → {jQuery}
Create a new container element for the template returning the jQuery object.
-
Returns
Examples
<div id="{current template id}" class="foogallery fg-masonry {additional classes}"> <div class="fg-column-width"></div> <div class="fg-gutter-width"></div> </div>
Details
-
<protected> onPreInit( event, self )
Listens for the
pre-init.foogallery
event. -
Description
Performs all pre-initialization work required by the Masonry template, specifically handling the
layout
option and building up the required Masonry options.Parameters
Name Type Description event
jQuery.Event The jQuery.Event object for the event.
self
FooGallery.MasonryTemplate The current instance of the template.
Details
-
<protected> onParsedItems( event, self, items )
Listens for the
parsed-items.foogallery
event. -
Description
Instructs Masonry to perform a layout operation whenever items are parsed.
Parameters
Name Type Description event
jQuery.Event The jQuery.Event object for the event.
self
FooGallery.MasonryTemplate The current instance of the template.
items
Array.<FooGallery.Item> The array of items that were parsed.
Details
-
<protected> onAppendedItems( event, self, items )
Listens for the
appended-items.foogallery
event. -
Description
Instructs Masonry to perform a layout operation whenever items are appended.
Parameters
Name Type Description event
jQuery.Event The jQuery.Event object for the event.
self
FooGallery.MasonryTemplate The current instance of the template.
items
Array.<FooGallery.Item> The array of items that were parsed.
Details
-
<protected> onDetachItem( event, self, item )
Listens for the
detach-item.foogallery
event. -
Description
If not already overridden this method will override the default logic to detach an item and replace it with Masonry specific logic.
Parameters
Name Type Description event
jQuery.Event The jQuery.Event object for the event.
self
FooGallery.MasonryTemplate The current instance of the template.
item
FooGallery.Item The item to detach.
Details
-
<protected> onDetachedItems( event, self, items )
Listens for the
detached-items.foogallery
event. -
Description
Instructs Masonry to perform a layout operation whenever items are detached.
Parameters
Name Type Description event
jQuery.Event The jQuery.Event object for the event.
self
FooGallery.MasonryTemplate The current instance of the template.
items
Array.<FooGallery.Item> The array of items that were detached.
Details
-
initialize( [ parent ] ) → {Promise.<FooGallery.Template>}
Initialize the template.
-
Description
Once resolved all options, objects and elements required by the template have been parsed or created and the initial load is complete.
Parameters
Name Type Attributes Description parent
jQuery | HTMLElement | string <optional> If no element was supplied to the constructor you must supply a parent element for the template to append itself to. This can be a jQuery object, HTMLElement or a CSS selector.
Returns
Fires
Details
-
destroy()
Destroy the template.
-
Description
Once this method is called it can not be stopped and the template will be destroyed.
Fires
Details
-
loadAvailable() → {Promise.<Array.<FooGallery.Item>>}
Check if any available items need to be loaded and loads them.
-
Returns
Details
-
raise( eventName [, args ] ) → {jQuery.Event}
Raises the supplied
eventName
on the template element. -
Description
This method also executes any listeners set on the template object itself. These listeners are not bound to the element but are executed after the event is raised but before any default logic is executed. The names of these listeners use the following convention; prefix the
eventName
with"on-"
and then camel-case the result. e.g."pre-init"
becomesonPreInit
.Parameters
Name Type Attributes Description eventName
string The name of the event to raise.
args
Array <optional> An additional arguments to supply to the listeners for the event.
Returns
Examples
FooGallery.MyTemplate = FooGallery.Template.extend({ onPreInit: function(event, template){ // do something } });
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
-
Options
An object containing the default options for the Masonry template.
-
Description
Apart from the
layout
option the template object is identical to the standard Masonry options.
Note that the template overrides and sets its' own values for the following options based primarily on thelayout
value;itemSelector
,columnWidth
,gutter
,isFitWidth
,percentPosition
andtransitionDuration
.
Thelayout
value can be classed into two categories, fixed width and column type layouts. You can see in the examples below the options the template sets for each of these types of layouts.Properties
Name Type Attributes Description template
object <optional> An object containing the custom options for the Masonry template.
Name Type Attributes Default Description layout
string <optional> "col4" The layout to use for the template; "fixed", "col2", "col3", "col4" or "col5".
cls
FooGallery.MasonryTemplate~CSSClasses <optional> An object containing all CSS classes for the Masonry template.
Examples
{ "itemSelector": ".fg-item", // this selector is generated from the classes.item.elem value. "columnWidth": ".fg-column-width", // this selector is generated from the classes.masonry.columnWidth value. "gutter": ".fg-gutter-width", // this selector is generated from the classes.masonry.gutterWidth value. "transitionDuration": 0 // disables masonry's inline transitions to prevent them overriding our CSS class transitions }
{ "isFitWidth": true, "percentPosition": false }
{ "isFitWidth": false, "percentPosition": true }
Details
-
CSSClasses
An object containing the default CSS classes for the Masonry template.
-
Properties
Name Type Attributes Default Description container
string <optional> "foogallery fg-masonry" The base CSS class names to apply to the container element.
columnWidth
string <optional> "fg-column-width" The CSS class name to apply to the Masonry column sizer element.
gutterWidth
string <optional> "fg-gutter-width" The CSS class name to apply to the Masonry gutter sizer element.
layout
object <optional> An object containing all layout classes.
Name Type Attributes Default Description fixed
string <optional> "fg-masonry-fixed" The CSS class name for a fixed width layout.
col2
string <optional> "fg-masonry-2col" The CSS class name for a two column layout.
col3
string <optional> "fg-masonry-3col" The CSS class name for a three column layout.
col4
string <optional> "fg-masonry-4col" The CSS class name for a four column layout.
col5
string <optional> "fg-masonry-5col" The CSS class name for a five column layout.
layouts
string <optional> "fg-masonry-fixed fg-masonry-2col fg-masonry-3col fg-masonry-4col fg-masonry-5col" A space delimited string of all CSS class names from the
layout
object.Details
-
CSSSelectors
An object containing all CSS selectors for the Masonry template.
-
Description
This object is automatically generated from a classes object and its properties mirror those except the class name values are converted into CSS selectors.
Properties
Name Type Attributes Default Description container
string <optional> ".foogallery.fg-masonry" The CSS selector for the container element.
columnWidth
string <optional> ".fg-column-width" The CSS selector for the Masonry column sizer element.
gutterWidth
string <optional> ".fg-gutter-width" The CSS selector for the Masonry gutter sizer element.
layout
object <optional> An object containing all layout CSS selectors.
Name Type Attributes Default Description fixed
string <optional> ".fg-masonry-fixed" The CSS selector for a fixed width layout.
col2
string <optional> ".fg-masonry-2col" The CSS selector for a two column layout.
col3
string <optional> ".fg-masonry-3col" The CSS selector for a three column layout.
col4
string <optional> ".fg-masonry-4col" The CSS selector for a four column layout.
col5
string <optional> ".fg-masonry-5col" The CSS selector for a five column layout.
Details