diff --git a/app/assets/javascripts/discourse/helpers/application_helpers.js b/app/assets/javascripts/discourse/helpers/application_helpers.js index f3223a7d7..ef7ab697e 100644 --- a/app/assets/javascripts/discourse/helpers/application_helpers.js +++ b/app/assets/javascripts/discourse/helpers/application_helpers.js @@ -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); } diff --git a/app/assets/javascripts/discourse/lib/html.js b/app/assets/javascripts/discourse/lib/html.js index c880a216a..d98addbc4 100644 --- a/app/assets/javascripts/discourse/lib/html.js +++ b/app/assets/javascripts/discourse/lib/html.js @@ -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 = "<" + elem + " class='badge-category-parent' style=\"" + (Discourse.HTML.categoryStyle(parent)||'') + + html = "<" + elem + " class='badge-category-parent" + extraClasses + "' style=\"" + (Discourse.HTML.categoryStyle(parent)||'') + "\" href=\"" + (opts.link === false ? '' : url) + "\">" + (Em.get(parent, 'read_restricted') ? " " : "") + Em.get(parent, 'name') + "" + diff --git a/app/assets/javascripts/discourse/templates/discovery/categories.js.handlebars b/app/assets/javascripts/discourse/templates/discovery/categories.js.handlebars index 476d3ac66..5da6fcb52 100644 --- a/app/assets/javascripts/discourse/templates/discovery/categories.js.handlebars +++ b/app/assets/javascripts/discourse/templates/discovery/categories.js.handlebars @@ -18,7 +18,7 @@
{{#if controller.ordering}}{{/if}} - {{categoryLink this allowUncategorized=true}} + {{categoryLink this allowUncategorized=true extraClasses="bigger"}} {{#if unreadTopics}} {{unbound unreadTopics}} {{/if}} @@ -42,7 +42,7 @@
{{i18n categories.subcategories}} {{#each subcategories}} - {{categoryLink this}} + {{categoryLink this showParent=true}} {{#if unreadTopics}} {{unbound unreadTopics}} {{/if}} diff --git a/app/assets/javascripts/discourse/templates/featured_topics.js.handlebars b/app/assets/javascripts/discourse/templates/featured_topics.js.handlebars index e4cb4ef5f..d9c341106 100644 --- a/app/assets/javascripts/discourse/templates/featured_topics.js.handlebars +++ b/app/assets/javascripts/discourse/templates/featured_topics.js.handlebars @@ -62,7 +62,7 @@
{{i18n categories.subcategories}} {{#each subcategory in subcategories}} - {{categoryLink subcategory}} + {{categoryLink subcategory showParent=true}} {{/each}}
diff --git a/app/assets/stylesheets/desktop/topic-list.scss b/app/assets/stylesheets/desktop/topic-list.scss index 0f1ecb2e4..bf7b9c41b 100644 --- a/app/assets/stylesheets/desktop/topic-list.scss +++ b/app/assets/stylesheets/desktop/topic-list.scss @@ -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; }