envjs 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. data/.jslintrbrc +29 -0
  2. data/.project +17 -0
  3. data/CHANGELOG.rdoc +3 -0
  4. data/DTD/xhtml-lat1.ent +196 -0
  5. data/DTD/xhtml-special.ent +80 -0
  6. data/DTD/xhtml-symbol.ent +237 -0
  7. data/DTD/xhtml.soc +14 -0
  8. data/DTD/xhtml1-frameset.dtd +1235 -0
  9. data/DTD/xhtml1-strict.dtd +978 -0
  10. data/DTD/xhtml1-transitional.dtd +1201 -0
  11. data/DTD/xhtml1.dcl +192 -0
  12. data/Makefile +7 -0
  13. data/Manifest.txt +287 -0
  14. data/{README → README.rdoc} +24 -3
  15. data/Rakefile +196 -0
  16. data/Wakefile +24 -0
  17. data/build.properties +9 -0
  18. data/build.xml +247 -0
  19. data/gm/jquery.js +6002 -0
  20. data/gm/mainx.js +2648 -0
  21. data/gm/sensx.js +135 -0
  22. data/gm/t.js +6 -0
  23. data/gm/x.html +76 -0
  24. data/htmlparser/BrowserTreeBuilder.java +456 -0
  25. data/htmlparser/README +34 -0
  26. data/htmlparser/build.sh +38 -0
  27. data/jsl/jsl +0 -0
  28. data/jsl/jsl.default.conf +129 -0
  29. data/jsl/jsl.exe +0 -0
  30. data/lib/envjs.rb +2 -0
  31. data/lib/envjs/env.js +22 -3
  32. data/lib/envjs/event_loop.js +2 -0
  33. data/lib/envjs/static.js +155 -21
  34. data/licenses/GPL-LICENSE.txt +278 -0
  35. data/licenses/MIT-LICENSE.txt +20 -0
  36. data/src/base64.js +80 -0
  37. data/src/build.js +6 -0
  38. data/src/cruft/bad.html +24 -0
  39. data/src/cruft/dom.js +606 -0
  40. data/src/cruft/element.js +297 -0
  41. data/src/cruft/good.html +30 -0
  42. data/src/cruft/good.js +32 -0
  43. data/src/cruft/internal.js +81 -0
  44. data/src/cruft/parser.js +458 -0
  45. data/src/css/properties.js +293 -0
  46. data/src/css/rule.js +22 -0
  47. data/src/css/sizzle.js +717 -0
  48. data/src/css/stylesheet.js +52 -0
  49. data/src/dom/attr.js +55 -0
  50. data/src/dom/cdatasection.js +31 -0
  51. data/src/dom/characterdata.js +119 -0
  52. data/src/dom/comment.js +30 -0
  53. data/src/dom/doctype.js +9 -0
  54. data/src/dom/document.js +553 -0
  55. data/src/dom/dom.js +134 -0
  56. data/src/dom/element.js +217 -0
  57. data/src/dom/entities.js +273 -0
  58. data/src/dom/exception.js +28 -0
  59. data/src/dom/fragment.js +37 -0
  60. data/src/dom/implementation.js +602 -0
  61. data/src/dom/instruction.js +51 -0
  62. data/src/dom/namednodemap.js +374 -0
  63. data/src/dom/namespace.js +50 -0
  64. data/src/dom/node.js +618 -0
  65. data/src/dom/nodelist.js +195 -0
  66. data/src/dom/parser.js +1207 -0
  67. data/src/dom/text.js +73 -0
  68. data/src/event/event.js +39 -0
  69. data/src/event/mouseevent.js +4 -0
  70. data/src/event/uievent.js +8 -0
  71. data/src/html/a.js +110 -0
  72. data/src/html/anchor.js +80 -0
  73. data/src/html/area.js +57 -0
  74. data/src/html/base.js +26 -0
  75. data/src/html/blockquote-q.js +19 -0
  76. data/src/html/body.js +19 -0
  77. data/src/html/button.js +21 -0
  78. data/src/html/canvas.js +14 -0
  79. data/src/html/col-colgroup.js +49 -0
  80. data/src/html/collection.js +72 -0
  81. data/src/html/cookie.js +151 -0
  82. data/src/html/del-ins.js +25 -0
  83. data/src/html/div.js +28 -0
  84. data/src/html/document.js +359 -0
  85. data/src/html/element.js +380 -0
  86. data/src/html/fieldset.js +19 -0
  87. data/src/html/form.js +484 -0
  88. data/src/html/frame.js +89 -0
  89. data/src/html/frameset.js +25 -0
  90. data/src/html/head.js +44 -0
  91. data/src/html/html.js +0 -0
  92. data/src/html/htmlparser.js +340 -0
  93. data/src/html/iframe.js +26 -0
  94. data/src/html/image.js +0 -0
  95. data/src/html/img.js +62 -0
  96. data/src/html/input-elements.js +307 -0
  97. data/src/html/input.js +65 -0
  98. data/src/html/label.js +26 -0
  99. data/src/html/legend.js +19 -0
  100. data/src/html/link.js +82 -0
  101. data/src/html/map.js +22 -0
  102. data/src/html/meta.js +37 -0
  103. data/src/html/object.js +89 -0
  104. data/src/html/optgroup.js +25 -0
  105. data/src/html/option.js +97 -0
  106. data/src/html/param.js +38 -0
  107. data/src/html/script.js +122 -0
  108. data/src/html/select.js +129 -0
  109. data/src/html/style.js +31 -0
  110. data/src/html/table.js +199 -0
  111. data/src/html/tbody-thead-tfoot.js +91 -0
  112. data/src/html/td-th.js +18 -0
  113. data/src/html/textarea.js +25 -0
  114. data/src/html/title.js +20 -0
  115. data/src/html/tr.js +114 -0
  116. data/src/intro.js +141 -0
  117. data/src/outro.js +70 -0
  118. data/src/parser/html5.detailed.js +10762 -0
  119. data/src/parser/html5.min.js +503 -0
  120. data/src/parser/html5.pretty.js +10815 -0
  121. data/src/parser/intro.js +42 -0
  122. data/src/parser/outro.js +9 -0
  123. data/src/platform/core.js +323 -0
  124. data/src/platform/johnson.js +479 -0
  125. data/src/platform/rhino.js +327 -0
  126. data/src/platform/static/intro.js +41 -0
  127. data/src/platform/static/outro.js +30 -0
  128. data/src/profile/aop.js +238 -0
  129. data/src/profile/profile.js +402 -0
  130. data/src/serializer/xml.js +21 -0
  131. data/src/svg/animatedstring.js +25 -0
  132. data/src/svg/document.js +25 -0
  133. data/src/svg/element.js +22 -0
  134. data/src/svg/locatable.js +17 -0
  135. data/src/svg/rect.js +18 -0
  136. data/src/svg/rectelement.js +24 -0
  137. data/src/svg/stylable.js +49 -0
  138. data/src/svg/svgelement.js +22 -0
  139. data/src/svg/transformable.js +15 -0
  140. data/src/window/css.js +15 -0
  141. data/src/window/dialog.js +16 -0
  142. data/src/window/document.js +28 -0
  143. data/src/window/event.js +262 -0
  144. data/src/window/history.js +62 -0
  145. data/src/window/location.js +138 -0
  146. data/src/window/navigator.js +48 -0
  147. data/src/window/screen.js +53 -0
  148. data/src/window/timer.js +21 -0
  149. data/src/window/window.js +284 -0
  150. data/src/window/xhr.js +127 -0
  151. data/src/xpath/expression.js +49 -0
  152. data/src/xpath/implementation.js +2482 -0
  153. data/src/xpath/result.js +67 -0
  154. data/src/xpath/util.js +551 -0
  155. data/src/xpath/xmltoken.js +149 -0
  156. data/src/xslt/COPYING +34 -0
  157. data/src/xslt/ajaxslt-0.8.1/AUTHORS +1 -0
  158. data/src/xslt/ajaxslt-0.8.1/ChangeLog +136 -0
  159. data/src/xslt/ajaxslt-0.8.1/Makefile +49 -0
  160. data/src/xslt/ajaxslt-0.8.1/README +102 -0
  161. data/src/xslt/ajaxslt-0.8.1/TODO +15 -0
  162. data/src/xslt/ajaxslt-0.8.1/dom.js +566 -0
  163. data/src/xslt/ajaxslt-0.8.1/dom_unittest.html +24 -0
  164. data/src/xslt/ajaxslt-0.8.1/dom_unittest.js +131 -0
  165. data/src/xslt/ajaxslt-0.8.1/simplelog.js +79 -0
  166. data/src/xslt/ajaxslt-0.8.1/test/xpath.html +18 -0
  167. data/src/xslt/ajaxslt-0.8.1/test/xpath_script.js +45 -0
  168. data/src/xslt/ajaxslt-0.8.1/test/xslt.html +58 -0
  169. data/src/xslt/ajaxslt-0.8.1/test/xslt_script.js +33 -0
  170. data/src/xslt/ajaxslt-0.8.1/unittestsuite.html +26 -0
  171. data/src/xslt/ajaxslt-0.8.1/xmltoken.js +149 -0
  172. data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.html +18 -0
  173. data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.js +811 -0
  174. data/src/xslt/ajaxslt-0.8.1/xpath_unittest.html +39 -0
  175. data/src/xslt/ajaxslt-0.8.1/xpath_unittest.js +557 -0
  176. data/src/xslt/ajaxslt-0.8.1/xpathdebug.js +234 -0
  177. data/src/xslt/ajaxslt-0.8.1/xslt_unittest.html +138 -0
  178. data/src/xslt/ajaxslt-0.8.1/xslt_unittest.js +68 -0
  179. data/src/xslt/implementation.js +625 -0
  180. data/src/xslt/processor.js +37 -0
  181. data/src/xslt/util.js +449 -0
  182. data/test/foo.html +8 -0
  183. data/test/foo.js +40 -0
  184. data/test/jquery.js +6002 -0
  185. data/test/x.js +1 -0
  186. data/test/y.js +1 -0
  187. metadata +245 -14
