author | Julien Cristau <julien.cristau@logilab.fr> |
Thu, 12 Dec 2013 16:18:58 +0100 | |
changeset 9371 | 1348202527a6 |
parent 6140 | 65a619eb31c4 |
child 10907 | 9ae707db5265 |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
6140
65a619eb31c4
[boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6048
diff
changeset
|
18 |
"""helper classes to generate simple (X)HTML tags""" |
980
59552ba2015f
more tags, map klass -> class avoiding needs to use **dict
sylvain.thenault@logilab.fr
parents:
909
diff
changeset
|
19 |
|
59552ba2015f
more tags, map klass -> class avoiding needs to use **dict
sylvain.thenault@logilab.fr
parents:
909
diff
changeset
|
20 |
__docformat__ = "restructuredtext en" |
59552ba2015f
more tags, map klass -> class avoiding needs to use **dict
sylvain.thenault@logilab.fr
parents:
909
diff
changeset
|
21 |
|
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3847
diff
changeset
|
22 |
from cubicweb.uilib import simple_sgml_tag, sgml_attributes |
980
59552ba2015f
more tags, map klass -> class avoiding needs to use **dict
sylvain.thenault@logilab.fr
parents:
909
diff
changeset
|
23 |
|
845 | 24 |
class tag(object): |
1623 | 25 |
def __init__(self, name, escapecontent=True): |
845 | 26 |
self.name = name |
1623 | 27 |
self.escapecontent = escapecontent |
28 |
||
845 | 29 |
def __call__(self, __content=None, **attrs): |
1623 | 30 |
attrs.setdefault('escapecontent', self.escapecontent) |
845 | 31 |
return simple_sgml_tag(self.name, __content, **attrs) |
32 |
||
3803
414bb8439002
[web ui] decorate form buttons with icons (at last)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2517
diff
changeset
|
33 |
button = tag('button') |
845 | 34 |
input = tag('input') |
35 |
textarea = tag('textarea') |
|
36 |
a = tag('a') |
|
37 |
span = tag('span') |
|
1623 | 38 |
div = tag('div', False) |
845 | 39 |
img = tag('img') |
846 | 40 |
label = tag('label') |
895
e78ae38506db
select tag now accepts a multiple argument
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
861
diff
changeset
|
41 |
option = tag('option') |
980
59552ba2015f
more tags, map klass -> class avoiding needs to use **dict
sylvain.thenault@logilab.fr
parents:
909
diff
changeset
|
42 |
h1 = tag('h1') |
59552ba2015f
more tags, map klass -> class avoiding needs to use **dict
sylvain.thenault@logilab.fr
parents:
909
diff
changeset
|
43 |
h2 = tag('h2') |
59552ba2015f
more tags, map klass -> class avoiding needs to use **dict
sylvain.thenault@logilab.fr
parents:
909
diff
changeset
|
44 |
h3 = tag('h3') |
59552ba2015f
more tags, map klass -> class avoiding needs to use **dict
sylvain.thenault@logilab.fr
parents:
909
diff
changeset
|
45 |
h4 = tag('h4') |
59552ba2015f
more tags, map klass -> class avoiding needs to use **dict
sylvain.thenault@logilab.fr
parents:
909
diff
changeset
|
46 |
h5 = tag('h5') |
3847
7cf2b338a8e7
[common] add tr, th and td tags
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3803
diff
changeset
|
47 |
tr = tag('tr') |
7cf2b338a8e7
[common] add tr, th and td tags
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3803
diff
changeset
|
48 |
th = tag('th') |
7cf2b338a8e7
[common] add tr, th and td tags
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3803
diff
changeset
|
49 |
td = tag('td') |
6048
4695b1ee58a0
fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5424
diff
changeset
|
50 |
iframe = tag('iframe') |
861
7985b5db2284
provide a mini HTML select tag constructor
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
846
diff
changeset
|
51 |
|
1054 | 52 |
def select(name, id=None, multiple=False, options=[], **attrs): |
895
e78ae38506db
select tag now accepts a multiple argument
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
861
diff
changeset
|
53 |
if multiple: |
909
4685a8c21d73
select needs to accept an id
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
895
diff
changeset
|
54 |
attrs['multiple'] = 'multiple' |
4685a8c21d73
select needs to accept an id
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
895
diff
changeset
|
55 |
if id: |
4685a8c21d73
select needs to accept an id
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
895
diff
changeset
|
56 |
attrs['id'] = id |
1647
9936aca2453d
sort attribute for testing purpose
sylvain.thenault@logilab.fr
parents:
1623
diff
changeset
|
57 |
attrs['name'] = name |
2517
d664652b7f9c
select attributes should be escaped
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
58 |
html = [u'<select %s>' % sgml_attributes(attrs)] |
861
7985b5db2284
provide a mini HTML select tag constructor
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
846
diff
changeset
|
59 |
html += options |
7985b5db2284
provide a mini HTML select tag constructor
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
846
diff
changeset
|
60 |
html.append(u'</select>') |
7985b5db2284
provide a mini HTML select tag constructor
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
846
diff
changeset
|
61 |
return u'\n'.join(html) |
7985b5db2284
provide a mini HTML select tag constructor
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
846
diff
changeset
|
62 |