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/>.
|
|
|
|
*/
|
|
|
|
|
2018-11-12 16:33:24 +00:00
|
|
|
( function () {
|
2014-03-17 08:07:53 +00:00
|
|
|
// Shortcut for prototype later
|
|
|
|
var SP;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents the file reuse dialog and link to open it.
|
2016-07-18 13:49:27 +00:00
|
|
|
*
|
2014-03-17 08:07:53 +00:00
|
|
|
* @class mw.mmv.ui.reuse.Share
|
|
|
|
* @extends mw.mmv.ui.reuse.Tab
|
|
|
|
* @param {jQuery} $container
|
|
|
|
*/
|
|
|
|
function Share( $container ) {
|
2014-09-16 20:33:05 +00:00
|
|
|
mw.mmv.ui.reuse.Tab.call( this, $container );
|
2014-03-17 08:07:53 +00:00
|
|
|
this.init();
|
|
|
|
}
|
2018-11-12 16:33:24 +00:00
|
|
|
OO.inheritClass( Share, mw.mmv.ui.reuse.Tab );
|
2014-03-17 08:07:53 +00:00
|
|
|
SP = Share.prototype;
|
|
|
|
|
|
|
|
SP.init = function () {
|
2014-06-04 21:12:52 +00:00
|
|
|
this.$pane.addClass( 'mw-mmv-share-pane' )
|
2014-03-17 08:07:53 +00:00
|
|
|
.appendTo( this.$container );
|
|
|
|
|
2019-05-23 14:27:43 +00:00
|
|
|
this.pageInput = new mw.widgets.CopyTextLayout( {
|
|
|
|
help: mw.message( 'multimediaviewer-share-explanation' ).text(),
|
|
|
|
helpInline: true,
|
|
|
|
align: 'top',
|
|
|
|
textInput: {
|
|
|
|
placeholder: mw.message( 'multimediaviewer-reuse-loading-placeholder' ).text()
|
|
|
|
},
|
|
|
|
button: {
|
|
|
|
label: '',
|
|
|
|
title: mw.msg( 'multimediaviewer-reuse-copy-share' )
|
|
|
|
}
|
2014-03-17 08:07:53 +00:00
|
|
|
} );
|
|
|
|
|
2019-05-23 14:27:43 +00:00
|
|
|
this.pageInput.on( 'copy', function () {
|
2014-09-05 12:52:53 +00:00
|
|
|
mw.mmv.actionLogger.log( 'share-link-copied' );
|
|
|
|
} );
|
|
|
|
|
2014-03-17 08:07:53 +00:00
|
|
|
this.$pageLink = $( '<a>' )
|
2014-03-31 21:33:12 +00:00
|
|
|
.addClass( 'mw-mmv-share-page-link' )
|
2014-03-17 08:07:53 +00:00
|
|
|
.prop( 'alt', mw.message( 'multimediaviewer-link-to-page' ).text() )
|
|
|
|
.prop( 'target', '_blank' )
|
|
|
|
.html( ' ' )
|
2014-09-05 12:52:53 +00:00
|
|
|
.appendTo( this.$pane )
|
2018-04-24 14:47:41 +00:00
|
|
|
.on( 'click', function () {
|
2015-02-15 06:18:55 +00:00
|
|
|
mw.mmv.actionLogger.log( 'share-page' );
|
2014-09-05 12:52:53 +00:00
|
|
|
} );
|
2014-03-17 08:07:53 +00:00
|
|
|
|
|
|
|
this.pageInput.$element.appendTo( this.$pane );
|
|
|
|
|
|
|
|
this.$pane.appendTo( this.$container );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the pane.
|
|
|
|
*/
|
|
|
|
SP.show = function () {
|
2014-09-16 20:33:05 +00:00
|
|
|
mw.mmv.ui.reuse.Tab.prototype.show.call( this );
|
2014-03-19 22:35:55 +00:00
|
|
|
this.select();
|
2014-03-17 08:07:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
* @param {mw.mmv.model.Image} image
|
|
|
|
*/
|
|
|
|
SP.set = function ( image ) {
|
2019-05-16 13:19:44 +00:00
|
|
|
var url = image.descriptionUrl + mw.mmv.getMediaHash( image.title );
|
2014-04-14 23:22:28 +00:00
|
|
|
|
2019-05-23 14:27:43 +00:00
|
|
|
this.pageInput.textInput.setValue( url );
|
2014-03-19 22:35:55 +00:00
|
|
|
|
|
|
|
this.select();
|
|
|
|
|
2014-03-17 08:07:53 +00:00
|
|
|
this.$pageLink.prop( 'href', url );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
SP.empty = function () {
|
2019-05-23 14:27:43 +00:00
|
|
|
this.pageInput.textInput.setValue( '' );
|
2014-03-17 08:07:53 +00:00
|
|
|
this.$pageLink.prop( 'href', null );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2019-05-23 14:27:43 +00:00
|
|
|
* Selects the text in the readonly textbox.
|
2014-03-19 22:35:55 +00:00
|
|
|
*/
|
|
|
|
SP.select = function () {
|
2019-05-23 14:27:43 +00:00
|
|
|
this.pageInput.selectText();
|
2014-03-19 22:35:55 +00:00
|
|
|
};
|
|
|
|
|
2014-03-17 08:07:53 +00:00
|
|
|
mw.mmv.ui.reuse.Share = Share;
|
2018-11-12 16:33:24 +00:00
|
|
|
}() );
|