forked from mootools/mootools-more
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding tests for Keyboard.
- Loading branch information
Showing
5 changed files
with
131 additions
and
68 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<style> | ||
div { | ||
border: 1px solid white; | ||
color: #fff; | ||
background: #000; | ||
} | ||
.active { | ||
border: 1px solid black; | ||
color: #000; | ||
background: #fff; | ||
} | ||
</style> | ||
|
||
<div id="sa">shift + a</div> | ||
<div id="enter">enter</div> | ||
<div id="up">up</div> | ||
<div id="ctrld">ctrl+d</div> | ||
<div id="space">space</div> | ||
<div id="escape">escape</div> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
tests: [ | ||
{ | ||
title: "Keyboard:activate", | ||
description: "Captures keyboard evnets as you type them.", | ||
verify: "Enter the keys defined in the box to make them toggle colors. Do they toggle?", | ||
before: function(){ | ||
var kb = new Keyboard({ | ||
preventDefault: true, | ||
events: { | ||
'shift+a': function(){ | ||
$('sa').toggleClass('active'); | ||
}, | ||
'enter': function(){ | ||
$('enter').toggleClass('active'); | ||
}, | ||
'up': function(){ | ||
$('up').toggleClass('active'); | ||
}, | ||
'control+d': function(){ | ||
$('ctrld').toggleClass('active'); | ||
}, | ||
'space': function(){ | ||
$('space').toggleClass('active'); | ||
}, | ||
'esc': function(){ | ||
$('escape').toggleClass('active'); | ||
} | ||
} | ||
}) | ||
$(document.body).store('kb', kb); | ||
} | ||
}, | ||
{ | ||
title: "Keyboard:deactivate", | ||
description: "Disables the keyboard set up in the previous test.", | ||
verify: "Hitting any of the keys will no longer toggle the colors. Are the keys no longer active?", | ||
before: function(){ | ||
$(document.body).retrieve('kb').deactivate(); | ||
} | ||
} | ||
|
||
] | ||
} |
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