Skip to main content

Javascript library to make gallery overlays

Project description


This package provides a javascript library to make gallery overlays such as Lightbox. But the main difference is that you have full control over the rendering and fetching of gallery items.

The gallery is able to notify if the user has reached the first or last item. This can be useful when more items should be loaded as a batch.

The items of the gallery can be extended or reset.

The gallery always tracks the active item.

An API provides a way to control the gallery from outside.


Add the package as dependency to your


or to your buildout configuration:

eggs += ftw.showroom

and rerun buildout.

Install the Generic Setup profile.


Plone 4.3

JavaScript development


Rebuilding the library (resources/javascript.js):

grunt build

Watching for changes and rebuild the bundle automatically:

grunt watch

or the default task

grunt watch


Running all test:

npm test


grunt test

Running a specific test:

grunt test --grep="Name of your test"

Client library

Getting Started

The client library depends on Grunt. Assuming you already have Node.js installed on your system, run the following command:

sudo npm install -g grunt

To install the dependencies, run the following command:

npm install

And with npm you get the following packages:

  • Grunt - JavaScript task runner.
  • Babel - ES6 Transpiler.
  • Browserify - Dependency Bundler
  • Karma - JavaScript test runner.
  • Jasmine - JavaScript test suite.
  • Chai - JavaScript Assertion Library.


Run the following command to re-build the library:

grunt build

Run the following command to watch for changes which trigger a rebuild:


Build options

See for more information about browserify.

Source Maps

Browserify comes with a built-in support to generate source maps. It is already enabled by default, but feel free to disable source maps. Refer to this article to enable source maps in Google Chrome, if you haven’t already done so.


Run all tests

grunt test

Run a specific test

grunt test --grep="Name of your test"


Creates an empty showroom instance with default options

let showroom = Showroom();

The showroom constructor accepts a NodeList or a jQuery. The items can provide a target as an HTML data attribute (data-showroom-target) to define the endpoint where the item will fetch its content from. To make a title visible in the overlay provide a title as an HTML data attribute (data-showroom-title).

  <li class="item"
    <a>Item 1</a>
  <li class="item"
    <a>Item 2</a>
let items = document.querySelectorAll(".item");
let showroom = Showroom(items);


let items = $(".item");
let showroom = Showroom(items);


The showrooms provide the following options.

Option Default Description
cssClass “ftw-showroom” Class attribute on the root element of the gallery
render See rendering. section Override the default render behavior
tail Empty function Called when the user reaches the last element of the gallery
head Empty function Is getting called when the user reaches the first element of the gallery
fetch See fetching. section Override the default fetch behavior
beforeRender noop Hook to augment the item for example
template See template section Override the default gallery template
target body Element Define a selector where the gallery will be attached
offset 0 Offset for the current item counter, useful for batches


ftw.showroom fires the following events on document:

Event Params Description
showroom:item:shown showroom Invoked every time an item is shown, so if showroom opens, every time the selected showroom item changes.

To listen to an event use the following code:

$(document).on('showroom:item:shown', function (showroom) {
  // do something with the showroom/item


The default fetching function uses the target provided by each item to make an AJAX call to retrieve its content.

function fetch(item) { return $.get(; };

This function can be overridden, see Configuration.

let showroom = Showroom(items,
    fetch: (item) => { return "<p>Some other content</p>"; }


The default rendering function returns an HTML string using the default Handlebars template padding the internal showroom data, the prefeteched content and the active item.

function render(content) {
  return $.when(content).pipe((content) => {
    return $(template({ showroom: data, content: content, item: register.current }));

This function can be overridden, see Configuration.

let showroom = Showroom(items,
    render: (content) => { return $(template()); }


References are useful if you want to open a showroom item that is referenced by more than one element on the same page. You just have to add the showroom-reference class and the data-showroom-target-item attribute to make the connection. The data-showroom-target-item attribute contains an id which references a showroom item on the page. You have to set the data-showroom-id by manually on the showroom item to make the connection with the reference.

There is currently no interface to make the connection manually. But you have to call showroom.refresh() to refresh the references.

<!-- The showroom item -->

<a href="#"

<!-- The reference (a link in that case) -->

<a class="showroom-reference"


Opens a specific item. If no item is specified the showroom tries to show the first in the store otherwise it does nothing.;



Closes the overlay by hiding the element.


Opens the next item in the item queue. When the pointer reaches the last item the showroom does nothing.;


Opens the previous item in the item queue. When the pointer reaches the first item the showroom does nothing.



Extend the current item queue with new items. The items are appended at the end of the queue. The pointer remains unaffected. The append method accepts a NodeList or a jQuery

let newItems = document.querySelectorAll(".newItems");


let newItems = $(".newItems");


Extend the current item queue with new items, similar to the append method, but the items are prepended at the beginning of the queue. The pointer remains unaffected. The prepend method accepts a NodeList or a jQuery

let newItems = document.querySelectorAll(".newItems");


let newItems = $(".newItems");


Reset the current item store with new items. The overlay will be closed and the pointer set to 0. To empty the item store reset with no arguments.

let newItems = document.querySelectorAll(".newItems");


let newItems = document.querySelectorAll(".newItems");


After destroying the showroom is no longer able to open any items. The store will be reset and the marker class removed. The overlay will be closed as well. All items will loose their data-showroom-id.



Updates the total value and rerenders the opened overlay. The method does only allow numeric values.



Updates the offset. Prevents negative offsets. The method does only allow numeric values.



Refreshes the showroom references.



1.5.1 (2018-03-12)

  • 1.5.0 Did not work properly, since the dist command was not executed. [mathias.leimgruber]

1.5.0 (2018-03-08)

  • Introduce “showroom:item:shown” event

1.4.0 (2017-07-11)

  • Introduce before render hook. [Kevin Bieri]

1.3.1 (2016-11-02)

  • Introduce uninstall profile [Kevin Bieri]
  • Introduce upgrade steps [Kevin Bieri]
  • Cleanup version pinnings [Kevin Bieri]

1.3.0 (2016-10-18)

  • Refactor event binding using event delegation. Since these changes all the showroom items must have showroom-item class Therefore manually refreshing events is no longer necessary [Kevin Bieri]

1.2.1 (2016-08-29)

  • Prevent register#set from calling tail twice [Kevin Bieri]

1.2.0 (2016-08-23)

  • Make template configurable [Kevin Bieri]
  • Introduce showroom references [Kevin Bieri]
  • Provide offset option for showroom. The offset is added to the current number and allows to display correct item number for batched items. [deiferni]

1.1.1 (2016-07-04)

  • Fix unordered list styles. [Kevin Bieri]

1.1.0 (2016-06-27)

  • Provide option to prepend items to the showroom queue. [phgross]

1.0.0 (2016-05-24)

  • Nothing changed yet

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ftw.showroom, version 1.5.1
Filename, size File type Python version Upload date Hashes
Filename, size ftw.showroom-1.5.1.tar.gz (67.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page