Show:

A base class for A.Url.

In order to understand what each attribute/method does, you need to see the anatomy of a URL:

 foo://example.com:8042/over/there?name=ferret#nose
                             \_/   \______________/\_________/ \_________/ \__/
                            Scheme     Authority       Path       Query   Anchor
                            

Constructor

A.Url

(
  • config
)

Parameters:

  • config Object

    Object literal specifying widget configuration properties.

Methods

_afterAction

(
  • action
)
protected

Executes right after an action finishes running.

Parameters:

  • action Object

    Object containing the state and action type (undo or redo) to be executed.

_defBeforeActionFn

(
  • event
)
protected

This is the default function for the beforeUndo and beforeRedo events.

Parameters:

_indexParameters

() protected

Indexes all parameters into the query.

_indexParts

(
  • url
)
protected

Indexes all URL parts to its private attributes.

Parameters:

  • url Object

_makeEventName

() String protected

Constructs the event's name based on its prefix and the action type related to it.

Returns:

String:

Returns the camel case version of prefix plus actionType.

_onRedoKey

() EventFacade

Calls redo method on ctrl + y keydown event

Returns:

EventFacade:

event

_onUndoKey

() EventFacade

Calls undo method on ctrl + z keydown event

Returns:

EventFacade:

event

_prevBeforeActionFn

(
  • event
)
protected

This function runs when a beforeUndo or beforeRedo event is prevented.

Parameters:

_removeStatesBeyondMaxDepth

() protected

Removes states in the stack if it's over the max depth limit.

_runAction

(
  • action
)
protected

Executes the given action (which can be either undo or redo).

Parameters:

  • action Object

    Object containing the state and action type (undo or redo) to be executed.

_runNextPendingAction

() protected

Executes the next pending action, if one exists.

_shouldIgnoreNewActions

() Boolean protected

Checks if new actions (calls to undo/redo) should be ignored. Actions should only be ignored if the queueable attribute is false and there is currently an action in progress.

Returns:

Boolean:

_tryMerge

() Boolean protected

Tries to merge the given state to one at the current position in the stack.

Returns:

Boolean:

Returns true if the merge happened and false otherwise.

add

(
  • state
)

Adds a state to the stack and makes it the current state. Note that all states that could be redone will be removed from the stack after this. Valid states are objects that have at least 2 functions: undo and redo. These functions can return promises, in which case any subsequent calls will be queued, waiting for all pending promises to end.

Parameters:

  • state Object | Function

    Object that contains undo and redo action methods (and, optionally, a 'merge' method).

addParameter

(
  • key
  • values
)

Adds a single parameter in the URL.

Parameters:

  • key Object
  • values Object

addParameters

(
  • parameters
)

Adds a list of parameters in the URL.

Parameters:

  • parameters Object

canRedo

() Boolean

Checks if it's possible to redo an action.

Returns:

Boolean:

canUndo

() Boolean

Checks if it's possible to undo an action.

Returns:

Boolean:

clearHistory

()

Resets the stack, clearing all states and pending actions.

getAnchor

() String

Gets the anchor.

Returns:

String:

getAuthority

() String

Gets the authority.

Returns:

String:

getDirectory

() String

Gets the directory.

Returns:

String:

getFile

() String

Gets the file.

Returns:

String:

getHost

() String

Gets the host.

Returns:

String:

getParameter

(
  • key
)
String

Gets a single parameter.

Parameters:

  • key Object

Returns:

String:

getParameters

() Array

Gets a list of parameters.

Returns:

Array:

getPassword

() String

Gets the password.

Returns:

String:

getPath

() String

Gets the path.

Returns:

String:

getPort

() String

Gets the port.

Returns:

String:

getProtocol

() String

Gets the protocol.

Returns:

String:

getQuery

() String

Gets the query.

Returns:

String:

getRelative

() String

Gets the relative.

Returns:

String:

getSource

() String

Gets the source.

Returns:

String:

getUser

() String

Gets the user.

Returns:

String:

getUserInfo

() String

Gets the user info.

Returns:

String:

hasParameter

(
  • key
)
Boolean

Checks if the URL has a parameter.

Parameters:

  • key Object

Returns:

Boolean:

initializer

() protected

Constructor for the Undo/Redo component.

isActionInProgress

() Boolean

Checks if either an undo or a redo action is currently in progress.

Returns:

Boolean:

redo

() Boolean

Redoes the next state.

Returns:

Boolean:

Returns false if there was no state to be redone and true, otherwise.

redoPeek

() Boolean

Returns the state that will be redone when calling redo().

Returns:

Boolean:

removeParameter

(
  • key
)

Removes a single parameter from the parameters list.

Parameters:

  • key Object

removeParameters

(
  • parameters
)

Removes a list of parameters from the parameters list.

Parameters:

  • parameters Object

setAnchor

(
  • val
)

Sets the anchor.

Parameters:

  • val Object

setAuthority

(
  • val
)

Sets the authority.

Parameters:

  • val Object

setDirectory

(
  • val
)

Sets the directory.

Parameters:

  • val Object

setFile

(
  • val
)

Sets the file.

Parameters:

  • val Object

setHost

(
  • val
)

Sets the host.

Parameters:

  • val Object

setParameter

(
  • key
  • opt_values
)

Sets a single parameter.

Parameters:

  • key Object
  • opt_values Object

setParameters

(
  • parameters
)

Sets a list of parameters.

Parameters:

  • parameters Object

setPassword

(
  • val
)

Sets the password.

Parameters:

  • val Object

setPath

(
  • val
)

Sets the path.

Parameters:

  • val Object

setPort

(
  • val
)

Sets the port.

Parameters:

  • val Object

setProtocol

(
  • val
)

Sets the protocol.

Parameters:

  • val Object

setRelative

(
  • val
)

Sets the relative.

Parameters:

  • val Object

setSource

(
  • val
)

Sets the source.

Parameters:

  • val Object

setUser

(
  • val
)

Sets the user.

Parameters:

  • val Object

setUserInfo

(
  • val
)

Sets the user info.

Parameters:

  • val Object

toString

() String

Generates the entire URL based on each attribute.

Returns:

String:

undo

() Boolean

Undoes the last state.

Returns:

Boolean:

Returns false if there was no state to be undone and true, otherwise.

undoPeek

() Boolean

Returns the state that will be undone when calling undo().

Returns:

Boolean:

Properties

_currentStateIndex

Number protected

This index points to the last state that was executed. Calling undo() will undo the state this index points to.

_pendingActions

Array protected

List of pending actions.

_states

Array protected

List of states containing undo and redo action methods added by the user through the add method.

Attributes

maxUndoDepth

Number

Limits the states stack size. Useful for memory optimization.

Default: 100

queueable

Boolean

Defines how this module will behave when the user calls undo or redo while an action is still in progress. If false, these calls will be ignored. If true, they will be queued, running in order as soon as the pending action finishes.

Default: false

Events

afterRedo

Fired after a redo has finished running.

afterUndo

Fired after an undo has finished running.

beforeRedo

Fired right before a redo is run.

beforeUndo

Fired right before an undo is run.