Skip to content
This repository
  • 7 commits
  • 5 files changed
  • 0 comments
  • 2 contributors
94  css/khan-exercise.css
@@ -236,18 +236,19 @@ div.timeline-total {
236 236
 
237 237
 .lite #streak-bar-container {
238 238
 	position: absolute;
239  
-	top: 10px;
  239
+	top: 7px;
240 240
 	left: 15px;
241 241
 }
242 242
 
243 243
 .lite #answercontent {
244 244
 	position: absolute;
245 245
 	right: 5px;
246  
-	top: 12px;
  246
+	top: 7px;
247 247
 	padding: 0px;
248 248
 	border: none;
249 249
 	-webkit-box-shadow: none;
250 250
 	overflow: visible;
  251
+	text-align: right;
251 252
 }
252 253
 
253 254
 .lite #answercontent > * {
@@ -281,15 +282,44 @@ div.timeline-total {
281 282
 	font-family: inherit;
282 283
 }
283 284
 
284  
-.lite #solutionarea input {
285  
-	font-size: 14px;
  285
+@-webkit-keyframes pulse {
  286
+	0% {
  287
+		-webkit-box-shadow: 0 0 12px rgba(137, 185, 8, .2);
  288
+	}
  289
+	50% {
  290
+		-webkit-box-shadow: 0 0 12px rgba(137, 185, 8, 0.9);
  291
+	}
  292
+	100% {
  293
+		-webkit-box-shadow: 0 0 12px rgba(137, 185, 8, .2);
  294
+	}
  295
+}
  296
+
  297
+.lite #solutionarea input.number {
  298
+	font-size: 16px;
  299
+	text-align: right;
  300
+	
  301
+	-webkit-animation-name: pulse;
  302
+	-webkit-animation-duration: 1.5s;
  303
+	-webkit-animation-iteration-count: infinite;
  304
+	-webkit-animation-timing-function: ease-in-out;
  305
+	-webkit-box-shadow: none;
  306
+	-moz-box-shadow: none;
  307
+	box-shadow: none;
286 308
 }
287 309
 
288 310
 .lite #answercontent .simple-button {
289  
-	margin-top: -5px;
290 311
 	color: #fff !important;
291 312
 	font-size: 14px;
292 313
 	text-shadow: none;
  314
+	clear: left;
  315
+	margin: 0 auto;
  316
+	display: none;
  317
+}
  318
+
  319
+.lite .single-exercise .unit-rating li.current-rating {
  320
+	top: 2px;
  321
+	left: 2px;
  322
+	height: 22px;
293 323
 }
294 324
 
295 325
 #warning-bar {
@@ -411,3 +441,57 @@ div.timeline-total {
411 441
   text-decoration: none;
412 442
   font-size: 11px;
413 443
 }
  444
+
  445
+#software-keyboard {
  446
+  width: 186px;
  447
+  font-size: 26px;
  448
+  position: fixed;
  449
+  right: 10px;
  450
+  top: 90px;
  451
+  border: 5px solid #000;
  452
+  background: #000;
  453
+  -moz-border-radius: 8px;
  454
+  -webkit-border-radius: 8px;
  455
+  border-radius: 8px;
  456
+  -webkit-box-shadow: 0 0 8px rgba(0, 0, 0, 1);
  457
+}
  458
+
  459
+#software-keyboard .triangle {
  460
+  position: absolute;
  461
+  top: -22px;
  462
+  right: 0px;
  463
+  font-size: 0px;
  464
+  line-height: 0%;
  465
+  width: 0px;
  466
+  border-top: 10px solid rgba(0,0,0,0);
  467
+  border-left: 10px solid rgba(0,0,0,0);
  468
+  border-right: 10px solid rgba(0,0,0,0);
  469
+  border-bottom: 10px solid black;
  470
+}
  471
+
  472
+#software-keyboard .key {
  473
+  text-align: center;
  474
+  width: 60px;
  475
+  line-height: 30px;
  476
+  display: inline-block;
  477
+  margin: 0;
  478
+}
  479
+
  480
+#software-keyboard .key-bs {
  481
+	height: 42px;
  482
+}
  483
+
  484
+#software-keyboard .key-bs .ui-icon {
  485
+	margin: 4px auto;
  486
+	position: relative;
  487
+	top: -28px;
  488
+}
  489
+
  490
+#software-keyboard .simple-button {
  491
+	font-size: 16px;
  492
+	width: 100%;
  493
+}
  494
+
  495
+#software-keyboard #next-question-button {
  496
+	font-size: 14px;
  497
