Commit f9631ad1 authored by Porter Libby's avatar Porter Libby
Browse files

update keyboard events

parent 3f4eca70
......@@ -24,7 +24,9 @@
<!-- LOCAL CSS -->
<link rel="apple-touch-icon" href="icon.png">
<link rel="stylesheet" href="public/css/keyb.css">
<link rel="stylesheet" href="public/css/main.css">
<!-- LOCAL JS -->
<script src="public/js/searchBar.js"></script>
......@@ -124,8 +126,29 @@
<script>
var parent = document.getElementById('block-1');
create_searchbar(parent,'major_selection');
if ('ontouchstart' in document.documentElement){
$("#block-1 #searchbar").keyboard({}); // create virtual keyboard if touchscreen is detected
if (!('ontouchstart' in document.documentElement)){
$("#block-1 #searchbar").keyboard({
usePreview: false,
autoAccept: true,
autoAcceptOnEsc: true,
keyBinding: 'mousedown touchstart',
accepted : function(e, keyboard, el) {
var event = new Event('input', {
bubbles: true,
cancelable: true,
});
el.dispatchEvent(event);
},
change : function(e, keyboard, el) {
var event = new Event('input', {
bubbles: true,
cancelable: true,
});
el.dispatchEvent(event);
}
}); // create virtual keyboard if touchscreen is detected
}
</script>
</div>
......
/* keyboard - jQuery UI Widget */
.ui-keyboard { padding: .3em; position: absolute; left: 0; top: 0; z-index: 16000; }
.ui-keyboard-has-focus { z-index: 16001; }
.ui-keyboard div { font-size: 1.1em; }
.ui-keyboard-button { height: 2em; min-width: 2em; margin: .1em; cursor: pointer; overflow: hidden; line-height: 2em; -moz-user-focus: ignore; }
.ui-keyboard-button span { padding: 0; margin: 0; white-space:nowrap; display: inline-block; }
.ui-keyboard-button-endrow { clear: left; }
.ui-keyboard-space { width: 15em; }
.ui-keyboard-space span, .ui-keyboard-empty span { font: 0/0 a; text-shadow: none; color: transparent; } /* see http://nicolasgallagher.com/another-css-image-replacement-technique/ */
.ui-keyboard-preview-wrapper { text-align: center; }
.ui-keyboard-preview { text-align: left; margin: 0 0 3px 0; display: inline; width: 99%;} /* width is calculated in IE, since 99% = 99% full browser width =( */
.ui-keyboard-keyset { text-align: center; white-space: nowrap; }
.ui-keyboard-input { text-align: left; }
.ui-keyboard-input-current { -moz-box-shadow: 1px 1px 10px #00f; -webkit-box-shadow: 1px 1px 10px #00f; box-shadow: 1px 1px 10px #00f; }
.ui-keyboard-placeholder { color: #888; }
.ui-keyboard-nokeyboard { color: #888; border-color: #888; } /* disabled or readonly inputs, or use input[disabled='disabled'] { color: #f00; } */
.ui-keyboard-spacer { display: inline-block; width: 1px; height: 0; cursor: default; }
.ui-keyboard-input.light, .ui-keyboard-preview.light { color: #222; background: #ddd; }
.ui-keyboard-input.dark, .ui-keyboard-preview.dark { color: #ddd; background: #222; }
/* combo key styling - toggles diacritics on/off */
.ui-keyboard-button.ui-keyboard-combo.ui-state-default { border-color: #ffaf0f; }
.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default{
color: #6f263d;
}
/* (in)valid inputs */
button.ui-keyboard-accept.ui-keyboard-valid-input { border-color: #0c0; background: #080; color: #fff; }
button.ui-keyboard-accept.ui-keyboard-valid-input:hover { background: #0a0; }
button.ui-keyboard-accept.ui-keyboard-invalid-input { border-color: #c00; background: #800; color: #fff; opacity: 0.5; filter: alpha(opacity=50); }
button.ui-keyboard-accept.ui-keyboard-invalid-input:hover { background: #a00; }
/*** Caret extension definition ***/
/* margin-top => is added to the caret height (top & bottom) */
.ui-keyboard-caret { background: #c00; width: 1px; margin-top: 3px; }
/* jQuery Mobile specific definitions
* Toggle button image definitions
* Extender button image
* Media queries can be found in the keyboard.css file,
* but are not included here
*/
\ No newline at end of file
......@@ -25,7 +25,7 @@ function create_searchbar(parent, key){
names_for_search.push(dictionary[key][x]);
}
autocomplete(document.getElementById("searchbar"), names_for_search);
autocomplete(parent.querySelector("#searchbar"), names_for_search);
}
function autocomplete(inp, arr) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment