PageRenderTime 72ms CodeModel.GetById 36ms app.highlight 6ms RepoModel.GetById 17ms 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
 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        """)