Merge pull request #10 from hermwong/master

changes for phonegap 1.0.0rc2
diff --git a/VERSION b/VERSION
index 70974c2..8862dba 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1 @@
-1.0.0rc1
-
+1.0.0rc2
diff --git a/changes.txt b/changes.txt
index 178eba1..13c628d 100644
--- a/changes.txt
+++ b/changes.txt
@@ -1,17 +1,5 @@
-Herm Wong (6):
-      added SQLite example in demo app
-      update readme to use phonegap-webos instead of phonegap-palm
-      modified so that instantiating phonegap is no longer required
-      removed unnecessary navigator.device.deviceReady call
-      remove unneccessary Mojo object check
-      updated device apis to set name and platform on device ready
-
-alunny (2):
-      fire deviceready after DOMContentLoaded
-      README updates
-
-davebalmer (3):
-      Changed DOCTYPE to HTML5
-      Added webOS 3.0 compatibility property.
-      Changed Palm to HP :)
-
+Herm Wong (4):
+	added touch events
+	updated README.md
+	phonegap-webos issue # 7
+	add the thumbs.js lib to the repo
\ No newline at end of file
diff --git a/lib/thumbs.0.5.2.js b/lib/thumbs.0.5.2.js
new file mode 100644
index 0000000..3228f84
--- /dev/null
+++ b/lib/thumbs.0.5.2.js
@@ -0,0 +1,80 @@
+(function(window) {
+
+    /**
+     * Do not use thumbs.js on touch-enabled devices
+     * 
+     * Thanks to Jesse MacFadyen (purplecabbage):
+     * https://gist.github.com/850593#gistcomment-22484
+     */
+    try {
+        document.createEvent('TouchEvent');
+        return;
+    }
+    catch(e) {
+    }
+
+    /**
+     * Map touch events to mouse events
+     */
+    var eventMap = {
+        'mousedown': 'touchstart',
+        'mouseup':   'touchend',
+        'mousemove': 'touchmove'
+    };
+
+    /**
+     * Fire touch events
+     *
+     * Monitor mouse events and fire a touch event on the
+     * object broadcasting the mouse event. This approach
+     * likely has poorer performance than hijacking addEventListener
+     * but it is a little more browser friendly.
+     */
+    window.addEventListener('load', function() {
+        for (var key in eventMap) {
+            document.body.addEventListener(key, function(e) {
+                // Supports:
+                //   - addEventListener
+                //   - setAttribute
+                var event = createTouchEvent(eventMap[e.type], e);
+                e.target.dispatchEvent(event);
+
+                // Supports:
+                //   - element.ontouchstart
+                var fn = e.target['on' + eventMap[e.type]];
+                if (typeof fn === 'function') fn(e);
+            }, false);
+        }
+    }, false);
+
+    /**
+     * Utility function to create a touch event.
+     *
+     * @param  name  {String} of the event
+     * @return event {Object}
+     */
+    var createTouchEvent = function(name, e) {
+        var event = document.createEvent('MouseEvents');
+
+        event.initMouseEvent(
+            name,
+            e.bubbles,
+            e.cancelable,
+            e.view,
+            e.detail,
+            e.screenX,
+            e.screenY,
+            e.clientX,
+            e.clientY,
+            e.ctrlKey,
+            e.altKey,
+            e.shiftKey,
+            e.metaKey,
+            e.button,
+            e.relatedTarget
+        );
+
+        return event;
+    };
+
+})(window);