API Docs for: 1.0.0
Show:

eZ.BinaryBaseEditView Class

The BinaryBase field edit view. This class is meant to be extended.

Constructor

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
)
protected

Set the file attribute with a struct based on the file object from the input file element.

Parameters:

  • e EventFacade

    event facade

  • file File

    the File object from the input file element

_beforeReadFile

(
  • file
)
protected

Method called before we start reading the content of the selected file. The default implementation does nothing, it is meant to be overridden in the views extending the binary base edit view.

Parameters:

  • file File

    the selected file

_chooseFile

(
  • e
)
protected

Event handler for the tap event on the upload button

Parameters:

_completeFieldValue

(
  • fieldValue
)
Object

Method called at the end of the field value building process in _getFieldValue. It takes the fieldValue in parameter and MUST return the final field value. By default, it only returns the passed field value. It is meant to be overridden in views extending the binary base edit view if the field value is supposed to have additional properties.

Parameters:

  • fieldValue Object

Returns:

Object:

_createFileStruct

(
  • file
  • content
)
Object protected

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 String

    base64 encoded binaryfile content

Returns:

Object:

_drop

(
  • e
)
protected

Event handler for the drop DOM event.

Parameters:

_fileSetter

(
  • value
)
Object protected

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:

Object:

_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:

Object | Null | Undefined:

_getHumanMaxSize

() String protected

Returns a "human" readable version of the max allowed file size

Returns:

String:

_getOverSizeMessage

(
  • name
)
String protected

Returns the warning message suitable when the user tries to use a too big file

Parameters:

  • name String

    the filename the user wants to use

Returns:

String:

_hideWarning

(
  • e
)
protected

Event handler for the tap event on the hide link of the warning box.

Parameters:

_isCreatingTranslation

() Boolean protected

Check if a new translation is being created.

Returns:

Boolean:

_isEmpty

() Boolean protected

Checks whether the file field is currently empty.

Returns:

Boolean:

_maxSize

() protected

Returns the maximum allowed size in bytes or 0 if no limit is set.

Returns:

Number

_prepareDrop

(
  • e
)
protected

Event handler for the dragenter and dragover DOM event

Parameters:

_readFile

(
  • file
)
protected

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 File

    the File object from the input file element

_removeBinaryFile

(
  • e
)
protected

Event handler for the tap event on the remove button

Parameters:

_setStateClasses

() protected

Set the state classes on the view container

_toggleClass

(
  • Mixed
  • cl
)
private

Toggle a class on the view container based on the value

Parameters:

  • Mixed Object

    value

  • cl String

    the 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

_uiHandleWarningMessage

() protected

warningChange event handler, it displays/hides the warning message depending on the attribute value.

_uiPrepareDropArea

(
  • the
)
protected

Prepares visually the drop area

Parameters:

_uiResetDropArea

() protected

Resets visually the drop area

_updateFile

(
  • e
)
protected

Event handler for the change event on the file input

Parameters:

_valid

(
  • file
)
protected

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 File

    the File object to be stored in the field

Returns:

Boolean

_validSize

(
  • file
)
Boolean private

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 File

    the File object to be stored in the field

Returns:

Boolean:

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.

fileReader

FileReader readonly

FileReader instance

updated

Boolean readonly

Flag indicating whether the user changed something in the binaryfile field. This attribute is used to avoid sending the same binaryfile again and again.

warning

String | False readonly

Stores the warning message (if any) or false