/** * jQuery hashchange 1.0.0 * * (based on jquery.history) * * Copyright (c) 2008 Chris Leishman (chrisleishman.com) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. */ (function($) { $.fn.extend({ hashchange: function(callback) { this.bind('hashchange', callback) }, openOnClick: function(href) { if (href === undefined || href.length == 0) href = '#'; return this.click(function(ev) { if (href && href.charAt(0) == '#') { // execute load in separate call stack window.setTimeout(function() { $.locationHash(href) }, 0); } else { window.location(href); } ev.stopPropagation(); return false; }); } }); // IE 8 introduces the hashchange event natively - so nothing more to do if ($.browser.msie && document.documentMode && document.documentMode >= 8) { $.extend({ locationHash: function(hash) { if (!hash) hash = '#'; else if (hash.charAt(0) != '#') hash = '#' + hash; location.hash = hash; } }); return; } var curHash; // hidden iframe for IE (earlier than 8) var iframe; $.extend({ locationHash: function(hash) { if (curHash === undefined) return; if (!hash) hash = '#'; else if (hash.charAt(0) != '#') hash = '#' + hash; location.hash = hash; if (curHash == hash) return; curHash = hash; if ($.browser.msie) updateIEFrame(hash); $.event.trigger('hashchange'); } }); $(document).ready(function() { curHash = location.hash; if ($.browser.msie) { // stop the callback firing twice during init if no hash present if (curHash == '') curHash = '#'; // add hidden iframe for IE iframe = $('