Members
- 
			<nullable> masonry :MasonryThe current Masonry instance for the template. 
- 
	DescriptionThis value is nulluntil after thepre-init.foogalleryevent has been raised.Details
- 
			cls :FooGallery.MasonryTemplate~CSSClassesThe CSS classes for the Masonry template. 
- 
	Details
- 
			sel :FooGallery.MasonryTemplate~CSSSelectorsThe CSS selectors for the Masonry template. 
- 
	Details
- 
			$el :jQueryThe jQuery object for the template container. 
- 
	Details
- 
			opt :FooGallery~OptionsThe options for the template. 
- 
	Details
- 
			template :objectAny custom options for the template. 
- 
	Details
- 
			id :stringThe ID for the template. 
- 
	Details
- 
			createdSelf :booleanWhether or not the template created its' own container element. 
- 
	Details
- 
			il8n :FooGallery~il8nThe il8n strings for the template. 
- 
	Details
- 
			items :FooGallery.ItemsThe item manager for the template. 
- 
	Details
- 
			<nullable> pages :FooGallery.PagingThe page manager for the template. 
- 
	Details
- 
			state :FooGallery.StateThe state manager for the template. 
- 
	Details
Methods
- 
			<protected> create() → {jQuery}Create a new container element for the template returning the jQuery object. 
- 
	ReturnsExamplesThe following displays the raw HTML output by this method. <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.foogalleryevent.
- 
	DescriptionPerforms all pre-initialization work required by the Masonry template, specifically handling the layoutoption and building up the required Masonry options.ParametersName Type Description eventjQuery.Event The jQuery.Event object for the event. selfFooGallery.MasonryTemplate The current instance of the template. Details
- 
			<protected> onParsedItems( event, self, items )Listens for the parsed-items.foogalleryevent.
- 
	DescriptionInstructs Masonry to perform a layout operation whenever items are parsed. ParametersName Type Description eventjQuery.Event The jQuery.Event object for the event. selfFooGallery.MasonryTemplate The current instance of the template. itemsArray.<FooGallery.Item> The array of items that were parsed. Details
- 
			<protected> onAppendedItems( event, self, items )Listens for the appended-items.foogalleryevent.
- 
	DescriptionInstructs Masonry to perform a layout operation whenever items are appended. ParametersName Type Description eventjQuery.Event The jQuery.Event object for the event. selfFooGallery.MasonryTemplate The current instance of the template. itemsArray.<FooGallery.Item> The array of items that were parsed. Details
- 
			<protected> onDetachItem( event, self, item )Listens for the detach-item.foogalleryevent.
- 
	DescriptionIf not already overridden this method will override the default logic to detach an item and replace it with Masonry specific logic. ParametersName Type Description eventjQuery.Event The jQuery.Event object for the event. selfFooGallery.MasonryTemplate The current instance of the template. itemFooGallery.Item The item to detach. Details
- 
			<protected> onDetachedItems( event, self, items )Listens for the detached-items.foogalleryevent.
- 
	DescriptionInstructs Masonry to perform a layout operation whenever items are detached. ParametersName Type Description eventjQuery.Event The jQuery.Event object for the event. selfFooGallery.MasonryTemplate The current instance of the template. itemsArray.<FooGallery.Item> The array of items that were detached. Details
- 
			initialize( [ parent ] ) → {Promise.<FooGallery.Template>}Initialize the template. 
- 
	DescriptionOnce resolved all options, objects and elements required by the template have been parsed or created and the initial load is complete. ParametersName Type Attributes Description parentjQuery | 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. ReturnsFiresDetails
- 
			destroy()Destroy the template. 
- 
	DescriptionOnce this method is called it can not be stopped and the template will be destroyed. FiresDetails
- 
			loadAvailable() → {Promise.<Array.<FooGallery.Item>>}Check if any available items need to be loaded and loads them. 
- 
	ReturnsDetails
- 
			raise( eventName [, args ] ) → {jQuery.Event}Raises the supplied eventNameon the template element.
- 
	DescriptionThis 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 eventNamewith"on-"and then camel-case the result. e.g."pre-init"becomesonPreInit.ParametersName Type Attributes Description eventNamestring The name of the event to raise. argsArray <optional> An additional arguments to supply to the listeners for the event. ReturnsExamplesThe following displays a listener for the "pre-init.foogallery"event in a sub-classed template.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. 
- 
	DescriptionParametersName Type Attributes Description definitionObject <optional> An object containing any methods to implement/override. ReturnsExamplesThe 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. 
- 
	DescriptionThis 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. ParametersName 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.ExamplesThe 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
- 
			OptionsAn object containing the default options for the Masonry template. 
- 
	DescriptionApart from the layoutoption 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 thelayoutvalue;itemSelector,columnWidth,gutter,isFitWidth,percentPositionandtransitionDuration.
 Thelayoutvalue 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.PropertiesName Type Attributes Description templateobject <optional> An object containing the custom options for the Masonry template. Name Type Attributes Default Description layoutstring <optional> "col4" The layout to use for the template; "fixed", "col2", "col3", "col4" or "col5". clsFooGallery.MasonryTemplate~CSSClasses <optional> An object containing all CSS classes for the Masonry template. ExamplesFor both fixed and column layouts the template sets the below option values. { "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 }For fixed layouts ( "fixed") the template sets the below options. If a number was supplied for thecolumnWidthorgutteroptions it is applied to the relevant elements before they are replaced by the selector seen above.{ "isFitWidth": true, "percentPosition": false }For column layouts ( "col2","col3","col4","col5") the template sets the below options.{ "isFitWidth": false, "percentPosition": true }Details
- 
			CSSClassesAn object containing the default CSS classes for the Masonry template. 
- 
	PropertiesName Type Attributes Default Description containerstring <optional> "foogallery fg-masonry" The base CSS class names to apply to the container element. columnWidthstring <optional> "fg-column-width" The CSS class name to apply to the Masonry column sizer element. gutterWidthstring <optional> "fg-gutter-width" The CSS class name to apply to the Masonry gutter sizer element. layoutobject <optional> An object containing all layout classes. Name Type Attributes Default Description fixedstring <optional> "fg-masonry-fixed" The CSS class name for a fixed width layout. col2string <optional> "fg-masonry-2col" The CSS class name for a two column layout. col3string <optional> "fg-masonry-3col" The CSS class name for a three column layout. col4string <optional> "fg-masonry-4col" The CSS class name for a four column layout. col5string <optional> "fg-masonry-5col" The CSS class name for a five column layout. layoutsstring <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 layoutobject.Details
- 
			CSSSelectorsAn object containing all CSS selectors for the Masonry template. 
- 
	DescriptionThis object is automatically generated from a classes object and its properties mirror those except the class name values are converted into CSS selectors. PropertiesName Type Attributes Default Description containerstring <optional> ".foogallery.fg-masonry" The CSS selector for the container element. columnWidthstring <optional> ".fg-column-width" The CSS selector for the Masonry column sizer element. gutterWidthstring <optional> ".fg-gutter-width" The CSS selector for the Masonry gutter sizer element. layoutobject <optional> An object containing all layout CSS selectors. Name Type Attributes Default Description fixedstring <optional> ".fg-masonry-fixed" The CSS selector for a fixed width layout. col2string <optional> ".fg-masonry-2col" The CSS selector for a two column layout. col3string <optional> ".fg-masonry-3col" The CSS selector for a three column layout. col4string <optional> ".fg-masonry-4col" The CSS selector for a four column layout. col5string <optional> ".fg-masonry-5col" The CSS selector for a five column layout. Details