Extends
Constructor
new ve.ui.MediaSizeWidget([scalable], [config])
#
Hierarchy
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:
|
Widget that lets the user edit dimensions (width and height), based on a scalable object.
Methods
getCurrentDimensions() → {Object}
#
getMaxDimensions() → {Object}
#
getRatio() → {number}
#
Get the current aspect ratio
Returns:
Aspect ratio
- Type
- number
getScalable() → {ve.dm.Scalable}
#
Get the attached scalable object
Returns:
The scalable object representing the media source being resized.
- Type
- ve.dm.Scalable
getSizeType() → {string}
#
Get the size type from the select widget
Returns:
The size type
- Type
- string
isCustomEmpty() → {boolean}
#
Check if the custom dimensions are empty.
Returns:
Both width/height values are empty
- Type
- boolean
isEmpty() → {boolean}
#
Check if all inputs are empty.
Returns:
All input values are empty
- Type
- boolean
isValid() → {boolean}
#
Check whether the current value inputs are valid
- If placeholders are visible, the input is valid
- If inputs have non numeric values, input is invalid
- 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
Check whether the current value inputs are valid
- If placeholders are visible, the input is valid
- If inputs have non numeric values, input is invalid
- 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:
onScalableCurrentSizeChange(dimensions)
#
Respond to change in current dimensions in the scalable object.
Parameters:
Name | Type | Description |
---|---|---|
dimensions |
Object | Original dimensions |
onScalableDefaultSizeChange(isDefault)
#
Respond to default size or status change in the scalable object.
Parameters:
Name | Type | Description |
---|---|---|
isDefault |
boolean | Current default state |
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 |
onSizeTypeChoose(item)
#
Respond to size type change
Parameters:
Name | Type | Description |
---|---|---|
item |
OO.ui.OptionWidget | Selected size type item |
Fires:
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:
setDisabled()
#
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:
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:
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:
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:
updateDefaultDimensions()
#
Set default dimensions for the widget. Values are given by scalable's defaultDimensions. If no default dimensions are available, the defaults are removed.
updateDisabled() → {ve.ui.MediaSizeWidget}chainable
#
Update the disabled state of sub widgets
Returns:
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:
Events
change(dimensions)
#
Parameters:
Name | Type | Description |
---|---|---|
dimensions |
Object | Width and height dimensions |
changeSizeType(sizeType)
#
Parameters:
Name | Type | Description |
---|---|---|
sizeType |
string | 'default', 'custom' or 'scale' |
valid(isValid)
#
Parameters:
Name | Type | Description |
---|---|---|
isValid |
boolean | Current dimensions are valid |