Added bootstrap column number configuration

This commit is contained in:
ubi 2013-10-31 23:47:21 +08:00
parent b9f04ce715
commit 2c2b3186e4
2 changed files with 9 additions and 4 deletions

3
bootstrapform/config.py Normal file
View File

@ -0,0 +1,3 @@
from django.conf import settings
BOOTSTRAP_COLUMN_COUNT = getattr(settings, 'BOOTSTRAP_COLUMN_COUNT', 12)

View File

@ -2,6 +2,8 @@ from django.template import Context
from django.template.loader import get_template
from django import template
from bootstrapform import config
register = template.Library()
@register.filter
@ -31,14 +33,14 @@ def bootstrap_horizontal(element, label_cols={}):
try:
value_nb_cols = int(splited_class[-1])
except ValueError:
value_nb_cols = 12
value_nb_cols = config.BOOTSTRAP_COLUMN_COUNT
if value_nb_cols >= 12:
splited_class[-1] = 12
if value_nb_cols >= config.BOOTSTRAP_COLUMN_COUNT:
splited_class[-1] = config.BOOTSTRAP_COLUMN_COUNT
else:
offset_class = cl.split('-')
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(splited_class)