mediawiki-extensions-Multim.../resources/multilightbox/multilightbox.js
Gilles Dubuc a5cddef17a Lazy-load mmv
Also removes the index inside the location hash

Change-Id: I9429ff0101ab891f2c4c6aa2d989fbef0813252d
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/136
2014-02-18 15:55:15 -08:00

53 lines
1.1 KiB
JavaScript

( function () {
var MLBP;
/**
* @class mlb.MultiLightbox
* @constructor
* @param {number} [start=0]
* @param {Function} [InterfaceClass] type of interface to use
*/
function MultiLightbox( start, InterfaceClass ) {
this.currentIndex = start || 0;
this.onInterfaceReady = [];
this.initializeInterface( InterfaceClass );
this.interfaceReady();
}
MLBP = MultiLightbox.prototype;
/**
* Instantiates and initializes the interface object
* @param {Function} [InterfaceClass] type of interface to use
*/
MLBP.initializeInterface = function ( InterfaceClass ) {
InterfaceClass = InterfaceClass || window.LightboxInterface;
this.iface = new InterfaceClass();
};
MLBP.onInterface = function ( func ) {
if ( this.onInterfaceReady !== undefined ) {
this.onInterfaceReady.push( func );
} else {
func();
}
};
MLBP.interfaceReady = function () {
var i;
for ( i = 0; i < this.onInterfaceReady.length; i++ ) {
this.onInterfaceReady[i]();
}
this.onInterfaceReady = undefined;
};
MLBP.open = function () {
this.iface.empty();
this.iface.attach();
};
window.MultiLightbox = MultiLightbox;
}() );