2014-01-30 07:22:26 +00:00
|
|
|
( function ( mw, $ ) {
|
|
|
|
var MTH = {};
|
|
|
|
|
2014-04-14 18:32:30 +00:00
|
|
|
MTH.enterFullscreenMock = function () {
|
2014-01-30 07:22:26 +00:00
|
|
|
this.first().addClass( 'jq-fullscreened' ).data( 'isFullscreened', true );
|
2014-04-14 18:32:30 +00:00
|
|
|
|
2014-01-30 07:22:26 +00:00
|
|
|
$( document ).trigger( $.Event( 'jq-fullscreen-change', { element: this, fullscreen: true } ) );
|
|
|
|
};
|
|
|
|
|
2014-04-14 18:32:30 +00:00
|
|
|
MTH.exitFullscreenMock = function () {
|
2014-01-30 07:22:26 +00:00
|
|
|
this.first().removeClass( 'jq-fullscreened' ).data( 'isFullscreened', false );
|
|
|
|
|
|
|
|
$( document ).trigger( $.Event( 'jq-fullscreen-change', { element: this, fullscreen: false } ) );
|
|
|
|
};
|
|
|
|
|
2014-10-03 09:15:28 +00:00
|
|
|
/**
|
|
|
|
* Returns the exception thrown by callback, or undefined if no exception was thrown.
|
2016-07-18 13:49:27 +00:00
|
|
|
*
|
2014-10-03 09:15:28 +00:00
|
|
|
* @param {Function} callback
|
2016-07-18 13:49:27 +00:00
|
|
|
* @return {*}
|
2014-10-03 09:15:28 +00:00
|
|
|
*/
|
2014-04-14 18:32:30 +00:00
|
|
|
MTH.getException = function ( callback ) {
|
|
|
|
var ex;
|
|
|
|
try {
|
|
|
|
callback();
|
|
|
|
} catch ( e ) {
|
|
|
|
ex = e;
|
|
|
|
}
|
|
|
|
return ex;
|
|
|
|
};
|
|
|
|
|
2014-10-03 09:15:28 +00:00
|
|
|
/**
|
|
|
|
* Returns a fake local storage which is not saved between reloads.
|
2016-07-18 13:49:27 +00:00
|
|
|
*
|
|
|
|
* @param {Object} [initialData]
|
2014-10-03 09:15:28 +00:00
|
|
|
*/
|
|
|
|
MTH.getFakeLocalStorage = function ( initialData ) {
|
|
|
|
var bag = new mw.Map( initialData );
|
|
|
|
|
|
|
|
return {
|
|
|
|
getItem: function ( key ) { return bag.get( key ); },
|
|
|
|
setItem: function ( key, value ) { bag.set( key, value ); },
|
|
|
|
removeItem: function ( key ) { bag.set( key, null ); }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-04-03 09:18:26 +00:00
|
|
|
/**
|
|
|
|
* Returns a viewer object with all the appropriate placeholder functions.
|
2016-07-18 13:49:27 +00:00
|
|
|
*
|
|
|
|
* @return {mv.mmv.MultiMediaViewer} [description]
|
2016-04-03 09:18:26 +00:00
|
|
|
*/
|
|
|
|
MTH.getMultimediaViewer = function () {
|
|
|
|
return new mw.mmv.MultimediaViewer( {
|
|
|
|
imageQueryParameter: $.noop,
|
|
|
|
language: $.noop,
|
|
|
|
recordVirtualViewBeaconURI: $.noop,
|
|
|
|
extensions: function () {
|
2016-07-18 13:49:27 +00:00
|
|
|
return { jpg: 'default' };
|
2016-04-03 09:18:26 +00:00
|
|
|
}
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
2014-02-25 02:28:49 +00:00
|
|
|
mw.mmv.testHelpers = MTH;
|
2016-07-18 13:49:27 +00:00
|
|
|
} )( mediaWiki, jQuery );
|