@@ -0,0 +1,62 @@
1
+ /*
2
+ * history.js
3
+ */
4
+
5
+ var $currentHistoryIndex = 0;
6
+ var $history = [];
7
+
8
+ // Browser History
9
+ $w.__defineGetter__("history", function(){
10
+ return {
11
+ get length(){ return $history.length; },
12
+ back : function(count){
13
+ if(count){
14
+ go(-count);
15
+ }else{go(-1);}
16
+ },
17
+ forward : function(count){
18
+ if(count){
19
+ go(count);
20
+ }else{go(1);}
21
+ },
22
+ go : function(target){
23
+ if(typeof target == "number"){
24
+ target = $currentHistoryIndex+target;
25
+ if(target > -1 && target < $history.length){
26
+ if($history[target].location == "hash"){
27
+ $w.location.hash = $history[target].value;
28
+ }else{
29
+ $w.location = $history[target].value;
30
+ }
31
+ $currentHistoryIndex = target;
32
+ //remove the last item added to the history
33
+ //since we are moving inside the history
34
+ $history.pop();
35
+ }
36
+ }else{
37
+ //TODO: walk throu the history and find the 'best match'
38
+ }
39
+ }
40
+ };
41
+ });
42
+
43
+ //Here locationPart is the particutlar method/attribute
44
+ // of the location object that was modified. This allows us
45
+ // to modify the correct portion of the location object
46
+ // when we navigate the history
47
+ var __setHistory__ = function( value, locationPart){
48
+ if ( value == "about:blank" ) {
49
+ return;
50
+ }
51
+ $debug("adding value to history: " +value);
52
+ $currentHistoryIndex++;
53
+ $history.push({
54
+ location: locationPart||"href",
55
+ value: value
56
+ });
57
+ };
58
+
59
+ // Local Variables:
60
+ // espresso-indent-level:4
61
+ // c-basic-offset:4
62
+ // End:
@@ -0,0 +1,138 @@
1
+ /*
2
+ * location.js
3
+ * - requires env
4
+ */
5
+ $debug("Initializing Window Location.");
6
+ //the current location
7
+ var $location = '';
8
+
9
+ $w.__defineSetter__("location", function(url){
10
+ if (false) {
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
+ }
37
+ if( !$location || $location == "about:blank" ) {
38
+ // $w.__loadAWindowsDocument__(url);
39
+ $env.load(url);
40
+ } else {
41
+ $env.unload($w);
42
+ var proxy = $w.window;
43
+ // print("re",url);
44
+ $env.reload(proxy, url);
45
+ }
46
+ });
47
+
48
+ $w.__defineGetter__("location", function(url){
49
+ var hash = new RegExp('(\\#.*)'),
50
+ hostname = new RegExp('\/\/([^\:\/]+)'),
51
+ pathname = new RegExp('(\/[^\\?\\#]*)'),
52
+ port = new RegExp('\:(\\d+)\/'),
53
+ protocol = new RegExp('(^\\w*\:)'),
54
+ search = new RegExp('(\\?[^\\#]*)');
55
+ return {
56
+ get hash(){
57
+ var m = hash.exec(this.href);
58
+ return m&&m.length>1?m[1]:"";
59
+ },
60
+ set hash(_hash){
61
+ //setting the hash is the only property of the location object
62
+ //that doesn't cause the window to reload
63
+ _hash = _hash.indexOf('#')===0?_hash:"#"+_hash;
64
+ $location = this.protocol + this.host + this.pathname +
65
+ this.search + _hash;
66
+ setHistory(_hash, "hash");
67
+ },
68
+ get host(){
69
+ return this.hostname + ((this.port !== "")?":"+this.port:"");
70
+ },
71
+ set host(_host){
72
+ $w.location = this.protocol + _host + this.pathname +
73
+ this.search + this.hash;
74
+ },
75
+ get hostname(){
76
+ var m = hostname.exec(this.href);
77
+ return m&&m.length>1?m[1]:"";
78
+ },
79
+ set hostname(_hostname){
80
+ $w.location = this.protocol + _hostname + ((this.port==="")?"":(":"+this.port)) +
81
+ this.pathname + this.search + this.hash;
82
+ },
83
+ get href(){
84
+ //This is the only env specific function
85
+ return $location;
86
+ },
87
+ set href(url){
88
+ $w.location = url;
89
+ },
90
+ get pathname(){
91
+ var m = this.href;
92
+ m = pathname.exec(m.substring(m.indexOf(this.hostname)));
93
+ return m&&m.length>1?m[1]:"/";
94
+ },
95
+ set pathname(_pathname){
96
+ $w.location = this.protocol + this.host + _pathname +
97
+ this.search + this.hash;
98
+ },
99
+ get port(){
100
+ var m = port.exec(this.href);
101
+ return m&&m.length>1?m[1]:"";
102
+ },
103
+ set port(_port){
104
+ $w.location = this.protocol + this.hostname + ":"+_port + this.pathname +
105
+ this.search + this.hash;
106
+ },
107
+ get protocol(){
108
+ return this.href && protocol.exec(this.href)[0];
109
+ },
110
+ set protocol(_protocol){
111
+ $w.location = _protocol + this.host + this.pathname +
112
+ this.search + this.hash;
113
+ },
114
+ get search(){
115
+ var m = search.exec(this.href);
116
+ return m&&m.length>1?m[1]:"";
117
+ },
118
+ set search(_search){
119
+ $w.location = this.protocol + this.host + this.pathname +
120
+ _search + this.hash;
121
+ },
122
+ toString: function(){
123
+ return this.href;
124
+ },
125
+ reload: function(force){
126
+ // ignore 'force': we don't implement a cache
127
+ var thisWindow = $w;
128
+ $env.unload(thisWindow);
129
+ try { thisWindow = thisWindow.$thisWindowsProxyObject || thisWindow; }catch (e){}
130
+ $env.reload($window, thisWindow.location.href);
131
+ },
132
+ replace: function(url){
133
+ $location = url;
134
+ $w.location.reload();
135
+ }
136
+ };
137
+ });
138
+
@@ -0,0 +1,48 @@
1
+ /*
2
+ * navigator.js
3
+ * - requires env
4
+ */
5
+ $debug("Initializing Window Navigator.");
6
+
7
+ var $appCodeName = $env.appCodeName;//eg "Mozilla"
8
+ var $appName = $env.appName;//eg "Gecko/20070309 Firefox/2.0.0.3"
9
+
10
+ // Browser Navigator
11
+ $w.__defineGetter__("navigator", function(){
12
+ return {
13
+ get appCodeName(){
14
+ return $appCodeName;
15
+ },
16
+ get appName(){
17
+ return $appName;
18
+ },
19
+ get appVersion(){
20
+ return $version +" ("+
21
+ $w.navigator.platform +"; "+
22
+ "U; "+//?
23
+ $env.os_name+" "+$env.os_arch+" "+$env.os_version+"; "+
24
+ $env.lang+"; "+
25
+ "rv:"+$revision+
26
+ ")";
27
+ },
28
+ get cookieEnabled(){
29
+ return true;
30
+ },
31
+ get mimeTypes(){
32
+ return [];
33
+ },
34
+ get platform(){
35
+ return $env.platform;
36
+ },
37
+ get plugins(){
38
+ return [];
39
+ },
40
+ get userAgent(){
41
+ return $w.navigator.appCodeName + "/" + $w.navigator.appVersion + " " + $w.navigator.appName;
42
+ },
43
+ javaEnabled : function(){
44
+ return $env.javaEnabled;
45
+ }
46
+ };
47
+ });
48
+
@@ -0,0 +1,53 @@
1
+ /*
2
+ * screen.js
3
+ */
4
+ $debug("Initializing Window Screen.");
5
+
6
+ var $availHeight = 600,
7
+ $availWidth = 800,
8
+ $colorDepth = 16,
9
+ $height = 600,
10
+ $width = 800;
11
+
12
+ $w.__defineGetter__("screen", function(){
13
+ return {
14
+ get availHeight(){return $availHeight;},
15
+ get availWidth(){return $availWidth;},
16
+ get colorDepth(){return $colorDepth;},
17
+ get height(){return $height;},
18
+ get width(){return $width;}
19
+ };
20
+ });
21
+
22
+
23
+ $w.moveBy = function(dx,dy){
24
+ //TODO
25
+ };
26
+
27
+ $w.moveTo = function(x,y) {
28
+ //TODO
29
+ };
30
+
31
+ /*$w.print = function(){
32
+ //TODO
33
+ };*/
34
+
35
+ $w.resizeBy = function(dw, dh){
36
+ $w.resizeTo($width+dw,$height+dh);
37
+ };
38
+
39
+ $w.resizeTo = function(width, height){
40
+ $width = (width <= $availWidth) ? width : $availWidth;
41
+ $height = (height <= $availHeight) ? height : $availHeight;
42
+ };
43
+
44
+
45
+ $w.scroll = function(x,y){
46
+ //TODO
47
+ };
48
+ $w.scrollBy = function(dx, dy){
49
+ //TODO
50
+ };
51
+ $w.scrollTo = function(x,y){
52
+ //TODO
53
+ };
@@ -0,0 +1,21 @@
1
+ /*
2
+ * eventLoop.js
3
+ */
4
+
5
+ $debug("Initializing Window EventLoop.");
6
+
7
+ $w.setTimeout = function(fn, time){
8
+ return $master.eventLoop.setTimeout($inner,fn,time);
9
+ };
10
+
11
+ $w.setInterval = function(fn, time){
12
+ return $master.eventLoop.setInterval($inner,fn,time);
13
+ };
14
+
15
+ $w.clearInterval = $w.clearTimeout = function(num){
16
+ return $master.eventLoop.clear(num);
17
+ };
18
+
19
+ $w.$wait = $env.wait = $env.wait || function(wait) {
20
+ return $master.eventLoop.wait(wait);
21
+ };
@@ -0,0 +1,284 @@
1
+ /*
2
+ * window.js
3
+ * - this file will be wrapped in a closure providing the window object as $w
4
+ */
5
+ // a logger or empty function available to all modules.
6
+ var $log = $env.log,
7
+ $debug = $env.debug,
8
+ $info = $env.info,
9
+ $warn = $env.warn,
10
+ $error = $env.error;
11
+
12
+ //The version of this application
13
+ var $version = "0.1";
14
+ //This should be hooked to git or svn or whatever
15
+ var $revision = "0.0.0.0";
16
+
17
+ //These descriptions of window properties are taken loosely David Flanagan's
18
+ //'JavaScript - The Definitive Guide' (O'Reilly)
19
+
20
+ /**> $cookies - see cookie.js <*/
21
+ // read only boolean specifies whether the window has been closed
22
+ var $closed = false;
23
+
24
+ // a read/write string that specifies the default message that appears in the status line
25
+ var $defaultStatus = "Done";
26
+
27
+ // a read-only reference to the Document object belonging to this window
28
+ /**> $document - See document.js <*/
29
+
30
+ //IE only, refers to the most recent event object - this maybe be removed after review
31
+ var $event = null;
32
+
33
+ //A read-only array of window objects
34
+ //var $frames = []; // TODO: since window.frames can be accessed like a
35
+ // hash, will need an object to really implement
36
+
37
+ // a read-only reference to the History object
38
+ /**> $history - see location.js <**/
39
+
40
+ // read-only properties that specify the height and width, in pixels
41
+ var $innerHeight = 600, $innerWidth = 800;
42
+
43
+ // a read-only reference to the Location object. the location object does expose read/write properties
44
+ /**> $location - see location.js <**/
45
+
46
+ // The name of window/frame. Set directly, when using open(), or in frameset.
47
+ // May be used when specifying the target attribute of links
48
+ var $name;
49
+
50
+ // a read-only reference to the Navigator object
51
+ /**> $navigator - see navigator.js <**/
52
+
53
+ // a read/write reference to the Window object that contained the script that called open() to
54
+ //open this browser window. This property is valid only for top-level window objects.
55
+
56
+ var $opener = $openingWindow = options.opener;
57
+
58
+ // Read-only properties that specify the total height and width, in pixels, of the browser window.
59
+ // These dimensions include the height and width of the menu bar, toolbars, scrollbars, window
60
+ // borders and so on. These properties are not supported by IE and IE offers no alternative
61
+ // properties;
62
+ var $outerHeight = $innerHeight, $outerWidth = $innerWidth;
63
+
64
+ // Read-only properties that specify the number of pixels that the current document has been scrolled
65
+ //to the right and down. These are not supported by IE.
66
+ var $pageXOffset = 0, $pageYOffset = 0;
67
+
68
+
69
+ // A read-only reference to the Window object that contains this window
70
+ // or frame. If the window is a top-level window, parent refers to
71
+ // the window itself. If this window is a frame, this property refers
72
+ // to the window or frame that conatins it.
73
+ var $parent = options.parent || window;
74
+ try {
75
+ if ($parentWindow.$thisWindowsProxyObject)
76
+ $parent = $parentWindow.$thisWindowsProxyObject;
77
+ } catch(e){}
78
+
79
+
80
+
81
+ // a read-only refernce to the Screen object that specifies information about the screen:
82
+ // the number of available pixels and the number of available colors.
83
+ /**> $screen - see screen.js <**/
84
+ // read only properties that specify the coordinates of the upper-left corner of the screen.
85
+ var $screenX = 0, $screenY = 0;
86
+ var $screenLeft = $screenX, $screenTop = $screenY;
87
+
88
+ // a read/write string that specifies the current contents of the status line.
89
+ var $status = '';
90
+
91
+ // a read-only reference to the top-level window that contains this window. If this
92
+ // window is a top-level window it is simply a refernce to itself. If this window
93
+ // is a frame, the top property refers to the top-level window that contains the frame.
94
+ var $top = $parent && $parent.top || this;
95
+
96
+ // the window property is identical to the self property and to this obj
97
+ var $window = $w;
98
+ try {
99
+ if ($w.$thisWindowsProxyObject)
100
+ $window = $w.$thisWindowsProxyObject;
101
+ } catch(e){}
102
+ options.proxy && ( $window = options.proxy );
103
+
104
+ $debug("Initializing Window.");
105
+ __extend__($w,{
106
+ get closed(){return $closed;},
107
+ get defaultStatus(){return $defaultStatus;},
108
+ set defaultStatus(_defaultStatus){$defaultStatus = _defaultStatus;},
109
+ //get document(){return $document;}, - see document.js
110
+ get event(){return $event;},
111
+
112
+ get frames(){return undefined;}, // TODO: not yet any code to maintain list
113
+ get length(){return undefined;}, // should be frames.length, but.... TODO
114
+
115
+ //get history(){return $history;}, - see history.js
116
+ get innerHeight(){return $innerHeight;},
117
+ get innerWidth(){return $innerWidth;},
118
+ get clientHeight(){return $innerHeight;},
119
+ get clientWidth(){return $innerWidth;},
120
+ //get location(){return $location;}, see location.js
121
+ get name(){return $name;},
122
+ set name(newName){ $name = newName; },
123
+ //get navigator(){return $navigator;}, see navigator.js
124
+ get opener(){return $opener;},
125
+ get outerHeight(){return $outerHeight;},
126
+ get outerWidth(){return $outerWidth;},
127
+ get pageXOffest(){return $pageXOffset;},
128
+ get pageYOffset(){return $pageYOffset;},
129
+ get parent(){return $parent;},
130
+ //get screen(){return $screen;}, see screen.js
131
+ get screenLeft(){return $screenLeft;},
132
+ get screenTop(){return $screenTop;},
133
+ get screenX(){return $screenX;},
134
+ get screenY(){return $screenY;},
135
+ get self(){return $window;},
136
+ get status(){return $status;},
137
+ set status(_status){$status = _status;},
138
+ get top(){return $top || $window;},
139
+ get window(){return $window;},
140
+
141
+ // DOM0
142
+
143
+ Image: function() {
144
+ return document.createElement("img");
145
+ }
146
+ /*,
147
+ toString : function(){
148
+ return '[object Window]';
149
+ } FIX SMP */
150
+ });
151
+
152
+ $w.open = function(url, name, features, replace){
153
+ if (features)
154
+ $env.warn("'features' argument for 'window.open()' not yet implemented");
155
+ if (replace)
156
+ $env.warn("'replace' argument for 'window.open()' not yet implemented");
157
+
158
+ var undef;
159
+ if(url === undef || url === "") {
160
+ url = "about:blank";
161
+ }
162
+
163
+ var newWindow = $env.newwindow(this, null, url);
164
+ newWindow.$name = name;
165
+ return newWindow;
166
+ };
167
+
168
+ $w.close = function(){
169
+ $env.unload($w);
170
+ $closed = true;
171
+ };
172
+
173
+ $env.unload = function(windowToUnload){
174
+ try {
175
+ var event = windowToUnload.document.createEvent();
176
+ event.initEvent("unload");
177
+ windowToUnload.document.getElementsByTagName('body')[0].
178
+ dispatchEvent(event, false);
179
+ }
180
+ catch (e){} // maybe no/bad document loaded, ignore
181
+
182
+ var event = windowToUnload.document.createEvent();
183
+ event.initEvent("unload");
184
+ windowToUnload.dispatchEvent(event, false);
185
+ };
186
+
187
+
188
+ $env.load = function(url,xhr_options){
189
+ $location = $env.location(url);
190
+ __setHistory__($location);
191
+ try{
192
+ $w.document.load($location,xhr_options);
193
+ }catch(e){
194
+ $warn("Exception while loading window: "+e);
195
+ throw e;
196
+ }
197
+ };
198
+
199
+
200
+ /* Time related functions - see timer.js
201
+ * - clearTimeout
202
+ * - clearInterval
203
+ * - setTimeout
204
+ * - setInterval
205
+ */
206
+
207
+ /*
208
+ * Events related functions - see event.js
209
+ * - addEventListener
210
+ * - attachEvent
211
+ * - detachEvent
212
+ * - removeEventListener
213
+ *
214
+ * These functions are identical to the Element equivalents.
215
+ */
216
+
217
+ /*
218
+ * UIEvents related functions - see uievent.js
219
+ * - blur
220
+ * - focus
221
+ *
222
+ * These functions are identical to the Element equivalents.
223
+ */
224
+
225
+ /* Dialog related functions - see dialog.js
226
+ * - alert
227
+ * - confirm
228
+ * - prompt
229
+ */
230
+
231
+ /* Screen related functions - see screen.js
232
+ * - moveBy
233
+ * - moveTo
234
+ * - print
235
+ * - resizeBy
236
+ * - resizeTo
237
+ * - scrollBy
238
+ * - scrollTo
239
+ */
240
+
241
+ /* CSS related functions - see css.js
242
+ * - getComputedStyle
243
+ */
244
+
245
+ /*
246
+ * Shared utility methods
247
+ */
248
+ // Helper method for extending one object with another.
249
+ function __extend__(a,b) {
250
+ for ( var i in b ) {
251
+ var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i);
252
+ if ( g || s ) {
253
+ if ( g ) a.__defineGetter__(i, g);
254
+ if ( s ) a.__defineSetter__(i, s);
255
+ } else
256
+ a[i] = b[i];
257
+ } return a;
258
+ };
259
+
260
+
261
+ // from ariel flesler http://flesler.blogspot.com/2008/11/fast-trim-function-for-javascript.html
262
+ // this might be a good utility function to provide in the env.core
263
+ // as in might be useful to the parser and other areas as well
264
+ function trim( str ){
265
+ return (str || "").replace( /^\s+|\s+$/g, "" );
266
+
267
+ };
268
+ /*function trim( str ){
269
+ var start = -1,
270
+ end = str.length;
271
+ /*jsl:ignore*
272
+ while( str.charCodeAt(--end) < 33 );
273
+ while( str.charCodeAt(++start) < 33 );
274
+ /*jsl:end*
275
+ return str.slice( start, end + 1 );
276
+ };*/
277
+
278
+ //from jQuery
279
+ function __setArray__( target, array ) {
280
+ // Resetting the length to 0, then using the native Array push
281
+ // is a super-fast way to populate an object with array-like properties
282
+ target.length = 0;
283
+ Array.prototype.push.apply( target, array );
284
+ };