Expand all

mw.ForeignStructuredUpload.BookletLayout

Encapsulates the process of uploading a file to MediaWiki using the mw.ForeignStructuredUpload model.

Example

var uploadDialog = new mw.Upload.Dialog( {
    bookletClass: mw.ForeignStructuredUpload.BookletLayout,
    booklet: {
        target: 'local'
    }
} );
var windowManager = new OO.ui.WindowManager();
$( document.body ).append( windowManager.$element );
windowManager.addWindows( [ uploadDialog ] );

Extends

Constructor

new mw.ForeignStructuredUpload.BookletLayout(config) #

Create an instance of mw.ForeignStructuredUpload.BookletLayout.

Parameters:

Name Type Description
config Object

Configuration options

Properties:
Name Type Attributes Description
target string optional

Used to choose the target repository. If nothing is passed, the default is used.

Source:

Properties

infoForm :OO.ui.FormLayout #

The form rendered in the second step to get metadata. Rendered in renderInfoForm.

Type:

Inherited from:
Source:
The form rendered in the second step to get metadata.

insertForm :OO.ui.FormLayout #

The form rendered in the third step to show usage. Rendered in renderInsertForm.

Type:

Inherited from:
Source:
The form rendered in the third step to show usage.

uploadForm :OO.ui.FormLayout #

The form rendered in the first step to get the file object. Rendered in renderUploadForm.

Type:

Inherited from:
Source:
The form rendered in the first step to get the file object.

Methods

clear()protected #

Clear the values of all fields.

Overrides:
Source:
Clear the values of all fields.

createUpload() → {mw.Upload}protected #

Returns a mw.ForeignStructuredUpload with the target specified in config.

getDateFromExif(file) → {jQuery.Promise} #

Get original date from EXIF data.

Parameters:

Name Type Description
file File
Source:

Returns:

Promise resolved with the EXIF date

Type
jQuery.Promise
Get original date from EXIF data.

getDateFromLastModified(file) → {string|undefined} #

Get last modified date from file.

Parameters:

Name Type Description
file File
Source:

Returns:

Last modified date from file

Type
string | undefined
Get last modified date from file.

getErrorMessageForStateDetails() → {jQuery.Promise|undefined}protected #

Get an error message (as OO.ui.Error object) that should be displayed to the user for current state and state details.

Inherited from:
Source:

Returns:

A Promise that will be resolved with an OO.ui.Error.

Type
jQuery.Promise | undefined

Get an error message (as OO.ui.Error object) that should be displayed to the user for current state and state details.

getFile() → {File|null}protected #

Gets the file object from the upload form.

Inherited from:
Source:

Returns:

Type
File | null

Gets the file object from the upload form.

getFileWidget() → {OO.ui.SelectFileInputWidget|mw.widgets.StashedFileWidget} #

Gets the widget for displaying or inputting the file to upload.

Inherited from:
Source:

Returns:

Type
OO.ui.SelectFileInputWidget | mw.widgets.StashedFileWidget
Gets the widget for displaying or inputting the file to upload.

getFilename() → {string}protected #

Gets the file name from the information form.

getText() → {string}protected #

Gets the page text from the information form.

initialize() → {jQuery.Promise} #

Initialize for a new upload.

Overrides:
Source:

Returns:

Promise resolved when everything is initialized

Type
jQuery.Promise
Initialize for a new upload.

onInfoFormChange()protected #

Handle change events to the info form.

onUploadFormChange()protected #

Handle change events to the upload form.

renderInfoForm() → {OO.ui.FormLayout}protected #

Renders and returns the information form for collecting metadata and sets the infoForm property.

Overrides:
Source:

Returns:

Type
OO.ui.FormLayout

Renders and returns the information form for collecting metadata and sets the infoForm property.

renderInsertForm() → {OO.ui.FormLayout}protected #

Renders and returns the insert form to show file usage and sets the insertForm property.

Inherited from:
Source:

Returns:

Type
OO.ui.FormLayout

Renders and returns the insert form to show file usage and sets the insertForm property.

renderUploadForm() → {OO.ui.FormLayout}protected #

Renders and returns the upload form and sets the uploadForm property.

Overrides:
Source:

Returns:

Type
OO.ui.FormLayout

Renders and returns the upload form and sets the uploadForm property.

saveFile() → {jQuery.Promise}protected #

Saves the stash finalizes upload. Uses getFilename, and getText to get details from the form.

Overrides:
Source:

Returns:

Rejects the promise with an error, or resolves if the upload was successful.

Type
jQuery.Promise

Fires:

Saves the stash finalizes upload.

setFile(file)protected #

Sets the file object.

Parameters:

Name Type Description
file File | null

File to select

Inherited from:
Source:
Sets the file object.

setFilekey(filekey)protected #

Sets the filekey of a file already stashed on the server as the target of this upload operation.

Parameters:

Name Type Description
filekey string
Inherited from:
Source:

Sets the filekey of a file already stashed on the server as the target of this upload operation.

setFilename(filename)protected #

Prefills the information form with the given filename.

Parameters:

Name Type Description
filename string
Inherited from:
Source:
Prefills the information form with the given filename.

updateFilePreview()protected #

Updates the file preview on the info form when a file is added.

Inherited from:
Source:
Updates the file preview on the info form when a file is added.

uploadFile() → {jQuery.Promise}protected #

Uploads the file that was added in the upload form. Uses getFile to get the HTML5 file object.

Inherited from:
Source:

Returns:

Type
jQuery.Promise

Fires:

Uploads the file that was added in the upload form.

validateFilename(filename) → {jQuery.Promise} #

Parameters:

Name Type Description
filename mw.Title
Source:

Returns:

Resolves (on success) or rejects with OO.ui.Error

Type
jQuery.Promise