>, Customisation, Tutorials>Working with the Infradox script library

Working with the Infradox script library

Infradox XS uses a Javascript library. The library’s functions are configured with Back office settings. Many functions look for HTML elements by id’s and class names. Several functions have methods that can be overridden in your custom script.

Adding custom functions

Most of the website pages call an initialisation function once the pages is loaded. Such initialisation functions are part of the Infradox script. By adding your own script in the code editor (the “client script” file with id #4), you can call your own functions. Note that every client facing page will always call the generic client.init() function if it exists, and it will check for the presence of specific Javascript objects on specific pages. For example, on gallery pages you can use the object xsgallery, on pages with thumbnails you can use the object xsthumbs and so on.

Available custom Javascript objects

  • client
  • xsthumbs
  • xssidebarsearch
  • xsgallerygroup
  • xsgallery
  • xsfoundsets
  • xsorders
  • xsorder
  • xscart
  • xspricecalculator
  • xssearchdialog
  • xssuggestions
  • xslightboxclassic
  • xsgaevents

Thumbnail pages

The thumbnail pages use the thumbpages Javascript object. You can completely override this by enabling “thumbnail pages script” in the code editor – although it is advised to not use this to prevent compatibility problems with future updates. It is also possible to use the standard script and to then override certain methods/functions without enabling the “thumbnail pages script”. This is the preferred approach and described below.

To override certain functions, add the object xsthumbs to your custom script. You don’t have to override all the functions, just add the ones that you want to change/override.

Function nextpagebox

The nextpagebox function is used to determine if the next page box should be displayed, based on settings in Back office. To override this function, add it to your custom script. You may want to do this e.g. because you want the box to display always, never, using different HTML and so on. The standard function looks for the last thumbnail on the page and then calculates if there’s a gap. And if there is a gap, it will display the next page box.

The default HTML that is used to display the box, can be fetched from the thumbpages javascript object, thumbpages.cfg.nextpageboxhtml – which will return something like this when on a search results page (note that is will output HTML based on the page you’re on):

You can use the JSON object pagedata that exists in the HTML of all thumbnail pages in your functions.
Below is an example of the object:

.page.no is the current page
.page.count is the total number of pages
.page.slots is the number of thumbnails per page
.results.count is the number of files in the result set
.results.files is the total number of matched files
.results.pagetype is the pagetype, 1=search results
.layout.style is the current view style (e.g. grid, list, flow)
.layout.option is the current option for number of thumbnails per page, e.g. 1 for 24 per page, 2 for 48 per page and so on
.layout.fluid is either 0 or 1 if the fluid Back office setting is on
.spanning is no longer used

Function onlayoutdialog

By adding the function onlayoutdialog, you can manipulate the HTML before the dialog is displayed. E.g. to hide certain functions when the website is used on a mobile device. The normal function will still be called. To completely override the function that displays the dialog, add the function layoutdialog as described below.

Note that instead of using the default page layout dialog, you can also use buttons/links or a drop down menu for the page layout options (grid, list, small, large, flow). This is described in the article: Custom pagination bars for thumbnail pages.

Function layoutdialog

Add the function layoutdialog to override the default function that displays the layout dialog. Use the pagedata object (described above) for information about the currently selected layout options (style, option, fluid).

Function tvideo

Below is an example that is used to override the default function that displays thumbnail video. You can copy the code and change it as per your requirements. Note that the example below doesn’t have code support MSIE before version 9. The default code however does support MSIE before version 9.

Live keyword and gallery suggestions

If you want to override the functions that display the suggestions box, then add the object xssuggestions to your client script. The object in the Infradox script library is called infradoxsuggest. For more information about the suggestions function and how to configure it, read Live keyword suggestions.

Search dialog

You can create a modal search dialog to replace the default search side bar. This is described in a separate article: Creating a custom search dialog.

Gallery group pages

By default, gallery group pages use infinite scrolling if there are many gallery groups. This means that the first block of groups is loaded, and when you scroll to the bottom of the page, the next block of gallery group boxes is automatically loaded and appended to the page. You can however change this to use traditional pagination by changing the gallery group’s settings in the Gallery manager.

If you change a group’s pagination method from infinite scrolling to standard pagination, then the first block of groups is loaded and a pagination bar will show at the bottom of the page. To change how this pagination bar looks you can change the CSS. For more control you can override the pagination bar function by adding your own Javascript. Note that the default function to display the pagination bar is not called if you override it by adding your own function (described below).

You can also override the function that sets up hovering to display gallery info – if you have configured a gallery group to display with style 1, “large thumbnails”.

Add the object xsgallerygroup (see below) to your script, and then add your own code to the function onpaginationbar to manipulate the pagination bar.

The pagedat object (see above) has the following properties:

  • totalrows: the total number of rows in the dataset (each row is a gallery group)
  • parsedrows: the number of rows on the current page
  • pagenr: the current page number
  • rpp: rows per page
  • pagecount: the total number of pages based on the total number of rows and the number of rows per page

On gallery group pages, you can also use the embedded JSON object gminfo. See the example below:

Gallery pages

Add the object xsgallery (see below) to your script to have its init() function called by the standard gallery script. You init() function is called at the end of the gallery initialisation function. The first parameter is the configuration object (to view its properties you can add an alert with JSON.stringify()), and the second parameter is a callback function that you must call once your own script has executed. For example:

Set searching / xsfoundsets

This is explained in the article Set searching.

Side bar search

Add object xssidebarsearch to your script if you want to override the default search function (executed when searching from within the advanced search panel/side bar).
Example implementation:

Price calculator

The price calculator and its data/html when being displayed – on e.g. cart pages – can be manipulated by adding the xspricecalculator object to the client Javascript. This object can have methods that are called before the calculator is displayed, after its data is loaded, when HTML is generated to display on cart and order pages and so on. For detailed information, read Price calculator for RM images.

Cart page

The xscart object is used if you want to use Price agreements/subscriptions and/or the Multiple RF licences function. The cart page uses its own script that is edited separately in the code editor (template 43 – Cart script). Example code is provided – click on Load example in the code editor.
The xscart object can have the methods: beforecart, aftercart, rfmultiorderdetail, finalisecart and savecart.

Order page

The xsorder object can be added to the client script in the code editor. You can add two methods, i.e. beforeorder and afterorder.

Order history page

The xsorders object can be added to the client script in the code editor. You can add two methods, i.e. beforeorders and afterorders.

Lightbox pages (classic mode)

Add the object xslightboxclassic to have your init function called after the page has initialised. For example:


The client object is loaded on every client facing HTML page (not in back office). Please read Using Javascript in your pages for further information about this object and its methods.