Sha256: 61c5d29c567f3d8a68a56516d36fa604524ba7146bdb072520e1d4f764f5b7cf
Contents?: true
Size: 1.07 KB
Versions: 14
Compression:
Stored size: 1.07 KB
Contents
// A very simple history implementation. Generates events on the `document.body` element when the // hash changes, and includes a parsed object of parameters or a string from the hash. var History = (function() { var currentHash = null; function getMemo() { return currentHash.toParameters(); } function getHash() { return window.location.hash.substring(1); } function poll() { var hash = getHash(); if (currentHash !== hash) { currentHash = hash; $(document.body).trigger("hashchange", [getMemo()]); } } $(document).ready(function() { currentHash = getHash(); if ('onhashchange' in window) { $(window).on('hashchange', poll); } else { setInterval(poll, 50); } $(document.body).trigger("hashchange", [getMemo()]); }); return { add: function(params) { window.location.hash = "#" + $.objToQueryStr(params); }, currentHash: function() { return getHash(); } } })();
Version data entries
14 entries across 14 versions & 1 rubygems