mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-12-25 14:14:26 +00:00
21438d2b22
Repo was only used in two locations: 1. StripeButtons.set for `isCommons` - can be replaced by `descriptionUrl.includes('//commons.wikimedia.org/')` 2. EmbedFileFormatter.getSiteLink (unused) Furthermore: - Simplify StripeButtons (we only have one button) - Unwrap info objects consisting of `ImageModel` and `Repo` - Remove unused EmbedFileFormatter.getSiteLink - Inline EmbedFileFormatter.getCaption and EmbedFileFormatter.getLinkUrl - Fix JSDoc type `ImageModel` Reduces mmv bundle size from 28012 to 27246. Bug: T77349 Change-Id: Ia4388fe4d5e1d6112a992e826453cd5799a6a4b4
93 lines
2.4 KiB
JavaScript
93 lines
2.4 KiB
JavaScript
/*
|
|
* 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/>.
|
|
*/
|
|
|
|
const { Dialog } = require( 'mmv' );
|
|
const DownloadPane = require( './mmv.ui.download.pane.js' );
|
|
|
|
/**
|
|
* Represents the file download dialog and the link to open it.
|
|
*/
|
|
class DownloadDialog extends Dialog {
|
|
/**
|
|
* @param {jQuery} $container the element to which the dialog will be appended
|
|
* @param {jQuery} $openButton the button which opens the dialog. Only used for positioning.
|
|
* @param {Config} config
|
|
*/
|
|
constructor( $container, $openButton, config ) {
|
|
super( $container, $openButton, config );
|
|
|
|
this.download = new DownloadPane( this.$dialog );
|
|
this.$dialog.addClass( 'mw-mmv-download-dialog' );
|
|
|
|
this.eventPrefix = 'download';
|
|
}
|
|
|
|
/**
|
|
* Registers listeners.
|
|
*/
|
|
attach() {
|
|
this.download.attach();
|
|
|
|
this.handleEvent( 'mmv-download-open', this.handleOpenCloseClick.bind( this ) );
|
|
|
|
this.handleEvent( 'mmv-reuse-open', this.closeDialog.bind( this ) );
|
|
this.handleEvent( 'mmv-options-open', this.closeDialog.bind( this ) );
|
|
}
|
|
|
|
/**
|
|
* Sets data needed by contained tabs and makes dialog launch link visible.
|
|
*
|
|
* @param {ImageModel} image
|
|
*/
|
|
set( image ) {
|
|
this.download.set( image );
|
|
this.showImageWarnings( image );
|
|
}
|
|
|
|
/**
|
|
* Fired when the dialog is opened.
|
|
*
|
|
* @event DownloadDialog#mmv-download-opened
|
|
*/
|
|
|
|
/**
|
|
* Opens a dialog with information about file download.
|
|
*/
|
|
openDialog() {
|
|
super.openDialog();
|
|
|
|
$( document ).trigger( 'mmv-download-opened' );
|
|
}
|
|
|
|
/**
|
|
* Fired when the dialog is closed.
|
|
*
|
|
* @event DownloadDialog#mmv-download-closed
|
|
*/
|
|
|
|
/**
|
|
* Closes the download dialog.
|
|
*/
|
|
closeDialog() {
|
|
super.closeDialog();
|
|
|
|
$( document ).trigger( 'mmv-download-closed' );
|
|
}
|
|
}
|
|
|
|
module.exports = DownloadDialog;
|