Provides browser history management using the HTML5 history API.
When calling the add(), addValue(),
replace(), or replaceValue() methods on
HistoryHTML5, the following additional options are supported:
_changesrc
state
options
Changes the state. This method provides a common implementation shared by the public methods for changing state.
_defChangeFne
Default history:change event handler.
e
EventFacade
state change event facade
_fireChangeEventsrc
key
value
Fires a dynamic "[key]Change" event.
_fireEventssrc
changes
options
Called by _resolveChanges() when the state has changed. This method takes care of actually firing the necessary events.
_fireRemoveEventsrc
key
value
Fires a dynamic "[key]Remove" event.
_initconfig
Initializes this HistoryBase instance. This method is called by the constructor.
config
Object
configuration object
_isSimpleObjectvalue
Returns true if value is a simple object and not a
function or an array.
value
Mixed
_resolveChangessrc
newState
options
Resolves the changes (if any) between newState and the current state and fires appropriate events if things have changed.
_storeStatesrc
newState
options
Overrides HistoryBase's _storeState() and pushes or replaces
a history entry using the HTML5 history API when necessary.
addstate
options
Adds a state entry with new values for the specified keys. By default,
the new state will be merged into the existing state, and new values will
override existing values. Specifying a null or
undefined value will cause that key to be removed from the
new state entry.
state
Object
Object hash of key/value pairs.
options
Object
(optional) Zero or more of the following options:
If true (the default), the new state will be merged
into the existing state. New values will override existing values,
and null or undefined values will be
removed from the state.
<p>
If <code>false</code>, the existing state will be discarded as a
whole and the new state will take its place.
</p>
</dd>
addValuekey
value
options
Adds a state entry with a new value for a single key. By default, the new
value will be merged into the existing state values, and will override an
existing value with the same key if there is one. Specifying a
null or undefined value will cause the key to
be removed from the new state entry.
getkey
Returns the current value of the state parameter specified by key, or an object hash of key/value pairs for all current state parameters if no key is specified.
key
String
(optional) State parameter key.
replacestate
options
Same as add() except that a new browser history entry will
not be created. Instead, the current history entry will be replaced with
the new state.
replaceValuekey
value
options
Same as addValue() except that a new browser history entry
will not be created. Instead, the current history entry will be replaced
with the new state.
_configConfiguration object provided by the user on instantiation, or an empty object if one wasn't provided.
Default: {}
_initialStateResolved initial state: a merge of the user-supplied initial state
(if any) and any initial state provided by a subclass. This may
differ from _config.initialState. If neither the config
nor a subclass supplies an initial state, this property will be
null.
Default: {}
forceIf true, a history:change event will be fired whenever the URL
changes, even if there is no associated state change.
Default: false
SRC_POPSTATEConstant used to identify state changes originating from
popstate events.
[key]Change
Dynamic event fired when an individual history item is added or
changed. The name of this event depends on the name of the key that
changed. To listen to change events for a key named "foo", subscribe
to the fooChange event; for a key named "bar", subscribe
to barChange, etc.
Key-specific events are only fired for instance-level changes; that
is, changes that were made via the same History instance on which the
event is subscribed. To be notified of changes made by other History
instances, subscribe to the global history:change event.
e
EventFacade
Event facade with the following additional properties:
undefined if the item was just added and has no
previous value.
[key]Remove
Dynamic event fired when an individual history item is removed. The
name of this event depends on the name of the key that was removed.
To listen to remove events for a key named "foo", subscribe to the
fooRemove event; for a key named "bar", subscribe to
barRemove, etc.
Key-specific events are only fired for instance-level changes; that
is, changes that were made via the same History instance on which the
event is subscribed. To be notified of changes made by other History
instances, subscribe to the global history:change event.
e
EventFacade
Event facade with the following additional properties:
history:changeFired when the state changes. To be notified of all state changes
regardless of the History or YUI instance that generated them,
subscribe to this event on Y.Global. If you would rather
be notified only about changes generated by this specific History
instance, subscribe to this event on the instance.
e
EventFacade
Event facade with the following additional properties:
newVal and prevVal properties
representing the values of the item both before and after the
change. If the item was newly added, prevVal will be
undefined.