envjs19 0.3.8.20101029121421
Sign up to get free protection for your applications and to get access to all the features.
- data/.jslintrbrc +30 -0
- data/.project +17 -0
- data/CHANGELOG.rdoc +57 -0
- data/DTD/xhtml-lat1.ent +196 -0
- data/DTD/xhtml-special.ent +80 -0
- data/DTD/xhtml-symbol.ent +237 -0
- data/DTD/xhtml.soc +14 -0
- data/DTD/xhtml1-frameset.dtd +1235 -0
- data/DTD/xhtml1-strict.dtd +978 -0
- data/DTD/xhtml1-transitional.dtd +1201 -0
- data/DTD/xhtml1.dcl +192 -0
- data/Makefile +7 -0
- data/Manifest.txt +280 -0
- data/README.rdoc +65 -0
- data/Rakefile +196 -0
- data/Wakefile +11 -0
- data/bin/envjsrb +257 -0
- data/build.properties +9 -0
- data/build.xml +247 -0
- data/gm/jquery.js +6002 -0
- data/gm/mainx.js +2648 -0
- data/gm/sensx.js +135 -0
- data/gm/t.js +6 -0
- data/gm/x.html +76 -0
- data/htmlparser/BrowserTreeBuilder.java +456 -0
- data/htmlparser/README +34 -0
- data/htmlparser/build.sh +38 -0
- data/jsl/jsl +0 -0
- data/jsl/jsl.default.conf +129 -0
- data/jsl/jsl.exe +0 -0
- data/lib/envjs.rb +35 -0
- data/lib/envjs/event_loop.js +206 -0
- data/lib/envjs/net.rb +3 -0
- data/lib/envjs/net/cgi.rb +94 -0
- data/lib/envjs/net/file.rb +69 -0
- data/lib/envjs/options.rb +11 -0
- data/lib/envjs/runtime.rb +346 -0
- data/lib/envjs/tempfile.rb +24 -0
- data/licenses/GPL-LICENSE.txt +278 -0
- data/licenses/MIT-LICENSE.txt +20 -0
- data/src/base64.js +80 -0
- data/src/build.js +6 -0
- data/src/cruft/bad.html +24 -0
- data/src/cruft/dom.js +606 -0
- data/src/cruft/element.js +297 -0
- data/src/cruft/good.html +30 -0
- data/src/cruft/good.js +32 -0
- data/src/cruft/internal.js +81 -0
- data/src/cruft/parser.js +458 -0
- data/src/css/properties.js +293 -0
- data/src/css/rule.js +22 -0
- data/src/css/sizzle.js +717 -0
- data/src/css/stylesheet.js +52 -0
- data/src/dom/attr.js +55 -0
- data/src/dom/cdatasection.js +31 -0
- data/src/dom/characterdata.js +119 -0
- data/src/dom/comment.js +30 -0
- data/src/dom/doctype.js +9 -0
- data/src/dom/document.js +1023 -0
- data/src/dom/dom.js +134 -0
- data/src/dom/element.js +217 -0
- data/src/dom/entities.js +273 -0
- data/src/dom/exception.js +28 -0
- data/src/dom/fragment.js +37 -0
- data/src/dom/implementation.js +140 -0
- data/src/dom/instruction.js +51 -0
- data/src/dom/namednodemap.js +374 -0
- data/src/dom/namespace.js +50 -0
- data/src/dom/node.js +618 -0
- data/src/dom/nodelist.js +195 -0
- data/src/dom/parser.js +1207 -0
- data/src/dom/text.js +73 -0
- data/src/event/event.js +47 -0
- data/src/event/mouseevent.js +4 -0
- data/src/event/uievent.js +8 -0
- data/src/html/a.js +110 -0
- data/src/html/anchor.js +80 -0
- data/src/html/area.js +57 -0
- data/src/html/base.js +26 -0
- data/src/html/blockquote-q.js +19 -0
- data/src/html/body.js +19 -0
- data/src/html/button.js +21 -0
- data/src/html/canvas.js +14 -0
- data/src/html/col-colgroup.js +49 -0
- data/src/html/collection.js +72 -0
- data/src/html/cookie.js +153 -0
- data/src/html/del-ins.js +25 -0
- data/src/html/div.js +28 -0
- data/src/html/document.js +364 -0
- data/src/html/element.js +382 -0
- data/src/html/fieldset.js +19 -0
- data/src/html/form.js +484 -0
- data/src/html/frame.js +89 -0
- data/src/html/frameset.js +25 -0
- data/src/html/head.js +44 -0
- data/src/html/html.js +0 -0
- data/src/html/htmlparser.js +340 -0
- data/src/html/iframe.js +26 -0
- data/src/html/image.js +0 -0
- data/src/html/img.js +62 -0
- data/src/html/input-elements.js +307 -0
- data/src/html/input.js +65 -0
- data/src/html/label.js +26 -0
- data/src/html/legend.js +19 -0
- data/src/html/link.js +82 -0
- data/src/html/map.js +22 -0
- data/src/html/meta.js +37 -0
- data/src/html/object.js +89 -0
- data/src/html/optgroup.js +25 -0
- data/src/html/option.js +103 -0
- data/src/html/param.js +38 -0
- data/src/html/script.js +122 -0
- data/src/html/select.js +132 -0
- data/src/html/style.js +31 -0
- data/src/html/table.js +199 -0
- data/src/html/tbody-thead-tfoot.js +92 -0
- data/src/html/td-th.js +18 -0
- data/src/html/textarea.js +31 -0
- data/src/html/title.js +20 -0
- data/src/html/tr.js +114 -0
- data/src/intro.js +141 -0
- data/src/outro.js +70 -0
- data/src/parser/html5.detailed.js +10762 -0
- data/src/parser/html5.min.js +503 -0
- data/src/parser/html5.pretty.js +10815 -0
- data/src/parser/intro.js +42 -0
- data/src/parser/outro.js +9 -0
- data/src/platform/core.js +323 -0
- data/src/platform/johnson.js +484 -0
- data/src/platform/rhino.js +327 -0
- data/src/platform/static/intro.js +41 -0
- data/src/platform/static/outro.js +30 -0
- data/src/profile/aop.js +238 -0
- data/src/profile/profile.js +402 -0
- data/src/serializer/xml.js +21 -0
- data/src/svg/animatedstring.js +25 -0
- data/src/svg/document.js +25 -0
- data/src/svg/element.js +22 -0
- data/src/svg/locatable.js +17 -0
- data/src/svg/rect.js +18 -0
- data/src/svg/rectelement.js +24 -0
- data/src/svg/stylable.js +49 -0
- data/src/svg/svgelement.js +22 -0
- data/src/svg/transformable.js +15 -0
- data/src/window/css.js +15 -0
- data/src/window/dialog.js +16 -0
- data/src/window/document.js +28 -0
- data/src/window/event.js +265 -0
- data/src/window/history.js +62 -0
- data/src/window/location.js +156 -0
- data/src/window/navigator.js +48 -0
- data/src/window/screen.js +53 -0
- data/src/window/timer.js +21 -0
- data/src/window/window.js +284 -0
- data/src/window/xhr.js +135 -0
- data/src/xpath/expression.js +49 -0
- data/src/xpath/implementation.js +2505 -0
- data/src/xpath/result.js +67 -0
- data/src/xpath/util.js +551 -0
- data/src/xpath/xmltoken.js +149 -0
- data/src/xslt/COPYING +34 -0
- data/src/xslt/ajaxslt-0.8.1/AUTHORS +1 -0
- data/src/xslt/ajaxslt-0.8.1/ChangeLog +136 -0
- data/src/xslt/ajaxslt-0.8.1/Makefile +49 -0
- data/src/xslt/ajaxslt-0.8.1/README +102 -0
- data/src/xslt/ajaxslt-0.8.1/TODO +15 -0
- data/src/xslt/ajaxslt-0.8.1/dom.js +566 -0
- data/src/xslt/ajaxslt-0.8.1/dom_unittest.html +24 -0
- data/src/xslt/ajaxslt-0.8.1/dom_unittest.js +131 -0
- data/src/xslt/ajaxslt-0.8.1/simplelog.js +79 -0
- data/src/xslt/ajaxslt-0.8.1/test/xpath.html +18 -0
- data/src/xslt/ajaxslt-0.8.1/test/xpath_script.js +45 -0
- data/src/xslt/ajaxslt-0.8.1/test/xslt.html +58 -0
- data/src/xslt/ajaxslt-0.8.1/test/xslt_script.js +33 -0
- data/src/xslt/ajaxslt-0.8.1/unittestsuite.html +26 -0
- data/src/xslt/ajaxslt-0.8.1/xmltoken.js +149 -0
- data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.html +18 -0
- data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.js +811 -0
- data/src/xslt/ajaxslt-0.8.1/xpath_unittest.html +39 -0
- data/src/xslt/ajaxslt-0.8.1/xpath_unittest.js +557 -0
- data/src/xslt/ajaxslt-0.8.1/xpathdebug.js +234 -0
- data/src/xslt/ajaxslt-0.8.1/xslt_unittest.html +138 -0
- data/src/xslt/ajaxslt-0.8.1/xslt_unittest.js +68 -0
- data/src/xslt/implementation.js +625 -0
- data/src/xslt/processor.js +37 -0
- data/src/xslt/util.js +449 -0
- data/test/base64.js +80 -0
- data/test/call-load-test.js +15 -0
- data/test/data.js +45 -0
- data/test/debug.js +53 -0
- data/test/firebug/errorIcon.png +0 -0
- data/test/firebug/firebug.css +209 -0
- data/test/firebug/firebug.html +23 -0
- data/test/firebug/firebug.js +672 -0
- data/test/firebug/firebugx.js +10 -0
- data/test/firebug/infoIcon.png +0 -0
- data/test/firebug/warningIcon.png +0 -0
- data/test/fixtures/html/events.html +171 -0
- data/test/fixtures/html/iframe1.html +46 -0
- data/test/fixtures/html/iframe1a.html +46 -0
- data/test/fixtures/html/iframe2.html +45 -0
- data/test/fixtures/html/iframe3.html +28 -0
- data/test/fixtures/html/iframeN.html +57 -0
- data/test/fixtures/html/malformed.html +181 -0
- data/test/fixtures/html/scope.html +81 -0
- data/test/fixtures/html/trivial.html +19 -0
- data/test/fixtures/html/with_js.html +26 -0
- data/test/fixtures/images/icon-blue.png +0 -0
- data/test/fixtures/js/external_script.js +1 -0
- data/test/fixtures/js/script.js +1 -0
- data/test/fixtures/js/script_error.js +2 -0
- data/test/foo.html +8 -0
- data/test/foo.js +40 -0
- data/test/html/events.html +171 -0
- data/test/html/iframe1.html +46 -0
- data/test/html/iframe1a.html +46 -0
- data/test/html/iframe2.html +45 -0
- data/test/html/iframe3.html +30 -0
- data/test/html/iframeN.html +57 -0
- data/test/html/malformed.html +181 -0
- data/test/html/scope.html +87 -0
- data/test/html/script.js +1 -0
- data/test/html/trivial.html +19 -0
- data/test/html/with_js.html +26 -0
- data/test/index.html +328 -0
- data/test/java-prototype.js +9 -0
- data/test/jquery.js +6002 -0
- data/test/primary-tests.js +26 -0
- data/test/prototype-test.js +13 -0
- data/test/qunit.js +61 -0
- data/test/qunit/qunit/qunit.css +17 -0
- data/test/qunit/qunit/qunit.js +997 -0
- data/test/scope.html +19 -0
- data/test/scope.rb +24 -0
- data/test/smp/dmathieu/index.html +8 -0
- data/test/specs/dist/env.spec.js +1534 -0
- data/test/specs/envjs.spec.css +46 -0
- data/test/specs/parser/html.js +31 -0
- data/test/specs/parser/spec.html +40 -0
- data/test/specs/parser/xml.js +31 -0
- data/test/specs/qunit.bdd.js +210 -0
- data/test/specs/qunit.css +17 -0
- data/test/specs/qunit.js +997 -0
- data/test/specs/template/spec-0.js +31 -0
- data/test/specs/template/spec-1.js +31 -0
- data/test/specs/template/spec.html +40 -0
- data/test/specs/window/css.js +23 -0
- data/test/specs/window/dialog.js +25 -0
- data/test/specs/window/document.js +23 -0
- data/test/specs/window/event.js +25 -0
- data/test/specs/window/history.js +34 -0
- data/test/specs/window/location.js +34 -0
- data/test/specs/window/navigator.js +71 -0
- data/test/specs/window/screen.js +42 -0
- data/test/specs/window/spec.html +48 -0
- data/test/specs/window/timer.js +26 -0
- data/test/specs/window/window.js +53 -0
- data/test/specs/xhr/spec.html +47 -0
- data/test/specs/xhr/xhr.js +31 -0
- data/test/test.js +10 -0
- data/test/unit/dom.js +44 -0
- data/test/unit/elementmembers.js +92 -0
- data/test/unit/events.js +195 -0
- data/test/unit/fixtures/external_script.js +1 -0
- data/test/unit/form.js +40 -0
- data/test/unit/iframe.js +234 -0
- data/test/unit/insertion.js +23 -0
- data/test/unit/multi-window.js +212 -0
- data/test/unit/nu.validator.js +34 -0
- data/test/unit/onload.js +90 -0
- data/test/unit/parser.js +122 -0
- data/test/unit/prototypecompat.js +22 -0
- data/test/unit/proxy.js +6 -0
- data/test/unit/scope.js +209 -0
- data/test/unit/timer.js +115 -0
- data/test/unit/window.js +57 -0
- data/test/x.js +1 -0
- data/test/y.js +1 -0
- metadata +367 -0
data/src/svg/document.js
ADDED
@@ -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;
|
data/src/svg/element.js
ADDED
@@ -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:
|
data/src/svg/stylable.js
ADDED
@@ -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
|
+
});
|
data/src/window/event.js
ADDED
@@ -0,0 +1,265 @@
|
|
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.uiid]) {
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
if ( !$events[target.uuid][type] ){
|
41
|
+
$events[target.uuid][type] = [];
|
42
|
+
}
|
43
|
+
$events[target.uuid][type] =
|
44
|
+
$events[target.uuid][type].filter(function(f){
|
45
|
+
return f != fn;
|
46
|
+
});
|
47
|
+
};
|
48
|
+
|
49
|
+
$w.removeEventListener = function(type, fn){
|
50
|
+
__removeEventListener__(this, type, fn)
|
51
|
+
};
|
52
|
+
|
53
|
+
function __dispatchEvent__(target, event, bubbles){
|
54
|
+
try{
|
55
|
+
$debug("dispatching event " + event.type);
|
56
|
+
|
57
|
+
//the window scope defines the $event object, for IE(^^^) compatibility;
|
58
|
+
$event = event;
|
59
|
+
|
60
|
+
if (bubbles == undefined || bubbles == null)
|
61
|
+
bubbles = true;
|
62
|
+
|
63
|
+
if (!event.target) {
|
64
|
+
//$debug("no event target : "+event.target);
|
65
|
+
event.target = target;
|
66
|
+
}
|
67
|
+
//$debug("event target: " + event.target);
|
68
|
+
var handled = false;
|
69
|
+
if ( event.type && (target.nodeType ||
|
70
|
+
target.window === window || // compares outer objects under TM (inner == outer, but !== (currently)
|
71
|
+
target === window ||
|
72
|
+
target.__proto__ === window ||
|
73
|
+
target.$thisWindowsProxyObject === window)) {
|
74
|
+
//$debug("nodeType: " + target.nodeType);
|
75
|
+
if ( target.uuid && $events[target.uuid][event.type] ) {
|
76
|
+
var _this = target;
|
77
|
+
$debug('calling event handlers '+$events[target.uuid][event.type].length);
|
78
|
+
$events[target.uuid][event.type].forEach(function(fn){
|
79
|
+
$debug('calling event handler '+fn+' on target '+_this);
|
80
|
+
handled = (fn(event) == false) || handled;
|
81
|
+
});
|
82
|
+
}
|
83
|
+
|
84
|
+
if (target["on" + event.type]) {
|
85
|
+
$debug('calling event handler on'+event.type+' on target '+target);
|
86
|
+
handled = (target["on" + event.type](event) == false) || handled;
|
87
|
+
}
|
88
|
+
|
89
|
+
// SMP FIX: cancel/stop prop
|
90
|
+
if (!handled && event.$preventDefault) {
|
91
|
+
handled = true;
|
92
|
+
}
|
93
|
+
|
94
|
+
// print(event.type,target,handled);
|
95
|
+
|
96
|
+
if (!handled && event.type == "click" && target instanceof HTMLAnchorElement && target.href ) {
|
97
|
+
// window.location = target.href;
|
98
|
+
|
99
|
+
var url = target.href;
|
100
|
+
|
101
|
+
var skip = false;
|
102
|
+
|
103
|
+
if (url[0] === "#") {
|
104
|
+
window.location.hash = url;
|
105
|
+
// print("return anchor only: "+window.location);
|
106
|
+
skip = true;
|
107
|
+
}
|
108
|
+
|
109
|
+
if (!skip) {
|
110
|
+
var now = window.location.href.replace(/^file:\/\//,"").replace(/#.*/,"");
|
111
|
+
var to = $master.first_script_window && $master.first_script_window.location.href;
|
112
|
+
// var to = $env.location(url,window.location.href != "about:blank" ? window.location.href: undefined);
|
113
|
+
// I'm not sure why this code is here ... looking at the FSW
|
114
|
+
// print("nu",now,url,to);
|
115
|
+
to = to || $env.location(url,window.location.href);
|
116
|
+
// print("nu",now,url,to);
|
117
|
+
if (to && to.indexOf(now)===0 && to[now.length]==="#") {
|
118
|
+
skip = true;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
if (!skip) {
|
122
|
+
if (url && url.indexOf(now)===0 && url[now.length]==="#") {
|
123
|
+
// print("return diff anchor only");
|
124
|
+
skip = true;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
if (!skip) {
|
128
|
+
// print($location, window.location.href === $location, $location.indexOf("#")>0);
|
129
|
+
if (url === window.location.href && $location.indexOf("#")>0) {
|
130
|
+
// print('returning same with anchor');
|
131
|
+
skip = true;
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
if (!skip){
|
136
|
+
$env.reload(window, target.href, {referer: window.location.href});
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
if (!handled && event.type == "click" &&
|
141
|
+
target.form &&
|
142
|
+
( target instanceof HTMLInputElement || target instanceof HTMLTypeValueInputs ) &&
|
143
|
+
( ( target.tagName === "INPUT" &&
|
144
|
+
(target.type === "submit" ||
|
145
|
+
target.type === "image" ) ) ||
|
146
|
+
( target.tagName === "BUTTON" &&
|
147
|
+
( !target.type ||
|
148
|
+
target.type === "submit" ) ) ) ) {
|
149
|
+
target.form.clk = target;
|
150
|
+
try{
|
151
|
+
target.form.submit();
|
152
|
+
// __submit__(target.form);
|
153
|
+
}catch(e){
|
154
|
+
print("oopse",e);
|
155
|
+
print(e.stack);
|
156
|
+
e.backtrace && print(e.backtrace().join("\n"));
|
157
|
+
throw e;
|
158
|
+
};
|
159
|
+
delete target.form.clk;
|
160
|
+
}
|
161
|
+
|
162
|
+
// print(event.type,target.type,target.constructor+"");
|
163
|
+
// print("A",handled,event.type,target,target.type);
|
164
|
+
if (!handled && event.type == "click" && target instanceof HTMLInputElement && ( target.type == "checkbox" || target.type == "radio" ) ) {
|
165
|
+
target.checked = target.checked ? "" : "checked";
|
166
|
+
}
|
167
|
+
|
168
|
+
if (!handled && (event.type == "submit") && target instanceof HTMLFormElement) {
|
169
|
+
$env.unload($w);
|
170
|
+
var proxy = $w.window;
|
171
|
+
var data;
|
172
|
+
var boundary;
|
173
|
+
if (target.enctype === "multipart/form-data") {
|
174
|
+
boundary = (new Date).getTime();
|
175
|
+
}
|
176
|
+
data = $master["static"].__formSerialize__(target,undefined,boundary);
|
177
|
+
var options = {method: target.method || "get", referer: this.location.href};
|
178
|
+
if (options.method.toLowerCase() === "post" || options.method.toLowerCase() === "put") {
|
179
|
+
options.data = data;
|
180
|
+
var undef;
|
181
|
+
data = undef;
|
182
|
+
}
|
183
|
+
if (boundary) {
|
184
|
+
options["Content-Type"] = "multipart/form-data; boundary="+boundary;
|
185
|
+
} else {
|
186
|
+
options["Content-Type"] = 'application/x-www-form-urlencoded';
|
187
|
+
}
|
188
|
+
var action = target.action || window.location.href;
|
189
|
+
if (data) {
|
190
|
+
if (action.indexOf("?") < 0) {
|
191
|
+
action = action + "?";
|
192
|
+
}
|
193
|
+
if (action[action.length-1] != "?") {
|
194
|
+
action = action + "&";
|
195
|
+
}
|
196
|
+
var params = unescape(data).split("&");
|
197
|
+
var new_params = [];
|
198
|
+
for(var pi=0; pi < params.length; pi++) {
|
199
|
+
var pair = params[pi].split("=");
|
200
|
+
new_params.push(escape(pair[0])+"="+escape(pair[1]));
|
201
|
+
}
|
202
|
+
action = action + new_params.join("&");
|
203
|
+
}
|
204
|
+
$env.reload(proxy, action, options );
|
205
|
+
}
|
206
|
+
|
207
|
+
}else{
|
208
|
+
//$debug("non target: " + event.target + " \n this->"+target);
|
209
|
+
}
|
210
|
+
if (!handled && bubbles && target.parentNode){
|
211
|
+
//$debug('bubbling to parentNode '+target.parentNode);
|
212
|
+
__dispatchEvent__(target.parentNode, event, bubbles);
|
213
|
+
}
|
214
|
+
}catch(e){
|
215
|
+
$warn("Exception while dispatching events: "+e);
|
216
|
+
// print("oops e",e.stack);
|
217
|
+
// print("oops e",e.backtrace && e.backtrace().join("\n"));
|
218
|
+
// try { throw new Error("here"); } catch(x) { print("oops e",x.stack); }
|
219
|
+
throw e;
|
220
|
+
}
|
221
|
+
};
|
222
|
+
|
223
|
+
$env.__removeEventListener__ = __removeEventListener__;
|
224
|
+
$env.__addEventListener__ = __addEventListener__;
|
225
|
+
$env.__dispatchEvent__ = __dispatchEvent__;
|
226
|
+
|
227
|
+
$w.dispatchEvent = function(event, bubbles){
|
228
|
+
__dispatchEvent__(this, event, bubbles);
|
229
|
+
};
|
230
|
+
|
231
|
+
$w.__defineGetter__('onerror', function(){
|
232
|
+
return $onerror;
|
233
|
+
});
|
234
|
+
|
235
|
+
$w.__defineSetter__('onerror', function(fn){
|
236
|
+
return $onerror = fn;
|
237
|
+
});
|
238
|
+
|
239
|
+
/*$w.__defineGetter__('onload', function(){
|
240
|
+
return function(){
|
241
|
+
//var event = document.createEvent();
|
242
|
+
//event.initEvent("load");
|
243
|
+
//$w.dispatchEvent(event);
|
244
|
+
};
|
245
|
+
});
|
246
|
+
|
247
|
+
$w.__defineSetter__('onload', function(fn){
|
248
|
+
//$w.addEventListener('load', fn);
|
249
|
+
});
|
250
|
+
|
251
|
+
$w.__defineGetter__('onunload', function(){
|
252
|
+
return function(){
|
253
|
+
//$w.dispatchEvent('unload');
|
254
|
+
};
|
255
|
+
});
|
256
|
+
|
257
|
+
$w.__defineSetter__('onunload', function(fn){
|
258
|
+
//$w.addEventListener('unload', fn);
|
259
|
+
});*/
|
260
|
+
|
261
|
+
// Local Variables:
|
262
|
+
// espresso-indent-level:4
|
263
|
+
// c-basic-offset:4
|
264
|
+
// tab-width:4
|
265
|
+
// End:
|