1
2 r"""
3 :Copyright:
4
5 Copyright 2007 - 2015
6 Andr\xe9 Malo or his licensors, as applicable
7
8 :License:
9
10 Licensed under the Apache License, Version 2.0 (the "License");
11 you may not use this file except in compliance with the License.
12 You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
21
22 ======================
23 HTML form processors
24 ======================
25
26 HTML form processors.
27 """
28 if __doc__:
29
30 __doc__ = __doc__.encode('ascii').decode('unicode_escape')
31 __author__ = r"Andr\xe9 Malo".encode('ascii').decode('unicode_escape')
32 __docformat__ = "restructuredtext en"
33 __all__ = ['TabIndexer']
34
35 import itertools as _it
36
37 from . import _interfaces
38
39
41 """
42 Automatic tabindex filler to be used as `HTMLForm` post processor
43
44 :IVariables:
45 `next_index` : ``callable``
46 Function to deliver the next index
47 """
48 __implements__ = [_interfaces.PostProcInterface]
49
51 """
52 Initialization
53
54 :Parameters:
55 `start` : ``int``
56 Tabindex to start with
57 """
58 self.next_index = _it.count(start).next
59
60 - def __call__(self, method, node, kwargs):
61 """
62 Add tabindex to form elements
63
64 Exceptions: ``<form>``, ``<option>``, ``<datalist>``,
65 ``<input type="hidden">``
66
67 :See: `PostProcInterface`
68 """
69 if method not in ('form', 'option', 'hidden', 'datalist'):
70 node['tabindex'] = self.next_index()
71