Debian Codegraph @

extensions/MultimediaViewer/resources/mmv.ui.reuse/mmv.ui.reuse.share.js

raw symbols SCIP
1 /*
2 * This file is part of the MediaWiki extension MultimediaViewer.
3 *
4 * MultimediaViewer is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * MultimediaViewer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with MultimediaViewer. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 const { Config } = require( 'mmv.bootstrap' );
19 const Utils = require( './mmv.ui.utils.js' );
20 const { UiElement } = require( 'mmv' );
21
22 /**
23 * Represents the file reuse dialog and link to open it.
24 */
25 class Share extends UiElement {
26 /**
27 * @param {jQuery} $container
28 */
29 constructor( $container ) {
30 super( $container );
31
32 Utils.createHeader( mw.msg( 'multimediaviewer-share-tab' ) )
33 .appendTo( $container );
34
35 const $body = $( '<div>' )
36 .addClass( 'cdx-dialog__body mw-mmv-pt-0' )
37 .appendTo( $container );
38
39 [ this.$pageInput, this.$pageInputDiv ] = Utils.createInputWithCopy(
40 mw.msg( 'multimediaviewer-reuse-copy-share' ),
41 mw.msg( 'multimediaviewer-reuse-loading-placeholder' )
42 );
43 this.$pageInput.attr( 'title', mw.msg( 'multimediaviewer-share-explanation' ) );
44 this.$pageInputDiv.appendTo( $body );
45 }
46
47 /**
48 * Shows the pane.
49 */
50 show() {
51 super.show();
52 }
53
54 /**
55 * @inheritdoc
56 * @param {ImageModel} image
57 */
58 set( image ) {
59 const url = image.descriptionUrl + Config.getMediaHash( image.title );
60 this.$pageInput.val( url );
61 }
62
63 /**
64 * @inheritdoc
65 */
66 empty() {
67 this.$pageInput.val( '' );
68 }
69 }
70
71 module.exports = Share;