You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
574 B
Plaintext
20 lines
574 B
Plaintext
(function($) {
|
|
$.enterfocus = function(selector, callback) {
|
|
var boxArray = [].slice.call(document.querySelectorAll(selector));
|
|
for (var index in boxArray) {
|
|
var box = boxArray[index];
|
|
box.addEventListener('keyup', function(event) {
|
|
if (event.keyCode == 13) {
|
|
var boxIndex = boxArray.indexOf(this);
|
|
if (boxIndex == boxArray.length - 1) {
|
|
if (callback) callback();
|
|
} else {
|
|
//console.log(boxIndex);
|
|
var nextBox = boxArray[++boxIndex];
|
|
nextBox.focus();
|
|
}
|
|
}
|
|
}, false);
|
|
}
|
|
};
|
|
}(window.mui = window.mui || {})); |