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.
|
|
|
|
* @param {Function} callback
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
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.
|
|
|
|
* @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 ); }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2014-02-25 02:28:49 +00:00
|
|
|
mw.mmv.testHelpers = MTH;
|
2014-01-30 07:22:26 +00:00
|
|
|
} )( mediaWiki, jQuery );
|