eZ.MediaEditView Class
The Media edit view
Constructor
eZ.MediaEditView
()
Item Index
Methods
- _afterRender
- _base64ToFileStruct
- _beforeReadFile
- _chooseFile
- _completeFieldValue
- _createFileStruct
- _drop
- _fileSetter
- _getFieldValue
- _getHumanMaxSize
- _getOverSizeMessage
- _getPlayerNode
- _hideWarning
- _isCreatingTranslation
- _isEmpty
- _maxSize
- _mediaError
- _prepareDrop
- _readFile
- _removeBinaryFile
- _setStateClasses
- _toggleClass
- _trackVersionSave
- _uiBinaryFileChange
- _uiHandleWarningMessage
- _uiPrepareDropArea
- _uiResetDropArea
- _updateFile
- _updateSetting
- _updateSize
- _updateWidthHeightPlaceholder
- _valid
- _validSize
- _variables
- _watchPlayerEvents
- validate
Attributes
Methods
_afterRender
()
protected
Method called at the end of the render process. The default implementation does nothing, it is meant to be overridden in the view extending the binary base edit view.
_base64ToFileStruct
-
e
-
file
Set the file attribute with a struct based on the file object from the input file element.
Parameters:
-
e
EventFacadeevent facade
-
file
Filethe File object from the input file element
_beforeReadFile
()
protected
Removes the being updated and unsupported class before reading the content of the file
_chooseFile
-
e
Event handler for the tap event on the upload button
Parameters:
-
e
EventFacadeevent facade of the tap event
_completeFieldValue
-
fieldValue
Completes the field value with the player settings
Parameters:
-
fieldValue
Object
Returns:
_createFileStruct
-
file
-
content
Creates the file structure based on the File object provided by the input file and on the base64 encoded binaryfile content. It also creates a blob URL for the newly selected object.
Parameters:
-
file
File -
content
Stringbase64 encoded binaryfile content
Returns:
_fileSetter
-
value
file attribute setter. It converts the different input type to a consistent object no matter if the file attribute is filled from the REST fieldValue or from the user input.
Parameters:
-
value
Object | Null
Returns:
_getFieldValue
()
Object | Null | Undefined
protected
Returns the field value suitable for the REST API based on the current input. It makes to sure to only send the actual content when it's needed. It returns null if no file has been chosen yet or undefined if no change happened since the version save event.
Returns:
_getHumanMaxSize
()
String
protected
Returns a "human" readable version of the max allowed file size
Returns:
_getOverSizeMessage
-
name
Returns the warning message suitable when the user tries to use a too big file
Parameters:
-
name
Stringthe filename the user wants to use
Returns:
_hideWarning
-
e
Event handler for the tap event on the hide link of the warning box.
Parameters:
-
e
EventFacadetap event facade
_isCreatingTranslation
()
Boolean
protected
Check if a new translation is being created.
Returns:
_isEmpty
()
Boolean
protected
Checks whether the file field is currently empty.
Returns:
_maxSize
()
protected
Returns the maximum allowed size in bytes or 0 if no limit is set.
Returns:
Number
_mediaError
-
player
Adds the unsupported class and resets the width/height placeholder when the file can not read by the browser
Parameters:
-
player
Nodethe video/audio node
_prepareDrop
-
e
Event handler for the dragenter and dragover DOM event
Parameters:
_readFile
-
file
Read the content of the choosen File (if its size match the field
configuration) and update the file
attribute with the corresponding
structure
Parameters:
-
file
Filethe File object from the input file element
_removeBinaryFile
-
e
Event handler for the tap event on the remove button
Parameters:
-
e
EventFacadeevent facade of tap event
_setStateClasses
()
protected
Set the state classes on the view container
_toggleClass
-
Mixed
-
cl
Toggle a class on the view container based on the value
Parameters:
-
Mixed
Objectvalue
-
cl
Stringthe class to toggle
_trackVersionSave
()
private
Sets the updated
attribute to false when the attached version is
saved. This is to avoid sending again and again the same file
_uiBinaryFileChange
-
e
Reflects the new binaryfile object in the generated UI
Parameters:
-
e
EventFacadethe binaryfile change event facade
_uiHandleWarningMessage
()
protected
warningChange event handler, it displays/hides the warning message depending on the attribute value.
_uiPrepareDropArea
-
the
Prepares visually the drop area
Parameters:
-
the
EventFacadeevent facade of the drag* event
_uiResetDropArea
()
protected
Resets visually the drop area
_updateFile
-
e
Event handler for the change event on the file input
Parameters:
-
e
EventFacadeevent facade of the change event
_updateSetting
-
e
Event handler for the DOM change event on the controller, autoplay and loop checkboxes.
Parameters:
_updateSize
-
e
Event handler the valuechange event on the width and height input
Parameters:
_updateWidthHeightPlaceholder
-
widthValue
-
heightValue
Sets the placeholder attribute on the width and height input with the given values
_valid
-
file
Checks whether the File in parameter is valid for the field. By default, only the size of the file is checked against the maximum allowed file size.
Parameters:
-
file
Filethe File object to be stored in the field
Returns:
Boolean
_validSize
-
file
Checks whether the size is valid according to the field definition
configuration. If the file can not be accepted, a warning message is
set in the warning
attribute.
Parameters:
-
file
Filethe File object to be stored in the field
Returns:
_variables
()
Object
protected
Defines the variables to be imported in the field edit template.
Returns:
_watchPlayerEvents
()
protected
Sets the event handler on the video/audio element to handle the being updated state, the width/height placeholder and a potential file format error
validate
()
Validates the current input of the image against the is required field definition setting.
Attributes
file
Object | Null
readonly
The file struct object for the current field. This attribute has a setter to accept either null value, any REST fieldValue or an object created from a File.