2014-03-17 08:07:53 +00:00
|
|
|
/*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2023-05-20 06:42:20 +00:00
|
|
|
const { getMediaHash } = require( 'mmv.head' );
|
2024-05-22 19:49:26 +00:00
|
|
|
const Utils = require( './mmv.ui.utils.js' );
|
2024-05-04 14:00:17 +00:00
|
|
|
const { UiElement } = require( 'mmv' );
|
2023-05-19 14:56:40 +00:00
|
|
|
|
2024-05-21 20:12:08 +00:00
|
|
|
/**
|
|
|
|
* Represents the file reuse dialog and link to open it.
|
|
|
|
*/
|
|
|
|
class Share extends UiElement {
|
2014-03-17 08:07:53 +00:00
|
|
|
/**
|
2024-05-21 20:12:08 +00:00
|
|
|
* @param {jQuery} $container
|
2014-03-17 08:07:53 +00:00
|
|
|
*/
|
2024-05-21 20:12:08 +00:00
|
|
|
constructor( $container ) {
|
|
|
|
super( $container );
|
2023-05-20 12:38:59 +00:00
|
|
|
|
2024-05-28 18:04:50 +00:00
|
|
|
Utils.createHeader( mw.msg( 'multimediaviewer-share-tab' ) )
|
2024-05-21 20:12:08 +00:00
|
|
|
.appendTo( $container );
|
2023-05-20 12:38:59 +00:00
|
|
|
|
2024-05-21 20:12:08 +00:00
|
|
|
const $body = $( '<div>' )
|
|
|
|
.addClass( 'cdx-dialog__body mw-mmv-pt-0' )
|
|
|
|
.appendTo( $container );
|
2023-05-20 12:38:59 +00:00
|
|
|
|
2024-05-21 20:12:08 +00:00
|
|
|
[ this.$pageInput, this.$pageInputDiv ] = Utils.createInputWithCopy(
|
2024-05-28 18:04:50 +00:00
|
|
|
mw.msg( 'multimediaviewer-reuse-copy-share' ),
|
|
|
|
mw.msg( 'multimediaviewer-reuse-loading-placeholder' )
|
2024-05-21 20:12:08 +00:00
|
|
|
);
|
2024-05-28 18:04:50 +00:00
|
|
|
this.$pageInput.attr( 'title', mw.msg( 'multimediaviewer-share-explanation' ) );
|
2024-05-21 20:12:08 +00:00
|
|
|
this.$pageInputDiv.appendTo( $body );
|
|
|
|
}
|
2023-05-20 12:38:59 +00:00
|
|
|
|
2024-05-21 20:12:08 +00:00
|
|
|
/**
|
|
|
|
* Shows the pane.
|
|
|
|
*/
|
|
|
|
show() {
|
|
|
|
super.show();
|
|
|
|
}
|
2023-05-20 12:38:59 +00:00
|
|
|
|
2024-05-21 20:12:08 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
2024-05-29 08:54:16 +00:00
|
|
|
* @param {ImageModel} image
|
2024-05-21 20:12:08 +00:00
|
|
|
*/
|
|
|
|
set( image ) {
|
|
|
|
const url = image.descriptionUrl + getMediaHash( image.title );
|
|
|
|
this.$pageInput.val( url );
|
|
|
|
}
|
2023-05-20 12:38:59 +00:00
|
|
|
|
2024-05-21 20:12:08 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
empty() {
|
|
|
|
this.$pageInput.val( '' );
|
2014-03-17 08:07:53 +00:00
|
|
|
}
|
2024-05-21 20:12:08 +00:00
|
|
|
}
|
2014-03-19 22:35:55 +00:00
|
|
|
|
2024-05-21 20:12:08 +00:00
|
|
|
module.exports = Share;
|