/library/platform/uiOpera.py
Python | 69 lines | 67 code | 1 blank | 1 comment | 0 complexity | e6fd25523433c10e66a430926d65b442 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
- # FocusImplOld
- class Focus:
- def blur(self, elem):
- JS("""
- elem.firstChild.blur();
- """)
-
- def createFocusable(self):
- JS("""
- var div = $doc.createElement('div');
- var input = $doc.createElement('input');
- input.type = 'text';
- input.style.width = input.style.height = 0;
- input.style.zIndex = -1;
- input.style.position = 'absolute';
- input.addEventListener(
- 'blur',
- function(evt) { if (this.parentNode.onblur) this.parentNode.onblur(evt); },
- false);
- input.addEventListener(
- 'focus',
- function(evt) { if (this.parentNode.onfocus) this.parentNode.onfocus(evt); },
- false);
- div.addEventListener(
- 'mousedown',
- function(evt) { this.firstChild.focus(); },
- false);
-
- div.appendChild(input);
- return div;
- """)
- def focus(self, elem):
- JS("""
- elem.firstChild.focus();
- """)
-
- def getTabIndex(self, elem):
- JS("""
- return elem.firstChild.tabIndex;
- """)
-
- def setAccessKey(self, elem, key):
- JS("""
- elem.firstChild.accessKey = key;
- """)
-
- def setTabIndex(self, elem, index):
- JS("""
- elem.firstChild.tabIndex = index;
- """)
- class FormPanel:
- def getTextContents(self, iframe):
- JS("""
- try {
- if (!iframe.contentWindow.document)
- return null;
-
- return iframe.contentWindow.document.body.innerText;
- } catch (e) {
- return null;
- }
- """)