Sha256: 0f912701da9bc3d38953fb23899b0769ae83c43edb2a3eb5899b0c7c49e159ad
Contents?: true
Size: 1.07 KB
Versions: 16
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. window.History = (function() { var currentHash = null; function getMemo() { return $.deserialize(currentHash); } 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(obj) { window.location.hash = "#" + $.serialize(obj); }, currentHash: function() { return getHash(); } }; })();
Version data entries
16 entries across 16 versions & 1 rubygems