mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-16 20:35:09 +00:00
53a3d9a379
Some of the code encountered accessed mw.config directly, I cleaned that up by migrating to mmv.Config, which is an abstraction added to avoid peeking at mw.config directly. Bug: T132064 Change-Id: I2a95ba703e6c7f46296f8e435bceec769dceebf9
61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
( function ( mw, $ ) {
|
|
var MTH = {};
|
|
|
|
MTH.enterFullscreenMock = function () {
|
|
this.first().addClass( 'jq-fullscreened' ).data( 'isFullscreened', true );
|
|
|
|
$( document ).trigger( $.Event( 'jq-fullscreen-change', { element: this, fullscreen: true } ) );
|
|
};
|
|
|
|
MTH.exitFullscreenMock = function () {
|
|
this.first().removeClass( 'jq-fullscreened' ).data( 'isFullscreened', false );
|
|
|
|
$( document ).trigger( $.Event( 'jq-fullscreen-change', { element: this, fullscreen: false } ) );
|
|
};
|
|
|
|
/**
|
|
* Returns the exception thrown by callback, or undefined if no exception was thrown.
|
|
* @param {Function} callback
|
|
* @returns {*}
|
|
*/
|
|
MTH.getException = function ( callback ) {
|
|
var ex;
|
|
try {
|
|
callback();
|
|
} catch ( e ) {
|
|
ex = e;
|
|
}
|
|
return ex;
|
|
};
|
|
|
|
/**
|
|
* Returns a fake local storage which is not saved between reloads.
|
|
* @param {object} [initialData]
|
|
*/
|
|
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 ); }
|
|
};
|
|
};
|
|
|
|
/**
|
|
* Returns a viewer object with all the appropriate placeholder functions.
|
|
* @returns {[type]} [description]
|
|
*/
|
|
MTH.getMultimediaViewer = function () {
|
|
return new mw.mmv.MultimediaViewer( {
|
|
imageQueryParameter: $.noop,
|
|
language: $.noop,
|
|
recordVirtualViewBeaconURI: $.noop,
|
|
extensions: function () {
|
|
return { 'jpg' : 'default' };
|
|
}
|
|
} );
|
|
};
|
|
|
|
mw.mmv.testHelpers = MTH;
|
|
} )( mediaWiki, jQuery ); |