mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-09-23 18:30:11 +00:00
Reduce number of RL modules in MultimediaViewer
Having many modules makes the startup module in the head unnecessarily longer. Things should only be in their own module if they're going to be loaded on demand on their own or are a shared dependency of separate modules that are. This change brings down the amount of modules declared by Media Viewer from 53 to 8. The ones that remain are mostly things loaded on demand. Bug: T103706 Change-Id: I5b0d29209599285b93217e96def818e641646c73
This commit is contained in:
parent
479a3a6c29
commit
95dcc971b0
File diff suppressed because it is too large
Load diff
|
@ -248,10 +248,11 @@ class MultimediaViewerHooks {
|
|||
'tests/qunit/mmv/mmv.testhelpers.js',
|
||||
),
|
||||
'dependencies' => array(
|
||||
'mmv',
|
||||
'mmv.head',
|
||||
'mmv.bootstrap',
|
||||
'mmv.ui.reuse.share',
|
||||
'mmv.ui.reuse.embed',
|
||||
'mmv',
|
||||
'mmv.ui.ondemandshareddependencies',
|
||||
'mmv.ui.reuse.shareembed',
|
||||
'mmv.ui.download.pane',
|
||||
'mmv.ui.tipsyDialog',
|
||||
'moment',
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
// We wait for document readiness because mw.loader.using writes to the DOM
|
||||
// which can cause a blank page if it happens before DOM readiness
|
||||
$document.ready( function () {
|
||||
mw.loader.using( [ 'mmv.bootstrap.autostart', 'mmv.logging.DurationLogger' ], function () {
|
||||
mw.loader.using( [ 'mmv.bootstrap.autostart' ], function () {
|
||||
mw.mmv.bootstrap.whenThumbsReady().then( function () {
|
||||
mw.mmv.durationLogger.stop( 'early-click-to-replay-click', start ).record( 'early-click-to-replay-click' );
|
||||
|
||||
|
|
|
@ -976,7 +976,7 @@
|
|||
* Preloads JS and CSS dependencies that aren't needed to display the first image, but could be needed later
|
||||
*/
|
||||
MMVP.preloadDependencies = function () {
|
||||
mw.loader.load( [ 'mmv.ui.reuse.share', 'mmv.ui.reuse.embed', 'mmv.ui.reuse.download', 'moment' ] );
|
||||
mw.loader.load( [ 'mmv.ui.reuse.shareembed', 'moment' ] );
|
||||
};
|
||||
|
||||
mw.mmv.MultimediaViewer = MultimediaViewer;
|
||||
|
|
|
@ -40,8 +40,7 @@
|
|||
*/
|
||||
this.ooTabs = null;
|
||||
|
||||
this.loadDependencies.push( 'mmv.ui.reuse.share' );
|
||||
this.loadDependencies.push( 'mmv.ui.reuse.embed' );
|
||||
this.loadDependencies.push( 'mmv.ui.reuse.shareembed' );
|
||||
|
||||
this.$dialog.addClass( 'mw-mmv-reuse-dialog' );
|
||||
|
||||
|
|
|
@ -10,7 +10,13 @@
|
|||
$.scrollTo = oldScrollTo;
|
||||
}
|
||||
|
||||
QUnit.module( 'mmv.lightboxInterface', QUnit.newMwEnvironment() );
|
||||
QUnit.module( 'mmv.lightboxInterface', QUnit.newMwEnvironment( {
|
||||
setup: function () {
|
||||
// animation would keep running, conflict with other tests
|
||||
this.sandbox.stub( $.fn, 'animate' ).returnsThis();
|
||||
}
|
||||
} ) );
|
||||
|
||||
|
||||
QUnit.test( 'Sanity test, object creation and ui construction', 20, function ( assert ) {
|
||||
var lightbox = new mw.mmv.LightboxInterface();
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
imageSrc = 'Foo bar.jpg',
|
||||
image = { filePageTitle: new mw.Title( 'File:' + imageSrc ) };
|
||||
|
||||
// animation would keep running, conflict with other tests
|
||||
this.sandbox.stub( $.fn, 'animate' ).returnsThis();
|
||||
|
||||
window.location.hash = '';
|
||||
|
||||
viewer.setupEventHandlers();
|
||||
|
@ -180,6 +183,9 @@
|
|||
},
|
||||
viewer = new mw.mmv.MultimediaViewer( { get: $.noop } );
|
||||
|
||||
// animation would keep running, conflict with other tests
|
||||
this.sandbox.stub( $.fn, 'animate' ).returnsThis();
|
||||
|
||||
viewer.thumbs = [];
|
||||
viewer.displayPlaceholderThumbnail = $.noop;
|
||||
viewer.setImage = $.noop;
|
||||
|
@ -278,6 +284,9 @@
|
|||
QUnit.test( 'resetBlurredThumbnailStates', 4, function ( assert ) {
|
||||
var viewer = new mw.mmv.MultimediaViewer( { get: $.noop } );
|
||||
|
||||
// animation would keep running, conflict with other tests
|
||||
this.sandbox.stub( $.fn, 'animate' ).returnsThis();
|
||||
|
||||
assert.ok( !viewer.realThumbnailShown, 'Real thumbnail state is correct' );
|
||||
assert.ok( !viewer.blurredThumbnailShown, 'Placeholder state is correct' );
|
||||
|
||||
|
@ -456,6 +465,9 @@
|
|||
modifiers = [ undefined, 'altKey', 'ctrlKey', 'shiftKey', 'metaKey' ],
|
||||
oldScrollTo = $.scrollTo;
|
||||
|
||||
// animation would keep running, conflict with other tests
|
||||
this.sandbox.stub( $.fn, 'animate' ).returnsThis();
|
||||
|
||||
$.scrollTo = function () { return { scrollTop: $.noop, on: $.noop, off: $.noop }; };
|
||||
|
||||
viewer.setupEventHandlers();
|
||||
|
|
|
@ -16,7 +16,12 @@
|
|||
*/
|
||||
|
||||
( function ( mw, $ ) {
|
||||
QUnit.module( 'mw.mmv.ui.Permission', QUnit.newMwEnvironment() );
|
||||
QUnit.module( 'mw.mmv.ui.Permission', QUnit.newMwEnvironment( {
|
||||
setup: function () {
|
||||
// animation would keep running, conflict with other tests
|
||||
this.sandbox.stub( $.fn, 'animate' ).returnsThis();
|
||||
}
|
||||
} ) );
|
||||
|
||||
QUnit.test( 'Constructor sanity check', 1, function ( assert ) {
|
||||
var $qf = $( '#qunit-fixture' ),
|
||||
|
@ -68,10 +73,7 @@
|
|||
QUnit.test( 'grow()', 3, function ( assert ) {
|
||||
var $qf = $( '#qunit-fixture' ),
|
||||
permission = new mw.mmv.ui.Permission( $qf ),
|
||||
text = 'Nothing to see here.',
|
||||
oldAnimate = $.fn.animate; // animation would keep running, conflict with other tests
|
||||
|
||||
$.fn.animate = function () { return this; };
|
||||
text = 'Nothing to see here.';
|
||||
|
||||
permission.set( text );
|
||||
permission.grow();
|
||||
|
@ -79,17 +81,12 @@
|
|||
assert.ok( !permission.$text.is( ':visible' ), 'permission text is not visible' );
|
||||
assert.ok( permission.$html.is( ':visible' ), 'permission html is visible' );
|
||||
assert.ok( permission.$close.is( ':visible' ), 'close button is visible' );
|
||||
|
||||
$.fn.animate = oldAnimate;
|
||||
} );
|
||||
|
||||
QUnit.test( 'shrink()', 3, function ( assert ) {
|
||||
var $qf = $( '#qunit-fixture' ),
|
||||
permission = new mw.mmv.ui.Permission( $qf ),
|
||||
text = 'Nothing to see here.',
|
||||
oldAnimate = $.fn.animate; // animation would keep running, conflict with other tests
|
||||
|
||||
$.fn.animate = function () { return this; };
|
||||
text = 'Nothing to see here.';
|
||||
|
||||
permission.set( text );
|
||||
permission.grow();
|
||||
|
@ -98,16 +95,12 @@
|
|||
assert.ok( permission.$text.is( ':visible' ), 'permission text is visible' );
|
||||
assert.ok( !permission.$html.is( ':visible' ), 'permission html is not visible' );
|
||||
assert.ok( !permission.$close.is( ':visible' ), 'close button is not visible' );
|
||||
|
||||
$.fn.animate = oldAnimate;
|
||||
} );
|
||||
|
||||
QUnit.test( 'isFullSize()', 3, function ( assert ) {
|
||||
var $qf = $( '#qunit-fixture' ),
|
||||
permission = new mw.mmv.ui.Permission( $qf ),
|
||||
text = 'Nothing to see here.';
|
||||
// animation would keep running, conflict with other tests
|
||||
this.sandbox.stub( $.fn, 'animate' ).returnsThis();
|
||||
|
||||
permission.set( text );
|
||||
assert.ok( !permission.isFullSize(), 'permission is not full-size' );
|
||||
|
|
Loading…
Reference in a new issue