+}
14  khan-exercise.js
@@ -525,6 +525,10 @@ Khan.loadScripts( scripts, function() {
525 525
 	// Base modules required for every problem
526 526
 	Khan.require( [ "answer-types", "tmpl" ] );
527 527
 
  528
+	if ( true || typeof userExercise !== "undefined" && userExercise.tablet ) {
  529
+		Khan.require( [ "software-keyboard" ] );
  530
+	}
  531
+
528 532
 	Khan.require( document.documentElement.getAttribute("data-require") );
529 533
 
530 534
 	if ( typeof userExercise !== "undefined" ) {
@@ -866,14 +870,16 @@ function makeProblem( id, seed ) {
866 870
 	solution.remove();
867 871
 	choices.remove();
868 872
 
869  
-	// Add the problem into the page
870  
-	jQuery( "#workarea" ).toggle( workAreaWasVisible ).fadeIn();
871  
-	Khan.scratchpad.resize();
872  
-
873 873
 	// Enable the all answer input elements except the check answer button.
874 874
 	jQuery( "#answercontent input" ).not( '#check-answer-button' )
875 875
 		.removeAttr( "disabled" );
876 876
 
  877
+	problem.runModules( problem, "Post" );
  878
+
  879
+	// Add the problem into the page
  880
+	jQuery( "#workarea" ).toggle( workAreaWasVisible ).fadeIn();
  881
+	Khan.scratchpad.resize();
  882
+
877 883
 	// Only enable the check answer button if we are not still waiting for
878 884
 	// server acknowledgement of the previous problem.
879 885
 	if ( !jQuery("#throbber").is(':visible') ) {
2  utils/answer-types.js
@@ -392,7 +392,7 @@ jQuery.extend( Khan.answerTypes, {
392 392
 		var input;
393 393
 		
394 394
 		if ( typeof userExercise !== "undefined" && userExercise.tablet ) {
395  
-			input = jQuery("<input type='number'/>");
  395
+			input = jQuery("<input type='text' class='number'/>");
396 396
 		}
397 397
 
398 398
 		return Khan.answerTypes.text( solutionarea, solution, fallback, verifier, input );
6,764  utils/jquery.mobile-1.0rc1.js
6764 additions, 0 deletions not shown
80  utils/software-keyboard.js
... ...
@@ -0,0 +1,80 @@
  1
+jQuery.fn["software-keyboardPost"] = function() {
  2
+	var softwareKeyboard = jQuery( "#software-keyboard" ),
  3
+		solutionarea = jQuery( "#solutionarea" ),
  4
+		inputs = solutionarea.find( ":input" )
  5
+			.prop( "readonly", true )
  6
+			.css( "-webkit-tap-highlight-color", "rgba(0, 0, 0, 0)" ),
  7
+		field = inputs.first();
  8
+
  9
+	var keyPressed = function( key ) {
  10
+		// Normal key
  11
+		if ( key !== "bs" ) {
  12
+			field.val( field.val() + key );
  13
+		
  14
+		} else {
  15
+			// Assume for now that it is backspace
  16
+			field.val( field.val().slice( 0, -1 ) );
  17
+		}
  18
+
  19
+		return false;
  20
+	};
  21
+
  22
+	if ( !softwareKeyboard.length ) {
  23
+		softwareKeyboard = jQuery( "<div>" )
  24
+			.attr( "id", "software-keyboard" )
  25
+			.append( "<div class='triangle'></div>" )
  26
+			.prependTo( "#problemarea" );
  27
+
  28
+		var keys = [ [ "1", "2", "3" ], [ "4", "5", "6" ], [ "7", "8", "9" ], [ ".", "0", "bs" ] ];
  29
+		var corners = {
  30
+			"1": "ui-corner-tl",
  31
+			"3": "ui-corner-tr",
  32
+			".": "ui-corner-bl",
  33
+			"bs": "ui-corner-br"
  34
+		};
  35
+
  36
+		jQuery.each( keys, function( i, row ) {
  37
+			var rowDiv = jQuery( "<div>" )
  38
+				.attr( "class", "row" )
  39
+				.appendTo( softwareKeyboard );
  40
+
  41
+			jQuery.each( row, function( j, key ) {
  42
+				var keyClass = "key key-" + ( { ".": "dot" }[ key ] || key );
  43
+				var corner = corners[ key ] || "";
  44
+				var keySpan = jQuery( "<span class='ui-btn " + corner + " ui-btn-up-c'><span class='ui-btn-inner " + corner + "'>" +
  45
+				 	"<span class='ui-btn-text'>" + (key === "bs" ? "&nbsp;" : key) + "</span>" +
  46
+					(key === "bs" ? "<span class='ui-icon ui-icon-back ui-icon-shadow'></span>" : "") + "</span></span>" )
  47
+					.addClass( keyClass )
  48
+					.appendTo( rowDiv );
  49
+				var canceled = false, downTime;
  50
+
  51
+				var evtPrefix = "";
  52
+				if ( jQuery.mobile != null ) {
  53
+					evtPrefix = "v";
  54
+					keySpan.bind( "vmousecancel", function() {
  55
+						keySpan.removeClass( "ui-btn-down-c" );
  56
+						canceled = true;
  57
+					} );
  58
+					keySpan.bind( "vmousemove", function() {
  59
+						// Prevent weirdo scrolling
  60
+						return false;
  61
+					} );
  62
+				}
  63
+
  64
+				keySpan.bind( evtPrefix + "mousedown", function() {
  65
+					keySpan.addClass( "ui-btn-down-c" );
  66
+					canceled = false;
  67
+				} );
  68
+				keySpan.bind( evtPrefix + "mouseup", function() {
  69
+					keySpan.removeClass( "ui-btn-down-c" );
  70
+
  71
+					if ( !canceled ) {
  72
+						return keyPressed( key );
  73
+					}
  74
+				} );
  75
+			} );
  76
+		} );
  77
+		
  78
+		jQuery( "#answercontent .simple-button" ).appendTo( softwareKeyboard );
  79
+	}
  80
+};

No commit comments for this range

Something went wrong with that request. Please try again.