PageRenderTime 28ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 1ms

/library/platform/uiOldMoz.py

http://pyjamas.googlecode.com/
Python | 55 lines | 53 code | 1 blank | 1 comment | 0 complexity | 2e26bc45c3ef1da67bebb406fe516781 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. # FocusImplOld
  2. class Focus:
  3. def blur(self, elem):
  4. JS("""
  5. elem.firstChild.blur();
  6. """)
  7. def createFocusable(self):
  8. JS("""
  9. var div = $doc.createElement('div');
  10. var input = $doc.createElement('input');
  11. input.type = 'text';
  12. input.style.width = input.style.height = 0;
  13. input.style.zIndex = -1;
  14. input.style.position = 'absolute';
  15. input.addEventListener(
  16. 'blur',
  17. function(evt) { if (this.parentNode.onblur) this.parentNode.onblur(evt); },
  18. false);
  19. input.addEventListener(
  20. 'focus',
  21. function(evt) { if (this.parentNode.onfocus) this.parentNode.onfocus(evt); },
  22. false);
  23. div.addEventListener(
  24. 'mousedown',
  25. function(evt) { this.firstChild.focus(); },
  26. false);
  27. div.appendChild(input);
  28. return div;
  29. """)
  30. def focus(self, elem):
  31. JS("""
  32. elem.firstChild.focus();
  33. """)
  34. def getTabIndex(self, elem):
  35. JS("""
  36. return elem.firstChild.tabIndex;
  37. """)
  38. def setAccessKey(self, elem, key):
  39. JS("""
  40. elem.firstChild.accessKey = key;
  41. """)
  42. def setTabIndex(self, elem, index):
  43. JS("""
  44. elem.firstChild.tabIndex = index;
  45. """)