mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
Fixed a bunch of 'best of' errors and cleaned up JS.
This commit is contained in:
@ -49,7 +49,7 @@ Discourse.AdminCustomizeController = Ember.Controller.extend({
|
|||||||
var selected;
|
var selected;
|
||||||
if (result) {
|
if (result) {
|
||||||
selected = _this.get('content.selectedItem');
|
selected = _this.get('content.selectedItem');
|
||||||
selected["delete"]();
|
selected.destroy();
|
||||||
_this.set('content.selectedItem', null);
|
_this.set('content.selectedItem', null);
|
||||||
return _this.get('content').removeObject(selected);
|
return _this.get('content').removeObject(selected);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ Discourse.SiteCustomization = Discourse.Model.extend({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
"delete": function() {
|
destroy: function() {
|
||||||
if (!this.id) return;
|
if (!this.id) return;
|
||||||
|
|
||||||
return $.ajax({
|
return $.ajax({
|
||||||
|
@ -10,6 +10,7 @@ Discourse.TopicController = Discourse.ObjectController.extend({
|
|||||||
userFilters: new Em.Set(),
|
userFilters: new Em.Set(),
|
||||||
multiSelect: false,
|
multiSelect: false,
|
||||||
bestOf: false,
|
bestOf: false,
|
||||||
|
summaryCollapsed: true,
|
||||||
needs: ['header', 'modal', 'composer', 'quoteButton'],
|
needs: ['header', 'modal', 'composer', 'quoteButton'],
|
||||||
|
|
||||||
filter: (function() {
|
filter: (function() {
|
||||||
@ -19,9 +20,14 @@ Discourse.TopicController = Discourse.ObjectController.extend({
|
|||||||
}).property('userFilters.[]', 'bestOf'),
|
}).property('userFilters.[]', 'bestOf'),
|
||||||
|
|
||||||
filterDesc: (function() {
|
filterDesc: (function() {
|
||||||
var filter;
|
var filter = this.get('filter');
|
||||||
if (!(filter = this.get('filter'))) return null;
|
if (!filter) return null;
|
||||||
return Em.String.i18n("topic.filters." + filter);
|
|
||||||
|
if (filter !== 'user') return Em.String.i18n("topic.filters." + filter);
|
||||||
|
|
||||||
|
// If we're a user filter, include the count
|
||||||
|
return Em.String.i18n("topic.filters.user", {count: this.get('userFilters.length')});
|
||||||
|
|
||||||
}).property('filter'),
|
}).property('filter'),
|
||||||
|
|
||||||
selectedPosts: (function() {
|
selectedPosts: (function() {
|
||||||
@ -83,6 +89,10 @@ Discourse.TopicController = Discourse.ObjectController.extend({
|
|||||||
this.toggleProperty('multiSelect');
|
this.toggleProperty('multiSelect');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toggleSummary: function() {
|
||||||
|
this.toggleProperty('summaryCollapsed');
|
||||||
|
},
|
||||||
|
|
||||||
moveSelected: function() {
|
moveSelected: function() {
|
||||||
var _ref;
|
var _ref;
|
||||||
return (_ref = this.get('controllers.modal')) ? _ref.show(Discourse.MoveSelectedView.create({
|
return (_ref = this.get('controllers.modal')) ? _ref.show(Discourse.MoveSelectedView.create({
|
||||||
@ -148,71 +158,56 @@ Discourse.TopicController = Discourse.ObjectController.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggleParticipant: function(user) {
|
toggleParticipant: function(user) {
|
||||||
var userFilters, username;
|
|
||||||
this.set('bestOf', false);
|
this.set('bestOf', false);
|
||||||
username = Em.get(user, 'username');
|
var username = Em.get(user, 'username');
|
||||||
userFilters = this.get('userFilters');
|
var userFilters = this.get('userFilters');
|
||||||
if (userFilters.contains(username)) {
|
if (userFilters.contains(username)) {
|
||||||
userFilters.remove(username);
|
userFilters.remove(username);
|
||||||
} else {
|
} else {
|
||||||
userFilters.add(username);
|
userFilters.add(username);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
enableBestOf: function(e) {
|
enableBestOf: function(e) {
|
||||||
this.set('bestOf', true);
|
this.set('bestOf', true);
|
||||||
this.get('userFilters').clear();
|
this.get('userFilters').clear();
|
||||||
return false;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
showBestOf: (function() {
|
|
||||||
if (this.get('bestOf') === true) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return this.get('content.has_best_of') === true;
|
|
||||||
}).property('bestOf', 'content.has_best_of'),
|
|
||||||
|
|
||||||
postFilters: (function() {
|
postFilters: (function() {
|
||||||
if (this.get('bestOf') === true) {
|
if (this.get('bestOf') === true) return { bestOf: true };
|
||||||
return {
|
return { userFilters: this.get('userFilters') };
|
||||||
bestOf: true
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
userFilters: this.get('userFilters')
|
|
||||||
};
|
|
||||||
}).property('userFilters.[]', 'bestOf'),
|
}).property('userFilters.[]', 'bestOf'),
|
||||||
|
|
||||||
reloadTopics: (function() {
|
reloadPosts: (function() {
|
||||||
var posts, topic,
|
var topic = this.get('content');
|
||||||
_this = this;
|
|
||||||
topic = this.get('content');
|
|
||||||
if (!topic) return;
|
if (!topic) return;
|
||||||
posts = topic.get('posts');
|
|
||||||
|
var posts = topic.get('posts');
|
||||||
if (!posts) return;
|
if (!posts) return;
|
||||||
posts.clear();
|
|
||||||
this.set('content.loaded', false);
|
// Leave the first post -- we keep it above the filter controls
|
||||||
return Discourse.Topic.find(this.get('content.id'), this.get('postFilters')).then(function(result) {
|
posts.removeAt(1, posts.length - 1);
|
||||||
var first;
|
var topicController = this;
|
||||||
first = result.posts.first();
|
return Discourse.Topic.find(this.get('id'), this.get('postFilters')).then(function(result) {
|
||||||
|
var first = result.posts.first();
|
||||||
if (first) {
|
if (first) {
|
||||||
_this.set('currentPost', first.post_number);
|
topicController.set('currentPost', first.post_number);
|
||||||
}
|
}
|
||||||
$('#topic-progress .solid').data('progress', false);
|
$('#topic-progress .solid').data('progress', false);
|
||||||
result.posts.each(function(p) {
|
result.posts.each(function(p) {
|
||||||
return posts.pushObject(Discourse.Post.create(p, topic));
|
// Skip the first post
|
||||||
|
if (p.post_number === 1) return;
|
||||||
|
posts.pushObject(Discourse.Post.create(p, topic));
|
||||||
});
|
});
|
||||||
return _this.set('content.loaded', true);
|
|
||||||
});
|
});
|
||||||
}).observes('postFilters'),
|
}).observes('postFilters'),
|
||||||
|
|
||||||
deleteTopic: function(e) {
|
deleteTopic: function(e) {
|
||||||
var _this = this;
|
var topicController = this;
|
||||||
this.unsubscribe();
|
this.unsubscribe();
|
||||||
this.get('content')["delete"](function() {
|
this.get('content').destroy().then(function() {
|
||||||
_this.set('message', Em.String.i18n('topic.deleted'));
|
topicController.set('message', Em.String.i18n('topic.deleted'));
|
||||||
_this.set('loaded', false);
|
topicController.set('loaded', false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -411,7 +406,7 @@ Discourse.TopicController = Discourse.ObjectController.extend({
|
|||||||
post.set('can_delete', false);
|
post.set('can_delete', false);
|
||||||
post.set('version', post.get('version') + 1);
|
post.set('version', post.get('version') + 1);
|
||||||
}
|
}
|
||||||
return post["delete"]();
|
post.destroy();
|
||||||
},
|
},
|
||||||
|
|
||||||
postRendered: function(post) {
|
postRendered: function(post) {
|
||||||
|
@ -21,10 +21,7 @@ Discourse.Category = Discourse.Model.extend({
|
|||||||
}).property('topic_count'),
|
}).property('topic_count'),
|
||||||
|
|
||||||
save: function(args) {
|
save: function(args) {
|
||||||
var url,
|
var url = Discourse.getURL("/categories");
|
||||||
_this = this;
|
|
||||||
|
|
||||||
url = Discourse.getURL("/categories");
|
|
||||||
if (this.get('id')) {
|
if (this.get('id')) {
|
||||||
url = Discourse.getURL("/categories/") + (this.get('id'));
|
url = Discourse.getURL("/categories/") + (this.get('id'));
|
||||||
}
|
}
|
||||||
@ -41,14 +38,8 @@ Discourse.Category = Discourse.Model.extend({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
"delete": function(callback) {
|
destroy: function(callback) {
|
||||||
var _this = this;
|
return $.ajax(Discourse.getURL("/categories/") + (this.get('slug')), { type: 'DELETE' });
|
||||||
return $.ajax(Discourse.getURL("/categories/") + (this.get('slug')), {
|
|
||||||
type: 'DELETE',
|
|
||||||
success: function() {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -175,13 +175,8 @@ Discourse.Post = Discourse.Model.extend({
|
|||||||
return $.ajax(Discourse.getURL("/posts/") + (this.get('id')) + "/recover", { type: 'PUT', cache: false });
|
return $.ajax(Discourse.getURL("/posts/") + (this.get('id')) + "/recover", { type: 'PUT', cache: false });
|
||||||
},
|
},
|
||||||
|
|
||||||
"delete": function(complete) {
|
destroy: function(complete) {
|
||||||
return $.ajax(Discourse.getURL("/posts/") + (this.get('id')), {
|
return $.ajax(Discourse.getURL("/posts/") + (this.get('id')), { type: 'DELETE' });
|
||||||
type: 'DELETE',
|
|
||||||
success: function(result) {
|
|
||||||
return typeof complete === "function" ? complete() : void 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Update the properties of this post from an obj, ignoring cooked as we should already
|
// Update the properties of this post from an obj, ignoring cooked as we should already
|
||||||
|
@ -197,13 +197,8 @@ Discourse.Topic = Discourse.Model.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Delete this topic
|
// Delete this topic
|
||||||
"delete": function(callback) {
|
destroy: function() {
|
||||||
return $.ajax(Discourse.getURL("/t/") + (this.get('id')), {
|
return $.ajax(Discourse.getURL("/t/") + (this.get('id')), { type: 'DELETE' });
|
||||||
type: 'DELETE',
|
|
||||||
success: function() {
|
|
||||||
return typeof callback === "function" ? callback() : void 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Load the posts for this topic
|
// Load the posts for this topic
|
||||||
@ -420,7 +415,7 @@ Discourse.Topic.reopenClass({
|
|||||||
if (opts.userFilters && opts.userFilters.length > 0) {
|
if (opts.userFilters && opts.userFilters.length > 0) {
|
||||||
data.username_filters = [];
|
data.username_filters = [];
|
||||||
opts.userFilters.forEach(function(username) {
|
opts.userFilters.forEach(function(username) {
|
||||||
return data.username_filters.push(username);
|
data.username_filters.push(username);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<a href='#' {{bindAttr class=":poster view.toggled:toggled"}} {{action toggleParticipant this target="controller"}} title="{{unbound username}}">
|
<a href='#' {{bindAttr class=":poster view.toggled:toggled"}} {{action toggleParticipant this}} title="{{unbound username}}">
|
||||||
<span class='post-count'>{{unbound post_count}}</span>
|
<span class='post-count'>{{unbound post_count}}</span>
|
||||||
{{avatar this imageSize="medium"}}
|
{{avatar this imageSize="medium"}}
|
||||||
</a>
|
</a>
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<h3><i class='icon icon-bullhorn'></i> {{i18n best_of.title}}</h3>
|
<h3><i class='icon icon-bullhorn'></i> {{i18n best_of.title}}</h3>
|
||||||
<p>{{{i18n best_of.description count="controller.content.posts_count"}}}</p>
|
{{#if controller.bestOf}}
|
||||||
|
<p>{{{i18n best_of.enabled_description}}}</p>
|
||||||
<button class='btn' {{action enableBestOf target="controller"}}>{{i18n best_of.button}}</button>
|
<button class='btn' {{action cancelFilter}}>{{i18n best_of.disable}}</button>
|
||||||
|
{{else}}
|
||||||
|
<p>{{{i18n best_of.description count="controller.content.posts_count"}}}</p>
|
||||||
|
<button class='btn' {{action enableBestOf}}>{{i18n best_of.enable}}</button>
|
||||||
|
{{/if}}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
<nav class='buttons'>
|
<nav class='buttons'>
|
||||||
{{#if view.summaryView.collapsed}}
|
{{#if controller.summaryCollapsed}}
|
||||||
<button class='btn collapsed' {{action toggleMore target="view.summaryView"}} title="{{i18n topic.toggle_information}}">
|
<button class='btn collapsed' {{action toggleSummary}} title="{{i18n topic.toggle_information}}">
|
||||||
<i class='icon icon-chevron-down'></i>
|
<i class='icon icon-chevron-down'></i>
|
||||||
</button>
|
</button>
|
||||||
{{else}}
|
{{else}}
|
||||||
<button class='btn' {{action toggleMore target="view.summaryView"}} title="{{i18n topic.toggle_information}}">
|
<button class='btn' {{action toggleSummary}} title="{{i18n topic.toggle_information}}">
|
||||||
<i class='icon icon-chevron-up'></i>
|
<i class='icon icon-chevron-up'></i>
|
||||||
</button>
|
</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
||||||
{{#if view.summaryView.collapsed}}
|
{{#if controller.summaryCollapsed}}
|
||||||
<section class='summary collapsed'>
|
<section class='summary collapsed'>
|
||||||
<ul class="clearfix">
|
<ul class="clearfix">
|
||||||
<li>
|
<li>
|
||||||
@ -39,13 +39,13 @@
|
|||||||
<li>
|
<li>
|
||||||
<h4>{{i18n links}}</h4>
|
<h4>{{i18n links}}</h4>
|
||||||
{{number view.topic.links.length}}
|
{{number view.topic.links.length}}
|
||||||
</li>
|
</li>
|
||||||
{{#if view.topic.fewParticipants}}
|
{{#if view.topic.fewParticipants}}
|
||||||
<li class='avatars'>
|
<li class='avatars'>
|
||||||
{{#each view.topic.fewParticipants}}{{view Discourse.ParticipantView participantBinding="this"}}{{/each}}
|
{{#each view.topic.fewParticipants}}{{view Discourse.ParticipantView participantBinding="this"}}{{/each}}
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@
|
|||||||
|
|
||||||
{{#if view.topic.participants}}
|
{{#if view.topic.participants}}
|
||||||
<section class='avatars clearfix'>
|
<section class='avatars clearfix'>
|
||||||
{{#each view.topic.participants}}{{view Discourse.ParticipantView participantBinding="this"}}{{/each}}
|
{{#each view.topic.participants}}{{view Discourse.ParticipantView participantBinding="this"}}{{/each}}
|
||||||
</section>
|
</section>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
@ -82,12 +82,12 @@
|
|||||||
<section class='links'>
|
<section class='links'>
|
||||||
<ul class='topic-links'>
|
<ul class='topic-links'>
|
||||||
{{#collection contentBinding="view.parentView.infoLinks" itemTagName="li"}}
|
{{#collection contentBinding="view.parentView.infoLinks" itemTagName="li"}}
|
||||||
<span class='badge badge-notification clicks' title='clicks'>{{view.content.clicks}}</span>
|
<span class='badge badge-notification clicks' title='clicks'>{{view.content.clicks}}</span>
|
||||||
<a href="{{unbound view.content.url}}" target="_blank" class='topic-link track-link' data-user-id="{{unbound view.content.user_id}}" data-ignore-post-id="true" title="{{unbound view.content.url}}">
|
<a href="{{unbound view.content.url}}" target="_blank" class='topic-link track-link' data-user-id="{{unbound view.content.user_id}}" data-ignore-post-id="true" title="{{unbound view.content.url}}">
|
||||||
{{#if view.content.title}}{{shorten view.content.title}}{{else}}{{shortenUrl view.content.url}}{{/if}}
|
{{#if view.content.title}}{{shorten view.content.title}}{{else}}{{shortenUrl view.content.url}}{{/if}}
|
||||||
{{#if view.content.internal}}<i class='icon-arrow-right' title='topic link'></i>{{/if}}
|
{{#if view.content.internal}}<i class='icon-arrow-right' title='topic link'></i>{{/if}}
|
||||||
</a>
|
</a>
|
||||||
{{/collection}}
|
{{/collection}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{{#if view.parentView.showAllLinksControls}}
|
{{#if view.parentView.showAllLinksControls}}
|
||||||
|
@ -11,41 +11,45 @@ Discourse.PostMenuView = Discourse.View.extend({
|
|||||||
classNames: ['post-menu-area', 'clearfix'],
|
classNames: ['post-menu-area', 'clearfix'],
|
||||||
|
|
||||||
render: function(buffer) {
|
render: function(buffer) {
|
||||||
var post,
|
var post = this.get('post');
|
||||||
_this = this;
|
|
||||||
post = this.get('post');
|
|
||||||
this.renderReplies(post, buffer);
|
this.renderReplies(post, buffer);
|
||||||
buffer.push("<nav class='post-controls'>");
|
buffer.push("<nav class='post-controls'>");
|
||||||
|
|
||||||
|
var postMenuView = this;
|
||||||
Discourse.get('postButtons').forEach(function(button) {
|
Discourse.get('postButtons').forEach(function(button) {
|
||||||
var renderer = "render" + button;
|
var renderer = "render" + button;
|
||||||
if(_this[renderer]) _this[renderer](post, buffer);
|
if(postMenuView[renderer]) postMenuView[renderer](post, buffer);
|
||||||
});
|
});
|
||||||
return buffer.push("</nav>");
|
buffer.push("</nav>");
|
||||||
},
|
},
|
||||||
|
|
||||||
// Delegate click actions
|
// Delegate click actions
|
||||||
click: function(e) {
|
click: function(e) {
|
||||||
var $target, action, _name;
|
var $target = $(e.target);
|
||||||
$target = $(e.target);
|
var action = $target.data('action') || $target.parent().data('action');
|
||||||
action = $target.data('action') || $target.parent().data('action');
|
|
||||||
if (!action) return;
|
if (!action) return;
|
||||||
return typeof this[_name = "click" + (action.capitalize())] === "function" ? this[_name]() : void 0;
|
|
||||||
|
var handler = this["click" + action.capitalize()];
|
||||||
|
if (!handler) return;
|
||||||
|
|
||||||
|
handler.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Trigger re-rendering
|
// Trigger re-rendering
|
||||||
needsToRender: function() {
|
needsToRender: function() {
|
||||||
return this.rerender();
|
this.rerender();
|
||||||
}.observes('post.deleted_at', 'post.flagsAvailable.@each', 'post.url', 'post.bookmarked', 'post.reply_count', 'post.showRepliesBelow', 'post.can_delete'),
|
}.observes('post.deleted_at', 'post.flagsAvailable.@each', 'post.url', 'post.bookmarked', 'post.reply_count', 'post.showRepliesBelow', 'post.can_delete'),
|
||||||
|
|
||||||
// Replies Button
|
// Replies Button
|
||||||
renderReplies: function(post, buffer) {
|
renderReplies: function(post, buffer) {
|
||||||
var icon, reply_count;
|
|
||||||
if (!post.get('showRepliesBelow')) return;
|
if (!post.get('showRepliesBelow')) return;
|
||||||
reply_count = post.get('reply_count');
|
|
||||||
|
var reply_count = post.get('reply_count');
|
||||||
buffer.push("<button class='show-replies' data-action='replies'>");
|
buffer.push("<button class='show-replies' data-action='replies'>");
|
||||||
buffer.push("<span class='badge-posts'>" + reply_count + "</span>");
|
buffer.push("<span class='badge-posts'>" + reply_count + "</span>");
|
||||||
buffer.push(Em.String.i18n("post.has_replies", { count: reply_count }));
|
buffer.push(Em.String.i18n("post.has_replies", { count: reply_count }));
|
||||||
icon = this.get('postView.repliesShown') ? 'icon-chevron-up' : 'icon-chevron-down';
|
|
||||||
|
var icon = this.get('postView.repliesShown') ? 'icon-chevron-up' : 'icon-chevron-down';
|
||||||
return buffer.push("<i class='icon " + icon + "'></i></button>");
|
return buffer.push("<i class='icon " + icon + "'></i></button>");
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -64,14 +68,14 @@ Discourse.PostMenuView = Discourse.View.extend({
|
|||||||
// Show the correct button (undo or delete)
|
// Show the correct button (undo or delete)
|
||||||
if (post.get('deleted_at')) {
|
if (post.get('deleted_at')) {
|
||||||
if (post.get('can_recover')) {
|
if (post.get('can_recover')) {
|
||||||
return buffer.push("<button title=\"" +
|
buffer.push("<button title=\"" +
|
||||||
(Em.String.i18n("post.controls.undelete")) +
|
(Em.String.i18n("post.controls.undelete")) +
|
||||||
"\" data-action=\"recover\" class=\"delete\"><i class=\"icon-undo\"></i></button>");
|
"\" data-action=\"recover\" class=\"delete\"><i class=\"icon-undo\"></i></button>");
|
||||||
}
|
}
|
||||||
} else if (post.get('can_delete')) {
|
} else if (post.get('can_delete')) {
|
||||||
return buffer.push("<button title=\"" +
|
buffer.push("<button title=\"" +
|
||||||
(Em.String.i18n("post.controls.delete")) +
|
(Em.String.i18n("post.controls.delete")) +
|
||||||
"\" data-action=\"delete\" class=\"delete\"><i class=\"icon-trash\"></i></button>");
|
"\" data-action=\"delete\" class=\"delete\"><i class=\"icon-trash\"></i></button>");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -90,9 +94,9 @@ Discourse.PostMenuView = Discourse.View.extend({
|
|||||||
// Like button
|
// Like button
|
||||||
renderLike: function(post, buffer) {
|
renderLike: function(post, buffer) {
|
||||||
if (!post.get('actionByName.like.can_act')) return;
|
if (!post.get('actionByName.like.can_act')) return;
|
||||||
return buffer.push("<button title=\"" +
|
buffer.push("<button title=\"" +
|
||||||
(Em.String.i18n("post.controls.like")) +
|
(Em.String.i18n("post.controls.like")) +
|
||||||
"\" data-action=\"like\" class='like'><i class=\"icon-heart\"></i></button>");
|
"\" data-action=\"like\" class='like'><i class=\"icon-heart\"></i></button>");
|
||||||
},
|
},
|
||||||
|
|
||||||
clickLike: function() {
|
clickLike: function() {
|
||||||
@ -103,9 +107,9 @@ Discourse.PostMenuView = Discourse.View.extend({
|
|||||||
// Flag button
|
// Flag button
|
||||||
renderFlag: function(post, buffer) {
|
renderFlag: function(post, buffer) {
|
||||||
if (!this.present('post.flagsAvailable')) return;
|
if (!this.present('post.flagsAvailable')) return;
|
||||||
return buffer.push("<button title=\"" +
|
buffer.push("<button title=\"" +
|
||||||
(Em.String.i18n("post.controls.flag")) +
|
(Em.String.i18n("post.controls.flag")) +
|
||||||
"\" data-action=\"flag\"><i class=\"icon-flag\"></i></button>");
|
"\" data-action=\"flag\"><i class=\"icon-flag\"></i></button>");
|
||||||
},
|
},
|
||||||
|
|
||||||
clickFlag: function() {
|
clickFlag: function() {
|
||||||
@ -115,9 +119,9 @@ Discourse.PostMenuView = Discourse.View.extend({
|
|||||||
// Edit button
|
// Edit button
|
||||||
renderEdit: function(post, buffer) {
|
renderEdit: function(post, buffer) {
|
||||||
if (!post.get('can_edit')) return;
|
if (!post.get('can_edit')) return;
|
||||||
return buffer.push("<button title=\"" +
|
buffer.push("<button title=\"" +
|
||||||
(Em.String.i18n("post.controls.edit")) +
|
(Em.String.i18n("post.controls.edit")) +
|
||||||
"\" data-action=\"edit\"><i class=\"icon-pencil\"></i></button>");
|
"\" data-action=\"edit\"><i class=\"icon-pencil\"></i></button>");
|
||||||
},
|
},
|
||||||
|
|
||||||
clickEdit: function() {
|
clickEdit: function() {
|
||||||
@ -126,18 +130,18 @@ Discourse.PostMenuView = Discourse.View.extend({
|
|||||||
|
|
||||||
// Share button
|
// Share button
|
||||||
renderShare: function(post, buffer) {
|
renderShare: function(post, buffer) {
|
||||||
return buffer.push("<button title=\"" +
|
buffer.push("<button title=\"" +
|
||||||
(Em.String.i18n("post.controls.share")) +
|
(Em.String.i18n("post.controls.share")) +
|
||||||
"\" data-share-url=\"" + (post.get('url')) + "\"><i class=\"icon-link\"></i></button>");
|
"\" data-share-url=\"" + (post.get('url')) + "\"><i class=\"icon-link\"></i></button>");
|
||||||
},
|
},
|
||||||
|
|
||||||
// Reply button
|
// Reply button
|
||||||
renderReply: function(post, buffer) {
|
renderReply: function(post, buffer) {
|
||||||
if (!this.get('controller.content.can_create_post')) return;
|
if (!this.get('controller.content.can_create_post')) return;
|
||||||
return buffer.push("<button title=\"" +
|
buffer.push("<button title=\"" +
|
||||||
(Em.String.i18n("post.controls.reply")) +
|
(Em.String.i18n("post.controls.reply")) +
|
||||||
"\" class='create' data-action=\"reply\"><i class='icon-reply'></i>" +
|
"\" class='create' data-action=\"reply\"><i class='icon-reply'></i>" +
|
||||||
(Em.String.i18n("topic.reply.title")) + "</button>");
|
(Em.String.i18n("topic.reply.title")) + "</button>");
|
||||||
},
|
},
|
||||||
|
|
||||||
clickReply: function() {
|
clickReply: function() {
|
||||||
@ -146,19 +150,19 @@ Discourse.PostMenuView = Discourse.View.extend({
|
|||||||
|
|
||||||
// Bookmark button
|
// Bookmark button
|
||||||
renderBookmark: function(post, buffer) {
|
renderBookmark: function(post, buffer) {
|
||||||
var icon;
|
|
||||||
if (!Discourse.get('currentUser')) return;
|
if (!Discourse.get('currentUser')) return;
|
||||||
icon = 'bookmark';
|
|
||||||
|
var icon = 'bookmark';
|
||||||
if (!this.get('post.bookmarked')) {
|
if (!this.get('post.bookmarked')) {
|
||||||
icon += '-empty';
|
icon += '-empty';
|
||||||
}
|
}
|
||||||
return buffer.push("<button title=\"" +
|
buffer.push("<button title=\"" +
|
||||||
(Em.String.i18n("post.controls.bookmark")) +
|
(Em.String.i18n("post.controls.bookmark")) +
|
||||||
"\" data-action=\"bookmark\"><i class=\"icon-" + icon + "\"></i></button>");
|
"\" data-action=\"bookmark\"><i class=\"icon-" + icon + "\"></i></button>");
|
||||||
},
|
},
|
||||||
|
|
||||||
clickBookmark: function() {
|
clickBookmark: function() {
|
||||||
return this.get('post').toggleProperty('bookmarked');
|
this.get('post').toggleProperty('bookmarked');
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -15,17 +15,12 @@ Discourse.PostView = Discourse.View.extend({
|
|||||||
'post.hidden:hidden',
|
'post.hidden:hidden',
|
||||||
'post.deleted_at:deleted',
|
'post.deleted_at:deleted',
|
||||||
'parentPost:replies-above'],
|
'parentPost:replies-above'],
|
||||||
|
|
||||||
siteBinding: Ember.Binding.oneWay('Discourse.site'),
|
|
||||||
composeViewBinding: Ember.Binding.oneWay('Discourse.composeView'),
|
|
||||||
quoteButtonViewBinding: Ember.Binding.oneWay('Discourse.quoteButtonView'),
|
|
||||||
postBinding: 'content',
|
postBinding: 'content',
|
||||||
|
|
||||||
// TODO really we should do something cleaner here... this makes it work in debug but feels really messy
|
// TODO really we should do something cleaner here... this makes it work in debug but feels really messy
|
||||||
screenTrack: (function() {
|
screenTrack: (function() {
|
||||||
var parentView, screenTrack;
|
var parentView = this.get('parentView');
|
||||||
parentView = this.get('parentView');
|
var screenTrack = null;
|
||||||
screenTrack = null;
|
|
||||||
while (parentView && !screenTrack) {
|
while (parentView && !screenTrack) {
|
||||||
screenTrack = parentView.get('screenTrack');
|
screenTrack = parentView.get('screenTrack');
|
||||||
parentView = parentView.get('parentView');
|
parentView = parentView.get('parentView');
|
||||||
@ -41,9 +36,7 @@ Discourse.PostView = Discourse.View.extend({
|
|||||||
// If the cooked content changed, add the quote controls
|
// If the cooked content changed, add the quote controls
|
||||||
cookedChanged: (function() {
|
cookedChanged: (function() {
|
||||||
var postView = this;
|
var postView = this;
|
||||||
Em.run.next(function() {
|
Em.run.next(function() { postView.insertQuoteControls(); });
|
||||||
postView.insertQuoteControls();
|
|
||||||
});
|
|
||||||
}).observes('post.cooked'),
|
}).observes('post.cooked'),
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
@ -56,10 +49,9 @@ Discourse.PostView = Discourse.View.extend({
|
|||||||
this.toggleProperty('post.selected');
|
this.toggleProperty('post.selected');
|
||||||
}
|
}
|
||||||
|
|
||||||
var $target = $(e.target);
|
if ($(e.target).closest('.cooked').length === 0) return;
|
||||||
if ($target.closest('.cooked').length === 0) return;
|
|
||||||
var qbc = this.get('controller.controllers.quoteButton');
|
|
||||||
|
|
||||||
|
var qbc = this.get('controller.controllers.quoteButton');
|
||||||
if (qbc && Discourse.get('currentUser.enable_quoting')) {
|
if (qbc && Discourse.get('currentUser.enable_quoting')) {
|
||||||
e.context = this.get('post');
|
e.context = this.get('post');
|
||||||
qbc.selectText(e);
|
qbc.selectText(e);
|
||||||
|
@ -10,7 +10,6 @@ Discourse.TopicSummaryView = Ember.ContainerView.extend(Discourse.Presence, {
|
|||||||
topicBinding: 'controller.content',
|
topicBinding: 'controller.content',
|
||||||
classNameBindings: ['hidden', ':topic-summary'],
|
classNameBindings: ['hidden', ':topic-summary'],
|
||||||
LINKS_SHOWN: 5,
|
LINKS_SHOWN: 5,
|
||||||
collapsed: true,
|
|
||||||
allLinksShown: false,
|
allLinksShown: false,
|
||||||
|
|
||||||
showAllLinksControls: (function() {
|
showAllLinksControls: (function() {
|
||||||
@ -21,15 +20,15 @@ Discourse.TopicSummaryView = Ember.ContainerView.extend(Discourse.Presence, {
|
|||||||
}).property('allLinksShown', 'topic.links'),
|
}).property('allLinksShown', 'topic.links'),
|
||||||
|
|
||||||
infoLinks: (function() {
|
infoLinks: (function() {
|
||||||
var allLinks;
|
|
||||||
if (this.blank('topic.links')) return [];
|
if (this.blank('topic.links')) return [];
|
||||||
allLinks = this.get('topic.links');
|
|
||||||
|
var allLinks = this.get('topic.links');
|
||||||
if (this.get('allLinksShown')) return allLinks;
|
if (this.get('allLinksShown')) return allLinks;
|
||||||
return allLinks.slice(0, this.LINKS_SHOWN);
|
return allLinks.slice(0, this.LINKS_SHOWN);
|
||||||
}).property('topic.links', 'allLinksShown'),
|
}).property('topic.links', 'allLinksShown'),
|
||||||
|
|
||||||
newPostCreated: (function() {
|
newPostCreated: (function() {
|
||||||
return this.rerender();
|
this.rerender();
|
||||||
}).observes('topic.posts_count'),
|
}).observes('topic.posts_count'),
|
||||||
|
|
||||||
hidden: (function() {
|
hidden: (function() {
|
||||||
@ -47,21 +46,17 @@ Discourse.TopicSummaryView = Ember.ContainerView.extend(Discourse.Presence, {
|
|||||||
topic: this.get('topic'),
|
topic: this.get('topic'),
|
||||||
summaryView: this
|
summaryView: this
|
||||||
}));
|
}));
|
||||||
return this.trigger('appendSummaryInformation', this);
|
this.trigger('appendSummaryInformation', this);
|
||||||
},
|
|
||||||
|
|
||||||
toggleMore: function() {
|
|
||||||
return this.toggleProperty('collapsed');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
showAllLinks: function() {
|
showAllLinks: function() {
|
||||||
return this.set('allLinksShown', true);
|
this.set('allLinksShown', true);
|
||||||
},
|
},
|
||||||
|
|
||||||
appendSummaryInformation: function(container) {
|
appendSummaryInformation: function(container) {
|
||||||
|
|
||||||
// If we have a best of view
|
// If we have a best of view
|
||||||
if (this.get('controller.showBestOf')) {
|
if (this.get('controller.has_best_of')) {
|
||||||
container.pushObject(Em.View.create({
|
container.pushObject(Em.View.create({
|
||||||
templateName: 'topic_summary/best_of_toggle',
|
templateName: 'topic_summary/best_of_toggle',
|
||||||
tagName: 'section',
|
tagName: 'section',
|
||||||
|
@ -203,8 +203,10 @@ en:
|
|||||||
|
|
||||||
best_of:
|
best_of:
|
||||||
title: "Best Of"
|
title: "Best Of"
|
||||||
|
enabled_description: You are currently viewing the "Best Of" view of this topic.
|
||||||
description: "There are <b>{{count}}</b> posts in this topic. That's a lot! Would you like to save time by switching your view to show only the posts with the most interactions and responses?"
|
description: "There are <b>{{count}}</b> posts in this topic. That's a lot! Would you like to save time by switching your view to show only the posts with the most interactions and responses?"
|
||||||
button: 'Switch to "Best Of" view'
|
enable: 'Switch to "Best Of" view'
|
||||||
|
disable: 'Cancel "Best Of"'
|
||||||
|
|
||||||
private_message_info:
|
private_message_info:
|
||||||
title: "Private Conversation"
|
title: "Private Conversation"
|
||||||
@ -498,7 +500,9 @@ en:
|
|||||||
login_reply: 'Log In to Reply'
|
login_reply: 'Log In to Reply'
|
||||||
|
|
||||||
filters:
|
filters:
|
||||||
user: "You're viewing only posts by specific user(s)."
|
user:
|
||||||
|
one: "You're viewing only posts by a specific user."
|
||||||
|
other: "You're viewing only posts made by specific users."
|
||||||
best_of: "You're viewing only the 'Best Of' posts."
|
best_of: "You're viewing only the 'Best Of' posts."
|
||||||
cancel: "Show all posts in this topic again."
|
cancel: "Show all posts in this topic again."
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user