Author: humbedooh
Date: Mon Feb 8 13:01:29 2016
New Revision: 1729161
URL: http://svn.apache.org/viewvc?rev=1729161&view=rev
Log:
attempt at a touch handler for tablets
Modified:
steve/trunk/pysteve/www/htdocs/js/steve_stv.js
Modified: steve/trunk/pysteve/www/htdocs/js/steve_stv.js
URL:
http://svn.apache.org/viewvc/steve/trunk/pysteve/www/htdocs/js/steve_stv.js?rev=1729161&r1=1729160&r2=1729161&view=diff
==============================================================================
--- steve/trunk/pysteve/www/htdocs/js/steve_stv.js (original)
+++ steve/trunk/pysteve/www/htdocs/js/steve_stv.js Mon Feb 8 13:01:29 2016
@@ -535,6 +535,7 @@ function loadIssue(election, issue, uid,
}
function displayIssueSTV(code, response, state) {
+ initTouch()
chars =
['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
// Corresponding STV letters, in same order as nominees
election_data = response
if (code != 200) {
@@ -662,3 +663,27 @@ function castVotesCallback(code, respons
}
}
+
+function touchHandler(event) {
+ var touch = event.changedTouches[0];
+
+ var simEvent = document.createEvent("MouseEvent");
+ simEvent.initMouseEvent({
+ touchstart: "mousedown",
+ touchmove: "mousemove",
+ touchend: "mouseup"
+ }[event.type], true, true, window, 1,
+ touch.screenX, touch.screenY,
+ touch.clientX, touch.clientY, false,
+ false, false, false, 0, null);
+
+ touch.target.dispatchEvent(simEvent);
+ event.preventDefault();
+}
+
+function initTouch() {
+ document.addEventListener("touchstart", touchHandler, true);
+ document.addEventListener("touchmove", touchHandler, true);
+ document.addEventListener("touchend", touchHandler, true);
+ document.addEventListener("touchcancel", touchHandler, true);
+}
\ No newline at end of file