Skip to content

Commit

Permalink
Cleaned up chosen integration.
Browse files Browse the repository at this point in the history
  • Loading branch information
melinath committed Aug 15, 2013
1 parent 3486808 commit 5997e08
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 76 deletions.
20 changes: 18 additions & 2 deletions djam/sass/_overrides.scss
Expand Up @@ -39,9 +39,14 @@ body {

.chzn-container-single .chzn-single{
line-height: $line-height-base;
height: $line-height-base;
height: 8px + ($line-height-base * $font-size-base);
padding-top: 4px;
padding-bottom: 4px;
padding-right: 48px;

span {
margin-right: 0;
}
}

.chzn-container .chzn-results li {
Expand All @@ -56,5 +61,16 @@ body {

.chzn-container-single .chzn-search input{
// uses border-box.
height: 28px;
height: 8px + ($line-height-base * $font-size-base);
}

.chzn-container-multi .chzn-choices {
@extend input;
@extend .form-control;
min-width: 200px;

.search-field input{
// uses border-box.
height: 25px;
}
}
126 changes: 65 additions & 61 deletions djam/static/djam/css/djam.css

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions djam/static/djam/js/djam.kickoff.js
Expand Up @@ -11,9 +11,10 @@ jQuery(function($) {

$('select option[value=""]').text("");
$('select[data-required="0"]').chosen({
allow_single_deselect: true
allow_single_deselect: true,
width: 'auto'
});
$('select[data-required="1"]').chosen();
$('select[data-required="1"]').chosen({width: 'auto'});

function addLinkPopup(e) {
e.preventDefault();
Expand Down Expand Up @@ -111,7 +112,7 @@ jQuery(function($) {
inputEle.val(values[contentType.val()] || "");

if (opts.choices.length > 0) {
inputEle.chosen();
inputEle.chosen({width: 'auto'});
}
inputEle.change(storeValue);

Expand All @@ -122,7 +123,7 @@ jQuery(function($) {
}
}

contentType.chosen().change(function() {
contentType.chosen({width: 'auto'}).change(function() {
getContentType(contentType.val(), displayObjectInput);
});
contentType.change();
Expand Down
9 changes: 5 additions & 4 deletions djam/templates/floppyforms/clearable_input.html
Expand Up @@ -6,10 +6,11 @@
{% if value.url %}
<p>{% trans "Currently:" %} <a target="_blank" href="{{ value.url }}">{{ value }}</a></p>
{% if not required %}
<p>
<label class='checkbox' for="{{ checkbox_id }}">
<input type="checkbox" name="{{ checkbox_name }}" id="{{ checkbox_id }}"> {% trans "Clear" %}
<div class='checkbox'>
<label for="{{ checkbox_id }}">
<input type="checkbox" name="{{ checkbox_name }}" id="{{ checkbox_id }}">
{% trans "Clear" %}
</label>
</p>
</div>
{% endif %}
{% endif %}
11 changes: 8 additions & 3 deletions djam/templates/floppyforms/radio.html
@@ -1,3 +1,8 @@
<ul>{% for group_name, choices in optgroups %}{% for choice in choices %}
<li><label for="{{ attrs.id }}_{{ forloop.counter }}"><input type="radio" id="{{ attrs.id }}_{{ forloop.counter }}" value="{{ choice.0 }}" name="{{ name }}"{% if choice.0 in value %} checked{% endif %}> {{ choice.1 }}</label></li>
{% endfor %}{% endfor %}</ul>
{% for group_name, choices in optgroups %}{% for choice in choices %}
<div class='radio'>
<label for="{{ attrs.id }}_{{ forloop.counter }}">
<input type="radio" id="{{ attrs.id }}_{{ forloop.counter }}" value="{{ choice.0 }}" name="{{ name }}"{% if choice.0 in value %} checked{% endif %}>
{{ choice.1 }}
</label>
</div>
{% endfor %}{% endfor %}
2 changes: 1 addition & 1 deletion djam/templates/floppyforms/select.html
@@ -1,4 +1,4 @@
<select name="{{ name }}"{% if multiple %} multiple="multiple"{% endif %}{% include "floppyforms/attrs.html" %}>{% for group_name, group_choices in optgroups %}{% if group_name %}
<select class='form-control' name="{{ name }}"{% if multiple %} multiple="multiple"{% endif %}{% include "floppyforms/attrs.html" %}>{% for group_name, group_choices in optgroups %}{% if group_name %}
<optgroup label="{{ group_name }}">{% endif %}{% for option in group_choices %}
<option value="{{ option.0 }}"{% if option.0 in value %} selected="selected"{% endif %}>{{ option.1 }}</option>{% endfor %}{% if group_name %}
</optgroup>{% endif %}{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion djam/templates/floppyforms/textarea.html
@@ -1 +1 @@
<textarea class='input-block-level' name="{{ name }}"{% include "floppyforms/attrs.html" %}>{% if value %}{{ value }}{% endif %}</textarea>
<textarea class='form-control' name="{{ name }}"{% include "floppyforms/attrs.html" %}>{% if value %}{{ value }}{% endif %}</textarea>

0 comments on commit 5997e08

Please sign in to comment.