mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 12:40:40 +08:00
Use sub-category badge on categories page too
This commit is contained in:
parent
32b7405941
commit
5d4995640b
|
@ -79,6 +79,7 @@ function categoryLinkHTML(category, options) {
|
|||
if (options.hash.allowUncategorized) { categoryOptions.allowUncategorized = true; }
|
||||
if (options.hash.showParent) { categoryOptions.showParent = true; }
|
||||
if (options.hash.link !== undefined) { categoryOptions.link = options.hash.link; }
|
||||
if (options.hash.extraClasses) { categoryOptions.extraClasses = options.hash.extraClasses; }
|
||||
if (options.hash.categories) {
|
||||
categoryOptions.categories = Em.Handlebars.get(this, options.hash.categories, options);
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ Discourse.HTML = {
|
|||
@param {Boolean} opts.allowUncategorized Whether we allow rendering of the uncategorized category (default false)
|
||||
@param {Boolean} opts.showParent Whether to visually show whether category is a sub-category (default false)
|
||||
@param {Boolean} opts.link Whether this category badge should link to the category (default true)
|
||||
@param {String} opts.extraClasses add this string to the class attribute of the badge
|
||||
@returns {String} the html category badge
|
||||
**/
|
||||
categoryBadge: function(category, opts) {
|
||||
|
@ -87,9 +88,11 @@ Discourse.HTML = {
|
|||
restricted = Em.get(category, 'read_restricted'),
|
||||
url = Discourse.getURL("/category/") + Discourse.Category.slugFor(category),
|
||||
elem = (opts.link === false ? 'span' : 'a'),
|
||||
extraClasses = (opts.extraClasses ? (' ' + opts.extraClasses) : ''),
|
||||
html = "<" + elem + " href=\"" + (opts.link === false ? '' : url) + "\" ";
|
||||
|
||||
html += "data-drop-close=\"true\" class=\"badge-category" + (restricted ? ' restricted' : '' ) + "\" ";
|
||||
html += "data-drop-close=\"true\" class=\"badge-category" + (restricted ? ' restricted' : '' ) +
|
||||
extraClasses + "\" ";
|
||||
|
||||
// Add description if we have it
|
||||
if (description) html += "title=\"" + Handlebars.Utils.escapeExpression(description) + "\" ";
|
||||
|
@ -107,7 +110,7 @@ Discourse.HTML = {
|
|||
|
||||
if (opts.showParent && category.get('parent_category_id')) {
|
||||
var parent = Discourse.Category.findById(category.get('parent_category_id'));
|
||||
html = "<span class='badge-wrapper'><" + elem + " class='badge-category-parent' style=\"" + (Discourse.HTML.categoryStyle(parent)||'') +
|
||||
html = "<span class='badge-wrapper'><" + elem + " class='badge-category-parent" + extraClasses + "' style=\"" + (Discourse.HTML.categoryStyle(parent)||'') +
|
||||
"\" href=\"" + (opts.link === false ? '' : url) + "\"><span class='category-name'>" +
|
||||
(Em.get(parent, 'read_restricted') ? "<i class='fa fa-group'></i> " : "") +
|
||||
Em.get(parent, 'name') + "</span></" + elem + ">" +
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<div>
|
||||
<div class="pull-left">
|
||||
{{#if controller.ordering}}<i class="fa fa-bars"></i>{{/if}}
|
||||
{{categoryLink this allowUncategorized=true}}
|
||||
{{categoryLink this allowUncategorized=true extraClasses="bigger"}}
|
||||
{{#if unreadTopics}}
|
||||
<a href={{unbound unreadUrl}} class='badge new-posts badge-notification' title='{{i18n topic.unread_topics count="unreadTopics"}}'>{{unbound unreadTopics}}</a>
|
||||
{{/if}}
|
||||
|
@ -42,7 +42,7 @@
|
|||
<div class='subcategories'>
|
||||
{{i18n categories.subcategories}}
|
||||
{{#each subcategories}}
|
||||
{{categoryLink this}}
|
||||
{{categoryLink this showParent=true}}
|
||||
{{#if unreadTopics}}
|
||||
<a href={{unbound unreadUrl}} class='badge new-posts badge-notification' title='{{i18n topic.unread_topics count="unreadTopics"}}'>{{unbound unreadTopics}}</a>
|
||||
{{/if}}
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
<div class='subcategories'>
|
||||
{{i18n categories.subcategories}}
|
||||
{{#each subcategory in subcategories}}
|
||||
{{categoryLink subcategory}}
|
||||
{{categoryLink subcategory showParent=true}}
|
||||
{{/each}}
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
@ -295,10 +295,6 @@
|
|||
|
||||
.subcategories {
|
||||
margin-top: 10px;
|
||||
.badge-category {
|
||||
font-size: 12px;
|
||||
padding: 4px;
|
||||
}
|
||||
}
|
||||
.featured-users {
|
||||
float: right;
|
||||
|
@ -307,7 +303,7 @@
|
|||
.category-description {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.badge-category {
|
||||
.badge-category.bigger {
|
||||
padding: 6px 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user