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,25 @@
1
+ $debug("Defining SVGDocument");
2
+ /*
3
+ * SVGDocument - DOM Level 2
4
+ */
5
+ /**
6
+ * @class SVGDocument - The Document interface represents the entire SVG or XML document.
7
+ * Conceptually, it is the root of the document tree, and provides the primary access to the document's data.
8
+ *
9
+ * @extends DOMDocument
10
+ */
11
+ var SVGDocument = function() {
12
+ throw new Error("SVGDocument() not implemented");
13
+ };
14
+ SVGDocument.prototype = new DOMDocument();
15
+ __extend__(SVGDocument.prototype, {
16
+ createElement: function(tagName){
17
+ $debug("SVGDocument.createElement( "+tagName+" )");
18
+ var node;
19
+ if(tagName === "rect") {node = new SVGRectElement(this);}
20
+ else {node = new SVGSVGElement(this);}
21
+ node.tagName = tagName;
22
+ return node;
23
+ }});
24
+
25
+ // $w.SVGDocument = SVGDocument;
@@ -0,0 +1,22 @@
1
+ $debug("Defining SVGElement");
2
+ /*
3
+ * SVGElement - DOM Level 2
4
+ */
5
+ var SVGElement = function(ownerDocument,name) {
6
+ DOMElement.apply(this,arguments);
7
+ };
8
+
9
+ SVGElement.prototype = new DOMElement();
10
+ __extend__(SVGElement.prototype, {
11
+ toString : function(){
12
+ return "SVGElement #"+this._id + " "+ this.tagName + (this.id?" => "+this.id:'');
13
+ }
14
+ });
15
+
16
+ // $w.SVGElement = SVGElement;
17
+
18
+ // Local Variables:
19
+ // espresso-indent-level:4
20
+ // c-basic-offset:4
21
+ // tab-width:4
22
+ // End:
@@ -0,0 +1,17 @@
1
+ $debug("Defining SVGLocatable");
2
+ var SVGLocatable = function() {
3
+ };
4
+ SVGLocatable.prototype = {};
5
+ __extend__(SVGLocatable.prototype, {
6
+ getBBox: function() {
7
+ return new SVGRect(0,0,1,1);
8
+ }
9
+ });
10
+
11
+ // $w.SVGLocatable = SVGLocatable;
12
+
13
+ // Local Variables:
14
+ // espresso-indent-level:4
15
+ // c-basic-offset:4
16
+ // tab-width:4
17
+ // End:
data/src/svg/rect.js ADDED
@@ -0,0 +1,18 @@
1
+ $debug("Defining SVGRect");
2
+ var SVGRect = function(x,y,width,height) {
3
+ this.x = x;
4
+ this.y = y;
5
+ this.width = width;
6
+ this.height = height;
7
+ };
8
+ SVGRect.prototype = {};
9
+ __extend__(SVGRect.prototype, {
10
+ });
11
+
12
+ // $w.SVGRect = SVGRect;
13
+
14
+ // Local Variables:
15
+ // espresso-indent-level:4
16
+ // c-basic-offset:4
17
+ // tab-width:4
18
+ // End:
@@ -0,0 +1,24 @@
1
+ $debug("Defining SVGRectElement");
2
+ /*
3
+ * SVGRectElement - DOM Level 2
4
+ */
5
+ var SVGRectElement = function(ownerDocument) {
6
+ SVGElement.apply(this,arguments);
7
+ SVGStylable.apply(this,arguments);
8
+ SVGTransformable.apply(this,arguments);
9
+ };
10
+
11
+ SVGRectElement.prototype = new SVGElement;
12
+ __extend__(SVGRectElement.prototype, SVGStylable.prototype );
13
+ __extend__(SVGRectElement.prototype, SVGTransformable.prototype );
14
+ __extend__(SVGRectElement.prototype, {
15
+ });
16
+ SVGRectElement.prototype.constructor = SVGRectElement;
17
+
18
+ // $w.SVGRectElement = SVGRectElement;
19
+
20
+ // Local Variables:
21
+ // espresso-indent-level:4
22
+ // c-basic-offset:4
23
+ // tab-width:4
24
+ // End:
@@ -0,0 +1,49 @@
1
+ $debug("Defining SVGStylable");
2
+ /*
3
+ * SVGStylable - DOM Level 2
4
+ */
5
+ var SVGStylable = function(ownerDocument,name) {
6
+ var self = this;
7
+ (this.__className__ = new SVGAnimatedString).__callback__ = function(v) {
8
+ SVGElement.prototype.setAttribute.call(self,"class",v);
9
+ };
10
+ };
11
+
12
+ SVGStylable.prototype = {};
13
+ __extend__(SVGStylable.prototype, {
14
+ setAttribute: function(k,v) {
15
+ if(k === "class") {
16
+ this.__className__.__baseVal__ = v;
17
+ }
18
+ SVGElement.prototype.setAttribute.apply(this,arguments);
19
+ },
20
+ removeAttribute: function(k) {
21
+ if(k === "class") {
22
+ this.__className__.baseVal = "";
23
+ }
24
+ SVGElement.prototype.removeAttribute.apply(this,arguments);
25
+ },
26
+ setAttributeNS: function(ns,k,v) {
27
+ if(k === "class") {
28
+ this.__className__.__baseVal__ = v;
29
+ }
30
+ SVGElement.prototype.setAttributeNS.apply(this,arguments);
31
+ },
32
+ removeAttributeNS: function(ns,k) {
33
+ if(k === "class") {
34
+ this.__className__.baseVal = "";
35
+ }
36
+ SVGElement.prototype.removeAttributeNS.apply(this,arguments);
37
+ },
38
+ get className() {
39
+ return this.__className__;
40
+ }
41
+ });
42
+
43
+ // $w.SVGStylable = SVGStylable;
44
+
45
+ // Local Variables:
46
+ // espresso-indent-level:4
47
+ // c-basic-offset:4
48
+ // tab-width:4
49
+ // End:
@@ -0,0 +1,22 @@
1
+ $debug("Defining SVGSVGElement");
2
+ /*
3
+ * SVGSVGElement - DOM Level 2
4
+ */
5
+ var SVGSVGElement = function(ownerDocument) {
6
+ SVGElement.apply(this,arguments);
7
+ SVGStylable.apply(this,arguments);
8
+ };
9
+
10
+ SVGSVGElement.prototype = new SVGElement;
11
+ __extend__(SVGSVGElement.prototype, SVGStylable.prototype );
12
+ __extend__(SVGSVGElement.prototype, {
13
+ });
14
+ SVGSVGElement.prototype.constructor = SVGSVGElement;
15
+
16
+ // $w.SVGSVGElement = SVGSVGElement;
17
+
18
+ // Local Variables:
19
+ // espresso-indent-level:4
20
+ // c-basic-offset:4
21
+ // tab-width:4
22
+ // End:
@@ -0,0 +1,15 @@
1
+ $debug("Defining SVGTransformable");
2
+ var SVGTransformable = function() {
3
+ SVGLocatable.apply(this,arguments);
4
+ };
5
+ SVGTransformable.prototype = new SVGLocatable;
6
+ __extend__(SVGLocatable.prototype, {
7
+ });
8
+
9
+ // $w.SVGTransformable = SVGTransformable;
10
+
11
+ // Local Variables:
12
+ // espresso-indent-level:4
13
+ // c-basic-offset:4
14
+ // tab-width:4
15
+ // End:
data/src/window/css.js ADDED
@@ -0,0 +1,15 @@
1
+ /*
2
+ * css.js
3
+ */
4
+ $debug("Initializing Window CSS");
5
+ // returns a CSS2Properties object that represents the style
6
+ // attributes and values used to render the specified element in this
7
+ // window. Any length values are always expressed in pixel, or
8
+ // absolute values.
9
+
10
+ $w.getComputedStyle = function(elt, pseudo_elt){
11
+ //TODO
12
+ //this is a naive implementation
13
+ $debug("Getting computed style");
14
+ return elt?elt.style:new CSS2Properties({cssText:""});
15
+ };
@@ -0,0 +1,16 @@
1
+ /*
2
+ * dialog.js
3
+ */
4
+ $debug("Initializing Window Dialogs.");
5
+ $w.alert = function(message){
6
+ $env.warn(message);
7
+ };
8
+
9
+ $w.confirm = function(question){
10
+ //FIX (?)
11
+ return true;
12
+ };
13
+
14
+ $w.prompt = function(message, defaultMsg){
15
+ //TODO
16
+ };
@@ -0,0 +1,28 @@
1
+ /*
2
+ * document.js
3
+ *
4
+ * DOM Level 2 /DOM level 3 (partial)
5
+ *
6
+ * This file adds the document object to the window and allows you
7
+ * you to set the window.document using an html string or dom object.
8
+ *
9
+ */
10
+
11
+ $debug("Initializing document.implementation");
12
+ var $implementation = new DOMImplementation();
13
+ // $implementation.namespaceAware = false;
14
+ $implementation.errorChecking = false;
15
+
16
+ // read only reference to the Document object
17
+ var $document;
18
+ { // a temporary scope, nothing more
19
+ var referrer = "";
20
+ try {
21
+ referrer = $openingWindow.location.href;
22
+ } catch (e){ /* or not */ }
23
+ $document = new HTMLDocument($implementation, $w, referrer);
24
+ }
25
+
26
+ $w.__defineGetter__("document", function(){
27
+ return $document;
28
+ });
@@ -0,0 +1,262 @@
1
+ /*
2
+ * event.js
3
+ */
4
+ // Window Events
5
+ //$debug("Initializing Window Event.");
6
+ var $events = [{}],
7
+ $onerror,
8
+ $onload,
9
+ $onunload;
10
+
11
+ function __addEventListener__(target, type, fn){
12
+
13
+ //$debug("adding event listener \n\t" + type +" \n\tfor "+target+" with callback \n\t"+fn);
14
+ if ( !target.uuid ) {
15
+ target.uuid = $events.length;
16
+ $events[target.uuid] = {};
17
+ }
18
+ if ( !$events[target.uuid][type] ){
19
+ $events[target.uuid][type] = [];
20
+ }
21
+ if ( $events[target.uuid][type].indexOf( fn ) < 0 ){
22
+ $events[target.uuid][type].push( fn );
23
+ }
24
+ };
25
+
26
+
27
+ $w.addEventListener = function(type, fn){
28
+ __addEventListener__(this, type, fn);
29
+ };
30
+
31
+
32
+ function __removeEventListener__(target, type, fn){
33
+ if ( !target.uuid ) {
34
+ target.uuid = $events.length;
35
+ $events[target.uuid] = {};
36
+ }
37
+ if ( !$events[target.uuid][type] ){
38
+ $events[target.uuid][type] = [];
39
+ }
40
+ $events[target.uuid][type] =
41
+ $events[target.uuid][type].filter(function(f){
42
+ return f != fn;
43
+ });
44
+ };
45
+
46
+ $w.removeEventListener = function(type, fn){
47
+ __removeEventListener__(this, type, fn)
48
+ };
49
+
50
+
51
+
52
+ function __dispatchEvent__(target, event, bubbles){
53
+ try{
54
+ $debug("dispatching event " + event.type);
55
+
56
+ //the window scope defines the $event object, for IE(^^^) compatibility;
57
+ $event = event;
58
+
59
+ if (bubbles == undefined || bubbles == null)
60
+ bubbles = true;
61
+
62
+ if (!event.target) {
63
+ //$debug("no event target : "+event.target);
64
+ event.target = target;
65
+ }
66
+ //$debug("event target: " + event.target);
67
+ var handled = false;
68
+ if ( event.type && (target.nodeType ||
69
+ target.window === window || // compares outer objects under TM (inner == outer, but !== (currently)
70
+ target === window ||
71
+ target.__proto__ === window ||
72
+ target.$thisWindowsProxyObject === window)) {
73
+ //$debug("nodeType: " + target.nodeType);
74
+ if ( target.uuid && $events[target.uuid][event.type] ) {
75
+ var _this = target;
76
+ $debug('calling event handlers '+$events[target.uuid][event.type].length);
77
+ $events[target.uuid][event.type].forEach(function(fn){
78
+ $debug('calling event handler '+fn+' on target '+_this);
79
+ handled = (fn(event) == false) || handled;
80
+ });
81
+ }
82
+
83
+ if (target["on" + event.type]) {
84
+ $debug('calling event handler on'+event.type+' on target '+target);
85
+ handled = (target["on" + event.type](event) == false) || handled;
86
+ }
87
+
88
+ // SMP FIX: cancel/stop prop
89
+
90
+ // print(event.type,target,handled);
91
+
92
+ if (!handled && event.type == "click" && target instanceof HTMLAnchorElement && target.href ) {
93
+ // window.location = target.href;
94
+
95
+ var url = target.href;
96
+
97
+ var skip = false;
98
+
99
+ if (url[0] === "#") {
100
+ // print("return anchor only");
101
+ skip = true;
102
+ }
103
+
104
+ if (!skip) {
105
+ var now = window.location.href.replace(/^file:\/\//,"").replace(/#.*/,"");
106
+ var to = $master.first_script_window && $master.first_script_window.location.href;
107
+ // var to = $env.location(url,window.location.href != "about:blank" ? window.location.href: undefined);
108
+ // I'm not sure why this code is here ... looking at the FSW
109
+ // print("nu",now,url,to);
110
+ to = to || $env.location(url,window.location.href);
111
+ // print("nu",now,url,to);
112
+ if (to && to.indexOf(now)===0 && to[now.length]==="#") {
113
+ skip = true;
114
+ }
115
+ }
116
+ if (!skip) {
117
+ if (url && url.indexOf(now)===0 && url[now.length]==="#") {
118
+ // print("return diff anchor only");
119
+ skip = true;
120
+ }
121
+ }
122
+ if (!skip) {
123
+ // print($location, window.location.href === $location, $location.indexOf("#")>0);
124
+ if (url === window.location.href && $location.indexOf("#")>0) {
125
+ // print('returning same with anchor');
126
+ skip = true;
127
+ }
128
+ }
129
+
130
+ if (!skip){
131
+ $env.reload(window, target.href, {referer: window.location.href});
132
+ }
133
+ }
134
+
135
+ if (!handled && event.type == "click" &&
136
+ target.form &&
137
+ ( target instanceof HTMLInputElement || target instanceof HTMLTypeValueInputs ) &&
138
+ ( ( target.tagName === "INPUT" &&
139
+ (target.type === "submit" ||
140
+ target.type === "image" ) ) ||
141
+ ( target.tagName === "BUTTON" &&
142
+ ( !target.type ||
143
+ target.type === "submit" ) ) ) ) {
144
+ target.form.clk = target;
145
+ try{
146
+ target.form.submit();
147
+ // __submit__(target.form);
148
+ }catch(e){
149
+ print("oopse",e);
150
+ print(e.stack);
151
+ e.backtrace && print(e.backtrace().join("\n"));
152
+ throw e;
153
+ };
154
+ delete target.form.clk;
155
+ }
156
+
157
+ // print(event.type,target.type,target.constructor+"");
158
+ // print("A",handled,event.type,target,target.type);
159
+ if (!handled && event.type == "click" && target instanceof HTMLInputElement && ( target.type == "checkbox" || target.type == "radio" ) ) {
160
+ target.checked = target.checked ? "" : "checked";
161
+ }
162
+
163
+ if (!handled && (event.type == "submit") && target instanceof HTMLFormElement) {
164
+ $env.unload($w);
165
+ var proxy = $w.window;
166
+ var data;
167
+ var boundary;
168
+ if (target.enctype === "multipart/form-data") {
169
+ boundary = (new Date).getTime();
170
+ }
171
+ data = $master["static"].__formSerialize__(target,undefined,boundary);
172
+ var options = {method: target.method || "get", referer: this.location.href};
173
+ if (options.method === "post" || options.method === "put") {
174
+ options.data = data;
175
+ var undef;
176
+ data = undef;
177
+ }
178
+ if (boundary) {
179
+ options["Content-Type"] = "multipart/form-data; boundary="+boundary;
180
+ } else {
181
+ options["Content-Type"] = 'application/x-www-form-urlencoded';
182
+ }
183
+ var action = target.action || window.location.href;
184
+ if (data) {
185
+ if (action.indexOf("?") < 0) {
186
+ action = action + "?";
187
+ }
188
+ if (action[action.length-1] != "?") {
189
+ action = action + "&";
190
+ }
191
+ var params = unescape(data).split("&");
192
+ var new_params = [];
193
+ for(var pi=0; pi < params.length; pi++) {
194
+ var pair = params[pi].split("=");
195
+ new_params.push(escape(pair[0])+"="+escape(pair[1]));
196
+ }
197
+ action = action + new_params.join("&");
198
+ }
199
+ $env.reload(proxy, action, options );
200
+ }
201
+
202
+ }else{
203
+ //$debug("non target: " + event.target + " \n this->"+target);
204
+ }
205
+ if (!handled && bubbles && target.parentNode){
206
+ //$debug('bubbling to parentNode '+target.parentNode);
207
+ __dispatchEvent__(target.parentNode, event, bubbles);
208
+ }
209
+ }catch(e){
210
+ $warn("Exception while dispatching events: "+e);
211
+ // print("oops e",e.stack);
212
+ // print("oops e",e.backtrace && e.backtrace().join("\n"));
213
+ // try { throw new Error("here"); } catch(x) { print("oops e",x.stack); }
214
+ throw e;
215
+ }
216
+ };
217
+
218
+ $env.__removeEventListener__ = __removeEventListener__;
219
+ $env.__addEventListener__ = __addEventListener__;
220
+ $env.__dispatchEvent__ = __dispatchEvent__;
221
+
222
+ $w.dispatchEvent = function(event, bubbles){
223
+ __dispatchEvent__(this, event, bubbles);
224
+ };
225
+
226
+ $w.__defineGetter__('onerror', function(){
227
+ return function(){
228
+ //$w.dispatchEvent('error');
229
+ };
230
+ });
231
+
232
+ $w.__defineSetter__('onerror', function(fn){
233
+ //$w.addEventListener('error', fn);
234
+ });
235
+
236
+ /*$w.__defineGetter__('onload', function(){
237
+ return function(){
238
+ //var event = document.createEvent();
239
+ //event.initEvent("load");
240
+ //$w.dispatchEvent(event);
241
+ };
242
+ });
243
+
244
+ $w.__defineSetter__('onload', function(fn){
245
+ //$w.addEventListener('load', fn);
246
+ });
247
+
248
+ $w.__defineGetter__('onunload', function(){
249
+ return function(){
250
+ //$w.dispatchEvent('unload');
251
+ };
252
+ });
253
+
254
+ $w.__defineSetter__('onunload', function(fn){
255
+ //$w.addEventListener('unload', fn);
256
+ });*/
257
+
258
+ // Local Variables:
259
+ // espresso-indent-level:4
260
+ // c-basic-offset:4
261
+ // tab-width:4
262
+ // End: