API Docs for: 1.0.0
Show:

eZ.BinaryFileEditView Class

The BinaryFile edit view

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 protected

Removes the url property from the fieldValue so that the fieldValue represents a valid BinaryFile\Value object.

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:

_getMimeTypeClass

(
  • mimeType
)
private

Returns the class reflecting the full mime type. The subtype part is sanitized so that we generate a valid class

Parameters:

  • mimeType String

    the mime type ("text/plain" for instance)

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:

_getTypeClass

(
  • mimeType
)
String private

Returns the class reflecting the type part of mime type. (ie "text" in "text/plain").

Parameters:

  • mimeType String

    the mime type ("text/plain" for instance)

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

_setTypeClasses

(
  • add
  • binaryfile
)
protected

Adds or removes classes based on the mimetype of the file currently selected

Parameters:

  • add Boolean

    whether to add or remove the class

  • binaryfile Object

    the binary file struct

_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

_uiBinaryFileChange

(
  • e
)
protected

Reflects the new binaryfile object in the generated UI

Parameters:

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

_variables

() Object protected

Defines the variables to be imported in the field edit template.

Returns:

Object:

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