Namespace: History

History

Class representing an abstraction of the history API.

Version:
  • 0.9
Author:

Members


<static> documentRoot :string

(getter/setter) Sets the document root from a passed URL returns the saved document root or a / if not set

Type:
  • string
Default Value:
  • '/'

<static> history :object

(getter/setter) Provides an error if the user tries to set the history object returns the window history object

Type:
  • object

<static> TLDN :string

(getter/setter) Sets the top level domain name. returns the recorded TLDN or, by default, window.location.hostname.

Type:
  • string

<static> observeTLDN :boolean

(getter/setter) whether to observe the TLDN or true (default).

Type:
  • boolean
Default Value:
  • true

<static> devmode :boolean

(getter/setter) Whether this history object is in devmode. Defaults to false

Type:
  • boolean
Default Value:
  • false

<static> initialiased :boolean

(getter/setter) Whether this history object is initialiased.

Type:
  • boolean
Default Value:
  • false

<static> support :boolean

(getter/setter) Whether history is supported by the browser or device. Provides an error if the user tries to set the support value, unless the object is in devmode

Type:
  • boolean

<static> $length :integer

(getter/setter) The length of the history stack

Type:
  • integer

Methods


<static> emitEvent(eventID, data)

Emits an event from the history object

Parameters:
Name Type Description
eventID string

the event ID to emit

data object

= {} the data to include with the event

Example
let listener = function(e) {
  console.log(e.detail)
  e.target.removeEventListener(e.type, arguments.callee);
}
document.addEventListener("ajax-get-addedToDom", listener);

<static> init(devmode)

Initialises the History class. Nothing should be able to operate here unless this has run with a support = true.

Parameters:
Name Type Default Description
devmode boolean false

Indicated whether the object is running in dev mode (will log outputs to console)

Returns:

Returns whether init ran or not

Type
boolean

<static> push(URL, title, stateObj)

Construct and push a URL state

Parameters:
Name Type Description
URL string

The URL to push, can be relative, absolute or full

title string

The title to push.

stateObj object

A state to push to the stack. This will be popped when naviagting back

Returns:

Indicates whether the push succeeded

Type
boolean
Example
AJAXObj.push('/dev/foo/bar', 'The title for the history object')

<static> back()

Takes the user back to the previous state. Simply wraps the history object's back method.


<static> forward()

Takes the user forward to the next state. Simply wraps the history object's forward method.


<private, static> _fixURL(URL, includeDocRoot, includeTrails)

Takes a provided URL and returns the version that is usable

Parameters:
Name Type Default Description
URL string

The URL to be passed

includeDocRoot boolean true

= true Whether to include the docroot on the passed URL

includeTrails boolean true

= true Whether to include found hashes and params

Returns:

The passed and formatted URL

Type
string

<private, static> _popstate(e)

Listener for the popstate method

Parameters:
Name Type Description
e object

the passed event object

Returns:

void