Coverage for khufu/navigation/searchbox.py : 75%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# encoding: utf-8
2from . import *
4def searchbox(
5 size='medium',
6 htmlId="",
7 placeHolder=False,
8 button=False,
9 buttonSize='small',
10 buttonColor='grey',
11 navBar=False,
12 pull=False,
13 actionScript="#"
14):
15 """ *Create a Search box*
17 **Key Arguments**
19 - ``size`` -- size = mini | small | medium | large | xlarge | xxlarge
20 - ``htmlId`` -- the html id of the search bar
21 - ``placeholder`` -- placeholder text
22 - ``button`` -- do you want a search button?
23 - ``buttonSize``
24 - ``buttonColor``
25 - ``actionScript`` -- the script used to action the search text
28 **Return**
30 - ``markup`` -- markup for the searchbar """
33 if button:
34 button = """<button type="submit" class="btn-%(buttonSize)s btn-%(buttonColor)s">Search</button>""" % locals(
35 )
36 else:
37 button = ''
38 if placeHolder:
39 placeHolder = """placeholder="%(placeHolder)s" """ % locals()
40 else:
41 placeHolder = ''
42 if navBar:
43 navBar = 'navbar-search'
44 else:
45 navBar = ''
46 if pull:
47 pull = """pull-%(pull)s""" % locals()
48 else:
49 pull = ''
51 markup = \
52 """
53 <form class="form-search pull-right" action="%(actionScript)s">
54 <input id="%(htmlId)s" name="%(htmlId)s" type="text" class="input-%(size)s search-query %(navBar)s %(pull)s" %(placeHolder)s >
55 %(button)s
56 </form>
57 """ % locals()
58 return markup