merging with the new category nav feature

Merge remote-tracking branch 'upstream/master'
This commit is contained in:
Kris Aubuchon 2013-10-28 17:08:00 -04:00
commit 5d19e66470
13 changed files with 84 additions and 22 deletions

View File

@ -7,16 +7,20 @@ Discourse.DiscourseBreadcrumbsComponent = Ember.Component.extend({
return !c.get('parentCategory');
}),
targetCategory: function() {
// Note we can't use Em.computed.or here because it returns a boolean not the object
firstCategory: function() {
return this.get('parentCategory') || this.get('category');
}.property('parentCategory', 'category'),
secondCategory: function() {
if (this.get('parentCategory')) return this.get('category');
return null;
}.property('category', 'parentCategory'),
childCategories: function() {
var self = this;
return this.get('categories').filter(function (c) {
return c.get('parentCategory') === self.get('targetCategory');
return c.get('parentCategory') === self.get('firstCategory');
});
}.property('targetCategory')
}.property('firstCategory')
});

View File

@ -7,6 +7,17 @@ Discourse.DiscourseCategorydropComponent = Ember.Component.extend({
return "icon icon-caret-right";
}.property('expanded'),
allCategoriesUrl: function() {
return this.get('category.parentCategory.url') || "/";
}.property('category'),
allCategoriesLabel: function() {
if (this.get('subCategory')) {
return I18n.t('categories.all_subcategories');
}
return I18n.t('categories.all');
}.property('category'),
badgeStyle: function() {
var category = this.get('category');
if (category) {

View File

@ -24,7 +24,7 @@ Discourse.Scrolling = Em.Mixin.create({
if (opts.debounce) {
onScrollMethod = Discourse.debounce(function() {
return scrollingMixin.scrolled();
}, 100);
}, opts.debounce);
} else {
onScrollMethod = function() {
return scrollingMixin.scrolled();

View File

@ -31,7 +31,7 @@ Discourse.Category = Discourse.Model.extend({
}.property('id'),
url: function() {
return Discourse.getURL("/category/") + (this.get('slug'));
return Discourse.getURL("/category/") + Discourse.Category.slugFor(this);
}.property('name'),
unreadUrl: function() {

View File

@ -253,6 +253,8 @@ Discourse.PostStream = Em.Object.extend({
if (opts.nearPost) {
Discourse.TopicView.jumpToPost(topic.get('id'), opts.nearPost);
} else {
Discourse.TopicView.jumpToPost(topic.get('id'), 1);
}
Discourse.URL.set('queryParams', postStream.get('streamFilters'));

View File

@ -1,12 +1,10 @@
<li>
{{discourse-categorydrop parentCategory=category categories=parentCategories}}
{{discourse-categorydrop category=firstCategory categories=parentCategories}}
</li>
<li>
{{discourse-categorydrop parentCategory=category category=targetCategory categories=childCategories}}
</li>
{{#if parentCategory}}
{{#if childCategories}}
<li>
{{boundCategoryLink category}}
{{discourse-categorydrop category=secondCategory categories=childCategories subCategory="true"}}
</li>
{{/if}}

View File

@ -1,12 +1,13 @@
{{#if category}}
{{boundCategoryLink category allowUncategorized=true}}
<a href="#" {{action expand}} class="badge-category" {{bindAttr style="badgeStyle"}}>{{category.name}}</a>
{{else}}
<a href='/' class='badge-category home' {{bindAttr style="badgeStyle"}}><i class='icon icon-home'></i></a>
<a href='#' {{action expand}} class='badge-category home' {{bindAttr style="badgeStyle"}}>{{allCategoriesLabel}}</i></a>
{{/if}}
{{#if categories}}
<a href='#' {{action expand}} class='badge-category category-dropdown-button' {{bindAttr style="badgeStyle"}}><i {{bindAttr class="iconClass"}}></i></a>
<section {{bindAttr class="expanded::hidden :category-dropdown-menu"}} class='chooser'>
<div class='cat'><a {{bindAttr href=allCategoriesUrl}} class='badge-category home'>{{allCategoriesLabel}}</a></div>
{{#each categories}}<div class='cat'>{{categoryLink this allowUncategorized=true}}</div>{{/each}}
</section>
{{/if}}

View File

@ -1,9 +1,7 @@
<div class='list-controls'>
<div class="container">
{{#if category}}
{{discourse-breadcrumbs category=category categories=categories}}
{{/if}}
{{discourse-breadcrumbs category=category categories=categories}}
<ul class="nav nav-pills" id='category-filter'>
{{each availableNavItems itemViewClass="Discourse.NavItemView"}}

View File

@ -10,5 +10,29 @@ window.PagedownCustom = {
return Discourse.__container__.lookup('controller:composer').send('importQuote');
}
}
]
],
customActions: {
"doBlockquote": function(chunk, postProcessing, oldDoBlockquote) {
// When traditional linebreaks are set, use the default Pagedown implementation
if (Discourse.SiteSettings.traditional_markdown_linebreaks) {
return oldDoBlockquote.call(this, chunk, postProcessing);
}
// Our custom blockquote for non-traditional markdown linebreaks
var result = [];
chunk.selection.split(/\n/).forEach(function (line) {
var newLine = "";
if (line.indexOf("> ") === 0) {
newLine += line.substr(2);
} else {
if (/\S/.test(line)) { newLine += "> " + line; }
}
result.push(newLine);
});
chunk.selection = result.join("\n");
}
}
};

View File

@ -342,8 +342,8 @@
.list-controls {
.home {
font-size: 20px;
font-weight: normal;
background-color: #eee;
color: #333;
}
.badge-category {

View File

@ -241,8 +241,8 @@
.list-controls {
.home {
font-size: 20px;
font-weight: normal;
color: #333;
background-color: #eee;
}
.badge-category {

View File

@ -184,6 +184,8 @@ en:
"13": "Inbox"
categories:
all: "all categories"
all_subcategories: "all subcategories"
category: "Category"
posts: "Posts"
topics: "Topics"

View File

@ -18,6 +18,17 @@
// ]
// };
//
// To extend actions:
//
// window.PagedownCustom = {
// customActions: {
// "doBlockquote": function(chunk, postProcessing, oldDoBlockquote) {
// console.log('custom blockquote called!');
// return oldDoBlockquote.call(this, chunk, postProcessing);
// }
// }
// };
(function () {
@ -1470,6 +1481,17 @@
}
function bindCommand(method) {
if (typeof PagedownCustom != "undefined" && PagedownCustom.customActions) {
var custom = PagedownCustom.customActions[method];
if (custom) {
return function() {
var args = Array.prototype.slice.call(arguments);
args.push(commandManager[method]);
return custom.apply(commandManager, args);
};
}
}
if (typeof method === "string")
method = commandManager[method];
return function () { method.apply(commandManager, arguments); }