PageRenderTime 18ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/library/platform/uiOpera.py

http://pyjamas.googlecode.com/
Python | 69 lines | 67 code | 1 blank | 1 comment | 0 complexity | e6fd25523433c10e66a430926d65b442 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. """)
  46. class FormPanel:
  47. def getTextContents(self, iframe):
  48. JS("""
  49. try {
  50. if (!iframe.contentWindow.document)
  51. return null;
  52. return iframe.contentWindow.document.body.innerText;
  53. } catch (e) {
  54. return null;
  55. }
  56. """)