]>
Commit | Line | Data |
---|---|---|
2f01fe57 AD |
1 | /* |
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. | |
3 | Available via Academic Free License >= 2.1 OR the modified BSD license. | |
4 | see: http://dojotoolkit.org/license for details | |
5 | */ | |
6 | ||
7 | ||
8 | if(!dojo._hasResource["dojo.hash"]){ | |
9 | dojo._hasResource["dojo.hash"]=true; | |
10 | dojo.provide("dojo.hash"); | |
11 | (function(){ | |
12 | dojo.hash=function(_1,_2){ | |
13 | if(!arguments.length){ | |
14 | return _3(); | |
15 | } | |
16 | if(_1.charAt(0)=="#"){ | |
17 | _1=_1.substring(1); | |
18 | } | |
19 | if(_2){ | |
20 | _4(_1); | |
21 | }else{ | |
22 | location.href="#"+_1; | |
23 | } | |
24 | return _1; | |
25 | }; | |
26 | var _5=null,_6=null,_7=dojo.config.hashPollFrequency||100; | |
27 | function _8(_9,_a){ | |
28 | var i=_9.indexOf(_a); | |
29 | return (i>=0)?_9.substring(i+1):""; | |
30 | }; | |
31 | function _3(){ | |
32 | return _8(location.href,"#"); | |
33 | }; | |
34 | function _b(){ | |
35 | dojo.publish("/dojo/hashchange",[_3()]); | |
36 | }; | |
37 | function _c(){ | |
38 | if(_3()===_5){ | |
39 | return; | |
40 | } | |
41 | _5=_3(); | |
42 | _b(); | |
43 | }; | |
44 | function _4(_d){ | |
45 | if(_6){ | |
46 | if(_6.isTransitioning()){ | |
47 | setTimeout(dojo.hitch(null,_4,_d),_7); | |
48 | return; | |
49 | } | |
50 | var _e=_6.iframe.location.href; | |
51 | var _f=_e.indexOf("?"); | |
52 | _6.iframe.location.replace(_e.substring(0,_f)+"?"+_d); | |
53 | return; | |
54 | } | |
55 | location.replace("#"+_d); | |
56 | _c(); | |
57 | }; | |
58 | function _10(){ | |
59 | var ifr=document.createElement("iframe"),_11="dojo-hash-iframe",_12=dojo.config.dojoBlankHtmlUrl||dojo.moduleUrl("dojo","resources/blank.html"); | |
60 | ifr.id=_11; | |
61 | ifr.src=_12+"?"+_3(); | |
62 | ifr.style.display="none"; | |
63 | document.body.appendChild(ifr); | |
64 | this.iframe=dojo.global[_11]; | |
65 | var _13,_14,_15,_16,_17,_18=this.iframe.location; | |
66 | function _19(){ | |
67 | _5=_3(); | |
68 | _13=_17?_5:_8(_18.href,"?"); | |
69 | _14=false; | |
70 | _15=null; | |
71 | }; | |
72 | this.isTransitioning=function(){ | |
73 | return _14; | |
74 | }; | |
75 | this.pollLocation=function(){ | |
76 | if(!_17){ | |
77 | try{ | |
78 | var _1a=_8(_18.href,"?"); | |
79 | if(document.title!=_16){ | |
80 | _16=this.iframe.document.title=document.title; | |
81 | } | |
82 | } | |
83 | catch(e){ | |
84 | _17=true; | |
85 | console.error("dojo.hash: Error adding history entry. Server unreachable."); | |
86 | } | |
87 | } | |
88 | var _1b=_3(); | |
89 | if(_14&&_5===_1b){ | |
90 | if(_17||_1a===_15){ | |
91 | _19(); | |
92 | _b(); | |
93 | }else{ | |
94 | setTimeout(dojo.hitch(this,this.pollLocation),0); | |
95 | return; | |
96 | } | |
97 | }else{ | |
98 | if(_5===_1b&&(_17||_13===_1a)){ | |
99 | }else{ | |
100 | if(_5!==_1b){ | |
101 | _5=_1b; | |
102 | _14=true; | |
103 | _15=_1b; | |
104 | ifr.src=_12+"?"+_15; | |
105 | _17=false; | |
106 | setTimeout(dojo.hitch(this,this.pollLocation),0); | |
107 | return; | |
108 | }else{ | |
109 | if(!_17){ | |
110 | location.href="#"+_18.search.substring(1); | |
111 | _19(); | |
112 | _b(); | |
113 | } | |
114 | } | |
115 | } | |
116 | } | |
117 | setTimeout(dojo.hitch(this,this.pollLocation),_7); | |
118 | }; | |
119 | _19(); | |
120 | setTimeout(dojo.hitch(this,this.pollLocation),_7); | |
121 | }; | |
122 | dojo.addOnLoad(function(){ | |
123 | if("onhashchange" in dojo.global&&(!dojo.isIE||(dojo.isIE>=8&&document.compatMode!="BackCompat"))){ | |
124 | dojo.connect(dojo.global,"onhashchange",_b); | |
125 | }else{ | |
126 | if(document.addEventListener){ | |
127 | _5=_3(); | |
128 | setInterval(_c,_7); | |
129 | }else{ | |
130 | if(document.attachEvent){ | |
131 | _6=new _10(); | |
132 | } | |
133 | } | |
134 | } | |
135 | }); | |
136 | })(); | |
137 | } |