Expand all

ve.ui.MediaSizeWidget

Extends

Constructor

new ve.ui.MediaSizeWidget([scalable], [config]) #

Widget that lets the user edit dimensions (width and height), based on a scalable object.

Parameters:

Name Type Attributes Description
scalable ve.dm.Scalable optional
config Object optional

Configuration options

Properties:
Name Type Attributes Description
noDefaultDimensions boolean optional

The item being sized doesn't have default dimensions

dimensionsAlign string optional

Alignment for the dimensions widget

Source:

Widget that lets the user edit dimensions (width and height), based on a scalable object.

Methods

getCurrentDimensions() → {Object} #

Retrieve the current dimensions

Returns:

Width and height

Type
Object
Source:
Retrieve the current dimensions

getMaxDimensions() → {Object} #

Retrieve the currently defined maximum dimensions

Returns:

dimensions Height and width

Type
Object
Source:
Retrieve the currently defined maximum dimensions

getRatio() → {number} #

Get the current aspect ratio

Returns:

Aspect ratio

Type
number
Source:
Get the current aspect ratio

getScalable() → {ve.dm.Scalable} #

Get the attached scalable object

Returns:

The scalable object representing the media source being resized.

Type
ve.dm.Scalable
Source:
Get the attached scalable object

getSizeType() → {string} #

Get the size type from the select widget

Returns:

The size type

Type
string
Source:
Get the size type from the select widget

isCustomEmpty() → {boolean} #

Check if the custom dimensions are empty.

Returns:

Both width/height values are empty

Type
boolean
Source:
Check if the custom dimensions are empty.

isEmpty() → {boolean} #

Check if all inputs are empty.

Returns:

All input values are empty

Type
boolean
Source:
Check if all inputs are empty.

isValid() → {boolean} #

Check whether the current value inputs are valid

  1. If placeholders are visible, the input is valid
  2. If inputs have non numeric values, input is invalid
  3. If inputs have numeric values, validate through scalable calculations to see if the dimensions follow the rules.

Returns:

Valid or invalid dimension values

Type
boolean
Source:

Check whether the current value inputs are valid

  1. If placeholders are visible, the input is valid
  2. If inputs have non numeric values, input is invalid
  3. If inputs have numeric values, validate through scalable calculations to see if the dimensions follow the rules.

onDimensionsChange(type, value) #

Respond to width/height input value change. Only update dimensions if the value is numeric. Invoke validation for every change.

This is triggered every time the dimension widget has its values changed either by the user or externally. The external call to 'setCurrentDimensions' will result in this event being evoked if the dimension inputs have changed, and same with changing dimensions type.

The 'change' event for the entire widget is emitted through this method, as it means that the actual values have changed, regardless of whether they are valid or not.

Parameters:

Name Type Description
type string

The input that was updated, 'width' or 'height'

value string

The new value of the input

Fires:

Source:
Respond to width/height input value change.

onScalableCurrentSizeChange(dimensions) #

Respond to change in current dimensions in the scalable object.

Parameters:

Name Type Description
dimensions Object

Original dimensions

Source:
Respond to change in current dimensions in the scalable object.

onScalableDefaultSizeChange(isDefault) #

Respond to default size or status change in the scalable object.

Parameters:

Name Type Description
isDefault boolean

Current default state

Source:
Respond to default size or status change in the scalable object.

onScalableOriginalSizeChange(dimensions) #

Respond to change in original dimensions in the scalable object. Specifically, enable or disable the 'default' option.

Parameters:

Name Type Description
dimensions Object

Original dimensions

Source:
Respond to change in original dimensions in the scalable object.

onSizeTypeChoose(item) #

Respond to size type change

Parameters:

Name Type Description
item OO.ui.OptionWidget

Selected size type item

Fires:

Source:
Respond to size type change

setCurrentDimensions(dimensions) #

Updates the current dimensions in the inputs, either one at a time or both

Parameters:

Name Type Description
dimensions Object

Dimensions with width and height

Fires:

Source:
Updates the current dimensions in the inputs, either one at a time or both

setMaxDimensions(dimensions) → {ve.ui.MediaSizeWidget}chainable #

Set the maximum dimensions for the image. These will be limited only if enforcedMax is true.

Parameters:

Name Type Description
dimensions Object

Height and width

Returns:

Type
ve.ui.MediaSizeWidget
Source:
Set the maximum dimensions for the image.

setRatio(ratio) → {ve.ui.MediaSizeWidget}chainable #

Set the image aspect ratio explicitly

Parameters:

Name Type Description
ratio number

Numerical value of an aspect ratio

Returns:

Type
ve.ui.MediaSizeWidget
Source:
Set the image aspect ratio explicitly

setScalable(scalable) → {ve.ui.MediaSizeWidget}chainable #

Set the scalable object the widget deals with

Parameters:

Name Type Description
scalable ve.dm.Scalable

A scalable object representing the media source being resized.

Returns:

Type
ve.ui.MediaSizeWidget
Source:
Set the scalable object the widget deals with

setSizeType(sizeType) → {ve.ui.MediaSizeWidget}chainable #

Select a size type in the select widget

Parameters:

Name Type Description
sizeType string

The size type to select

Returns:

Type
ve.ui.MediaSizeWidget
Source:
Select a size type in the select widget

updateDefaultDimensions() #

Set default dimensions for the widget. Values are given by scalable's defaultDimensions. If no default dimensions are available, the defaults are removed.

Source:
Set default dimensions for the widget.

updateDisabled() → {ve.ui.MediaSizeWidget}chainable #

Update the disabled state of sub widgets

Returns:

Type
ve.ui.MediaSizeWidget
Source:
Update the disabled state of sub widgets

validateDimensions() → {boolean} #

Validate current dimensions. Explicitly call for validating the current dimensions. This is especially useful if we've changed conditions for the widget, like limiting image dimensions for thumbnails when the image type changes. Triggers the error class if needed.

Returns:

Current dimensions are valid

Type
boolean

Fires:

Source:
Validate current dimensions.

Events

change(dimensions) #

Parameters:

Name Type Description
dimensions Object

Width and height dimensions

Source:

changeSizeType(sizeType) #

Parameters:

Name Type Description
sizeType string

'default', 'custom' or 'scale'

Source:

valid(isValid) #

Parameters:

Name Type Description
isValid boolean

Current dimensions are valid

Source: