commit:750cea86562f23ff138a663a0b945f89a4108622
author:Chip Black
committer:Chip Black
date:Sat Dec 5 19:27:14 2009 -0600
parents:be2b2f1a9583a8d0874de5bfde8d9b0ab67d964a
Add Bytex64.DOM
diff --git a/Bytex64.DOM.js b/Bytex64.DOM.js
line changes: +40/-0
index 0000000..97032f6
--- /dev/null
+++ b/Bytex64.DOM.js
@@ -0,0 +1,40 @@
+if (typeof(Bytex64) == 'undefined') Bytex64 = {};
+Bytex64.DOM = {};
+Bytex64.DOM.version = 1.0;
+
+// Quick Element
+Bytex64.DOM.qe = function(name, attrs) {
+    var e = document.createElement(name);
+
+    for (i in attrs)
+        e[i] = attrs[i];
+
+    return e;
+}
+
+// Shims for IE retardedness
+Bytex64.DOM.addEventListener = function(elem, etype, func) {
+    if (elem.addEventListener) {
+        elem.addEventListener(etype, func, false);
+    } else if (elem.attachEvent) {
+        elem.attachEvent("on" + etype, func);
+    }
+}
+
+Bytex64.DOM.removeEventListener = function(elem, etype, func) {
+    if (elem.removeEventListener) {
+        elem.removeEventListener(etype, func, false);
+    } else if (elem.detachEvent) {
+        elem.detachEvent("on" + etype, func);
+    }
+}
+
+Bytex64.DOM.preventDefault = function(e) {
+    if (e.preventDefault) {
+        e.preventDefault();
+    } else if (e.returnValue) {
+        e.returnValue = false;
+    }
+}
+
+/* vim: set ts=4 sts=4 sw=4 expandtab: */

diff --git a/demo.html b/demo.html
line changes: +22/-0
index 0000000..625e40e
--- /dev/null
+++ b/demo.html
@@ -0,0 +1,22 @@
+<html>
+<head>
+<title>Bytex64.js demo</title>
+<script type="text/javascript" src="Bytex64.DOM.js"></script>
+</head>
+<body>
+
+<h1>Bytex64.DOM</h1>
+
+<script type="text/javascript">
+function createButton() {
+	container = document.getElementById('buttoncontainer');
+	button = Bytex64.DOM.qe('button', {onclick: 'createButton()'});
+	button.appendChild(document.createTextNode('click'));
+	container.appendChild(button);
+}
+</script>
+
+<div id="buttoncontainer"><button onclick="createButton()">click</button></div>
+
+</body>
+</html>

diff --git a/doc/Bytex64.DOM.frag b/doc/Bytex64.DOM.frag
line changes: +61/-0
index 0000000..f9eab6f
--- /dev/null
+++ b/doc/Bytex64.DOM.frag
@@ -0,0 +1,61 @@
+$TITLE = 'Bytex64.DOM';
+
+$CONTENT = <<'EOD';
+<h2>Concepts</h2>
+
+<p>The Bytex64.DOM library provides simple routines to create and
+manipulate DOM elements.  In particular, it provides a quick element
+creation function, and provides functions that shim "missing"
+functionality in Internet Explorer.  Those who want to get started
+should skip to the Class Variables section; the rest of this is a rant
+against IE developers.
+
+<p>Modern Internet Explorer has shaped up quite nicely.  In standards
+mode, it supports CSS in a sane way that no longer requires box model
+hacks.  Its DOM support is now quite good, except for one niggling
+little bit: <a
+href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/">DOM
+Level 2 Events</a>.
+
+<p>For some unfathomable reason, the IE devs have decided to stick with
+their DHTML events API even though DOM L2 Events has been a W3C
+Specification (i.e., not a draft or work-in-progress) since the turn of
+the century.  Because of this continued incompatibility, web devs are
+forced to work around it.  This module contains my workarounds, which
+mimic the W3C API but internally call IE-specific event model functions
+on IE.
+
+<h2>Class Variables</h2>
+
+<dd>
+  <dt>Bytex64.DOM.version</dt>
+  <dd>The version of the library, in case you want to check for a
+  specific version</dd>
+</dd>
+
+<h2>Global Functions</h2>
+
+<dl>
+  <dt>Bytex64.DOM.qe(name, attrs)</dt>
+  <dd>Creates a DOM element with the given name and attributes.
+  <code>Attrs</code> is an object with key/value pairs for the object's
+  attributes.</dd>
+
+  <dt>Bytex64.DOM.addEventListener(elem, etype, func)</dt>
+  <dd>Like the W3C DOM function of the same name, attaches an event
+  listener for the event <code>etype</code> to the element
+  <code>elem</code>.  <code>Func</code> is the function to run when the
+  event fires.</dd>
+
+  <dt>Bytex64.DOM.removeEventListener(elem, etype, func)</dt>
+  <dd>The reverse of addEventListener; removes the given listener.</dd>
+
+  <dt>Bytex64.DOM.preventDefault(e)</dt>
+  <dd>Like the W3C DOM function of the same name, prevents the default
+  action from occurring when the event is done processing.
+  <code>E</code> is the event object currently being handled.  This can
+  be used, for example, to prevent links from being followed after they
+  are clicked.</dd>
+</dl>
+
+EOD

