Merge branch 'categories'

This commit is contained in:
Neil Lalonde 2013-04-03 17:50:42 -04:00
commit 68e9a727b8
4 changed files with 45 additions and 3 deletions

View File

@ -42,6 +42,18 @@ Discourse.ComboboxView = Discourse.View.extend({
_this = this;
$elem = this.$();
$elem.chosen({ template: this.template, disable_search_threshold: 5 });
if (this.overrideWidths) {
// The Chosen plugin hard-codes the widths in style attrs. :<
$elem.chosen().next().removeAttr("style");
$elem.chosen().next().find('.chzn-drop').removeAttr("style");
$elem.chosen().next().find('.chzn-search input').removeAttr("style");
}
if (this.classNames && this.classNames.length > 0) {
// Apply the classes to Chosen's dropdown div too:
this.classNames.each( function(c) {
$elem.chosen().next().addClass(c);
});
}
$elem.change(function(e) {
_this.set('value', $(e.target).val());
});

View File

@ -8,6 +8,8 @@
**/
Discourse.ComboboxViewCategory = Discourse.ComboboxView.extend({
none: 'category.none',
classNames: ['combobox category-combobox'],
overrideWidths: true,
dataAttributes: ['color', 'text_color', 'description'],
valueBinding: Ember.Binding.oneWay('source'),
@ -15,11 +17,11 @@ Discourse.ComboboxViewCategory = Discourse.ComboboxView.extend({
if (!templateData.color) return text;
var result = "<span class='badge-category' style='background-color: #" + templateData.color + '; color: #' +
templateData.text_color + ";' ";
templateData.text_color + ";' >" + text + "</span>";
if (templateData.description && templateData.description !== 'null') {
result += "title=\"" + templateData.description + "\" ";
result += '<div class="category-desc">' + templateData.description + '</div>';
}
return result + ">" + text + "</span>";
return result;
}
});

View File

@ -592,6 +592,10 @@ Copyright (c) 2011 by Harvest
this.result_clear_highlight();
this.result_highlight = el;
this.result_highlight.addClass("highlighted");
/*
The following code causes jumpy behaviour while scrolling, and I don't see what problem it solves:
maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
visible_top = this.search_results.scrollTop();
visible_bottom = maxHeight + visible_top;
@ -602,6 +606,7 @@ Copyright (c) 2011 by Harvest
} else if (high_top < visible_top) {
return this.search_results.scrollTop(high_top);
}
*/
}
};

View File

@ -230,6 +230,7 @@
min-width: 1280px;
.form-element {
.chzn-container {
width: 400px;
margin-top: 6px;
a {
padding-top: 4px;
@ -239,6 +240,28 @@
margin-top: 4px;
}
}
.category-combobox {
.category-desc {
margin: 8px 8px 0px 8px;
font-size: 12px;
}
width: 430px;
@include medium-width { width: 285px; }
@include small-width { width: 220px; }
.chzn-drop {
left: -9000px;
width: 428px;
@include medium-width { width: 283px; }
@include small-width { width: 218px; }
}
.chzn-search input {
width: 398px;
@include medium-width { width: 253px; }
@include small-width { width: 188px; }
}
}
}
#reply-title {
margin-right: 10px;