[enh] add nojs support into oscar-template

This commit is contained in:
Thomas Pointhuber 2015-01-15 15:48:50 +01:00
parent 410dbc573b
commit 5bfaabeb6b
6 changed files with 39 additions and 13 deletions

View File

@ -384,12 +384,17 @@ class Search(object):
for pd_name, pd in self.request_data.items(): for pd_name, pd in self.request_data.items():
if pd_name.startswith('category_'): if pd_name.startswith('category_'):
category = pd_name[9:] category = pd_name[9:]
# if category is not found in list, skip # if category is not found in list, skip
if category not in categories: if category not in categories:
continue continue
# add category to list if pd != 'off':
self.categories.append(category) # add category to list
self.categories.append(category)
elif category in self.categories:
# remove category from list if property is set to 'off'
self.categories.remove(category)
# if no category is specified for this search, # if no category is specified for this search,
# using user-defined default-configuration which # using user-defined default-configuration which

View File

@ -1,11 +1,14 @@
html{position:relative;min-height:100%} html{position:relative;min-height:100%}
body{margin-bottom:80px} body{margin-bottom:80px}
.footer{position:absolute;bottom:0;width:100%;height:60px} .footer{position:absolute;bottom:0;width:100%;height:60px}
input[type=checkbox]:checked~.label_hide_if_checked{display:none} input[type=checkbox]:checked+.label_hide_if_checked,input[type=checkbox]:checked+.label_hide_if_not_checked+.label_hide_if_checked{display:none}
input[type=checkbox]:not(:checked)~.label_hide_if_not_checked{display:none} input[type=checkbox]:not(:checked)+.label_hide_if_not_checked,input[type=checkbox]:not(:checked)+.label_hide_if_checked+.label_hide_if_not_checked{display:none}
.result_header{margin-bottom:5px;margin-top:20px}.result_header .favicon{margin-bottom:-3px} .result_header{margin-bottom:5px;margin-top:20px}
.result_header a{vertical-align:bottom}.result_header a .highlight{font-weight:bold} .result_header .favicon{margin-bottom:-3px}
.result-content{margin-top:5px}.result-content .highlight{font-weight:bold} .result_header a{vertical-align:bottom}
.result_header a .highlight{font-weight:bold}
.result-content{margin-top:5px}
.result-content .highlight{font-weight:bold}
.result-default{clear:both} .result-default{clear:both}
.result-images{float:left !important} .result-images{float:left !important}
.img-thumbnail{margin:5px;max-height:128px;min-height:128px} .img-thumbnail{margin:5px;max-height:128px;min-height:128px}
@ -20,3 +23,4 @@ input[type=checkbox]:not(:checked)~.label_hide_if_not_checked{display:none}
.search_categories{margin:10px 0;text-transform:capitalize} .search_categories{margin:10px 0;text-transform:capitalize}
.cursor-text{cursor:text !important} .cursor-text{cursor:text !important}
.cursor-pointer{cursor:pointer !important} .cursor-pointer{cursor:pointer !important}

View File

@ -1,9 +1,9 @@
// Hide element if checkbox is checked // Hide element if checkbox is checked
input[type=checkbox]:checked ~ .label_hide_if_checked { input[type=checkbox]:checked + .label_hide_if_checked, input[type=checkbox]:checked + .label_hide_if_not_checked + .label_hide_if_checked {
display:none; display:none;
} }
// Hide element if checkbox is not checked // Hide element if checkbox is not checked
input[type=checkbox]:not(:checked) ~ .label_hide_if_not_checked { input[type=checkbox]:not(:checked) + .label_hide_if_not_checked, input[type=checkbox]:not(:checked) + .label_hide_if_checked + .label_hide_if_not_checked {
display:none; display:none;
} }

View File

@ -36,7 +36,8 @@
</script> </script>
<noscript> <noscript>
<style type="text/css"> <style type="text/css">
.tab-content > .active_if_nojs {display: block;} .tab-content > .active_if_nojs, .active_if_nojs {display: block;}
.margin_top_if_nojs {margin-top: 20px;}
.hide_if_nojs {display: none !important;overflow:none !important;} .hide_if_nojs {display: none !important;overflow:none !important;}
</style> </style>
</noscript> </noscript>

View File

@ -1,6 +1,22 @@
<div id="categories" class="btn-group btn-toggle" data-toggle="buttons"> <!-- used if scripts are disabled -->
<noscript>
<div id="categories" class="btn-group btn-toggle">
{% for category in categories %}
<!--<div class="checkbox">-->
<input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}_nojs" name="category_{{ category }}" {% if category in selected_categories %}checked="checked"{% endif %} />
<label class="btn btn-sm btn-primary active label_hide_if_not_checked" for="checkbox_{{ category|replace(' ', '_') }}_nojs">{{ _(category) }}</label>
<label class="btn btn-sm btn-default label_hide_if_checked" for="checkbox_{{ category|replace(' ', '_') }}_nojs">{{ _(category) }}</label>
<!--</div>-->
{% if category in selected_categories %}<input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}_dis_activation" name="category_{{ category }}" value="off" checked="checked"/>{% endif %}
{% endfor %}
</div>
</noscript>
<div id="categories" class="btn-group btn-toggle hide_if_nojs" data-toggle="buttons">
{% for category in categories %} {% for category in categories %}
<label class="btn btn-sm {% if category in selected_categories %}btn-primary active{% else %}btn-default{% endif %}" data-btn-class="primary"> <label class="btn btn-sm {% if category in selected_categories %}btn-primary active{% else %}btn-default{% endif %}" data-btn-class="primary">
<input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}" name="category_{{ category }}" {% if category in selected_categories %}checked="checked"{% endif %} />{{ _(category) }}</label> <input class="hidden" type="checkbox" id="checkbox_{{ category|replace(' ', '_') }}" name="category_{{ category }}" {% if category in selected_categories %}checked="checked"{% endif %} />{{ _(category) }}</label>
{% endfor %} {% endfor %}
</div> </div>

View File

@ -8,8 +8,8 @@
</span> </span>
</div> </div>
<button type="button" class="btn btn-link btn-collapse center-block collapsed" data-toggle="collapse" data-target="#search_categories" data-btn-text-collapsed="{{ _('Show search filters') }}" data-btn-text-not-collapsed="{{ _('Hide search filters') }}">{{ _('Show search filters') }}</button> <button type="button" class="btn btn-link btn-collapse center-block collapsed hide_if_nojs" data-toggle="collapse" data-target="#search_categories" data-btn-text-collapsed="{{ _('Show search filters') }}" data-btn-text-not-collapsed="{{ _('Hide search filters') }}">{{ _('Show search filters') }}</button>
<div class="row collapse" id="search_categories"> <div class="row collapse active_if_nojs margin_top_if_nojs" id="search_categories">
<div class="col-md-12 text-center"> <div class="col-md-12 text-center">
{% include 'oscar/categories.html' %} {% include 'oscar/categories.html' %}
</div> </div>