Added bootstrap column number configuration
This commit is contained in:
parent
b9f04ce715
commit
2c2b3186e4
3
bootstrapform/config.py
Normal file
3
bootstrapform/config.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
BOOTSTRAP_COLUMN_COUNT = getattr(settings, 'BOOTSTRAP_COLUMN_COUNT', 12)
|
@ -2,6 +2,8 @@ from django.template import Context
|
|||||||
from django.template.loader import get_template
|
from django.template.loader import get_template
|
||||||
from django import template
|
from django import template
|
||||||
|
|
||||||
|
from bootstrapform import config
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
@ -31,14 +33,14 @@ def bootstrap_horizontal(element, label_cols={}):
|
|||||||
try:
|
try:
|
||||||
value_nb_cols = int(splited_class[-1])
|
value_nb_cols = int(splited_class[-1])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
value_nb_cols = 12
|
value_nb_cols = config.BOOTSTRAP_COLUMN_COUNT
|
||||||
|
|
||||||
if value_nb_cols >= 12:
|
if value_nb_cols >= config.BOOTSTRAP_COLUMN_COUNT:
|
||||||
splited_class[-1] = 12
|
splited_class[-1] = config.BOOTSTRAP_COLUMN_COUNT
|
||||||
else:
|
else:
|
||||||
offset_class = cl.split('-')
|
offset_class = cl.split('-')
|
||||||
offset_class[-1] = 'offset-' + str(value_nb_cols)
|
offset_class[-1] = 'offset-' + str(value_nb_cols)
|
||||||
splited_class[-1] = str(12 - value_nb_cols)
|
splited_class[-1] = str(config.BOOTSTRAP_COLUMN_COUNT - value_nb_cols)
|
||||||
markup_classes['single_value'] += ' ' + '-'.join(offset_class)
|
markup_classes['single_value'] += ' ' + '-'.join(offset_class)
|
||||||
markup_classes['single_value'] += ' ' + '-'.join(splited_class)
|
markup_classes['single_value'] += ' ' + '-'.join(splited_class)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user