Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
Make software keyboard actually work on the device
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiebits committed Oct 18, 2011
1 parent 0fa9dc2 commit 6fa68b5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
5 changes: 1 addition & 4 deletions khan-exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,7 @@ Khan.loadScripts( scripts, function() {
Khan.require( [ "answer-types", "tmpl" ] );

if ( true || typeof userExercise !== "undefined" && userExercise.tablet ) {
jQuery( document ).bind( "mobileinit", function() {
jQuery.mobile.autoInitializePage = false;
} );
Khan.require( [ "jquery.mobile-1.0rc1", "software-keyboard" ] );
Khan.require( [ "software-keyboard" ] );
}

Khan.require( document.documentElement.getAttribute("data-require") );
Expand Down
30 changes: 17 additions & 13 deletions utils/software-keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ jQuery.fn["software-keyboardPost"] = function() {
var solutionarea = jQuery("#solutionarea");

var inputs = solutionarea.find( ":input" );
inputs.prop( "readonly", true ).bind( "vclick", function() {
alert("hey");
} );
inputs.prop( "readonly", true )
.css( "-webkit-tap-highlight-color", "rgba(0, 0, 0, 0)" );

var keyPressed = function( key ) {
var field = solutionarea.find( ":input" ).first();
Expand Down Expand Up @@ -41,19 +40,24 @@ jQuery.fn["software-keyboardPost"] = function() {
.appendTo( rowDiv );
var canceled = false, downTime;

keySpan.bind( "vmousemove", function() {
// Prevent weirdo scrolling
return false;
} );
keySpan.bind( "vmousecancel", function() {
keySpan.removeClass( "down" );
canceled = true;
} );
keySpan.bind( "vmousedown", function() {
var evtPrefix = "";
if ( jQuery.mobile != null ) {
evtPrefix = "v";
keySpan.bind( "vmousecancel", function() {
keySpan.removeClass( "down" );
canceled = true;
} );
keySpan.bind( "vmousemove", function() {
// Prevent weirdo scrolling
return false;
} );
}

keySpan.bind( evtPrefix + "mousedown", function() {
keySpan.addClass( "down" );
canceled = false;
} );
keySpan.bind( "vmouseup", function() {
keySpan.bind( evtPrefix + "mouseup", function() {
keySpan.removeClass( "down" );

if ( !canceled ) {
Expand Down

0 comments on commit 6fa68b5

Please sign in to comment.