Constructor
new mw.Upload.BookletLayout(config)
#
BookletLayout class for encapsulating the process of uploading a file.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object | Configuration options; see also the config parameter for the
Properties
|
Extends
Properties
infoForm :OO.ui.FormLayout
#
The form rendered in the second step to get metadata.
Rendered in renderInfoForm
.
Type:
insertForm :OO.ui.FormLayout
#
The form rendered in the third step to show usage.
Rendered in renderInsertForm
.
Type:
uploadForm :OO.ui.FormLayout
#
The form rendered in the first step to get the file object.
Rendered in renderUploadForm
.
Type:
Methods
clear()protected
#
Clear the values of all fields.
createUpload() → {mw.Upload}protected
#
getErrorMessageForStateDetails() → {jQuery.Promise}protected
#
Get an error message (as OO.ui.Error object) that should be displayed to the user for current state and state details.
Returns:
A Promise that will be resolved with an OO.ui.Error.
- Type
- jQuery.Promise
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
#
null
}protected
#
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.
Returns:
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.
Returns:
Promise resolved when everything is initialized
- Type
- jQuery.Promise
onInfoFormChange()protected
#
Handle change events to the info form.
Fires:
onUploadFormChange()protected
#
Handle change events to the upload form.
Fires:
renderInfoForm() → {OO.ui.FormLayout}protected
#
Renders and returns the information form for collecting
metadata and sets the infoForm
property.
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.
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.
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.
Fires:
Returns:
Rejects the promise with an
error
, or resolves if the upload was successful.
- Type
- jQuery.Promise
setFile(file)protected
#
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 |
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 |
information form
with the given filename.
updateFilePreview()protected
#
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.
Fires:
Returns:
- Type
- jQuery.Promise
Events
fileSaved(imageInfo)
#
The file has been saved to the database.
Parameters:
Name | Type | Description |
---|---|---|
imageInfo |
Object |
fileUploadProgress(progress, duration)
#
Progress events for the uploaded file.
Parameters:
Name | Type | Description |
---|---|---|
progress |
number | In percentage |
duration |
Object | Duration object from |
fileUploaded()
#
The file has finished uploading.
infoValid(isValid)
#
The info form has changed.
Parameters:
Name | Type | Description |
---|---|---|
isValid |
boolean | The form is valid |
uploadValid(isValid)
#
The upload form has changed.
Parameters:
Name | Type | Description |
---|---|---|
isValid |
boolean | The form is valid |