2015-10-07 20:12:15 +00:00
|
|
|
/*!
|
2015-10-14 10:56:41 +00:00
|
|
|
* VisualEditor MediaWiki UserInterface media transfer handler class.
|
2015-10-07 20:12:15 +00:00
|
|
|
*
|
2020-01-08 17:13:04 +00:00
|
|
|
* @copyright 2011-2020 VisualEditor Team and others; see http://ve.mit-license.org
|
2015-10-07 20:12:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2015-10-14 10:56:41 +00:00
|
|
|
* Media transfer handler.
|
2015-10-07 20:12:15 +00:00
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.DataTransferHandler
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {ve.ui.Surface} surface
|
|
|
|
* @param {ve.ui.DataTransferItem} item
|
|
|
|
*/
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.MWMediaTransferHandler = function VeUiMWMediaTransferHandler() {
|
2015-10-07 20:12:15 +00:00
|
|
|
// Parent constructor
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.MWMediaTransferHandler.super.apply( this, arguments );
|
2015-10-07 20:12:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2015-10-14 10:56:41 +00:00
|
|
|
OO.inheritClass( ve.ui.MWMediaTransferHandler, ve.ui.DataTransferHandler );
|
2015-10-07 20:12:15 +00:00
|
|
|
|
|
|
|
/* Static properties */
|
|
|
|
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.MWMediaTransferHandler.static.name = 'media';
|
2015-10-07 20:12:15 +00:00
|
|
|
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.MWMediaTransferHandler.static.kinds = [ 'file' ];
|
2015-10-07 20:12:15 +00:00
|
|
|
|
|
|
|
// TODO: Pull available types and extensions from MW config
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.MWMediaTransferHandler.static.types = [ 'image/jpeg', 'image/png', 'image/gif', 'image/svg+xml' ];
|
2015-10-07 20:12:15 +00:00
|
|
|
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.MWMediaTransferHandler.static.extensions = [ 'jpg', 'jpeg', 'png', 'gif', 'svg' ];
|
2015-10-07 20:12:15 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.MWMediaTransferHandler.prototype.process = function () {
|
2022-02-21 18:07:07 +00:00
|
|
|
var file = this.item.getAsFile();
|
2015-10-07 20:12:15 +00:00
|
|
|
|
2022-02-21 18:07:07 +00:00
|
|
|
var action = ve.ui.actionFactory.create( 'window', this.surface );
|
2016-08-10 19:46:56 +00:00
|
|
|
action.open( 'media', { file: file } );
|
|
|
|
|
2015-10-07 20:12:15 +00:00
|
|
|
this.insertableDataDeferred.reject();
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.dataTransferHandlerFactory.register( ve.ui.MWMediaTransferHandler );
|