diff --git a/doc/Bytex64.DOM.html b/doc/Bytex64.DOM.html
line changes: +68/-0
index 0000000..707189f
--- /dev/null
+++ b/doc/Bytex64.DOM.html
@@ -0,0 +1,68 @@
+<html>
+<head>
+<title>Bytex64.DOM</title>
+<link rel="stylesheet" href="doc.css">
+</head>
+<body>
+<h1>Bytex64.DOM</h1>
+
+<h2>Concepts</h2>
+
+<p>The Bytex64.DOM library provides simple routines to create and
+manipulate DOM elements.  In particular, it provides a quick element
+creation function, and provides functions that shim "missing"
+functionality in Internet Explorer.  Those who want to get started
+should skip to the Class Variables section; the rest of this is a rant
+against IE developers.
+
+<p>Modern Internet Explorer has shaped up quite nicely.  In standards
+mode, it supports CSS in a sane way that no longer requires box model
+hacks.  Its DOM support is now quite good, except for one niggling
+little bit: <a
+href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/">DOM
+Level 2 Events</a>.
+
+<p>For some unfathomable reason, the IE devs have decided to stick with
+their DHTML events API even though DOM L2 Events has been a W3C
+Specification (i.e., not a draft or work-in-progress) since the turn of
+the century.  Because of this continued incompatibility, web devs are
+forced to work around it.  This module contains my workarounds, which
+mimic the W3C API but internally call IE-specific event model functions
+on IE.
+
+<h2>Class Variables</h2>
+
+<dd>
+  <dt>Bytex64.DOM.version</dt>
+  <dd>The version of the library, in case you want to check for a
+  specific version</dd>
+</dd>
+
+<h2>Global Functions</h2>
+
+<dl>
+  <dt>Bytex64.DOM.qe(name, attrs)</dt>
+  <dd>Creates a DOM element with the given name and attributes.
+  <code>Attrs</code> is an object with key/value pairs for the object's
+  attributes.</dd>
+
+  <dt>Bytex64.DOM.addEventListener(elem, etype, func)</dt>
+  <dd>Like the W3C DOM function of the same name, attaches an event
+  listener for the event <code>etype</code> to the element
+  <code>elem</code>.  <code>Func</code> is the function to run when the
+  event fires.</dd>
+
+  <dt>Bytex64.DOM.removeEventListener(elem, etype, func)</dt>
+  <dd>The reverse of addEventListener; removes the given listener.</dd>
+
+  <dt>Bytex64.DOM.preventDefault(e)</dt>
+  <dd>Like the W3C DOM function of the same name, prevents the default
+  action from occurring when the event is done processing.
+  <code>E</code> is the event object currently being handled.  This can
+  be used, for example, to prevent links from being followed after they
+  are clicked.</dd>
+</dl>
+
+
+</body>
+</html>

diff --git a/doc/Makefile b/doc/Makefile
line changes: +1/-1
index 172c3b6..491b187
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -1,4 +1,4 @@
-DOCS = Bytex64.FX
+DOCS = Bytex64.FX Bytex64.DOM
 
 all: $(addsuffix .html,$(DOCS))