comparison farol/templates/macros.j2 @ 44:df5182d0787f

Some macro cleanups
author Benoît Allard <benoit.allard@greenbone.net>
date Tue, 07 Oct 2014 09:45:46 +0200
parents 537d25b1593c
children 249b3ad750b1
comparison
equal deleted inserted replaced
43:c79082d0d44d 44:df5182d0787f
54 <span class="help-block">{{ help }}</span> 54 <span class="help-block">{{ help }}</span>
55 {% endif %} 55 {% endif %}
56 </div> 56 </div>
57 {% endmacro %} 57 {% endmacro %}
58 58
59 {% macro modal(id, title, size=None) %}
60 <div class="modal fade" id="{{ id }}" tabindex="-1" role="dialog" aria-labelledby="{{ id }}_title" aria-hidden="true">
61 <div class="modal-dialog{{ ' modal-%s' % size if size}}">
62 <div class="modal-content">
63 <div class="modal-header">
64 <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
65 <h4 class="modal-title" id="{{ id }}_title">{{ title }}</h4>
66 </div>
67 <div class="modal-body">
68 {{ caller() }}
69 </div>{# We don't need a footer yet ...
70 <div class="modal-footer">
71 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
72 <button type="button" class="btn btn-primary">Save changes</button>
73 </div>#}
74 </div>{# /.modal-content #}
75 </div>{# /.modal-dialog #}
76 </div>{# /.modal #}
77 {% endmacro %}
78
79 {% macro textarea(name, label, placeholder="", value=None, rows=10, required=False) %} 59 {% macro textarea(name, label, placeholder="", value=None, rows=10, required=False) %}
80 <div class="form-group"> 60 <div class="form-group">
81 {% if caller %} 61 {% if caller %}
82 {% set content=caller () %} 62 {% set content=caller () %}
83 {% call modal(name + "_modal", label) %} 63 {% call modal(name + "_modal", label) %}
130 <div class="{{ ["panel", "panel-" + type] | join(" ") }}"> 110 <div class="{{ ["panel", "panel-" + type] | join(" ") }}">
131 {% if heading %} 111 {% if heading %}
132 <div class="panel-heading"> 112 <div class="panel-heading">
133 {%- if title %}<h{{ title }} class="panel-title">{% endif -%} 113 {%- if title %}<h{{ title }} class="panel-title">{% endif -%}
134 {%- if collapsible %}<a data-toggle="collapse" href="#{{ heading | secure_filename }}">{% endif -%} 114 {%- if collapsible %}<a data-toggle="collapse" href="#{{ heading | secure_filename }}">{% endif -%}
135 {{ heading }}{% if badge is not none %}<span class="pull-right badge">{{ badge }}</span>{% endif %} 115 {{ heading }}
116 {%- if badge is not none %}<span class="pull-right badge">{{ badge }}</span>{% endif %}
136 {%- if collapsible %}</a>{% endif -%} 117 {%- if collapsible %}</a>{% endif -%}
137 {%- if title %}</h{{ title }}>{% endif -%} 118 {%- if title %}</h{{ title }}>{% endif -%}
138 </div> 119 </div>
139 {% endif %} 120 {% endif %}
140 {% if collapsible %}<div id="{{ heading | secure_filename }}" class="panel-collapse collapse{{ ' in' if extended}}">{% endif %} 121 {% if collapsible %}<div id="{{ heading | secure_filename }}" class="panel-collapse collapse{{ ' in' if extended}}">{% endif %}
141 <div class="panel-body"> 122 <div class="panel-body">
142 {{ caller() }} 123 {{ caller() }}
143 </div> 124 </div>
144 {% if collapsible %}</div>{% endif %} 125 {% if collapsible %}</div>{% endif %}
145 </div> 126 </div>
127 {% endmacro %}
128
129 {% macro modal(id, title, size=None) %}
130 <div class="modal fade" id="{{ id }}" tabindex="-1" role="dialog" aria-labelledby="{{ id }}_title" aria-hidden="true">
131 <div class="modal-dialog{{ ' modal-%s' % size if size}}">
132 <div class="modal-content">
133 <div class="modal-header">
134 <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
135 <h4 class="modal-title" id="{{ id }}_title">{{ title }}</h4>
136 </div>
137 <div class="modal-body">
138 {{ caller() }}
139 </div>{# We don't need a footer yet ...
140 <div class="modal-footer">
141 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
142 <button type="button" class="btn btn-primary">Save changes</button>
143 </div>#}
144 </div>{# /.modal-content #}
145 </div>{# /.modal-dialog #}
146 </div>{# /.modal #}
146 {% endmacro %} 147 {% endmacro %}
147 148
148 {# This should be placed inside a .form-horizontal #} 149 {# This should be placed inside a .form-horizontal #}
149 {% macro label_value(label, value, left=2, right=10) %} 150 {% macro label_value(label, value, left=2, right=10) %}
150 <div class="form-group"> 151 <div class="form-group">
154 </div> 155 </div>
155 </div> 156 </div>
156 {% endmacro %} 157 {% endmacro %}
157 158
158 {% macro examples(list) %} 159 {% macro examples(list) %}
159 {% if False %}
160 <dl>
161 <dt>Example{{ 's' if list | length > 1 }}:</dt>
162 {% for elem in list %}
163 <dd><samp>{{ elem }}</samp></dd>
164 {% endfor %}
165 </dl>
166 {% else %}
167 <p><strong>Example{{ 's' if list | length > 1 }}:</strong></p> 160 <p><strong>Example{{ 's' if list | length > 1 }}:</strong></p>
168 {% if list | length == 1 %} 161 {% if list | length == 1 %}
169 <samp>{{ list[0] }}</samp> 162 <samp>{{ list[0] }}</samp>
170 {% else %} 163 {% else %}
171 <ul> 164 <ul>
172 {%- for elem in list %} 165 {%- for elem in list %}
173 <li><samp>{{ elem }}</samp></li> 166 <li><samp>{{ elem }}</samp></li>
174 {%- endfor %} 167 {%- endfor %}
175 </ul> 168 </ul>
176 {% endif %} 169 {% endif %}
177 {% endif %}
178 {% endmacro %} 170 {% endmacro %}

http://farol.wald.intevation.org