history-html5-debug.js revision 2aec82ac14ef1ebde4d5cc4ad35848834dacec6e
/**
* Provides browser history management using the HTML5 history API.
*
* @module history
* @submodule history-html5
* @since 3.2.0
*/
/**
* <p>
* Provides browser history management using the HTML5 history API.
* </p>
*
* <p>
* When calling the <code>add()</code>, <code>addValue()</code>,
* <code>replace()</code>, or <code>replaceValue()</code> methods on
* <code>HistoryHTML5</code>, the following additional options are supported:
* </p>
*
* <dl>
* <dt><strong>title (String)</strong></dt>
* <dd>
* Title to use for the new history entry. Browsers will typically display
* this title to the user in the detailed history window or in a dropdown
* of the current document will be used.
* </dd>
*
* <dt><strong>url (String)</strong></dt>
* <dd>
* URL to display to the user for the new history entry. This URL will be
* visible in the browser's address bar and will be the bookmarked URL if
* absolute path ("/foo/bar"), or a full URL ("http://example.com/foo/bar").
* If you specify a full URL, the origin <i>must</i> be the same as the
* origin of the current page, or an error will occur. If no URL is
* specified, the current URL will not be changed.
* </dd>
* </dl>
*
* @class HistoryHTML5
* @extends HistoryBase
* @constructor
* @param {Object} config (optional) Configuration object.
*/
var HistoryBase = Y.HistoryBase,
SRC_POPSTATE = 'popstate',
function HistoryHTML5() {
}
// -- Initialization -------------------------------------------------------
// If both the initial state and the bookmarked state are objects, merge
// them (bookmarked state wins).
if (config.initialState
} else {
// Otherwise, the bookmarked state always wins if there is one. If
// there isn't a bookmarked state, history-base will take care of
// falling back to config.initialState or null.
this._initialState = bookmarkedState;
}
},
// -- Protected Methods ----------------------------------------------------
/**
* Overrides HistoryBase's <code>_storeState()</code> 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
*/
if (src !== SRC_POPSTATE) {
);
}
},
// -- Protected Event Handlers ---------------------------------------------
/**
* Handler for popstate events.
*
* @method _onPopState
* @param {Event} e
* @protected
*/
_onPopState: function (e) {
}
}, {
// -- Public Static Properties ---------------------------------------------
NAME: 'historyhtml5',
/**
* Constant used to identify state changes originating from
* <code>popstate</code> events.
*
* @property SRC_POPSTATE
* @type String
* @static
* @final
*/
});
}
Y.HistoryHTML5 = HistoryHTML5;
/**
* <p>
* If <code>true</code>, the <code>Y.History</code> alias will always point to
* <code>Y.HistoryHTML5</code> when the history-html5 module is loaded, even if
* the current browser doesn't support HTML5 history.
* </p>
*
* <p>
* If <code>false</code>, the <code>Y.History</code> alias will always point to
* <code>Y.HistoryHash</code> when the history-hash module is loaded, even if
* the current browser supports HTML5 history.
* </p>
*
* <p>
* If neither <code>true</code> nor <code>false</code>, the
* <code>Y.History</code> alias will point to the best available history adapter
* that the browser supports. This is the default behavior.
* </p>
*
* @property useHistoryHTML5
* @type boolean
* @for config
* @since 3.2.0
*/
// HistoryHTML5 will always win over HistoryHash unless useHistoryHTML5 is false
// or HTML5 history is not supported.
if (useHistoryHTML5 === true || (useHistoryHTML5 !== false &&
HistoryBase.html5)) {
Y.History = HistoryHTML5;
}