/library/platform/uiOpera.py
Python | 69 lines | 67 code | 1 blank | 1 comment | 0 complexity | e6fd25523433c10e66a430926d65b442 MD5 | raw file
1# FocusImplOld 2class Focus: 3 4 def blur(self, elem): 5 JS(""" 6 elem.firstChild.blur(); 7 """) 8 9 def createFocusable(self): 10 JS(""" 11 var div = $doc.createElement('div'); 12 var input = $doc.createElement('input'); 13 input.type = 'text'; 14 input.style.width = input.style.height = 0; 15 input.style.zIndex = -1; 16 input.style.position = 'absolute'; 17 18 input.addEventListener( 19 'blur', 20 function(evt) { if (this.parentNode.onblur) this.parentNode.onblur(evt); }, 21 false); 22 23 input.addEventListener( 24 'focus', 25 function(evt) { if (this.parentNode.onfocus) this.parentNode.onfocus(evt); }, 26 false); 27 28 div.addEventListener( 29 'mousedown', 30 function(evt) { this.firstChild.focus(); }, 31 false); 32 33 div.appendChild(input); 34 return div; 35 """) 36 37 def focus(self, elem): 38 JS(""" 39 elem.firstChild.focus(); 40 """) 41 42 def getTabIndex(self, elem): 43 JS(""" 44 return elem.firstChild.tabIndex; 45 """) 46 47 def setAccessKey(self, elem, key): 48 JS(""" 49 elem.firstChild.accessKey = key; 50 """) 51 52 def setTabIndex(self, elem, index): 53 JS(""" 54 elem.firstChild.tabIndex = index; 55 """) 56 57 58class FormPanel: 59 def getTextContents(self, iframe): 60 JS(""" 61 try { 62 if (!iframe.contentWindow.document) 63 return null; 64 65 return iframe.contentWindow.document.body.innerText; 66 } catch (e) { 67 return null; 68 } 69 """)