Created
March 20, 2012 20:19
-
-
Save SchizoDuckie/2140878 to your computer and use it in GitHub Desktop.
Cloud9 IDE Touch Enabler Monkeypatch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A proof of concept monkeypatch to make Cloud9 IDE work on a tablet. | |
* Since i'm an extremely lazy bastard I prepended this snippet directly in package/client/js/apf_release.js | |
* | |
* What does it do? | |
* - It fires a doubleclick for a 2-finger tap | |
* - It fires a mousewheel up / down event for a 2-finger swipe up / down. | |
* | |
* How does it work? | |
* Prepend the functions below to <cloud9>/package/client/js/apf_release.js, save, load in tablet. | |
* - 2-finger tap a file to open it from the tree | |
* - 2-finger swipe up/down to scroll up/down | |
* | |
* Why 2-finger events? | |
* - I Didn't want to mess with any existing bindings. | |
* | |
* Tested on Galaxy Tab 10.1 | |
*/ | |
var startY = 0; // for filtering small movements | |
// fire doubleclick event for 2 finger touches | |
document.body.addEventListener('touchstart', function(e) { | |
var touch = e.touches[0]; | |
if ( !touch || e.touches.length < 2) return; | |
startY = touch.clientY; | |
var me = document.createEvent("MouseEvents"); | |
me.initMouseEvent('dblclick', true, true, window, 1, touch.clientY, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, e.target ); | |
touch.target.dispatchEvent(me); | |
},false); | |
// fire mousewheel events for swipe up/down | |
document.body.addEventListener('touchmove', function(e) { | |
var touch = e.touches[0]; | |
if ( !touch || e.touches.length < 2 || Math.abs(touch.clientY - startY) < 10) return; // filter small movement | |
var direction = (touch.clientY - startY) > 0 ? 'up': 'down', | |
me = document.createEvent("MouseEvents"), | |
wheelData = (direction == 'up') ? 10 : -10; | |
me.initMouseEvent("mousewheel", true, true, window, wheelData, 0, 0, 0, 0, false, false, false, false, 0, touch.target ); | |
touch.target.dispatchEvent(me); | |
}, false); | |
Fantastic work! Any interested in tests from an iPad?
Might also be worth making this available as an extension https://github.com/ajaxorg/cloud9/wiki/List-of-3rd-party-extensions
Two years later and they still haven't made this a standard feature. And the code (assuming it still works the way it is here, or with something just as simple) is right here.
How can you be SO CLOSE to an implementation of functionality on a completely new device and yet not actually take the little leap to get there?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just started using cloud 9, how should I set this up?