You can not 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

  1. (function($) {
  2. $.enterfocus = function(selector, callback) {
  3. var boxArray = [].slice.call(document.querySelectorAll(selector));
  4. for (var index in boxArray) {
  5. var box = boxArray[index];
  6. box.addEventListener('keyup', function(event) {
  7. if (event.keyCode == 13) {
  8. var boxIndex = boxArray.indexOf(this);
  9. if (boxIndex == boxArray.length - 1) {
  10. if (callback) callback();
  11. } else {
  12. //console.log(boxIndex);
  13. var nextBox = boxArray[++boxIndex];
  14. nextBox.focus();
  15. }
  16. }
  17. }, false);
  18. }
  19. };
  20. }(window.mui = window.mui || {}));