Browse files

1.3 release candidate adds support for nodejs, python, and several ru…

…by integrations. official repository is moving to github.com/envjs. we are looking for various project maintence role volunteers to help make envjs the best project it can be. thanks for your patience during this transition
  • Loading branch information...
1 parent 419d08a commit 6bc00b67e5a4c6f49bb34bbcda845ce2c2ad433c thatcher committed Jan 26, 2011
Showing with 49,274 additions and 6,472 deletions.
  1. +73 −11 README
  2. +39 −0 bin/envjs
  3. +2 −2 build.properties
  4. +174 −88 build.xml
  5. +80 −0 doc/index.txt
  6. +278 −0 envjs/console.js
  7. +695 −0 envjs/css.js
  8. +8,964 −0 envjs/dom.js
  9. +720 −0 envjs/event.js
  10. +4,997 −0 envjs/html.js
  11. +66 −0 envjs/johnson.js
  12. +31 −0 envjs/johnson.rb
  13. +3 −0 envjs/node.js
  14. +14,358 −0 envjs/parser.js
  15. +3,045 −0 envjs/platform/core.js
  16. +363 −0 envjs/platform/johnson.js
  17. +331 −0 envjs/platform/node.js
  18. +461 −0 envjs/platform/rhino.js
  19. +332 −0 envjs/platform/rubyracer.js
  20. +347 −0 envjs/platform/spydermonkey.js
  21. +91 −0 envjs/rhino.js
  22. +72 −0 envjs/rubyracer.js
  23. +90 −0 envjs/rubyracer.rb
  24. +64 −0 envjs/spydermonkey.js
  25. +56 −0 envjs/spydermonkey.py
  26. +96 −0 envjs/timer.js
  27. +864 −0 envjs/window.js
  28. +566 −0 envjs/xhr.js
  29. +29 −0 examples/simple.js
  30. +0 −456 htmlparser/BrowserTreeBuilder.java
  31. +0 −284 htmlparser/HtmlParser.java
  32. +0 −88 htmlparser/HtmlParserModule.java
  33. +0 −34 htmlparser/README
  34. +0 −92 htmlparser/build.sh
  35. +4 −2 htmlparser/gwt2/build.sh
  36. +0 −9 htmlparser/gwt2/src/com/envjs/gwt/linker/ServerSingleScriptLinker.java
  37. +0 −34 htmlparser/gwt2/src/nu/validator/htmlparser/gwt/BrowserTreeBuilder.java
  38. +22 −12 htmlparser/gwt2/src/nu/validator/htmlparser/gwt/HtmlParser.java
  39. +14 −0 htmlparser/gwt2/src/nu/validator/htmlparser/gwt/HtmlParserModule.java
  40. +130 −2 misc/deaccessor.py
  41. +0 −183 platform-commonjs.js
  42. +10 −0 plugins/big_sites.js
  43. +5 −5 plugins/env.readability.js
  44. +1 −1 plugins/vendor/readability.js
  45. +1 −10 reports/cnn.html
  46. +43 −0 reports/null
  47. 0 reports/{svg.svg → svg.html}
  48. +5 −9 specs/console/boot.js
  49. +8 −0 specs/console/spec.js
  50. +5 −10 specs/css/boot.js
  51. +8 −0 specs/css/spec.js
  52. +5 −7 specs/dom/boot.js
  53. +691 −50 specs/dom/spec.js
  54. +14 −5 specs/env.qunit.js
  55. +4 −8 specs/event/boot.js
  56. +8 −0 specs/event/spec.js
  57. +0 −2 specs/frame/proxy.js
  58. +16 −13 specs/fulldoc/boot.js
  59. +8 −0 specs/fulldoc/spec.js
  60. +0 −6 specs/helpers.js
  61. +5 −22 specs/html/boot.js
  62. +20 −16 specs/html/spec.js
  63. +6 −13 specs/parser/boot.js
  64. +25 −5 specs/parser/spec.js
  65. +14 −8 specs/platform/core.js
  66. +1 −1 specs/qunit.js
  67. +4 −8 specs/timer/boot.js
  68. +13 −2 specs/timer/spec.js
  69. +5 −22 specs/window/boot.js
  70. +3 −15 specs/window/index.html
  71. +12 −24 specs/window/spec.js
  72. +1 −19 specs/xhr/boot.js
  73. +4 −6 specs/xhr/index.html
  74. +5 −3 specs/xhr/spec.js
  75. +10 −7 src/common/__extend__.js
  76. +3 −2 src/console/__global__.js
  77. +141 −138 src/console/console.js
  78. +9 −2 src/css/__global__.js
  79. +13 −1 src/css/document.js
  80. +10 −0 src/css/htmlelement.js
  81. +48 −30 src/css/properties.js
  82. +17 −7 src/css/rule.js
  83. +12 −2 src/css/styledeclaration.js
  84. +16 −6 src/css/stylesheet.js
  85. +8 −2 src/dom/__global__.js
  86. +10 −1 src/dom/attr.js
  87. +10 −1 src/dom/cdatasection.js
  88. +10 −1 src/dom/characterdata.js
  89. +10 −1 src/dom/comment.js
  90. +36 −41 src/dom/document.js
  91. +11 −1 src/dom/documentfragment.js
  92. +11 −1 src/dom/documenttype.js
  93. +12 −1 src/dom/domexception.js
  94. +16 −6 src/dom/domimplementation.js
  95. +1,667 −104 src/dom/domparser.js
  96. +42 −46 src/dom/element.js
  97. +11 −1 src/dom/entity.js
  98. +11 −1 src/dom/entityreference.js
  99. +236 −143 src/dom/namednodemap.js
  100. +15 −3 src/dom/namespace.js
  101. +73 −56 src/dom/node.js
  102. +271 −35 src/dom/nodelist.js
  103. +12 −2 src/dom/notation.js
  104. +11 −1 src/dom/processinginstruction.js
  105. +15 −5 src/dom/range.js
  106. +10 −1 src/dom/text.js
  107. +13 −1 src/dom/xmlserializer.js
  108. +3,211 −1,877 src/{xpath/implementation.js → dom/xpath.js}
  109. +10 −0 src/dom/xslt.js
  110. +10 −5 src/event/__global__.js
  111. +12 −1 src/event/documentevent.js
  112. +12 −1 src/event/event.js
  113. +11 −1 src/event/eventexception.js
  114. +71 −57 src/event/eventtarget.js
  115. +11 −1 src/event/keyboardevent.js
  116. +11 −1 src/event/mouseevent.js
  117. +12 −2 src/event/mutationevent.js
  118. +10 −5 src/event/uievent.js
  119. +14 −2 src/html/__global__.js
  120. +13 −1 src/html/a.js
  121. +12 −1 src/html/area.js
  122. +12 −1 src/html/base.js
  123. +14 −2 src/html/blockquote-q.js
  124. +13 −1 src/html/body.js
  125. +12 −2 src/html/br.js
  126. +14 −3 src/html/button.js
  127. +24 −2 src/html/canvas.js
  128. +13 −1 src/html/col-colgroup.js
  129. +32 −17 src/html/collection.js
  130. +13 −1 src/html/del-ins.js
  131. +11 −1 src/html/div.js
  132. +12 −1 src/html/dl.js
  133. +200 −188 src/html/document.js
  134. +18 −6 src/html/element.js
  135. +14 −2 src/html/fieldset.js
  136. +24 −10 src/html/form.js
  137. +11 −1 src/html/frame.js
  138. +11 −1 src/html/frameset.js
  139. +13 −1 src/html/h1.js
  140. +11 −15 src/html/head.js
  141. +12 −3 src/html/hr.js
  142. +12 −2 src/html/html.js
  143. +3 −3 src/html/htmlevents.js
  144. +13 −1 src/html/iframe.js
  145. +13 −21 src/html/img.js
  146. +5 −2 src/html/input-elements.js
  147. +14 −3 src/html/input.js
  148. +13 −1 src/html/label.js
  149. +12 −1 src/html/legend.js
  150. +12 −3 src/html/li.js
  151. +16 −39 src/html/link.js
  152. +13 −1 src/html/map.js
  153. +12 −1 src/html/meta.js
  154. +14 −3 src/html/object.js
  155. +13 −3 src/html/ol.js
  156. +15 −3 src/html/optgroup.js
  157. +56 −37 src/html/option.js
  158. +13 −1 src/html/p.js
  159. +12 −1 src/html/param.js
  160. +12 −3 src/html/pre.js
  161. +12 −1 src/html/script.js
  162. +16 −5 src/html/select.js
  163. +12 −1 src/html/span.js
  164. +13 −1 src/html/style.js
  165. +13 −1 src/html/table.js
  166. +14 −1 src/html/tbody-thead-tfoot.js
  167. +39 −7 src/html/td-th.js
  168. +14 −3 src/html/textarea.js
  169. +12 −2 src/html/title.js
  170. +13 −1 src/html/tr.js
  171. +12 −3 src/html/ul.js
  172. +13 −1 src/html/unknown.js
  173. +23 −7 src/parser/__global__.js
  174. +13 −7 src/parser/document.js
  175. +156 −48 src/parser/domparser.js
  176. +34 −9 src/parser/htmldocument.js
  177. +12 −0 src/parser/htmlelement.js
  178. +0 −507 src/parser/htmlparser.backup.js
  179. +3,469 −1,287 src/parser/htmlparser.js
