/* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add('history-html5', function (Y, NAME) { /** * Provides browser history management using the HTML5 history API. * * @module history * @submodule history-html5 * @since 3.2.0 */ /** *
* 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:
*
_storeState()
and pushes or replaces
* a history entry using the HTML5 history API when necessary.
*
* @method _storeState
* @param {String} src Source of the changes.
* @param {Object} newState New state to store.
* @param {Object} options Zero or more options.
* @protected
*/
_storeState: function (src, newState, options) {
if (src !== SRC_POPSTATE) {
win.history[src === SRC_REPLACE ? 'replaceState' : 'pushState'](
newState,
options.title || Y.config.doc.title || '',
options.url || Y.config.doc.URL
);
}
HistoryHTML5.superclass._storeState.apply(this, arguments);
},
// -- Protected Event Handlers ---------------------------------------------
/**
* Handler for popstate events.
*
* @method _onPopState
* @param {Event} e
* @protected
*/
_onPopState: function (e) {
this._resolveChanges(SRC_POPSTATE, e._event.state || null);
}
}, {
// -- Public Static Properties ---------------------------------------------
NAME: 'historyhtml5',
/**
* Constant used to identify state changes originating from
* popstate
events.
*
* @property SRC_POPSTATE
* @type String
* @static
* @final
*/
SRC_POPSTATE: SRC_POPSTATE
});
if (!Y.Node.DOM_EVENTS.popstate) {
Y.Node.DOM_EVENTS.popstate = 1;
}
Y.HistoryHTML5 = HistoryHTML5;
/**
*
* If true
, the Y.History
alias will always point to
* Y.HistoryHTML5
when the history-html5 module is loaded, even if
* the current browser doesn't support HTML5 history.
*
* If false
, the Y.History
alias will always point to
* Y.HistoryHash
when the history-hash module is loaded, even if
* the current browser supports HTML5 history.
*
* If neither true
nor false
, the
* Y.History
alias will point to the best available history adapter
* that the browser supports. This is the default behavior.
*