2014-01-06 21:53:42 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the MediaWiki extension MultimediaViewer.
|
|
|
|
*
|
|
|
|
* MultimediaViewer is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MultimediaViewer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MultimediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2014-02-25 01:54:05 +00:00
|
|
|
( function ( mw ) {
|
|
|
|
var MLBP;
|
|
|
|
|
2014-01-06 21:53:42 +00:00
|
|
|
/**
|
2014-02-25 01:54:05 +00:00
|
|
|
* Some interface functions for MMV.
|
|
|
|
* FIXME merge with Lightboxinterface, figure out better separation of responsibilities
|
2014-02-25 02:28:49 +00:00
|
|
|
* @class mw.mmv.MultiLightbox
|
2014-02-03 23:20:54 +00:00
|
|
|
* @constructor
|
|
|
|
* @param {number} initial
|
|
|
|
* @param {Function} InterfaceClass type of interface to use
|
2014-02-25 02:28:49 +00:00
|
|
|
* @param {mw.mmv.MultimediaViewer} viewer
|
2014-01-06 21:53:42 +00:00
|
|
|
*/
|
2014-02-17 15:09:23 +00:00
|
|
|
function MultiLightbox( initial, InterfaceClass, viewer ) {
|
2014-02-25 01:54:05 +00:00
|
|
|
this.currentIndex = initial || 0;
|
|
|
|
this.onInterfaceReady = [];
|
|
|
|
this.iface = new InterfaceClass( viewer );
|
|
|
|
this.interfaceReady();
|
2014-01-06 21:53:42 +00:00
|
|
|
}
|
|
|
|
|
2014-02-25 01:54:05 +00:00
|
|
|
MLBP = MultiLightbox.prototype;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Schedules stuff to run when IF is ready (or fires it immediately if it is already).
|
|
|
|
* TODO replace with event or promise
|
|
|
|
* @param {function()} func
|
|
|
|
*/
|
|
|
|
MLBP.onInterface = function ( func ) {
|
|
|
|
if ( this.onInterfaceReady !== undefined ) {
|
|
|
|
this.onInterfaceReady.push( func );
|
|
|
|
} else {
|
|
|
|
func();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface ready "event"
|
|
|
|
* TODO replace with real event or promise
|
|
|
|
*/
|
|
|
|
MLBP.interfaceReady = function () {
|
|
|
|
var i;
|
|
|
|
|
|
|
|
for ( i = 0; i < this.onInterfaceReady.length; i++ ) {
|
|
|
|
this.onInterfaceReady[i]();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.onInterfaceReady = undefined;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens the lightbox.
|
|
|
|
*/
|
|
|
|
MLBP.open = function () {
|
|
|
|
this.iface.empty();
|
|
|
|
this.iface.attach();
|
|
|
|
};
|
2014-01-06 21:53:42 +00:00
|
|
|
|
2014-02-25 02:28:49 +00:00
|
|
|
mw.mmv.MultiLightbox = MultiLightbox;
|
2014-02-25 01:54:05 +00:00
|
|
|
}( mediaWiki ) );
|