Sorry, we could not display the entire diff because too many files (307) changed.
View
84 README
@@ -4,7 +4,19 @@ env.js : A pure JavaScript browser environment.
Developed by John Resig (http://ejohn.org)
Major Contributers:
-Envjs Team
+Christopher Thatcher
+Nick Galbreath
+Steven Parkes
+
+Early Contributers and Integrated Project Authors:
+John Resig (Envjs Prototype and Concept)
+Yehuda Katz (Early XHR Implementation)
+Jon van Noort (Early DOM Implementation)
+David Joham (Early DOM Implementation)
+Scott Severtson (Early DOM Implementation)
+Steffen Meschkat (XPath Implementation)
+Henri Sivonen (HTML5Parser Implementation)
+
GitHub repositories:
http://github.com/jeresig/env-js/
@@ -13,6 +25,8 @@ http://github.com/thatcher/env-js/
Mailing List:
http://groups.google.com/group/envjs
+* BUG TRACKING HAS MOVED TO GITHUB!!
+http://github.com/thatcher/env-js/
Lighthouse (Bug Tracking):
http://envjs.lighthouseapp.com/
@@ -80,7 +94,6 @@ Getting the code:
* Variable naming should be short but complete words.
* Module level internal functions should be prefixed and appended with __.
For example __example__.
-
== contributing tests with patches ==
@@ -92,13 +105,46 @@ Getting the code:
those urls included in the spec.js;
-== platforms ==
+== Platforms ==
- Out of the box we have support for native platforms with rhino. A spidermonkey
- port is also being widely used, and we hope to integrate into the main branch
- or as a github plugin.
+=== 1.3 ===
+ Out of the box we have support for native platforms with rhino, nodejs,
+ python-spidermonkey, ruby-v8 (via therubyracer), and ruby-spidermonkey (via
+ johnson). We hope to support php and perl as well soon.
-Installing:
+ We hope to integrate a thin build and test wrapper for each platform which
+ is most familiar with its native build/test/install process so each platform
+ can feel closely integrated. For now however each test target can be run
+ independently the same way you run other scripts:
+
+ envjs <platform> specs/<module>/boot.js
+
+ where <module> is one of:
+ console | css | dom | event | html | parser | timer | window | xhr
+
+== 1.2 and lower ==
+ Out of the box 1.2 and lower will only run on rhino. Some support via ruby
+ was possible via steven parkes fork of envjs.
+
+== Installing ==
+
+=== 1.3 ===
+
+0) common usage -
+ bin/envjs <platform> file0.js file1.js file2.js ... fileN.js
+
+ - where <platform> is one of
+ node | spyd | rhino | rhino-debug | johnson | rubyracer
+
+1) fileX.js should be used to simply set window.location and do whatever
+ else your browser-javascript-loving-heart desires. For example
+
+ window.location = 'http://www.loc.gov/pictures/';
+
+Thats its! There are a lot of ways to use Envjs to be productive so enjoy!
+
+=== 1.2 and lower ===
+
0) common usage - all you need is env.rhino.js and rhino js.jar
java -jar js.jar -opt -1 myscript.js
@@ -155,6 +201,21 @@ Testing jQuery Compatibility:
* Checks out the given jQuery tag from Subversion into test/vendor/jQuery/[version],
moves dist/env.rhino.js into the correct location in their tree, and runs the test suites.
+== 1.3 change notes ==
+
+ * ALL JAVASCRIPT IS LOADED AND RUN BY DEFAULT!! WARNING !!
+ * Runs in Java, Nodejs, Ruby, and Python environments!
+ * Commonjs support. Just add envjs to your load path.
+ * Rhino no longer needs to be run in non-optimized mode. ( yeah! )
+ * XML Parser no longer uses e4x since it is not supported by V8 and
+ several other javascript engines. We reintroduced the old xml parser
+ to allow simplified support across all engines.
+ * Basic XPath support from googles ajaxslt project now included.
+ * NodeList are live, meaning getElementByTagName returns a nodelist
+ which will change when node are added or removed from the document.
+ * Reimplementation of Timer internals to allow
+ * Cleaned up all jslint errors and 99.9% of warnings.
+ * Added internal Category Logging implementation.
== 1.1 to 1.2 note ==
@@ -179,8 +240,9 @@ Testing jQuery Compatibility:
local path to a different version of the Rhino js.jar file. The
"javascript file" is the path to the JavaScript you wish to execute.
-Changes with new timer code:
+ Changes with new timer code:
-Previously with envjs, you could call Java's thread sleep() method to delay execution. This was mostly used in test suites. This may no
-longer work the same since it will inhibit all events from firing. You can now use the Envjs.wait(milliseconds) call to achieve an
-effect similar to calling sleep().
+ Previously with envjs, you could call Java's thread sleep() method to delay
+ execution. This was mostly used in test suites. This may no longer work the
+ same since it will inhibit all events from firing. You can now use the
+ Envjs.wait(milliseconds) call to achieve an effect similar to calling sleep().
View
39 bin/envjs
@@ -0,0 +1,39 @@
+#!/bin/sh
+# Usage: envjs <platorm> file.js [file2.js ...]
+###########################################################################
+ENVJS_PLATFORM='node'
+
+# first arguments ($1)
+# may be a platform or is a file and the default platorm is used
+if [ -n "$1" ]; then
+ if [ -n "$1" ]; then ENVJS_PLATFORM="$1"; shift; fi
+fi
+
+# Run envjs with the given platform
+###########################################################################
+case "$ENVJS_PLATFORM" in
+
+ "node")
+ node envjs/node.js $@
+ ;;
+ "rhino")
+ java -jar rhino/js.jar envjs/rhino.js $@
+ ;;
+ "rhino-debug")
+ java -cp rhino/js.jar org.mozilla.javascript.tools.debugger.Main envjs/rhino.js $@
+ ;;
+ "spyd")
+ python envjs/spydermonkey.py envjs/spydermonkey.js $@
+ ;;
+ "rubyracer")
+ ruby -rrubygems envjs/rubyracer.rb envjs/rubyracer.js $@
+ ;;
+ "johnson")
+ ruby -rrubygems envjs/johnson.rb envjs/johnson.js $@
+ ;;
+ *)
+ # platform default means $1 was actually a file
+ node envjs/node.js $ENVJS_PLATFORM $@
+ ;;
+esac
+
View
0 bin/prototype-1.6.0.3-test.js
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
0 bin/prototype_1.6.0.3_tmpl.txt
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
0 bin/test-jquery.js
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
0 bin/test-jquery.sh
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
0 bin/test-prototype.sh
Sorry, we could not display the changes to this file because there were too many other changes to display.
View
4 build.properties
@@ -1,8 +1,8 @@
PROJECT: env-js
BUILD_MAJOR: 1
-BUILD_MINOR: 2
-BUILD_ID: 35
+BUILD_MINOR: 3
+BUILD_ID: pre01
BUILD_VERSION: ${BUILD_MAJOR}.${BUILD_MINOR}.${BUILD_ID}
BUILD: ${PROJECT}.${BUILD_VERSION}
VERSION: ${BUILD} ${DSTAMP}
View
262 build.xml
@@ -30,7 +30,7 @@
location="rhino/js.jar"
description="Rhino JS Engine"/>
<property name="PREFIX"
- location="${basedir}/dist/"
+ location="${basedir}/envjs/"
description="Target parent folder for built files" />
<property name="DOCS_DIR"
location="${PREFIX}/docs"
@@ -58,26 +58,35 @@
<echo message=" },"/>
- <property name="CORE_DIST" location="${DIST_DIR}/platform/core.js" />
- <property name="RHINO_DIST" location="${DIST_DIR}/platform/rhino.js" />
- <property name="CONSOLE_DIST" location="${DIST_DIR}/console.js" />
- <property name="DOM_DIST" location="${DIST_DIR}/dom.js" />
- <property name="EVENT_DIST" location="${DIST_DIR}/event.js" />
- <property name="TIMER_DIST" location="${DIST_DIR}/timer.js" />
- <property name="HTML_DIST" location="${DIST_DIR}/html.js" />
- <property name="PARSER_DIST" location="${DIST_DIR}/parser.js" />
- <property name="XHR_DIST" location="${DIST_DIR}/xhr.js" />
- <property name="CSS_DIST" location="${DIST_DIR}/css.js" />
- <property name="WINDOW_DIST" location="${DIST_DIR}/window.js" />
- <property name="ENV_DIST" location="${DIST_DIR}/env.js" />
- <property name="ENV_JSLINT" location="${DIST_DIR}/env.jslint.js" />
- <property name="ENV_RHINO" location="${DIST_DIR}/env.rhino.js"/>
+ <property name="CORE_DIST" location="${DIST_DIR}/platform/core.js" />
+ <property name="RHINO_DIST" location="${DIST_DIR}/platform/rhino.js" />
+ <property name="NODE_DIST" location="${DIST_DIR}/platform/node.js" />
+ <property name="SPYDERMONKEY_DIST" location="${DIST_DIR}/platform/spydermonkey.js" />
+ <property name="RUBYRACER_DIST" location="${DIST_DIR}/platform/rubyracer.js" />
+ <property name="JOHNSON_DIST" location="${DIST_DIR}/platform/johnson.js" />
+ <property name="CONSOLE_DIST" location="${DIST_DIR}/console.js" />
+ <property name="DOM_DIST" location="${DIST_DIR}/dom.js" />
+ <property name="EVENT_DIST" location="${DIST_DIR}/event.js" />
+ <property name="TIMER_DIST" location="${DIST_DIR}/timer.js" />
+ <property name="HTML_DIST" location="${DIST_DIR}/html.js" />
+ <property name="PARSER_DIST" location="${DIST_DIR}/parser.js" />
+ <property name="XHR_DIST" location="${DIST_DIR}/xhr.js" />
+ <property name="CSS_DIST" location="${DIST_DIR}/css.js" />
+ <property name="WINDOW_DIST" location="${DIST_DIR}/window.js" />
+ <property name="ENV_DIST" location="${DIST_DIR}/env.js" />
+ <property name="ENV_JSLINT" location="${DIST_DIR}/env.jslint.js" />
+ <property name="ENV_RHINO" location="${DIST_DIR}/env.rhino.js"/>
+ <property name="ENV_NODE" location="${DIST_DIR}/env.node.js"/>
+ <property name="ENV_SPYDERMONKEY" location="${DIST_DIR}/env.spydermonkey.js"/>
+ <property name="ENV_RUBYRACER" location="${DIST_DIR}/env.rubyracer.js"/>
+ <property name="ENV_JOHNSON" location="${DIST_DIR}/env.johnson.js"/>
<echo message=" 'DISTRIBUTABLES': {"/>
<echo message=" 'CORE_DIST': '${CORE_DIST}',"/>
<echo message=" 'RHINO_DIST': '${RHINO_DIST}',"/>
- <echo message=" 'CONSOLE_DIST': '${CONSOLE_DIST}'"/>
- <echo message=" 'DOM_DIST': '${DOM_DIST}'"/>
+ <echo message=" 'NODE_DIST': '${NODE_DIST}',"/>
+ <echo message=" 'CONSOLE_DIST': '${CONSOLE_DIST}',"/>
+ <echo message=" 'DOM_DIST': '${DOM_DIST}',"/>
<echo message=" 'EVENT_DIST': '${EVENT_DIST}',"/>
<echo message=" 'TIMER_DIST': '${TIMER_DIST}',"/>
<echo message=" 'HTML_DIST': '${HTML_DIST}',"/>
@@ -87,6 +96,9 @@
<echo message=" 'WINDOW_DIST': '${WINDOW_DIST}',"/>
<echo message=" 'ENV_DIST': '${ENV_DIST}',"/>
<echo message=" 'ENV_RHINO': '${ENV_RHINO}',"/>
+ <echo message=" 'ENV_NODE': '${ENV_NODE}',"/>
+ <echo message=" 'ENV_SPYDERMONKEY':'${ENV_SPYDERMONKEY}',"/>
+ <echo message=" 'ENV_RUBYRACER':'${ENV_RUBYRACER}'"/>
<echo message=" }"/>
<echo message=" }"/>
@@ -123,7 +135,10 @@
<fileset dir="${SRC_DIR}" includes="common/intro.js" />
<fileset dir="${SRC_DIR}" includes="common/__extend__.js" />
<fileset dir="${SRC_DIR}" includes="common/__trim__.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/core/aspect.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/core/config.js" />
<fileset dir="${SRC_DIR}" includes="platform/core/console.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/core/logging.js" />
<fileset dir="${SRC_DIR}" includes="platform/core/dom.js" />
<fileset dir="${SRC_DIR}" includes="platform/core/event.js" />
<fileset dir="${SRC_DIR}" includes="platform/core/html.js" />
@@ -166,20 +181,22 @@
<token key="BUILD_VERSION" value="${BUILD_VERSION}"/>
</replacetokens>
</filterchain>
- <fileset dir="${SRC_DIR}" includes="platform/rhino/__global__.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/java-rhino/__global__.js" />
<fileset dir="${SRC_DIR}" includes="common/intro.js" />
<fileset dir="${SRC_DIR}" includes="common/__extend__.js" />
- <fileset dir="${SRC_DIR}" includes="platform/rhino/console.js" />
- <fileset dir="${SRC_DIR}" includes="platform/rhino/dom.js" />
- <fileset dir="${SRC_DIR}" includes="platform/rhino/event.js" />
- <fileset dir="${SRC_DIR}" includes="platform/rhino/html.js" />
- <fileset dir="${SRC_DIR}" includes="platform/rhino/svg.js" />
- <fileset dir="${SRC_DIR}" includes="platform/rhino/parser.js" />
- <fileset dir="${SRC_DIR}" includes="platform/rhino/timer.js" />
- <fileset dir="${SRC_DIR}" includes="platform/rhino/xhr.js" />
- <fileset dir="${SRC_DIR}" includes="platform/rhino/window.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/java-rhino/console.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/java-rhino/dom.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/java-rhino/event.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/java-rhino/html.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/java-rhino/svg.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/java-rhino/parser.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/java-rhino/timer.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/java-rhino/xhr.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/java-rhino/window.js" />
<fileset dir="${SRC_DIR}" includes="common/outro.js" />
</concat>
+ <copy file="${SRC_DIR}/platform/java-rhino/require.js"
+ tofile="${DIST_DIR}/rhino.js" />
<echo message="Finished Building ${RHINO_DIST}"/>
<echo message=""/>
</target>
@@ -199,6 +216,121 @@
</java>
<echo message=""/>
</target>
+
+ <target name="node-env">
+ <mkdir dir="${DIST_DIR}/platform" />
+ <echo message=""/>
+ <echo message="Building ${NODE_DIST}" />
+ <concat destfile="${NODE_DIST}">
+ <filterchain>
+ <replacetokens>
+ <token key="VERSION" value="node-env.${BUILD_VERSION}"/>
+ <token key="BUILD_VERSION" value="${BUILD_VERSION}"/>
+ </replacetokens>
+ </filterchain>
+ <fileset dir="${SRC_DIR}" includes="platform/node-v8/__global__.js" />
+ <fileset dir="${SRC_DIR}" includes="common/intro.js" />
+ <fileset dir="${SRC_DIR}" includes="common/__extend__.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/node-v8/console.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/node-v8/html.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/node-v8/timer.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/node-v8/window.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/node-v8/xhr.js" />
+ <fileset dir="${SRC_DIR}" includes="common/outro.js" />
+ </concat>
+ <copy file="${SRC_DIR}/platform/node-v8/require.js"
+ tofile="${DIST_DIR}/node.js" />
+ <echo message="Finished Building ${NODE_DIST}"/>
+ <echo message=""/>
+ </target>
+
+ <target name="spydermonkey-env">
+ <mkdir dir="${DIST_DIR}/platform" />
+ <echo message=""/>
+ <echo message="Building ${SPYDERMONKEY_DIST}" />
+ <concat destfile="${SPYDERMONKEY_DIST}">
+ <filterchain>
+ <replacetokens>
+ <token key="VERSION" value="node-env.${BUILD_VERSION}"/>
+ <token key="BUILD_VERSION" value="${BUILD_VERSION}"/>
+ </replacetokens>
+ </filterchain>
+ <fileset dir="${SRC_DIR}" includes="platform/python-spidermonkey/__global__.js" />
+ <fileset dir="${SRC_DIR}" includes="common/intro.js" />
+ <fileset dir="${SRC_DIR}" includes="common/__extend__.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/python-spidermonkey/console.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/python-spidermonkey/html.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/python-spidermonkey/timer.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/python-spidermonkey/window.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/python-spidermonkey/xhr.js" />
+ <fileset dir="${SRC_DIR}" includes="common/outro.js" />
+ </concat>
+ <copy file="${SRC_DIR}/platform/python-spidermonkey/require.js"
+ tofile="${DIST_DIR}/spydermonkey.js" />
+ <copy file="${SRC_DIR}/platform/python-spidermonkey/envjs.py"
+ tofile="${DIST_DIR}/spydermonkey.py" />
+ <echo message="Finished Building ${SPYDERMONKEY_DIST}"/>
+ <echo message=""/>
+ </target>
+
+
+ <target name="rubyracer-env">
+ <mkdir dir="${DIST_DIR}/platform" />
+ <echo message=""/>
+ <echo message="Building ${RUBYRACER_DIST}" />
+ <concat destfile="${RUBYRACER_DIST}">
+ <filterchain>
+ <replacetokens>
+ <token key="VERSION" value="rubyracer-env.${BUILD_VERSION}"/>
+ <token key="BUILD_VERSION" value="${BUILD_VERSION}"/>
+ </replacetokens>
+ </filterchain>
+ <fileset dir="${SRC_DIR}" includes="platform/ruby-v8/__global__.js" />
+ <fileset dir="${SRC_DIR}" includes="common/intro.js" />
+ <fileset dir="${SRC_DIR}" includes="common/__extend__.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/ruby-v8/console.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/ruby-v8/html.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/ruby-v8/timer.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/ruby-v8/window.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/ruby-v8/xhr.js" />
+ <fileset dir="${SRC_DIR}" includes="common/outro.js" />
+ </concat>
+ <copy file="${SRC_DIR}/platform/ruby-v8/require.js"
+ tofile="${DIST_DIR}/rubyracer.js" />
+ <copy file="${SRC_DIR}/platform/ruby-v8/envjs.rb"
+ tofile="${DIST_DIR}/rubyracer.rb" />
+ <echo message="Finished Building ${RUBYRACER_DIST}"/>
+ <echo message=""/>
+ </target>
+
+ <target name="johnson-env">
+ <mkdir dir="${DIST_DIR}/platform" />
+ <echo message=""/>
+ <echo message="Building ${JOHNSON_DIST}" />
+ <concat destfile="${JOHNSON_DIST}">
+ <filterchain>
+ <replacetokens>
+ <token key="VERSION" value="johnson-env.${BUILD_VERSION}"/>
+ <token key="BUILD_VERSION" value="${BUILD_VERSION}"/>
+ </replacetokens>
+ </filterchain>
+ <fileset dir="${SRC_DIR}" includes="platform/ruby-spidermonkey/__global__.js" />
+ <fileset dir="${SRC_DIR}" includes="common/intro.js" />
+ <fileset dir="${SRC_DIR}" includes="common/__extend__.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/ruby-spidermonkey/console.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/ruby-spidermonkey/html.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/ruby-spidermonkey/timer.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/ruby-spidermonkey/window.js" />
+ <fileset dir="${SRC_DIR}" includes="platform/ruby-spidermonkey/xhr.js" />
+ <fileset dir="${SRC_DIR}" includes="common/outro.js" />
+ </concat>
+ <copy file="${SRC_DIR}/platform/ruby-spidermonkey/require.js"
+ tofile="${DIST_DIR}/johnson.js" />
+ <copy file="${SRC_DIR}/platform/ruby-spidermonkey/envjs.rb"
+ tofile="${DIST_DIR}/johnson.rb" />
+ <echo message="Finished Building ${JOHNSON_DIST}"/>
+ <echo message=""/>
+ </target>
<!-- BUILD CONSOLE IMPLEMENTATIOM -->
<target name="console">
@@ -262,20 +394,21 @@
<fileset dir="${SRC_DIR}" includes="dom/text.js" />
<fileset dir="${SRC_DIR}" includes="dom/cdatasection.js" />
<fileset dir="${SRC_DIR}" includes="dom/comment.js" />
+ <fileset dir="${SRC_DIR}" includes="dom/domimplementation.js" />
+ <fileset dir="${SRC_DIR}" includes="dom/document.js" />
<fileset dir="${SRC_DIR}" includes="dom/documenttype.js" />
+ <fileset dir="${SRC_DIR}" includes="dom/documentfragment.js" />
+ <fileset dir="${SRC_DIR}" includes="dom/domexception.js" />
+ <fileset dir="${SRC_DIR}" includes="dom/domparser.js" />
<fileset dir="${SRC_DIR}" includes="dom/attr.js" />
<fileset dir="${SRC_DIR}" includes="dom/element.js" />
- <fileset dir="${SRC_DIR}" includes="dom/domexception.js" />
- <fileset dir="${SRC_DIR}" includes="dom/documentfragment.js" />
<fileset dir="${SRC_DIR}" includes="dom/processinginstruction.js" />
<fileset dir="${SRC_DIR}" includes="dom/entity.js" />
<fileset dir="${SRC_DIR}" includes="dom/entityreference.js" />
- <fileset dir="${SRC_DIR}" includes="dom/domimplementation.js" />
<fileset dir="${SRC_DIR}" includes="dom/notation.js" />
<fileset dir="${SRC_DIR}" includes="dom/range.js" />
- <fileset dir="${SRC_DIR}" includes="dom/document.js" />
- <fileset dir="${SRC_DIR}" includes="dom/domparser.js" />
<fileset dir="${SRC_DIR}" includes="dom/xmlserializer.js" />
+ <fileset dir="${SRC_DIR}" includes="dom/xpath.js" />
<fileset dir="${SRC_DIR}" includes="common/outro.js" />
</concat>
<echo message="Finished Building ${DOM_DIST}"/>
@@ -314,7 +447,6 @@
<fileset dir="${SRC_DIR}" includes="common/intro.js" />
<fileset dir="${SRC_DIR}" includes="common/__extend__.js" />
<fileset dir="${SRC_DIR}" includes="common/__setArray__.js" />
- <fileset dir="${SRC_DIR}" includes="event/aspect.js" />
<fileset dir="${SRC_DIR}" includes="event/eventtarget.js" />
<fileset dir="${SRC_DIR}" includes="event/event.js" />
<fileset dir="${SRC_DIR}" includes="event/uievent.js" />
@@ -357,8 +489,8 @@
<token key="BUILD_VERSION" value="${BUILD_VERSION}"/>
</replacetokens>
</filterchain>
- <fileset dir="${SRC_DIR}" includes="timer/__global__.js" />
<fileset dir="${SRC_DIR}" includes="common/intro.js" />
+ <fileset dir="${SRC_DIR}" includes="timer/__global__.js" />
<fileset dir="${SRC_DIR}" includes="timer/timer.js" />
<fileset dir="${SRC_DIR}" includes="common/outro.js" />
</concat>
@@ -578,11 +710,9 @@
<token key="BUILD_VERSION" value="${BUILD_VERSION}"/>
</replacetokens>
</filterchain>
- <fileset dir="${SRC_DIR}" includes="xhr/__global__.js" />
<fileset dir="${SRC_DIR}" includes="common/intro.js" />
+ <fileset dir="${SRC_DIR}" includes="xhr/__global__.js" />
<fileset dir="${SRC_DIR}" includes="common/__extend__.js" />
- <fileset dir="${SRC_DIR}" includes="common/__setArray__.js" />
- <fileset dir="${SRC_DIR}" includes="common/__trim__.js" />
<fileset dir="${SRC_DIR}" includes="xhr/document.js" />
<fileset dir="${SRC_DIR}" includes="xhr/location.js" />
<fileset dir="${SRC_DIR}" includes="xhr/xmlhttprequest.js" />
@@ -694,19 +824,19 @@
<echo message="${ENV_JSLINT} built." />
<exec executable="python"
input="${ENV_JSLINT}"
- output="dist/jslint-in.js" >
+ output="envjs/jslint-in.js" >
<arg value="misc/deaccessor.py" />
</exec>
<java fork="true"
jar="${RHINO_JAR}"
failonerror="false"
- output="dist/jslint-out.txt" >
+ output="envjs/jslint-out.txt" >
<arg value="misc/jslint.js"/>
- <arg value="dist/jslint-in.js"/>
+ <arg value="envjs/jslint-in.js"/>
<jvmarg value="-Dfile.encoding=utf-8"/>
<jvmarg value="-Xmx256m"/>
</java>
- <echo message="dist/jslint-out.txt has results" />
+ <echo message="envjs/jslint-out.txt has results" />
</target>
<!-- TODO: add back core/env-spec. Right now it breaks -->
@@ -716,7 +846,6 @@
dom-spec, event-spec, timer-spec,
html-spec, parser-spec, xhr-spec,
css-spec, window-spec">
- <!-- TODO: nice message saying all worked. Zap /dist on error? -->
</target>
<target name="clean" description="Clean up">
@@ -726,54 +855,11 @@
<target description="Main ENV concatenator"
name="zip"
- depends="core-env, rhino-env, console,
- dom, event, timer,
+ depends="core-env, rhino-env, node-env, spydermonkey-env,
+ rubyracer-env, johnson-env,
+ console, dom, event, timer,
html, parser, xhr,
css, window">
- <!-- CORE -->
- <echo message="Building ${ENV_DIST}" />
- <concat destfile="${ENV_DIST}">
- <filterchain>
- <replacetokens>
- <token key="VERSION" value="${BUILD_VERSION}"/>
- <token key="BUILD_VERSION" value="${BUILD_VERSION}"/>
- </replacetokens>
- </filterchain>
- <fileset dir="${DIST_DIR}" includes="platform/core.js" />
- <fileset dir="${DIST_DIR}" includes="console.js" />
- <fileset dir="${DIST_DIR}" includes="dom.js" />
- <fileset dir="${DIST_DIR}" includes="event.js" />
- <fileset dir="${DIST_DIR}" includes="timer.js" />
- <fileset dir="${DIST_DIR}" includes="html.js" />
- <fileset dir="${DIST_DIR}" includes="css.js" />
- <fileset dir="${DIST_DIR}" includes="parser.js" />
- <fileset dir="${DIST_DIR}" includes="xhr.js" />
- <fileset dir="${DIST_DIR}" includes="window.js" />
- </concat>
- <echo message="${ENV_DIST} built." />
-
- <!-- RHINO -->
- <echo message="Building ${ENV_RHINO}" />
- <concat destfile="${ENV_RHINO}">
- <filterchain>
- <replacetokens>
- <token key="VERSION" value="env-${BUILD_VERSION}"/>
- <token key="BUILD_VERSION" value="${BUILD_VERSION}"/>
- </replacetokens>
- </filterchain>
- <fileset dir="${DIST_DIR}" includes="platform/core.js" />
- <fileset dir="${DIST_DIR}" includes="platform/rhino.js" />
- <fileset dir="${DIST_DIR}" includes="console.js" />
- <fileset dir="${DIST_DIR}" includes="dom.js" />
- <fileset dir="${DIST_DIR}" includes="event.js" />
- <fileset dir="${DIST_DIR}" includes="timer.js" />
- <fileset dir="${DIST_DIR}" includes="html.js" />
- <fileset dir="${DIST_DIR}" includes="css.js" />
- <fileset dir="${DIST_DIR}" includes="parser.js" />
- <fileset dir="${DIST_DIR}" includes="xhr.js" />
- <fileset dir="${DIST_DIR}" includes="window.js" />
- </concat>
- <echo message="${ENV_RHINO} built." />
</target>
</project>
View
80 doc/index.txt
@@ -0,0 +1,80 @@
+a
+b | c
+
+[a,b,c]
+[b]
+[c]
+
+a
+b | c
+d
+
+[a,b,d,c]
+[b,d]
+[c]
+
+a
+b | c
+d e | f
+
+[a,b,d,e,c,f]
+[b,d,e]
+
+
+ a
+| \
+b c
+|\ |\
+d e f g
+|\ \ \
+h i j k
+| |
+l m
+|
+n
+
+ 0 10
+| \ |
+1 10 0 2
+|\ | \ | \ \
+2 7 11 12 1 2 0
+|\ \ \ \ \
+3 6 8 13 3 1 0
+| |
+4 9
+|
+5
+
+ x [x] -> {x:[0], y:[]}
+| \
+y x [x,y,x] -> {x:[0,2], y:[1]}
+|\ |\
+y y y x [x,y,y,y,x,y,x] -> {x:[0,4,6], y:[1,2,3,5]}
+|\ \ \
+x y x x [x,y,y,x,y,y,x,x,y,x,x] - > {x:[0,3,6,7,9,10], y:[1,2,4,5,8]}
+| |
+x x
+|
+y
+
+
+ x [x,y,y,x,x,y,y,y,x,x,x,y,x,x]
+| \ ->{ x:[0,3,4,8,9,10,12,13], y:[1,2,5,6,7,11], _p:[], _i:0 }
+| |
+y x [y,y,x,x,y,y,y,x,x] ->{ x:[2,3,7,8],y:[0,1,4,5,6], _p:[0], _c:[2,3,4,5,6,7,8,9], _i:1}
+|\ |\ [x,y,x,x] ->{ x:[0,2,3], y:[1], _p:[0], _c:[11,12,13], _i:10 }
+| | | |
+y y y x [y,x,x,y,y] ->{ x:[1,2], y:[0,3,4], _p:[1,0], _i:2 }
+|\ \ \ [y,x,x] ->{ x:[1,2], y:[0], _p:[1,0], _i:7 }
+| | | | [y] ->{ x:[], y:[0], _p:[10,0], _i:11 }
+| | | | [x,x] ->{ x:[0,1], y:[], _p:[10,0], _i:12 }
+| | | |
+x y x x [x,x,y] ->{ x:[0,1], y:[2], _p:[2,1,0], _c:[4,5], _i:3 }
+| | [y] ->{ x:[], y:[0], _p:[2,1,0], _c:[], _i:6 }
+| | [x,x] ->{ x:[0,1], y:[], _p:[7,1,0], _c:[9], _i:8 }
+| | [x] ->{ x:[0], y:[], _p:[12,10,0], _c:[], _i:13 }
+| |
+x x [x,y] ->{ x:[0], y:[1], _p:[3,2,1,0], _c:[5], _i:4 }
+| [x] ->{ x:[0], y:[], _p:[8,7,1,0], _c:[], _i:9 }
+|
+y [y] ->{ x:[], y:[0], _p:[4,3,2,1,0], _c:[], _i:5 }
View
278 envjs/console.js
@@ -0,0 +1,278 @@
+
+/**
+ * @author envjs team
+ * @Console
+ */
+
+var Envjs = Envjs || require('envjs/platform/core').Envjs;
+
+/*
+ * Envjs console.1.3.pre01
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ */
+
+//CLOSURE_START
+(function(){
+
+
+
+
+/**
+ * @author envjs team
+ * borrowed 99%-ish with love from firebug-lite
+ */
+
+//leaked globally on purpose;
+try{
+ console.log();
+}catch(e){
+
+
+function escapeHTML(value)
+{
+ return value;
+}
+
+function objectToString(object)
+{
+ try
+ {
+ return object+"";
+ }
+ catch (exc)
+ {
+ return null;
+ }
+}
+
+// ********************************************************************************************
+
+function appendText(object, html)
+{
+ html.push(escapeHTML(objectToString(object)));
+}
+
+function appendNull(object, html)
+{
+ html.push(escapeHTML(objectToString(object)));
+}
+
+function appendString(object, html)
+{
+ html.push(escapeHTML(objectToString(object)));
+}
+
+function appendInteger(object, html)
+{
+ html.push(escapeHTML(objectToString(object)));
+}
+
+function appendFloat(object, html)
+{
+ html.push(escapeHTML(objectToString(object)));
+}
+
+function appendFunction(object, html)
+{
+ var reName = /function ?(.*?)\(/;
+ var m = reName.exec(objectToString(object));
+ var name = m ? m[1] : "function";
+ html.push(escapeHTML(name));
+}
+
+function appendObjectFormatted(object, html)
+{
+ var text = objectToString(object);
+ var reObject = /\[object (.*?)\]/;
+
+ var m = reObject.exec(text);
+ html.push( m ? m[1] : text);
+}
+
+function appendSelector(object, html)
+{
+
+ html.push(escapeHTML(object.nodeName.toLowerCase()));
+ if (object.id) {
+ html.push(escapeHTML(object.id));
+ }
+ if (object.className) {
+ html.push(escapeHTML(object.className));
+ }
+}
+
+function appendNode(node, html)
+{
+ if (node.nodeType == 1)
+ {
+ html.push( node.nodeName.toLowerCase());
+
+ for (var i = 0; i < node.attributes.length; ++i)
+ {
+ var attr = node.attributes[i];
+ if (!attr.specified) {
+ continue;
+ }
+
+ html.push( attr.nodeName.toLowerCase(),escapeHTML(attr.nodeValue));
+ }
+
+ if (node.firstChild)
+ {
+ for (var child = node.firstChild; child; child = child.nextSibling) {
+ appendNode(child, html);
+ }
+
+ html.push( node.nodeName.toLowerCase());
+ }
+ }
+ else if (node.nodeType === 3)
+ {
+ html.push(escapeHTML(node.nodeValue));
+ }
+}
+
+function appendObject(object, html)
+{
+ try
+ {
+ if (object === undefined) {
+ appendNull("undefined", html);
+ } else if (object === null) {
+ appendNull("null", html);
+ } else if (typeof object == "string") {
+ appendString(object, html);
+ } else if (typeof object == "number") {
+ appendInteger(object, html);
+ } else if (typeof object == "function") {
+ appendFunction(object, html);
+ } else if (object.nodeType == 1) {
+ appendSelector(object, html);
+ } else if (typeof object == "object") {
+ appendObjectFormatted(object, html);
+ } else {
+ appendText(object, html);
+ }
+ }
+ catch (exc)
+ {
+ }
+}
+
+
+function parseFormat(format)
+{
+ var parts = [];
+
+ var reg = /((^%|[^\\]%)(\d+)?(\.)([a-zA-Z]))|((^%|[^\\]%)([a-zA-Z]))/;
+ var appenderMap = {s: appendText, d: appendInteger, i: appendInteger, f: appendFloat};
+
+ for (var m = reg.exec(format); m; m = reg.exec(format))
+ {
+ var type = m[8] ? m[8] : m[5];
+ var appender = type in appenderMap ? appenderMap[type] : appendObject;
+ var precision = m[3] ? parseInt(m[3], 10) : (m[4] == "." ? -1 : 0);
+
+ parts.push(format.substr(0, m[0][0] == "%" ? m.index : m.index+1));
+ parts.push({appender: appender, precision: precision});
+
+ format = format.substr(m.index+m[0].length);
+ }
+
+ parts.push(format);
+
+ return parts;
+}
+
+
+
+function logFormatted(objects, className)
+{
+ var html = [],
+ i= 0,
+ object;
+
+ var format = objects[0];
+ var objIndex = 0;
+
+ if (typeof(format) != "string")
+ {
+ format = "";
+ objIndex = -1;
+ }
+
+ var parts = parseFormat(format);
+ for (i = 0; i < parts.length; ++i)
+ {
+ var part = parts[i];
+ if (part && typeof(part) == "object")
+ {
+ object = objects[++objIndex];
+ part.appender(object, html);
+ }
+ else {
+ appendText(part, html);
+ }
+ }
+
+ for (i = objIndex+1; i < objects.length; ++i)
+ {
+ appendText(" ", html);
+
+ object = objects[i];
+ if (typeof(object) == "string") {
+ appendText(object, html);
+ } else {
+ appendObject(object, html);
+ }
+ }
+
+ Envjs.log(html.join(' '));
+}
+
+
+Console = function(module){
+ var $level,
+ $logger,
+ $null = function(){};
+ $logger = {
+ log: function(level){
+ logFormatted(arguments, "");
+ },
+ debug: function(level){
+ logFormatted(arguments, "DEBUG");
+ },
+ info: function(level){
+ logFormatted(arguments, "INFO");
+ },
+ warn: function(level){
+ logFormatted(arguments, "WARN");
+ },
+ error: function(level){
+ logFormatted(arguments, "ERROR");
+ },
+ trace: function(){
+ Envjs.trace();
+ }
+ };
+
+ return $logger;
+};
+
+console = new Console();
+exports.console = console;
+
+}
+
+
+
+/**
+ * @author john resig & the envjs team
+ * @uri http://www.envjs.com/
+ * @copyright 2008-2010
+ * @license MIT
+ */
+//CLOSURE_END
+}());
View
695 envjs/css.js
@@ -0,0 +1,695 @@
+
+/**
+ * DOM Style Level 2
+
+Leaked globally
+
+var CSS2Properties,
+ CSSRule,
+ CSSStyleRule,
+ CSSImportRule,
+ CSSMediaRule,
+ CSSFontFaceRule,
+ CSSPageRule,
+ CSSRuleList,
+ CSSStyleSheet,
+ StyleSheet,
+ StyleSheetList;
+
+*/
+
+var Envjs = Envjs || require('envjs/platform/core').Envjs,
+ Document = require('envjs/dom').Document,
+ HTMLElement = require('envjs/html').HTMLElement;
+/*
+ * Envjs css.1.3.pre01
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ */
+
+//CLOSURE_START
+(function(){
+
+
+
+
+
+/**
+ * @author john resig
+ */
+// Helper method for extending one object with another.
+function __extend__(a,b) {
+ for ( var i in b ) {
+ if(b.hasOwnProperty(i)){
+ var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i);
+ if ( g || s ) {
+ if ( g ) { a.__defineGetter__(i, g); }
+ if ( s ) { a.__defineSetter__(i, s); }
+ } else {
+ a[i] = b[i];
+ }
+ }
+ }
+ return a;
+}
+
+/**
+ * @author john resig
+ */
+//from jQuery
+function __setArray__( target, array ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ target.length = 0;
+ Array.prototype.push.apply( target, array );
+}
+
+/**
+ * @author ariel flesler
+ * http://flesler.blogspot.com/2008/11/fast-trim-function-for-javascript.html
+ * @param {Object} str
+ */
+function __trim__( str ){
+ return (str || "").replace( /^\s+|\s+$/g, "" );
+}
+
+
+(function(){
+
+var log = Envjs.logger();
+
+Envjs.once('tick', function(){
+ log = Envjs.logger('Envjs.DOM.Document').debug('available');
+});
+
+/**
+ * Interface DocumentStyle (introduced in DOM Level 2)
+ * http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.html#StyleSheets-StyleSheet-DocumentStyle
+ *
+ * interface DocumentStyle {
+ * readonly attribute StyleSheetList styleSheets;
+ * };
+ *
+ */
+
+__extend__(Document.prototype, {
+ get styleSheets() {
+ if (! this._styleSheets) {
+ this._styleSheets = new StyleSheetList();
+ }
+ return this._styleSheets;
+ }
+});
+
+}(/*Envjs.DOM.Document*/));
+/*
+ * CSS2Properties - DOM Level 2 CSS
+ * Renamed to CSSStyleDeclaration??
+ */
+
+var __toCamelCase__ = function(name) {
+ if (name) {
+ return name.replace(/\-(\w)/g, function(all, letter) {
+ return letter.toUpperCase();
+ });
+ }
+ return name;
+};
+
+var __toDashed__ = function(camelCaseName) {
+ if (camelCaseName) {
+ return camelCaseName.replace(/[A-Z]/g, function(all) {
+ return '-' + all.toLowerCase();
+ });
+ }
+ return camelCaseName;
+};
+
+var __cssTextToStyles__,
+ __supportedStyles__;
+
+
+(function(){
+
+var log = Envjs.logger();
+
+Envjs.once('tick', function(){
+ log = Envjs.logger('Envjs.CSS.CSS2Properties').debug('available');
+});
+
+exports.CSS2Properties = CSS2Properties = function(element){
+ //console.log('css2properties %s', __cssproperties__++);
+ this.styleIndex = __supportedStyles__;//non-standard
+ this.type = element.tagName;//non-standard
+ __setArray__(this, []);
+ __cssTextToStyles__(this, element.cssText || '');
+};
+__extend__(CSS2Properties.prototype, {
+ get cssText() {
+ var i, css = [];
+ for (i = 0; i < this.length; ++i) {
+ css.push(this[i] + ': ' + this.getPropertyValue(this[i]) + ';');
+ }
+ return css.join(' ');
+ },
+ set cssText(cssText) {
+ __cssTextToStyles__(this, cssText);
+ },
+ getPropertyCSSValue: function(name) {
+ //?
+ },
+ getPropertyPriority: function() {
+
+ },
+ getPropertyValue: function(name) {
+ var index, cname = __toCamelCase__(name);
+ if (cname in this.styleIndex) {
+ return this[cname];
+ } else {
+ index = Array.prototype.indexOf.apply(this, [name]);
+ if (index > -1) {
+ return this[index];
+ }
+ }
+ return null;
+ },
+ item: function(index) {
+ return this[index];
+ },
+ removeProperty: function(name) {
+ this.styleIndex[name] = null;
+ name = __toDashed__(name);
+ var index = Array.prototype.indexOf.apply(this, [name]);
+ if (index > -1) {
+ Array.prototype.splice.apply(this, [1,index]);
+ }
+ },
+ setProperty: function(name, value, priority) {
+ var nval;
+ name = __toCamelCase__(name);
+ if (value !== undefined && name in this.styleIndex) {
+ // NOTE: parseFloat('300px') ==> 300 no
+ // NOTE: Number('300px') ==> Nan yes
+ nval = Number(value);
+ this.styleIndex[name] = isNaN(nval) ? value : nval;
+ name = __toDashed__(name);
+ if (Array.prototype.indexOf.apply(this, [name]) === -1 ){
+ Array.prototype.push.apply(this,[name]);
+ }
+ }
+ },
+ toString: function() {
+ return '[object CSS2Properties]';
+ }
+});
+
+
+
+__cssTextToStyles__ = function(css2props, cssText) {
+ //console.log('__cssTextToStyles__ %s %s', css2props, cssText);
+ var i, style, styles = cssText.split(';');
+ for (i = 0; i < styles.length; ++i) {
+ style = styles[i].split(':');
+ if (style.length === 2) {
+ css2props.setProperty(
+ style[0].replace(' ', '', 'g'),
+ style[1].replace(' ', '', 'g')
+ );
+ }
+ }
+};
+
+//Obviously these arent all supported but by commenting out various
+//sections this provides a single location to configure what is
+//exposed as supported.
+__supportedStyles__ = {
+ azimuth: null,
+ background: null,
+ backgroundAttachment: null,
+ backgroundColor: 'rgb(0,0,0)',
+ backgroundImage: null,
+ backgroundPosition: null,
+ backgroundRepeat: null,
+ border: null,
+ borderBottom: null,
+ borderBottomColor: null,
+ borderBottomStyle: null,
+ borderBottomWidth: null,
+ borderCollapse: null,
+ borderColor: null,
+ borderLeft: null,
+ borderLeftColor: null,
+ borderLeftStyle: null,
+ borderLeftWidth: null,
+ borderRight: null,
+ borderRightColor: null,
+ borderRightStyle: null,
+ borderRightWidth: null,
+ borderSpacing: null,
+ borderStyle: null,
+ borderTop: null,
+ borderTopColor: null,
+ borderTopStyle: null,
+ borderTopWidth: null,
+ borderWidth: null,
+ bottom: null,
+ captionSide: null,
+ clear: null,
+ clip: null,
+ color: null,
+ content: null,
+ counterIncrement: null,
+ counterReset: null,
+ cssFloat: null,
+ cue: null,
+ cueAfter: null,
+ cueBefore: null,
+ cursor: null,
+ direction: 'ltr',
+ display: null,
+ elevation: null,
+ emptyCells: null,
+ font: null,
+ fontFamily: null,
+ fontSize: '1em',
+ fontSizeAdjust: null,
+ fontStretch: null,
+ fontStyle: null,
+ fontVariant: null,
+ fontWeight: null,
+ height: '',
+ left: null,
+ letterSpacing: null,
+ lineHeight: null,
+ listStyle: null,
+ listStyleImage: null,
+ listStylePosition: null,
+ listStyleType: null,
+ margin: null,
+ marginBottom: '0px',
+ marginLeft: '0px',
+ marginRight: '0px',
+ marginTop: '0px',
+ markerOffset: null,
+ marks: null,
+ maxHeight: null,
+ maxWidth: null,
+ minHeight: null,
+ minWidth: null,
+ opacity: 1,
+ orphans: null,
+ outline: null,
+ outlineColor: null,
+ outlineOffset: null,
+ outlineStyle: null,
+ outlineWidth: null,
+ overflow: null,
+ overflowX: null,
+ overflowY: null,
+ padding: null,
+ paddingBottom: '0px',
+ paddingLeft: '0px',
+ paddingRight: '0px',
+ paddingTop: '0px',
+ page: null,
+ pageBreakAfter: null,
+ pageBreakBefore: null,
+ pageBreakInside: null,
+ pause: null,
+ pauseAfter: null,
+ pauseBefore: null,
+ pitch: null,
+ pitchRange: null,
+ position: null,
+ quotes: null,
+ richness: null,
+ right: null,
+ size: null,
+ speak: null,
+ speakHeader: null,
+ speakNumeral: null,
+ speakPunctuation: null,
+ speechRate: null,
+ stress: null,
+ tableLayout: null,
+ textAlign: null,
+ textDecoration: null,
+ textIndent: null,
+ textShadow: null,
+ textTransform: null,
+ top: null,
+ unicodeBidi: null,
+ verticalAlign: null,
+ visibility: '',
+ voiceFamily: null,
+ volume: null,
+ whiteSpace: null,
+ widows: null,
+ width: '1px',
+ wordSpacing: null,
+ zIndex: 1
+};
+
+var __displayMap__ = {
+ DIV : 'block',
+ P : 'block',
+ A : 'inline',
+ CODE : 'inline',
+ PRE : 'block',
+ SPAN : 'inline',
+ TABLE : 'table',
+ THEAD : 'table-header-group',
+ TBODY : 'table-row-group',
+ TR : 'table-row',
+ TH : 'table-cell',
+ TD : 'table-cell',
+ UL : 'block',
+ LI : 'list-item'
+};
+
+var __addStyleAccessor__ = function(name){
+ if (name === 'width' || name === 'height') {
+ CSS2Properties.prototype.__defineGetter__(name, function() {
+ if (this.display === 'none'){
+ return '0px';
+ }
+ return this.styleIndex[name];
+ });
+ } else if (name === 'display') {
+ //display will be set to a tagName specific value if ''
+ CSS2Properties.prototype.__defineGetter__(name, function() {
+ var val = this.styleIndex[name];
+ val = val ? val :__displayMap__[this.type];
+ return val;
+ });
+ } else {
+ CSS2Properties.prototype.__defineGetter__(name, function() {
+ return this.styleIndex[name];
+ });
+ }
+ CSS2Properties.prototype.__defineSetter__(name, function(value) {
+ this.setProperty(name, value);
+ });
+};
+
+for (var style in __supportedStyles__) {
+ if (__supportedStyles__.hasOwnProperty(style)) {
+ __addStyleAccessor__(style);
+ }
+}
+
+}(/*Envjs.CSS.CSS2Properties*/));
+
+
+(function(){
+
+var log = Envjs.logger();
+
+Envjs.once('tick', function(){
+ log = Envjs.logger('Envjs.CSS.CSSRule').debug('available');
+});
+
+/*
+ * CSSRule - DOM Level 2
+ */
+exports.CSSRule = CSSRule = function(options) {
+
+ var $style,
+ $selectorText = options.selectorText ? options.selectorText : '';
+ $style = new CSS2Properties({
+ cssText: options.cssText ? options.cssText : null
+ });
+
+ return __extend__(this, {
+ get style(){
+ return $style;
+ },
+ get selectorText(){
+ return $selectorText;
+ },
+ set selectorText(selectorText){
+ $selectorText = selectorText;
+ },
+ toString : function(){
+ return "[object CSSRule]";
+ }
+ });
+};
+
+CSSRule.STYLE_RULE = 1;
+CSSRule.IMPORT_RULE = 3;
+CSSRule.MEDIA_RULE = 4;
+CSSRule.FONT_FACE_RULE = 5;
+CSSRule.PAGE_RULE = 6;
+//CSSRule.NAMESPACE_RULE = 10;
+
+
+CSSStyleRule = function() {
+
+};
+
+CSSImportRule = function() {
+
+};
+
+CSSMediaRule = function() {
+
+};
+
+CSSFontFaceRule = function() {
+
+};
+
+CSSPageRule = function() {
+
+};
+
+
+CSSRuleList = function(data) {
+ this.length = 0;
+ __setArray__(this, data);
+};
+
+__extend__(CSSRuleList.prototype, {
+ item : function(index) {
+ if ((index >= 0) && (index < this.length)) {
+ // bounds check
+ return this[index];
+ }
+ return null;
+ },
+ toString: function() {
+ return '[object CSSRuleList]';
+ }
+});
+
+}(/*Envjs.CSS.CSSRuleList*/));
+
+
+(function(){
+
+var log = Envjs.logger();
+
+Envjs.once('tick', function(){
+ log = Envjs.logger('Envjs.CSS.CSSStyleSheet').debug('available');
+});
+
+/**
+ * StyleSheet
+ * http://dev.w3.org/csswg/cssom/#stylesheet
+ *
+ * interface StyleSheet {
+ * readonly attribute DOMString type;
+ * readonly attribute DOMString href;
+ * readonly attribute Node ownerNode;
+ * readonly attribute StyleSheet parentStyleSheet;
+ * readonly attribute DOMString title;
+ * [PutForwards=mediaText] readonly attribute MediaList media;
+ * attribute boolean disabled;
+ * };
+ */
+StyleSheet = function() {};
+
+/*
+ * CSSStyleSheet
+ * http://dev.w3.org/csswg/cssom/#cssstylesheet
+ *
+ * interface CSSStyleSheet : StyleSheet {
+ * readonly attribute CSSRule ownerRule;
+ * readonly attribute CSSRuleList cssRules;
+ * unsigned long insertRule(DOMString rule, unsigned long index);
+ * void deleteRule(unsigned long index);
+ * };
+ */
+exports.CSSStyleSheets = CSSStyleSheet = function(options){
+ var $cssRules,
+ $disabled = options.disabled ? options.disabled : false,
+ $href = options.href ? options.href : null,
+ $parentStyleSheet = options.parentStyleSheet ? options.parentStyleSheet : null,
+ $title = options.title ? options.title : "",
+ $type = "text/css";
+
+ function parseStyleSheet(text){
+ //$debug("parsing css");
+ //this is pretty ugly, but text is the entire text of a stylesheet
+ var cssRules = [];
+ if (!text) {
+ text = '';
+ }
+ text = __trim__(text.replace(/\/\*(\r|\n|.)*\*\//g,""));
+ // TODO: @import
+ var blocks = text.split("}");
+ blocks.pop();
+ var i, j, len = blocks.length;
+ var definition_block, properties, selectors;
+ for (i=0; i<len; i++) {
+ definition_block = blocks[i].split("{");
+ if (definition_block.length === 2) {
+ selectors = definition_block[0].split(",");
+ for (j=0; j<selectors.length; j++) {
+ cssRules.push(new CSSRule({
+ selectorText : __trim__(selectors[j]),
+ cssText : definition_block[1]
+ }));
+ }
+ }
+ }
+ return cssRules;
+ }
+
+ $cssRules = new CSSRuleList(parseStyleSheet(options.textContent));
+
+ return __extend__(this, {
+ get cssRules(){
+ return $cssRules;
+ },
+ get rule(){
+ return $cssRules;
+ },//IE - may be deprecated
+ get href(){
+ return $href;
+ },
+ get parentStyleSheet(){
+ return $parentStyleSheet;
+ },
+ get title(){
+ return $title;
+ },
+ get type(){
+ return $type;
+ },
+ addRule: function(selector, style, index){/*TODO*/},
+ deleteRule: function(index){/*TODO*/},
+ insertRule: function(rule, index){/*TODO*/},
+ //IE - may be deprecated
+ removeRule: function(index){
+ this.deleteRule(index);
+ }
+ });
+};
+
+exports.StyleSheetList = StyleSheetList = function() {};
+
+StyleSheetList.prototype = [];
+
+__extend__(StyleSheetList.prototype, {
+ item : function(index) {
+ if ((index >= 0) && (index < this.length)) {
+ // bounds check
+ return this[index];
+ }
+ return null;
+ },
+ toString: function() {
+ return '[object StyleSheetList]';
+ }
+});
+
+}(/*Envjs.CSS.CSSStyleSheet*/));
+/**
+ * This extends HTMLElement to handle CSS-specific interfaces.
+ *
+ * More work / research would be needed to extend just (DOM) Element
+ * for xml use and additional changes for just HTMLElement.
+ */
+
+(function(){
+
+var log = Envjs.logger();
+
+Envjs.once('tick', function(){
+ log = Envjs.logger('Envjs.HTML.HTMLElement').debug('available');
+});
+
+
+/**
+ * Replace or add the getter for 'style'
+ *
+ * This could be wrapped in a closure
+ */
+var $css2properties = [{}];
+
+__extend__(HTMLElement.prototype, {
+ get style(){
+ if ( !this.css2uuid ) {
+ this.css2uuid = $css2properties.length;
+ $css2properties[this.css2uuid] = new CSS2Properties(this);
+ }
+ return $css2properties[this.css2uuid];
+ }
+});
+
+/**
+ * Change for how 'setAttribute("style", ...)' works
+ *
+ * We are truly adding functionality to HtmlElement.setAttribute, not
+ * replacing it. So we need to save the old one first, call it, then
+ * do our stuff. If we need to do more hacks like this, HTMLElement
+ * (or regular Element) needs to have a hooks array or dispatch table
+ * for global changes.
+ *
+ * This could be wrapped in a closure if desired.
+ */
+var updateCss2Props = function(elem, values) {
+ //console.log('__updateCss2Props__ %s %s', elem, values);
+ if ( !elem.css2uuid ) {
+ elem.css2uuid = $css2properties.length;
+ $css2properties[elem.css2uuid] = new CSS2Properties(elem);
+ }
+ __cssTextToStyles__($css2properties[elem.css2uuid], values);
+};
+
+var origSetAttribute = HTMLElement.prototype.setAttribute;
+
+HTMLElement.prototype.setAttribute = function(name, value) {
+ //console.log("CSS set attribute: " + name + ", " + value);
+ origSetAttribute.apply(this, arguments);
+ if (name === "style") {
+ updateCss2Props(this, value);
+ }
+};
+
+var origGetAttribute = HTMLElement.prototype.getAttribute;
+
+HTMLElement.prototype.getAttribute = function(name) {
+ //console.log("CSS set attribute: " + name + ", " + value);
+ var style;
+ if (name === "style") {
+ style = this.style.cssText;
+ return style===""?null:style;
+ }else{
+ return origGetAttribute.apply(this, arguments);
+ }
+};
+
+}(/*Envjs.HTML.HTMLElement*/));
+
+/**
+ * @author john resig & the envjs team
+ * @uri http://www.envjs.com/
+ * @copyright 2008-2010
+ * @license MIT
+ */
+//CLOSURE_END
+}());
View
8,964 envjs/dom.js
8,964 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
720 envjs/event.js
@@ -0,0 +1,720 @@
+/*
+ * Envjs event.1.3.pre01
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ *
+ * This file simply provides the global definitions we need to
+ * be able to correctly implement to core browser DOM Event interfaces.
+
+ - leaked globally -
+
+var Event,
+ MouseEvent,
+ UIEvent,
+ KeyboardEvent,
+ MutationEvent,
+ DocumentEvent,
+ EventTarget,
+ EventException;
+
+ */
+
+var Envjs = Envjs || require('envjs/platform/core').Envjs,
+ After = After || require('envjs/platform/core').After,
+ Document = Document || require('envjs/dom').Document;
+/*
+ * Envjs event.1.3.pre01
+ * Pure JavaScript Browser Environment
+ * By John Resig <http://ejohn.org/> and the Envjs Team
+ * Copyright 2008-2010 John Resig, under the MIT License
+ */
+
+//CLOSURE_START
+(function(){
+
+
+
+
+
+/**
+ * @author john resig
+ */
+// Helper method for extending one object with another.
+function __extend__(a,b) {
+ for ( var i in b ) {
+ if(b.hasOwnProperty(i)){
+ var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i);
+ if ( g || s ) {
+ if ( g ) { a.__defineGetter__(i, g); }
+ if ( s ) { a.__defineSetter__(i, s); }
+ } else {
+ a[i] = b[i];
+ }
+ }
+ }
+ return a;
+}
+
+/**
+ * @author john resig
+ */
+//from jQuery
+function __setArray__( target, array ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ target.length = 0;
+ Array.prototype.push.apply( target, array );
+}
+var __addEventListener__,
+ __removeEventListener__,
+ __dispatchEvent__,
+ __captureEvent__,
+ __bubbleEvent__;
+
+(function(){
+
+var log = Envjs.logger();
+
+Envjs.once('tick', function(){
+ log = Envjs.logger('Envjs.DOM2.EventTarget').debug('available');
+});
+
+/**
+ * @name EventTarget
+ * @w3c:domlevel 2
+ * @uri -//TODO: paste dom event level 2 w3c spc uri here
+ */
+exports.EventTarget = EventTarget = function(){};
+EventTarget.prototype.addEventListener = function(type, fn, phase){
+ __addEventListener__(this, type, fn, phase);
+};
+EventTarget.prototype.removeEventListener = function(type, fn, phase){
+ __removeEventListener__(this, type, fn, phase);
+};
+EventTarget.prototype.dispatchEvent = function(event, bubbles){
+ __dispatchEvent__(this, event, bubbles);
+};
+
+__extend__(Node.prototype, EventTarget.prototype);
+
+var $events = [{}];
+
+__addEventListener__ = function(target, type, fn, phase){
+ phase = !!phase?"CAPTURING":"BUBBLING";
+ if ( !target.uuid ) {
+ target.uuid = $events.length+'';
+ log.debug('add event uuid for %s %s', target, target.uuid);
+ }
+ if ( !$events[target.uuid] ) {
+ log.debug('creating listener for target: %s %s', target, target.uuid);
+ $events[target.uuid] = {};
+ }
+ if ( !$events[target.uuid][type] ){
+ log.debug('creating listener for type: %s %s %s', target, target.uuid, type);
+ $events[target.uuid][type] = {
+ CAPTURING:[],
+ BUBBLING:[]
+ };
+ }
+ if ( $events[target.uuid][type][phase].indexOf( fn ) < 0 ){
+ log.debug( 'adding event listener %s %s %s %s', target, target.uuid, type, phase);
+ $events[target.uuid][type][phase].push( fn );
+ }
+ log.debug('registered event listeners %s', $events.length);
+};
+
+__removeEventListener__ = function(target, type, fn, phase){
+ phase = !!phase?"CAPTURING":"BUBBLING";
+ if ( !target.uuid ) {
+ log.debug('target has never had registered events %s', target);
+ return;
+ }
+ if ( !$events[target.uuid] ) {
+ log.debug('target has no registered events to remove %s %s', target, target.uuid);
+ return;
+ }
+ if(type == '*'){
+ //used to clean all event listeners for a given node
+ log.debug('cleaning all event listeners for node %s %s',target, target.uuid);
+ delete $events[target.uuid];
+ return;
+ }else if ( !$events[target.uuid][type] ){
+ log.debug('target has no registered events of type %s to remove %s %s', type, target, target.uuid);
+ return;
+ }
+ $events[target.uuid][type][phase] =
+ $events[target.uuid][type][phase].filter(function(f){
+ log.debug('removing event listener %s %s %s %s', target, type, phase );
+ return f != fn;
+ });
+};
+
+var __eventuuid__ = 0;
+
+__dispatchEvent__ = function(target, event, bubbles){
+
+ if (!event.uuid) {
+ event.uuid = __eventuuid__++;
+ }
+ //the window scope defines the $event object, for IE(^^^) compatibility;
+ //$event = event;
+
+ if (bubbles === undefined || bubbles === null) {
+ bubbles = true;
+ }
+
+ if (!event.target) {
+ event.target = target;
+ }
+
+ log.debug('dispatching %s %s %s %s', event.uuid, target, event.type, bubbles);
+ if ( event.type && (target.nodeType || target === window )) {
+
+ __captureEvent__(target, event);
+
+ event.eventPhase = Event.AT_TARGET;
+ if ( target.uuid && $events[target.uuid] && $events[target.uuid][event.type] ) {
+ event.currentTarget = target;
+
+ log.debug('begin dispatching capturing phase %s %s', target, event.type);
+ $events[target.uuid][event.type].CAPTURING.forEach(