new ImageViewer( element, options )

The main class for the Image Viewer template for FooGallery.

Parameters
Name Type Description
element HTMLElement | jQuery | string

The element to initialize the plugin on.

options FooGallery.ImageViewer~Options

The options to initialize the plugin with.

Members


options :FooGallery.ImageViewer~Options

The options for the plugin.

Description

This property holds a copy of any user supplied options merged with the defaults.


$el :jQuery

The jQuery object wrapping the templates items.

Description

This is the outer most element that wraps all the templates items and is generally the foogallery element.


$items :jQuery

The jQuery object containing all items for the plugin.


$current :jQuery

The jQuery object that displays the current image count.


$prev :jQuery

The jQuery object for the previous button.


$next :jQuery

The jQuery object for the next button.


<static> defaults :FooGallery.ImageViewer~Options

The defaults for the plugin.

Methods


init()

Initialize the plugin performing initial binding of events and setting up of CSS classes.


destroy()

Destroy the plugin cleaning up any bound events.


prev()

Navigate to the previous item in the collection.

Description

If there is a previous item in the collection calling this method will navigate to it displaying its' image and updating the current image count.


next()

Navigate to the next item in the collection.

Description

If there is a next item in the collection calling this method will navigate to it displaying its' image and updating the current image count.


onFooBoxPrev( e )

Handles the "foobox.previous" event allowing the plugin to remain in sync with what is displayed in the lightbox.

Parameters
Name Type Description
e jQuery.Event

The jQuery.Event object for the event.


onFooBoxNext( e )

Handles the "foobox.next" event allowing the plugin to remain in sync with what is displayed in the lightbox.

Parameters
Name Type Description
e jQuery.Event

The jQuery.Event object for the event.


onPrevClick( e )

Handles the "click" event of the previous button.

Parameters
Name Type Description
e jQuery.Event

The jQuery.Event object for the event.


onNextClick( e )

Handles the "click" event of the next button.

Parameters
Name Type Description
e jQuery.Event

The jQuery.Event object for the event.


<static> extend( [ definition ] ) → {function}

Creates a new class that inherits from this one which in turn allows itself to be extended.

Description

Every class created using this method has both the extend and override static methods added to it to allow it to be extended.

Parameters
Name Type Attributes Description
definition Object <optional>

An object containing any methods to implement/override.

Returns

A new class that inherits from the base class.

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
); // => true


<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

The below example wraps the Person.prototype.dance method 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() ); // => false

Type Definitions


Options

The options for the plugin.

Properties
Name Type Attributes Default Description
attachFooBox boolean <optional>
true

Whether or not to bind to FooBox's previous and next events and keep the plugin in sync with the lightbox.