-
Notifications
You must be signed in to change notification settings - Fork 258
/
jquery.ba-hashchange.min.js
9 lines (9 loc) · 1.32 KB
/
jquery.ba-hashchange.min.js
1
2
3
4
5
6
7
8
9
/*
* jQuery hashchange event - v1.3pre - 7/5/2010
* http://benalman.com/projects/jquery-hashchange-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&(g===b||g>7);function a(m){m=m||i[c][l];return"#"+m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=50;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},s,p=a(),n=function(t){return t},o=n,r=n;m.start=function(){s||q()};m.stop=function(){s&&clearTimeout(s);s=b};function q(){var u=a(),t=r(p);if(u!==p){o(p=u,t);$(i).trigger(d)}else{if(t!==p){i[c][l]=i[c][l].replace(/#.*/,"")+t}}s=setTimeout(q,$[d+"Delay"])}h&&(function(){var t,u;m.start=function(){if(!t){u=$[d+"IframeSrc"];u=u&&u+a();t=$('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){u||o(a());q()}).attr("src",u||"javascript:0").insertAfter("body")[0].contentWindow}};m.stop=n;r=function(){return a(t[c][l])};o=function(y,v){if(y!==v){var x=t.document.open(),w=$[d+"Domain"];w&&x.write('<script>document.domain="'+w+'"<\/script>');x.close();t[c].hash=y}}})();return m})()})(jQuery,this);