1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 ======================
19 HTML form processors
20 ======================
21
22 HTML form processors.
23 """
24 __author__ = u"Andr\xe9 Malo"
25 __docformat__ = "restructuredtext en"
26 __all__ = ['TabIndexer']
27
28 import itertools as _it
29
30 from tdi.tools.htmlform._interfaces import PostProcInterface
31
32
34 """
35 Automatic tabindex filler to be used as `HTMLForm` post processor
36
37 :IVariables:
38 `next_index` : ``callable``
39 Function to deliver the next index
40 """
41 __implements__ = [PostProcInterface]
42
44 """
45 Initialization
46
47 :Parameters:
48 `start` : ``int``
49 Tabindex to start with
50 """
51 self.next_index = _it.count(start).next
52
53 - def __call__(self, method, node, kwargs):
54 """
55 Add tabindex to form elements
56
57 Exceptions: ``<form>``, ``<option>``, ``<datalist>``,
58 ``<input type="hidden">``
59
60 :See: `PostProcInterface`
61 """
62 if method not in ('form', 'option', 'hidden', 'datalist'):
63 node['tabindex'] = self.next_index()
64