envjs 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +5 -0
- data/Manifest.txt +1 -1
- data/lib/envjs.rb +1 -1
- data/lib/envjs/env.js +37 -27
- data/src/window/location.js +37 -27
- data/test/{dmathieu → smp/dmathieu}/index.html +0 -0
- data/test/unit/window.js +16 -0
- metadata +4 -4
data/CHANGELOG.rdoc
CHANGED
data/Manifest.txt
CHANGED
data/lib/envjs.rb
CHANGED
data/lib/envjs/env.js
CHANGED
@@ -1842,31 +1842,31 @@ var $location = '';
|
|
1842
1842
|
|
1843
1843
|
$w.__defineSetter__("location", function(url){
|
1844
1844
|
if (false) {
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1845
|
+
if (url[0] === "#") {
|
1846
|
+
// print("return anchor only");
|
1847
|
+
return;
|
1848
|
+
}
|
1849
|
+
var now = window.location.href.replace(/^file:\/\//,"").replace(/#.*/,"");
|
1850
|
+
var to = $master.first_script_window && $master.first_script_window.location.href;
|
1851
|
+
// var to = $env.location(url,window.location.href != "about:blank" ? window.location.href: undefined);
|
1852
|
+
// I'm not sure why this code is here ... looking at the FSW
|
1853
|
+
// print("nu",now,url,to);
|
1854
|
+
to = to || $env.location(url,window.location.href);
|
1855
|
+
// print("nu",now,url,to);
|
1856
|
+
if (to && to.indexOf(now)===0 && to[now.length]==="#") {
|
1857
|
+
// print("return diff anchor only");
|
1858
|
+
return;
|
1859
|
+
}
|
1860
|
+
if (url && url.indexOf(now)===0 && url[now.length]==="#") {
|
1861
|
+
// print("return diff anchor only");
|
1862
|
+
return;
|
1863
|
+
}
|
1864
|
+
// print($location, window.location.href === $location, $location.indexOf("#")>0);
|
1865
|
+
if (url === window.location.href && $location.indexOf("#")>0) {
|
1866
|
+
// print('returning same with anchor');
|
1867
|
+
return;
|
1868
|
+
}
|
1869
|
+
// print("ft",window.location.href,$location,url);
|
1870
1870
|
}
|
1871
1871
|
// debug("l",url,$w.location);
|
1872
1872
|
if( !$location || ( $location == "about:blank" && url !== "about:blank" ) ) {
|
@@ -1875,7 +1875,7 @@ $w.__defineSetter__("location", function(url){
|
|
1875
1875
|
} else {
|
1876
1876
|
$env.unload($w);
|
1877
1877
|
var proxy = $w.window;
|
1878
|
-
// print("re",url);
|
1878
|
+
// print("re",url);
|
1879
1879
|
$env.reload(proxy, url);
|
1880
1880
|
}
|
1881
1881
|
});
|
@@ -1895,8 +1895,13 @@ $w.__defineGetter__("location", function(url){
|
|
1895
1895
|
set hash(_hash){
|
1896
1896
|
//setting the hash is the only property of the location object
|
1897
1897
|
//that doesn't cause the window to reload
|
1898
|
+
var prot = this.protocol;
|
1899
|
+
// FIXME this is a hack until the new url stuff is integrated
|
1900
|
+
if (prot === "file:") {
|
1901
|
+
prot = "file:///";
|
1902
|
+
}
|
1898
1903
|
_hash = _hash.indexOf('#')===0?_hash:"#"+_hash;
|
1899
|
-
$location =
|
1904
|
+
$location = prot + this.host + this.pathname +
|
1900
1905
|
this.search + _hash;
|
1901
1906
|
__setHistory__(_hash, "hash");
|
1902
1907
|
},
|
@@ -1971,6 +1976,11 @@ $w.__defineGetter__("location", function(url){
|
|
1971
1976
|
};
|
1972
1977
|
});
|
1973
1978
|
|
1979
|
+
// Local Variables:
|
1980
|
+
// espresso-indent-level:4
|
1981
|
+
// c-basic-offset:4
|
1982
|
+
// tab-width:4
|
1983
|
+
// End:
|
1974
1984
|
/*
|
1975
1985
|
* history.js
|
1976
1986
|
*/
|
data/src/window/location.js
CHANGED
@@ -8,31 +8,31 @@ var $location = '';
|
|
8
8
|
|
9
9
|
$w.__defineSetter__("location", function(url){
|
10
10
|
if (false) {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
11
|
+
if (url[0] === "#") {
|
12
|
+
// print("return anchor only");
|
13
|
+
return;
|
14
|
+
}
|
15
|
+
var now = window.location.href.replace(/^file:\/\//,"").replace(/#.*/,"");
|
16
|
+
var to = $master.first_script_window && $master.first_script_window.location.href;
|
17
|
+
// var to = $env.location(url,window.location.href != "about:blank" ? window.location.href: undefined);
|
18
|
+
// I'm not sure why this code is here ... looking at the FSW
|
19
|
+
// print("nu",now,url,to);
|
20
|
+
to = to || $env.location(url,window.location.href);
|
21
|
+
// print("nu",now,url,to);
|
22
|
+
if (to && to.indexOf(now)===0 && to[now.length]==="#") {
|
23
|
+
// print("return diff anchor only");
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
if (url && url.indexOf(now)===0 && url[now.length]==="#") {
|
27
|
+
// print("return diff anchor only");
|
28
|
+
return;
|
29
|
+
}
|
30
|
+
// print($location, window.location.href === $location, $location.indexOf("#")>0);
|
31
|
+
if (url === window.location.href && $location.indexOf("#")>0) {
|
32
|
+
// print('returning same with anchor');
|
33
|
+
return;
|
34
|
+
}
|
35
|
+
// print("ft",window.location.href,$location,url);
|
36
36
|
}
|
37
37
|
// debug("l",url,$w.location);
|
38
38
|
if( !$location || ( $location == "about:blank" && url !== "about:blank" ) ) {
|
@@ -41,7 +41,7 @@ $w.__defineSetter__("location", function(url){
|
|
41
41
|
} else {
|
42
42
|
$env.unload($w);
|
43
43
|
var proxy = $w.window;
|
44
|
-
// print("re",url);
|
44
|
+
// print("re",url);
|
45
45
|
$env.reload(proxy, url);
|
46
46
|
}
|
47
47
|
});
|
@@ -61,8 +61,13 @@ $w.__defineGetter__("location", function(url){
|
|
61
61
|
set hash(_hash){
|
62
62
|
//setting the hash is the only property of the location object
|
63
63
|
//that doesn't cause the window to reload
|
64
|
+
var prot = this.protocol;
|
65
|
+
// FIXME this is a hack until the new url stuff is integrated
|
66
|
+
if (prot === "file:") {
|
67
|
+
prot = "file:///";
|
68
|
+
}
|
64
69
|
_hash = _hash.indexOf('#')===0?_hash:"#"+_hash;
|
65
|
-
$location =
|
70
|
+
$location = prot + this.host + this.pathname +
|
66
71
|
this.search + _hash;
|
67
72
|
__setHistory__(_hash, "hash");
|
68
73
|
},
|
@@ -137,3 +142,8 @@ $w.__defineGetter__("location", function(url){
|
|
137
142
|
};
|
138
143
|
});
|
139
144
|
|
145
|
+
// Local Variables:
|
146
|
+
// espresso-indent-level:4
|
147
|
+
// c-basic-offset:4
|
148
|
+
// tab-width:4
|
149
|
+
// End:
|
File without changes
|
data/test/unit/window.js
CHANGED
@@ -39,3 +39,19 @@ test("References to the window object", function() {
|
|
39
39
|
"for top-level document 'window.top' refers to itself");
|
40
40
|
}catch(e){print(e);}
|
41
41
|
});
|
42
|
+
|
43
|
+
test("Allows to change the window.location.hash parameter w/o hash", function() {
|
44
|
+
expect(1);
|
45
|
+
try {
|
46
|
+
window.location.hash = 'test';
|
47
|
+
ok(window.location.hash === '#test');
|
48
|
+
}catch(e){print(e);}
|
49
|
+
});
|
50
|
+
|
51
|
+
test("Allows to change the window.location.hash parameter w/hash", function() {
|
52
|
+
expect(1);
|
53
|
+
try {
|
54
|
+
window.location.hash = '#test';
|
55
|
+
ok(window.location.hash === '#test');
|
56
|
+
}catch(e){print(e);}
|
57
|
+
});
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 4
|
9
|
+
version: 0.3.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- John Resig
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-04-
|
19
|
+
date: 2010-04-22 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -278,7 +278,7 @@ files:
|
|
278
278
|
- test/call-load-test.js
|
279
279
|
- test/data.js
|
280
280
|
- test/debug.js
|
281
|
-
- test/dmathieu/index.html
|
281
|
+
- test/smp/dmathieu/index.html
|
282
282
|
- test/firebug/errorIcon.png
|
283
283
|
- test/firebug/firebug.css
|
284
284
|
- test/firebug/firebug.html
|