1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>What Input?</title>
<link
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"
rel="stylesheet">
<style>
.test-row {
margin-top: 50px;
}
input[type='text'],
input[type='password'] {
font-size: 16px;
}
/* indicator */
.input-display {
border-radius: 3px;
display: inline-block;
padding: 0 3px;
-webkit-transition: all 200ms;
transition: all 200ms;
}
[data-whatinput='mouse'] .-mouse {
background-color: #d9edf7;
color: #31708f;
}
[data-whatinput='keyboard'] .-keyboard {
background-color: #dff0d8;
color: #3c763d;
}
[data-whatinput='touch'] .-touch {
background-color: #fcf8e3;
color: #8a6d3b;
}
/* links */
a:focus {
position: relative;
z-index: 1;
}
[data-whatinput='keyboard'] a:focus {
box-shadow: 0 0 8px 2px rgba(60, 118, 61, 0.6);
outline: 2px solid #3c763d;
}
/* form controls */
[data-whatinput='mouse'] .form-control:focus {
border-color: #31708f;
outline: 0;
box-shadow:
inset 0 1px 1px rgba(0, 0, 0, .075),
0 0 8px rgba(49, 112, 143, 0.6);
}
[data-whatinput='keyboard'] .form-control:focus {
border-color: #3c763d;
outline: 0;
box-shadow:
inset 0 1px 1px rgba(0, 0, 0, .075),
0 0 8px rgba(60, 118, 61, 0.6);
}
[data-whatinput='touch'] .form-control:focus {
border-color: #8a6d3b;
outline: 0;
box-shadow:
inset 0 1px 1px rgba(0, 0, 0, .075),
0 0 8px rgba(138, 109, 59, 0.6);
}
</style>
<!--[if lte IE 8]>
<script src="lte-IE8.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="page-header">
<h1>What Input?</h1>
</div>
<p class="lead">A global utility for tracking the current input method (<span class="input-display -mouse">mouse</span>, <span class="input-display -keyboard">keyboard</span> or <span class="input-display -touch">touch</span>).</p>
<p>Tab, click or tap the links and form controls to see how What Input allows them to be styled differently.</p>
<div class="well test-row">
<div class="row">
<div class="col-md-6">
<div class="list-group">
<a class="list-group-item" href="#">Cras justo odio</a>
<a class="list-group-item" href="#">Dapibus ac facilisis in</a>
<a class="list-group-item" href="#">Morbi leo risus</a>
<a class="list-group-item" href="#">Porta ac consectetur ac</a>
<a class="list-group-item" href="#">Vestibulum at eros</a>
</div>
</div>
<div class="col-md-6">
<form>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="checkbox">
<label>
<input type="checkbox"> Check me out
</label>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</div>
</div>
<footer>
<p>Made with ♥ at <a href="http://viget.com/">Viget</a>.</p>
</footer>
</div>
<script src="dist/what-input.js"></script>
<script>
if ('addEventListener' in window && Array.prototype.indexOf) {
var link = document.querySelectorAll('a[href="#"]');
for (var i = 0, len = link.length; i < len; i++) {
link[i].addEventListener('keyup', function(event) {
if (whatInput.keys().length) console.log( '[test script] ' + whatInput.keys() );
});
link[i].addEventListener('click', function(event) {
event.preventDefault();
console.log( '[test script] ' + whatInput.ask() );
});
}
}
</script>
</body>
</html>
|