Ember Deprecations for Topics

This commit is contained in:
Robin Ward 2015-04-30 12:25:38 -04:00
parent 690b579a96
commit aee12fd6ef
33 changed files with 170 additions and 192 deletions

View File

@ -20,7 +20,7 @@ export default Ember.Component.extend({
}.observes("autoCloseTime", "limited"), }.observes("autoCloseTime", "limited"),
_isAutoCloseValid: function(autoCloseTime, limited) { _isAutoCloseValid: function(autoCloseTime, limited) {
var t = (autoCloseTime || "").trim(); var t = (autoCloseTime || "").toString().trim();
if (t.length === 0) { if (t.length === 0) {
// "empty" is always valid // "empty" is always valid
return true; return true;

View File

@ -1,11 +1,3 @@
/**
The controls for toggling the supression of deleted posts
@class ToggleDeletedComponent
@extends Ember.Component
@namespace Discourse
@module Discourse
**/
export default Ember.Component.extend({ export default Ember.Component.extend({
layoutName: 'components/toggle-deleted', layoutName: 'components/toggle-deleted',
tagName: 'section', tagName: 'section',

View File

@ -9,20 +9,20 @@ export default ObjectController.extend(ModalFunctionality, {
setAutoCloseTime: function() { setAutoCloseTime: function() {
var autoCloseTime = null; var autoCloseTime = null;
if (this.get("details.auto_close_based_on_last_post")) { if (this.get("model.details.auto_close_based_on_last_post")) {
autoCloseTime = this.get("details.auto_close_hours"); autoCloseTime = this.get("model.details.auto_close_hours");
} else if (this.get("details.auto_close_at")) { } else if (this.get("model.details.auto_close_at")) {
var closeTime = new Date(this.get("details.auto_close_at")); var closeTime = new Date(this.get("model.details.auto_close_at"));
if (closeTime > new Date()) { if (closeTime > new Date()) {
autoCloseTime = moment(closeTime).format("YYYY-MM-DD HH:mm"); autoCloseTime = moment(closeTime).format("YYYY-MM-DD HH:mm");
} }
} }
this.set("auto_close_time", autoCloseTime); this.set("model.auto_close_time", autoCloseTime);
}.observes("details.{auto_close_at,auto_close_hours}"), }.observes("model.details.{auto_close_at,auto_close_hours}"),
actions: { actions: {
saveAutoClose: function() { this.setAutoClose(this.get("auto_close_time")); }, saveAutoClose: function() { this.setAutoClose(this.get("model.auto_close_time")); },
removeAutoClose: function() { this.setAutoClose(null); } removeAutoClose: function() { this.setAutoClose(null); }
}, },
@ -30,18 +30,18 @@ export default ObjectController.extend(ModalFunctionality, {
var self = this; var self = this;
this.send('hideModal'); this.send('hideModal');
Discourse.ajax({ Discourse.ajax({
url: '/t/' + this.get('id') + '/autoclose', url: '/t/' + this.get('model.id') + '/autoclose',
type: 'PUT', type: 'PUT',
dataType: 'json', dataType: 'json',
data: { data: {
auto_close_time: time, auto_close_time: time,
auto_close_based_on_last_post: this.get("details.auto_close_based_on_last_post"), auto_close_based_on_last_post: this.get("model.details.auto_close_based_on_last_post"),
} }
}).then(function(result){ }).then(function(result){
if (result.success) { if (result.success) {
self.send('closeModal'); self.send('closeModal');
self.set('details.auto_close_at', result.auto_close_at); self.set('model.details.auto_close_at', result.auto_close_at);
self.set('details.auto_close_hours', result.auto_close_hours); self.set('model.details.auto_close_hours', result.auto_close_hours);
} else { } else {
bootbox.alert(I18n.t('composer.auto_close.error'), function() { self.send('reopenModal'); } ); bootbox.alert(I18n.t('composer.auto_close.error'), function() { self.send('reopenModal'); } );
} }

View File

@ -11,14 +11,14 @@ export default ObjectController.extend(ModalFunctionality, {
bannerCount: 0, bannerCount: 0,
categoryLink: function() { categoryLink: function() {
return categoryLinkHTML(this.get("category"), { allowUncategorized: true }); return categoryLinkHTML(this.get("model.category"), { allowUncategorized: true });
}.property("category"), }.property("model.category"),
unPinMessage: function() { unPinMessage: function() {
return this.get("pinned_globally") ? return this.get("model.pinned_globally") ?
I18n.t("topic.feature_topic.unpin_globally") : I18n.t("topic.feature_topic.unpin_globally") :
I18n.t("topic.feature_topic.unpin", { categoryLink: this.get("categoryLink") }); I18n.t("topic.feature_topic.unpin", { categoryLink: this.get("categoryLink") });
}.property("categoryLink", "pinned_globally"), }.property("categoryLink", "model.pinned_globally"),
pinMessage: function() { pinMessage: function() {
return I18n.t("topic.feature_topic.pin", { categoryLink: this.get("categoryLink") }); return I18n.t("topic.feature_topic.pin", { categoryLink: this.get("categoryLink") });
@ -32,7 +32,7 @@ export default ObjectController.extend(ModalFunctionality, {
this.set("loading", true); this.set("loading", true);
return Discourse.ajax("/topics/feature_stats.json", { return Discourse.ajax("/topics/feature_stats.json", {
data: { category_id: this.get("category.id") } data: { category_id: this.get("model.category.id") }
}).then(result => { }).then(result => {
if (result) { if (result) {
this.setProperties({ this.setProperties({

View File

@ -3,8 +3,8 @@ import ObjectController from 'discourse/controllers/object';
// This controller supports the admin menu on topics // This controller supports the admin menu on topics
export default ObjectController.extend({ export default ObjectController.extend({
menuVisible: false, menuVisible: false,
showRecover: Em.computed.and('deleted', 'details.can_recover'), showRecover: Em.computed.and('model.deleted', 'model.details.can_recover'),
isFeatured: Em.computed.or("pinned_at", "isBanner"), isFeatured: Em.computed.or("model.pinned_at", "model.isBanner"),
actions: { actions: {
show: function() { this.set('menuVisible', true); }, show: function() { this.set('menuVisible', true); },

View File

@ -24,11 +24,11 @@ export default Ember.ObjectController.extend({
if (isNaN(postIndex) || postIndex < 1) { if (isNaN(postIndex) || postIndex < 1) {
postIndex = 1; postIndex = 1;
} }
if (postIndex > this.get('postStream.filteredPostsCount')) { if (postIndex > this.get('model.postStream.filteredPostsCount')) {
postIndex = this.get('postStream.filteredPostsCount'); postIndex = this.get('model.postStream.filteredPostsCount');
} }
this.set('toPostIndex', postIndex); this.set('toPostIndex', postIndex);
var stream = this.get('postStream'), var stream = this.get('model.postStream'),
postId = stream.findPostIdForPostNumber(postIndex); postId = stream.findPostIdForPostNumber(postIndex);
if (!postId) { if (!postId) {
@ -65,36 +65,36 @@ export default Ember.ObjectController.extend({
}, },
streamPercentage: function() { streamPercentage: function() {
if (!this.get('postStream.loaded')) { return 0; } if (!this.get('model.postStream.loaded')) { return 0; }
if (this.get('postStream.highest_post_number') === 0) { return 0; } if (this.get('model.postStream.highest_post_number') === 0) { return 0; }
var perc = this.get('progressPosition') / this.get('postStream.filteredPostsCount'); var perc = this.get('progressPosition') / this.get('model.postStream.filteredPostsCount');
return (perc > 1.0) ? 1.0 : perc; return (perc > 1.0) ? 1.0 : perc;
}.property('postStream.loaded', 'progressPosition', 'postStream.filteredPostsCount'), }.property('model.postStream.loaded', 'progressPosition', 'model.postStream.filteredPostsCount'),
jumpTopDisabled: function() { jumpTopDisabled: function() {
return this.get('progressPosition') <= 3; return this.get('progressPosition') <= 3;
}.property('progressPosition'), }.property('progressPosition'),
filteredPostCountChanged: function(){ filteredPostCountChanged: function(){
if(this.get('postStream.filteredPostsCount') < this.get('progressPosition')){ if(this.get('model.postStream.filteredPostsCount') < this.get('progressPosition')){
this.set('progressPosition', this.get('postStream.filteredPostsCount')); this.set('progressPosition', this.get('model.postStream.filteredPostsCount'));
} }
}.observes('postStream.filteredPostsCount'), }.observes('model.postStream.filteredPostsCount'),
jumpBottomDisabled: function() { jumpBottomDisabled: function() {
return this.get('progressPosition') >= this.get('postStream.filteredPostsCount') || return this.get('progressPosition') >= this.get('model.postStream.filteredPostsCount') ||
this.get('progressPosition') >= this.get('highest_post_number'); this.get('progressPosition') >= this.get('highest_post_number');
}.property('postStream.filteredPostsCount', 'highest_post_number', 'progressPosition'), }.property('model.postStream.filteredPostsCount', 'highest_post_number', 'progressPosition'),
hideProgress: function() { hideProgress: function() {
if (!this.get('postStream.loaded')) return true; if (!this.get('model.postStream.loaded')) return true;
if (!this.get('currentPost')) return true; if (!this.get('model.currentPost')) return true;
if (this.get('postStream.filteredPostsCount') < 2) return true; if (this.get('model.postStream.filteredPostsCount') < 2) return true;
return false; return false;
}.property('postStream.loaded', 'currentPost', 'postStream.filteredPostsCount'), }.property('model.postStream.loaded', 'model.currentPost', 'model.postStream.filteredPostsCount'),
hugeNumberOfPosts: function() { hugeNumberOfPosts: function() {
return (this.get('postStream.filteredPostsCount') >= Discourse.SiteSettings.short_progress_text_threshold); return (this.get('model.postStream.filteredPostsCount') >= Discourse.SiteSettings.short_progress_text_threshold);
}.property('highest_post_number'), }.property('highest_post_number'),
jumpToBottomTitle: function() { jumpToBottomTitle: function() {

View File

@ -12,6 +12,9 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
selectedReplies: null, selectedReplies: null,
queryParams: ['filter', 'username_filters', 'show_deleted'], queryParams: ['filter', 'username_filters', 'show_deleted'],
searchHighlight: null, searchHighlight: null,
loadedAllPosts: false,
enteredAt: null,
firstPostExpanded: false,
maxTitleLength: Discourse.computed.setting('max_topic_title_length'), maxTitleLength: Discourse.computed.setting('max_topic_title_length'),
@ -20,14 +23,14 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
}.observes('topic'), }.observes('topic'),
_titleChanged: function() { _titleChanged: function() {
const title = this.get('title'); const title = this.get('model.title');
if (!Ember.isEmpty(title)) { if (!Ember.isEmpty(title)) {
// Note normally you don't have to trigger this, but topic titles can be updated // Note normally you don't have to trigger this, but topic titles can be updated
// and are sometimes lazily loaded. // and are sometimes lazily loaded.
this.send('refreshTitle'); this.send('refreshTitle');
} }
}.observes('title', 'category'), }.observes('model.title', 'category'),
termChanged: function() { termChanged: function() {
const dropdown = this.get('controllers.header.visibleDropdown'); const dropdown = this.get('controllers.header.visibleDropdown');
@ -47,47 +50,47 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
// semantics of loaded all posts are slightly diff at topic level, // semantics of loaded all posts are slightly diff at topic level,
// it just means that we "once" loaded all posts, this means we don't // it just means that we "once" loaded all posts, this means we don't
// keep re-rendering the suggested topics when new posts zoom in // keep re-rendering the suggested topics when new posts zoom in
let loaded = this.get('postStream.loadedAllPosts'); let loaded = this.get('model.postStream.loadedAllPosts');
if (loaded) { if (loaded) {
this.set('loadedTopicId', this.get('model.id')); this.set('model.loadedTopicId', this.get('model.id'));
} else { } else {
loaded = this.get('loadedTopicId') === this.get('model.id'); loaded = this.get('model.loadedTopicId') === this.get('model.id');
} }
this.set('loadedAllPosts', loaded); this.set('loadedAllPosts', loaded);
}.observes('postStream', 'postStream.loadedAllPosts'), }.observes('model.postStream', 'model.postStream.loadedAllPosts'),
show_deleted: function(key, value) { show_deleted: function(key, value) {
const postStream = this.get('postStream'); const postStream = this.get('model.postStream');
if (!postStream) { return; } if (!postStream) { return; }
if (arguments.length > 1) { if (arguments.length > 1) {
postStream.set('show_deleted', value); postStream.set('show_deleted', value);
} }
return postStream.get('show_deleted') ? true : undefined; return postStream.get('show_deleted') ? true : undefined;
}.property('postStream.summary'), }.property('model.postStream.summary'),
filter: function(key, value) { filter: function(key, value) {
const postStream = this.get('postStream'); const postStream = this.get('model.postStream');
if (!postStream) { return; } if (!postStream) { return; }
if (arguments.length > 1) { if (arguments.length > 1) {
postStream.set('summary', value === "summary"); postStream.set('summary', value === "summary");
} }
return postStream.get('summary') ? "summary" : undefined; return postStream.get('summary') ? "summary" : undefined;
}.property('postStream.summary'), }.property('model.postStream.summary'),
username_filters: function(key, value) { username_filters: function(key, value) {
const postStream = this.get('postStream'); const postStream = this.get('model.postStream');
if (!postStream) { return; } if (!postStream) { return; }
if (arguments.length > 1) { if (arguments.length > 1) {
postStream.set('streamFilters.username_filters', value); postStream.set('streamFilters.username_filters', value);
} }
return postStream.get('streamFilters.username_filters'); return postStream.get('streamFilters.username_filters');
}.property('postStream.streamFilters.username_filters'), }.property('model.postStream.streamFilters.username_filters'),
_clearSelected: function() { _clearSelected: function() {
this.set('selectedPosts', []); this.set('selectedPosts', []);
@ -95,7 +98,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
}.on('init'), }.on('init'),
_togglePinnedStates(property) { _togglePinnedStates(property) {
const value = this.get('pinned_at') ? false : true, const value = this.get('model.pinned_at') ? false : true,
topic = this.get('content'); topic = this.get('content');
// optimistic update // optimistic update
@ -189,7 +192,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
'class': 'btn-primary', 'class': 'btn-primary',
callback() { callback() {
Discourse.Post.deleteMany([post], [post]); Discourse.Post.deleteMany([post], [post]);
self.get('postStream.posts').forEach(function (p) { self.get('model.postStream.posts').forEach(function (p) {
if (p === post || p.get('reply_to_post_number') === post.get('post_number')) { if (p === post || p.get('reply_to_post_number') === post.get('post_number')) {
p.setDeletedState(user); p.setDeletedState(user);
} }
@ -246,7 +249,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
}, },
selectAll() { selectAll() {
const posts = this.get('postStream.posts'), const posts = this.get('model.postStream.posts'),
selectedPosts = this.get('selectedPosts'); selectedPosts = this.get('selectedPosts');
if (posts) { if (posts) {
selectedPosts.addObjects(posts); selectedPosts.addObjects(posts);
@ -261,11 +264,11 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
}, },
toggleParticipant(user) { toggleParticipant(user) {
this.get('postStream').toggleParticipant(Em.get(user, 'username')); this.get('model.postStream').toggleParticipant(Em.get(user, 'username'));
}, },
editTopic() { editTopic() {
if (!this.get('details.can_edit')) return false; if (!this.get('model.details.can_edit')) return false;
this.set('editingTopic', true); this.set('editingTopic', true);
return false; return false;
@ -326,7 +329,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
const selectedPosts = self.get('selectedPosts'), const selectedPosts = self.get('selectedPosts'),
selectedReplies = self.get('selectedReplies'), selectedReplies = self.get('selectedReplies'),
postStream = self.get('postStream'), postStream = self.get('model.postStream'),
toRemove = []; toRemove = [];
Discourse.Post.deleteMany(selectedPosts, selectedReplies); Discourse.Post.deleteMany(selectedPosts, selectedReplies);
@ -365,7 +368,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
}, },
togglePinned() { togglePinned() {
const value = this.get('pinned_at') ? false : true, const value = this.get('model.pinned_at') ? false : true,
topic = this.get('content'); topic = this.get('content');
// optimistic update // optimistic update
@ -403,7 +406,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
}, },
togglePinnedForUser() { togglePinnedForUser() {
if (this.get('pinned_at')) { if (this.get('model.pinned_at')) {
if (this.get('pinned')) { if (this.get('pinned')) {
this.get('content').clearPin(); this.get('content').clearPin();
} else { } else {
@ -428,7 +431,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
return Em.isEmpty(quotedText) ? Discourse.Post.loadQuote(post.get('id')) : quotedText; return Em.isEmpty(quotedText) ? Discourse.Post.loadQuote(post.get('id')) : quotedText;
}).then(function(q) { }).then(function(q) {
const postUrl = "" + location.protocol + "//" + location.host + post.get('url'), const postUrl = "" + location.protocol + "//" + location.host + post.get('url'),
postLink = "[" + Handlebars.escapeExpression(self.get('title')) + "](" + postUrl + ")"; postLink = "[" + Handlebars.escapeExpression(self.get('model.title')) + "](" + postUrl + ")";
composerController.appendText(I18n.t("post.continue_discussion", { postLink: postLink }) + "\n\n" + q); composerController.appendText(I18n.t("post.continue_discussion", { postLink: postLink }) + "\n\n" + q);
}); });
}, },
@ -448,7 +451,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
retryLoading() { retryLoading() {
const self = this; const self = this;
self.set('retrying', true); self.set('retrying', true);
this.get('postStream').refresh().then(function() { this.get('model.postStream').refresh().then(function() {
self.set('retrying', false); self.set('retrying', false);
}, function() { }, function() {
self.set('retrying', false); self.set('retrying', false);
@ -491,12 +494,12 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
}.property(), }.property(),
canMergeTopic: function() { canMergeTopic: function() {
if (!this.get('details.can_move_posts')) return false; if (!this.get('model.details.can_move_posts')) return false;
return (this.get('selectedPostsCount') > 0); return (this.get('selectedPostsCount') > 0);
}.property('selectedPostsCount'), }.property('selectedPostsCount'),
canSplitTopic: function() { canSplitTopic: function() {
if (!this.get('details.can_move_posts')) return false; if (!this.get('model.details.can_move_posts')) return false;
if (this.get('allPostsSelected')) return false; if (this.get('allPostsSelected')) return false;
return (this.get('selectedPostsCount') > 0); return (this.get('selectedPostsCount') > 0);
}.property('selectedPostsCount'), }.property('selectedPostsCount'),
@ -586,16 +589,16 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
this.unsubscribe(); this.unsubscribe();
const self = this; const self = this;
this.messageBus.subscribe("/topic/" + this.get('id'), function(data) { this.messageBus.subscribe("/topic/" + this.get('model.id'), function(data) {
const topic = self.get('model'); const topic = self.get('model');
if (data.notification_level_change) { if (data.notification_level_change) {
topic.set('details.notification_level', data.notification_level_change); topic.set('model.details.notification_level', data.notification_level_change);
topic.set('details.notifications_reason_id', data.notifications_reason_id); topic.set('model.details.notifications_reason_id', data.notifications_reason_id);
return; return;
} }
const postStream = self.get('postStream'); const postStream = self.get('model.postStream');
switch (data.type) { switch (data.type) {
case "revised": case "revised":
case "acted": case "acted":
@ -654,16 +657,16 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
// If our current post is changed, notify the router // If our current post is changed, notify the router
_currentPostChanged: function() { _currentPostChanged: function() {
const currentPost = this.get('currentPost'); const currentPost = this.get('model.currentPost');
if (currentPost) { if (currentPost) {
this.send('postChangedRoute', currentPost); this.send('postChangedRoute', currentPost);
} }
}.observes('currentPost'), }.observes('model.currentPost'),
readPosts(topicId, postNumbers) { readPosts(topicId, postNumbers) {
const postStream = this.get('postStream'); const postStream = this.get('model.postStream');
if(this.get('postStream.topic.id') === topicId){ if(this.get('model.postStream.topic.id') === topicId){
_.each(postStream.get('posts'), function(post){ _.each(postStream.get('posts'), function(post){
// optimise heavy loop // optimise heavy loop
// TODO identity map for postNumber // TODO identity map for postNumber
@ -673,8 +676,8 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
}); });
const max = _.max(postNumbers); const max = _.max(postNumbers);
if(max > this.get('last_read_post_number')){ if(max > this.get('model.last_read_post_number')){
this.set('last_read_post_number', max); this.set('model.sast_read_post_number', max);
} }
} }
}, },
@ -683,10 +686,10 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
topVisibleChanged(post) { topVisibleChanged(post) {
if (!post) { return; } if (!post) { return; }
const postStream = this.get('postStream'), const postStream = this.get('model.postStream'),
firstLoadedPost = postStream.get('firstLoadedPost'); firstLoadedPost = postStream.get('firstLoadedPost');
this.set('currentPost', post.get('post_number')); this.set('model.currentPost', post.get('post_number'));
if (post.get('post_number') === 1) { return; } if (post.get('post_number') === 1) { return; }
@ -721,7 +724,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
bottomVisibleChanged(post) { bottomVisibleChanged(post) {
if (!post) { return; } if (!post) { return; }
const postStream = this.get('postStream'), const postStream = this.get('model.postStream'),
lastLoadedPost = postStream.get('lastLoadedPost'); lastLoadedPost = postStream.get('lastLoadedPost');
this.set('controllers.topic-progress.progressPosition', postStream.progressIndexOfPost(post)); this.set('controllers.topic-progress.progressPosition', postStream.progressIndexOfPost(post));
@ -732,7 +735,7 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, BufferedCon
}, },
_showFooter: function() { _showFooter: function() {
this.set("controllers.application.showFooter", this.get("postStream.loadedAllPosts")); this.set("controllers.application.showFooter", this.get("model.postStream.loadedAllPosts"));
}.observes("postStream.loadedAllPosts") }.observes("model.postStream.loadedAllPosts")
}); });

View File

@ -11,7 +11,7 @@ export default Ember.Controller.extend({
// If inside a topic // If inside a topic
topicPostCount: null, topicPostCount: null,
postStream: Em.computed.alias('controllers.topic.postStream'), postStream: Em.computed.alias('controllers.topic.model.postStream'),
enoughPostsForFiltering: Em.computed.gte('topicPostCount', 2), enoughPostsForFiltering: Em.computed.gte('topicPostCount', 2),
viewingTopic: Em.computed.match('controllers.application.currentPath', /^topic\./), viewingTopic: Em.computed.match('controllers.application.currentPath', /^topic\./),
viewingAdmin: Em.computed.match('controllers.application.currentPath', /^admin\./), viewingAdmin: Em.computed.match('controllers.application.currentPath', /^admin\./),
@ -45,7 +45,7 @@ export default Ember.Controller.extend({
const currentUsername = this.get('username'), const currentUsername = this.get('username'),
wasVisible = this.get('visible'), wasVisible = this.get('visible'),
post = this.get('viewingTopic') && postId ? this.get('controllers.topic.postStream').findLoadedPost(postId) : null; post = this.get('viewingTopic') && postId ? this.get('postStream').findLoadedPost(postId) : null;
this.setProperties({ avatar: null, post: post, username: username }); this.setProperties({ avatar: null, post: post, username: username });

View File

@ -196,7 +196,7 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
var selectedPostId = parseInt($('.topic-post.selected article.boxed').data('post-id'), 10); var selectedPostId = parseInt($('.topic-post.selected article.boxed').data('post-id'), 10);
if (selectedPostId) { if (selectedPostId) {
var topicController = container.lookup('controller:topic'), var topicController = container.lookup('controller:topic'),
post = topicController.get('postStream.posts').findBy('id', selectedPostId); post = topicController.get('model.postStream.posts').findBy('id', selectedPostId);
if (post) { if (post) {
topicController.send(action, post); topicController.send(action, post);
} }

View File

@ -221,7 +221,7 @@ Discourse.URL = Ember.Object.createWithMixins({
var container = Discourse.__container__, var container = Discourse.__container__,
topicController = container.lookup('controller:topic'), topicController = container.lookup('controller:topic'),
opts = {}, opts = {},
postStream = topicController.get('postStream'); postStream = topicController.get('model.postStream');
if (newMatches[3]) opts.nearPost = newMatches[3]; if (newMatches[3]) opts.nearPost = newMatches[3];
if (path.match(/last$/)) { opts.nearPost = topicController.get('highest_post_number'); } if (path.match(/last$/)) { opts.nearPost = topicController.get('highest_post_number'); }

View File

@ -1,4 +1,6 @@
export default Em.Mixin.create({ export default Em.Mixin.create({
flashMessage: null,
needs: ['modal'], needs: ['modal'],
flash: function(message, messageClass) { flash: function(message, messageClass) {

View File

@ -20,10 +20,11 @@ export default Ember.Mixin.create({
_rerenderString() { _rerenderString() {
const $sel = this.$(); const $sel = this.$();
if ($sel) { return; } if (!$sel) { return; }
const buffer = []; const buffer = [];
this.renderString(buffer); this.renderString(buffer);
$sel.html(buffer.join('')); $sel.html(buffer.join(''));
}, },

View File

@ -241,7 +241,7 @@ Ember.CloakedCollectionView.reopen({
// topic_route deactivate // topic_route deactivate
$('.posts,#topic-title').hide(); $('.posts,#topic-title').hide();
self.cleanUp(); self.cleanUp();
self.set('controller.postStream.loaded', false); self.set('controller.model.postStream.loaded', false);
}; };
this.set('_callback', cb); this.set('_callback', cb);
popstateCallbacks.addObject(cb); popstateCallbacks.addObject(cb);

View File

@ -30,7 +30,7 @@ export default Discourse.Route.extend({
progress = postStream.progressIndexOfPost(closestPost); progress = postStream.progressIndexOfPost(closestPost);
topicController.setProperties({ topicController.setProperties({
currentPost: closest, 'model.currentPost': closest,
enteredAt: new Date().getTime().toString(), enteredAt: new Date().getTime().toString(),
}); });

View File

@ -182,7 +182,7 @@ const TopicRoute = Discourse.Route.extend(ShowFooter, {
this.controllerFor('user-card').set('visible', false); this.controllerFor('user-card').set('visible', false);
const topicController = this.controllerFor('topic'), const topicController = this.controllerFor('topic'),
postStream = topicController.get('postStream'); postStream = topicController.get('model.postStream');
postStream.cancelFilter(); postStream.cancelFilter();
topicController.set('multiSelect', false); topicController.set('multiSelect', false);

View File

@ -1,9 +1,9 @@
<form {{action "saveAutoClose" on="submit"}}> <form {{action "saveAutoClose" on="submit"}}>
<div class="modal-body"> <div class="modal-body">
{{auto-close-form autoCloseTime=auto_close_time {{auto-close-form autoCloseTime=model.auto_close_time
autoCloseValid=auto_close_valid autoCloseValid=auto_close_valid
autoCloseBasedOnLastPost=details.auto_close_based_on_last_post autoCloseBasedOnLastPost=model.details.auto_close_based_on_last_post
limited=details.auto_close_based_on_last_post }} limited=model.details.auto_close_based_on_last_post }}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class='btn btn-primary' type='submit' {{bind-attr disabled="auto_close_invalid"}}>{{i18n 'topic.auto_close_save'}}</button> <button class='btn btn-primary' type='submit' {{bind-attr disabled="auto_close_invalid"}}>{{i18n 'topic.auto_close_save'}}</button>

View File

@ -1,12 +1,12 @@
<div class="modal-body feature-topic"> <div class="modal-body feature-topic">
{{#if pinned_at}} {{#if model.pinned_at}}
<div class="feature-section"> <div class="feature-section">
<div class="button"> <div class="button">
{{d-button action="unpin" icon="thumb-tack" label="topic.feature.unpin" class="btn-primary"}} {{d-button action="unpin" icon="thumb-tack" label="topic.feature.unpin" class="btn-primary"}}
</div> </div>
<div class="desc"> <div class="desc">
<p>{{{unPinMessage}}}</p> <p>{{{unPinMessage}}}</p>
{{#if pinned_globally}} {{#if model.pinned_globally}}
<p>{{i18n "topic.feature_topic.global_pin_note"}}</p> <p>{{i18n "topic.feature_topic.global_pin_note"}}</p>
<p> <p>
{{#conditional-loading-spinner size="small" condition=loading}} {{#conditional-loading-spinner size="small" condition=loading}}
@ -57,14 +57,14 @@
<hr> <hr>
<div class="feature-section"> <div class="feature-section">
<div class="button"> <div class="button">
{{#if isBanner}} {{#if model.isBanner}}
{{d-button action="removeBanner" icon="thumb-tack" label="topic.feature.remove_banner" class="btn-primary"}} {{d-button action="removeBanner" icon="thumb-tack" label="topic.feature.remove_banner" class="btn-primary"}}
{{else}} {{else}}
{{d-button action="makeBanner" icon="thumb-tack" label="topic.feature.make_banner" class="btn-primary"}} {{d-button action="makeBanner" icon="thumb-tack" label="topic.feature.make_banner" class="btn-primary"}}
{{/if}} {{/if}}
</div> </div>
<div class="desc"> <div class="desc">
{{#if isBanner}} {{#if model.isBanner}}
<p>{{i18n "topic.feature_topic.remove_banner"}}</p> <p>{{i18n "topic.feature_topic.remove_banner"}}</p>
{{else}} {{else}}
<p>{{i18n "topic.feature_topic.make_banner"}}</p> <p>{{i18n "topic.feature_topic.make_banner"}}</p>

View File

@ -1,4 +1,4 @@
{{post-gap post=this postStream=controller.postStream before="true"}} {{post-gap post=this postStream=controller.model.postStream before="true"}}
<div class='row'> <div class='row'>
{{view 'reply-history' content=replyHistory}} {{view 'reply-history' content=replyHistory}}
@ -9,11 +9,11 @@
<div class='topic-avatar'> <div class='topic-avatar'>
<div class="contents"> <div class="contents">
{{#unboundIf userDeleted}} {{#if userDeleted}}
<i class="fa fa-trash-o deleted-user-avatar"></i> <i class="fa fa-trash-o deleted-user-avatar"></i>
{{else}} {{else}}
{{raw "post/poster-avatar" post=this classNames="main-avatar"}} {{raw "post/poster-avatar" post=this classNames="main-avatar"}}
{{/unboundIf}} {{/if}}
{{plugin-outlet "poster-avatar-bottom"}} {{plugin-outlet "poster-avatar-bottom"}}
</div> </div>
</div> </div>
@ -42,14 +42,14 @@
{{#if wiki}} {{#if wiki}}
<div class="post-info wiki" title="{{i18n 'post.wiki.about'}}" {{action "editPost" this}}>{{fa-icon "pencil-square-o"}}</div> <div class="post-info wiki" title="{{i18n 'post.wiki.about'}}" {{action "editPost" this}}>{{fa-icon "pencil-square-o"}}</div>
{{/if}} {{/if}}
{{#unboundIf via_email}} {{#if via_email}}
{{#if canViewRawEmail}} {{#if canViewRawEmail}}
<div class="post-info via-email raw-email" title="{{i18n 'post.via_email'}}" {{action "showRawEmail" this}}>{{fa-icon "envelope-o"}}</div> <div class="post-info via-email raw-email" title="{{i18n 'post.via_email'}}" {{action "showRawEmail" this}}>{{fa-icon "envelope-o"}}</div>
{{else}} {{else}}
<div class="post-info via-email" title="{{i18n 'post.via_email'}}">{{fa-icon "envelope-o"}}</div> <div class="post-info via-email" title="{{i18n 'post.via_email'}}">{{fa-icon "envelope-o"}}</div>
{{/if}} {{/if}}
{{/unboundIf}} {{/if}}
{{#unboundIf showUserReplyTab}} {{#if showUserReplyTab}}
<a href {{action "toggleReplyHistory" this target="view"}} class='reply-to-tab'> <a href {{action "toggleReplyHistory" this target="view"}} class='reply-to-tab'>
{{#if loadingReplyHistory}} {{#if loadingReplyHistory}}
{{i18n 'loading'}} {{i18n 'loading'}}
@ -59,7 +59,7 @@
<span>{{reply_to_user.username}}</span> <span>{{reply_to_user.username}}</span>
{{/if}} {{/if}}
</a> </a>
{{/unboundIf}} {{/if}}
<div {{bind-attr class=":read-state read"}} title="{{i18n 'post.unread'}}">{{fa-icon "circle"}}</div> <div {{bind-attr class=":read-state read"}} title="{{i18n 'post.unread'}}">{{fa-icon "circle"}}</div>
</div> </div>
@ -106,4 +106,4 @@
</article> </article>
{{post-gap post=this postStream=controller.postStream before="false"}} {{post-gap post=this postStream=controller.model.postStream before="false"}}

View File

@ -1,11 +1,11 @@
<p>{{count-i18n key=topic.multi_select.description countBinding="selectedPostsCount"}}</p> <p>{{count-i18n key=topic.multi_select.description count=selectedPostsCount}}</p>
{{#if canSelectAll}} {{#if canSelectAll}}
<p><a href='#' {{action "selectAll"}}>{{i18n 'topic.multi_select.select_all'}}</a></p> <p><a href {{action "selectAll"}}>{{i18n 'topic.multi_select.select_all'}}</a></p>
{{/if}} {{/if}}
{{#if canDeselectAll}} {{#if canDeselectAll}}
<p><a href='#' {{action "deselectAll"}}>{{i18n 'topic.multi_select.deselect_all'}}</a></p> <p><a href {{action "deselectAll"}}>{{i18n 'topic.multi_select.deselect_all'}}</a></p>
{{/if}} {{/if}}
{{#if canDeleteSelected}} {{#if canDeleteSelected}}
@ -22,4 +22,4 @@
<button class='btn' {{action "changeOwner"}}><i class='fa fa-user'></i> {{i18n 'topic.change_owner.action'}}</button> <button class='btn' {{action "changeOwner"}}><i class='fa fa-user'></i> {{i18n 'topic.change_owner.action'}}</button>
{{/if}} {{/if}}
<p class='cancel'><a href='#' {{action "toggleMultiSelect"}}>{{i18n 'topic.multi_select.cancel'}}</a></p> <p class='cancel'><a href {{action "toggleMultiSelect"}}>{{i18n 'topic.multi_select.cancel'}}</a></p>

View File

@ -11,7 +11,7 @@
</div> </div>
{{#each s in sources}} {{#each s in sources}}
{{share-source source=s title=title action="share"}} {{share-source source=s title=view.title action="share"}}
{{/each}} {{/each}}
<div class='link'> <div class='link'>

View File

@ -5,7 +5,7 @@
{{d-button action="toggleMultiSelect" icon="tasks" label="topic.actions.multi_select" class="btn-admin"}} {{d-button action="toggleMultiSelect" icon="tasks" label="topic.actions.multi_select" class="btn-admin"}}
</li> </li>
{{#if details.can_delete}} {{#if model.details.can_delete}}
<li> <li>
{{d-button action="deleteTopic" icon="trash-o" label="topic.actions.delete" class="btn-admin btn-danger"}} {{d-button action="deleteTopic" icon="trash-o" label="topic.actions.delete" class="btn-admin btn-danger"}}
</li> </li>
@ -18,7 +18,7 @@
{{/if}} {{/if}}
<li> <li>
{{#if closed}} {{#if model.closed}}
{{d-button action="toggleClosed" icon="unlock" label="topic.actions.open" class="btn-admin"}} {{d-button action="toggleClosed" icon="unlock" label="topic.actions.open" class="btn-admin"}}
{{else}} {{else}}
{{d-button action="toggleClosed" icon="lock" label="topic.actions.close" class="btn-admin"}} {{d-button action="toggleClosed" icon="lock" label="topic.actions.close" class="btn-admin"}}
@ -26,8 +26,8 @@
{{/if}} {{/if}}
</li> </li>
{{#unless isPrivateMessage}} {{#unless model.isPrivateMessage}}
{{#if visible}} {{#if model.visible}}
<li> <li>
{{#if isFeatured}} {{#if isFeatured}}
{{d-button action="showFeatureTopic" icon="thumb-tack" label="topic.actions.unpin" class="btn-admin"}} {{d-button action="showFeatureTopic" icon="thumb-tack" label="topic.actions.unpin" class="btn-admin"}}
@ -39,7 +39,7 @@
{{/unless}} {{/unless}}
<li> <li>
{{#if archived}} {{#if model.archived}}
{{d-button action="toggleArchived" icon="folder" label="topic.actions.unarchive" class="btn-admin"}} {{d-button action="toggleArchived" icon="folder" label="topic.actions.unarchive" class="btn-admin"}}
{{else}} {{else}}
{{d-button action="toggleArchived" icon="folder" label="topic.actions.archive" class="btn-admin"}} {{d-button action="toggleArchived" icon="folder" label="topic.actions.archive" class="btn-admin"}}
@ -47,7 +47,7 @@
</li> </li>
<li> <li>
{{#if visible}} {{#if model.visible}}
{{d-button action="toggleVisibility" icon="eye-slash" label="topic.actions.invisible" class="btn-admin"}} {{d-button action="toggleVisibility" icon="eye-slash" label="topic.actions.invisible" class="btn-admin"}}
{{else}} {{else}}
{{d-button action="toggleVisibility" icon="eye" label="topic.actions.visible" class="btn-admin"}} {{d-button action="toggleVisibility" icon="eye" label="topic.actions.visible" class="btn-admin"}}

View File

@ -18,7 +18,7 @@
{{/if}} {{/if}}
<nav id='topic-progress' title="{{i18n 'topic.progress.title'}}" {{bind-attr class="hideProgress:hidden"}}> <nav id='topic-progress' title="{{i18n 'topic.progress.title'}}" {{bind-attr class="hideProgress:hidden"}}>
<div class='nums'> <div class='nums'>
<h4>{{progressPosition}}</h4><span {{bind-attr class="hugeNumberOfPosts:hidden"}}> <span>/</span> <h4>{{postStream.filteredPostsCount}}</h4></span> <h4>{{progressPosition}}</h4><span {{bind-attr class="hugeNumberOfPosts:hidden"}}> <span>/</span> <h4>{{model.postStream.filteredPostsCount}}</h4></span>
</div> </div>
<i {{bind-attr class=":fa expanded::fa-sort"}}></i> <i {{bind-attr class=":fa expanded::fa-sort"}}></i>
<div class='bg'>&nbsp;</div> <div class='bg'>&nbsp;</div>

View File

@ -1,19 +1,19 @@
<div class='container'> <div class='container'>
{{custom-html "top"}} {{custom-html "top"}}
{{global-notice}} {{global-notice}}
{{discourse-banner user=currentUser banner=site.banner overlay=view.hasScrolled hide=errorLoading}} {{discourse-banner user=currentUser banner=site.banner overlay=view.hasScrolled hide=model.errorLoading}}
</div> </div>
{{plugin-outlet "topic-above-post-stream"}} {{plugin-outlet "topic-above-post-stream"}}
{{#if postStream.loaded}} {{#if model.postStream.loaded}}
{{#if postStream.firstPostPresent}} {{#if model.postStream.firstPostPresent}}
<div id='topic-title'> <div id='topic-title'>
<div class='container'> <div class='container'>
<div class="title-wrapper"> <div class="title-wrapper">
{{#if editingTopic}} {{#if editingTopic}}
{{#if isPrivateMessage}} {{#if model.isPrivateMessage}}
<span class="private-message-glyph">{{fa-icon "envelope"}}</span> <span class="private-message-glyph">{{fa-icon "envelope"}}</span>
{{autofocus-text-field id='edit-title' value=buffered.title maxLength=maxTitleLength}} {{autofocus-text-field id='edit-title' value=buffered.title maxLength=maxTitleLength}}
{{else}} {{else}}
@ -28,23 +28,23 @@
{{d-button action="cancelEditingTopic" class="btn-small no-text cancel-edit" icon="times"}} {{d-button action="cancelEditingTopic" class="btn-small no-text cancel-edit" icon="times"}}
{{else}} {{else}}
<h1> <h1>
{{#unless is_warning}} {{#unless model.is_warning}}
<span class="private-message-glyph">{{fa-icon "envelope"}}</span> <span class="private-message-glyph">{{fa-icon "envelope"}}</span>
{{/unless}} {{/unless}}
{{#if details.loaded}} {{#if model.details.loaded}}
{{topic-status topic=model}} {{topic-status topic=model}}
<a href='{{unbound url}}' {{action "jumpTop"}} class='fancy-title'> <a href='{{unbound model.url}}' {{action "jumpTop"}} class='fancy-title'>
{{{fancy_title}}} {{{model.fancy_title}}}
</a> </a>
{{/if}} {{/if}}
{{#if details.can_edit}} {{#if model.details.can_edit}}
<a href {{action "editTopic"}} class='edit-topic' title='{{i18n 'edit'}}'>{{fa-icon "pencil"}}</a> <a href {{action "editTopic"}} class='edit-topic' title='{{i18n 'edit'}}'>{{fa-icon "pencil"}}</a>
{{/if}} {{/if}}
</h1> </h1>
{{#unless isPrivateMessage}} {{#unless model.isPrivateMessage}}
{{topic-category topic=model}} {{topic-category topic=model}}
{{/unless}} {{/unless}}
{{/if}} {{/if}}
@ -59,39 +59,29 @@
{{view "selected-posts"}} {{view "selected-posts"}}
<div class="row"> <div class="row">
<section class="topic-area" id='topic' data-topic-id='{{unbound id}}'> <section class="topic-area" id='topic' data-topic-id='{{unbound model.id}}'>
<div class='posts-wrapper'> <div class='posts-wrapper'>
{{render 'topic-progress'}} {{render 'topic-progress'}}
{{conditional-loading-spinner condition=postStream.loadingAbove}} {{conditional-loading-spinner condition=model.postStream.loadingAbove}}
{{#unless postStream.loadingFilter}} {{#unless model.postStream.loadingFilter}}
{{cloaked-collection itemViewClass="post"
idProperty="post_number"
defaultHeight="200"
content=postStream.posts
slackRatio="15"
loadingHTML=""
preservesContext="true"
uncloakDefault="true"
offsetFixedTop="header"
offsetFixedBottom="#reply-control"}}
{{/unless}} {{/unless}}
{{conditional-loading-spinner condition=postStream.loadingBelow}} {{conditional-loading-spinner condition=model.postStream.loadingBelow}}
</div> </div>
<div id='topic-bottom'></div> <div id='topic-bottom'></div>
{{#conditional-loading-spinner condition=postStream.loadingFilter}} {{#conditional-loading-spinner condition=model.postStream.loadingFilter}}
{{#if loadedAllPosts}} {{#if loadedAllPosts}}
{{view 'topic-closing' topic=model}} {{view 'topic-closing' topic=model}}
{{view 'topic-footer-buttons' topic=model}} {{view 'topic-footer-buttons' topic=model}}
{{#if pending_posts_count}} {{#if model.pending_posts_count}}
<div class='has-pending-posts'> <div class='has-pending-posts'>
{{{i18n "queue.has_pending_posts" count=pending_posts_count}}} {{{i18n "queue.has_pending_posts" count=model.pending_posts_count}}}
{{#link-to 'queued-posts'}} {{#link-to 'queued-posts'}}
{{fa-icon 'check'}} {{fa-icon 'check'}}
@ -102,11 +92,11 @@
{{plugin-outlet "topic-above-suggested"}} {{plugin-outlet "topic-above-suggested"}}
{{#if details.suggested_topics.length}} {{#if model.details.suggested_topics.length}}
<div id='suggested-topics'> <div id='suggested-topics'>
<h3>{{i18n 'suggested_topics.title'}}</h3> <h3>{{i18n 'suggested_topics.title'}}</h3>
<div class='topics'> <div class='topics'>
{{basic-topic-list topics=details.suggested_topics postsAction="showTopicEntrance"}} {{basic-topic-list topics=model.details.suggested_topics postsAction="showTopicEntrance"}}
</div> </div>
<h3>{{{view.browseMoreMessage}}}</h3> <h3>{{{view.browseMoreMessage}}}</h3>
</div> </div>

View File

@ -4,22 +4,24 @@ export default ButtonView.extend({
classNames: ['bookmark'], classNames: ['bookmark'],
attributeBindings: ['disabled'], attributeBindings: ['disabled'],
textKey: function() { bookmarked: Ember.computed.alias('controller.model.bookmarked'),
return this.get('controller.bookmarked') ? 'bookmarked.clear_bookmarks' : 'bookmarked.title';
}.property('controller.bookmarked'),
rerenderTriggers: ['controller.bookmarked'], textKey: function() {
return this.get('bookmarked') ? 'bookmarked.clear_bookmarks' : 'bookmarked.title';
}.property('bookmarked'),
rerenderTriggers: ['bookmarked'],
helpKey: function() { helpKey: function() {
return this.get("controller.bookmarked") ? "bookmarked.help.unbookmark" : "bookmarked.help.bookmark"; return this.get("bookmarked") ? "bookmarked.help.unbookmark" : "bookmarked.help.bookmark";
}.property("controller.bookmarked"), }.property("bookmarked"),
click: function() { click: function() {
this.get('controller').send('toggleBookmark'); this.get('controller').send('toggleBookmark');
}, },
renderIcon: function(buffer) { renderIcon: function(buffer) {
var className = this.get("controller.bookmarked") ? "bookmarked" : ""; var className = this.get("bookmarked") ? "bookmarked" : "";
buffer.push("<i class='fa fa-bookmark " + className + "'></i>"); buffer.push("<i class='fa fa-bookmark " + className + "'></i>");
} }
}); });

View File

@ -160,7 +160,7 @@ const ComposerView = Discourse.View.extend(Ember.Evented, {
// If we are editing a post, we'll refresh its contents once. This is a feature that // If we are editing a post, we'll refresh its contents once. This is a feature that
// allows a user to refresh its contents once. // allows a user to refresh its contents once.
if (post && post.blank('refreshedPost')) { if (post && !post.get('refreshedPost')) {
refresh = true; refresh = true;
post.set('refreshedPost', true); post.set('refreshedPost', true);
} }

View File

@ -4,7 +4,7 @@ export default ButtonView.extend({
textKey: 'topic.invite_reply.title', textKey: 'topic.invite_reply.title',
helpKey: 'topic.invite_reply.help', helpKey: 'topic.invite_reply.help',
attributeBindings: ['disabled'], attributeBindings: ['disabled'],
disabled: Em.computed.or('controller.archived', 'controller.closed', 'controller.deleted'), disabled: Em.computed.or('controller.model.archived', 'controller.model.closed', 'controller.model.deleted'),
renderIcon(buffer) { renderIcon(buffer) {
buffer.push("<i class='fa fa-users'></i>"); buffer.push("<i class='fa fa-users'></i>");

View File

@ -0,0 +1,9 @@
export default Discourse.View.extend({
elementId: 'selected-posts',
topic: Ember.computed.alias('controller.model'),
classNameBindings: ['customVisibility'],
customVisibility: function() {
if (!this.get('controller.multiSelect')) return 'hidden';
}.property('controller.multiSelect')
});

View File

@ -1,21 +0,0 @@
/**
This view is used to handle the interface for multi selecting of posts.
@class SelectedPostsView
@extends Discourse.View
@namespace Discourse
@module Discourse
**/
Discourse.SelectedPostsView = Discourse.View.extend({
elementId: 'selected-posts',
templateName: 'selected_posts',
topicBinding: 'controller.content',
classNameBindings: ['customVisibility'],
customVisibility: (function() {
if (!this.get('controller.multiSelect')) return 'hidden';
}).property('controller.multiSelect')
});

View File

@ -40,15 +40,15 @@ export default Discourse.View.extend({
}.observes('controller.link'), }.observes('controller.link'),
didInsertElement: function() { didInsertElement: function() {
var shareView = this, var self = this,
$html = $('html'); $html = $('html');
$html.on('mousedown.outside-share-link', function(e) { $html.on('mousedown.outside-share-link', function(e) {
// Use mousedown instead of click so this event is handled before routing occurs when a // Use mousedown instead of click so this event is handled before routing occurs when a
// link is clicked (which is a click event) while the share dialog is showing. // link is clicked (which is a click event) while the share dialog is showing.
if (shareView.$().has(e.target).length !== 0) { return; } if (self.$().has(e.target).length !== 0) { return; }
shareView.get('controller').send('close'); self.get('controller').send('close');
return true; return true;
}); });
@ -91,16 +91,16 @@ export default Discourse.View.extend({
$shareLink.css({left: "" + x + "px"}); $shareLink.css({left: "" + x + "px"});
} }
shareView.set('controller.link', url); self.set('controller.link', url);
shareView.set('controller.postNumber', postNumber); self.set('controller.postNumber', postNumber);
shareView.set('controller.date', date); self.set('controller.date', date);
return false; return false;
}); });
$html.on('keydown.share-view', function(e){ $html.on('keydown.share-view', function(e){
if (e.keyCode === 27) { if (e.keyCode === 27) {
shareView.get('controller').send('close'); self.get('controller').send('close');
} }
}); });
}, },

View File

@ -29,7 +29,7 @@ export default Ember.View.extend({
_updateBar: function() { _updateBar: function() {
Em.run.scheduleOnce('afterRender', this, '_updateProgressBar'); Em.run.scheduleOnce('afterRender', this, '_updateProgressBar');
}.observes('controller.streamPercentage', 'postStream.stream.@each'), }.observes('controller.streamPercentage', 'controller.model.postStream.stream.@each'),
_updateProgressBar: function() { _updateProgressBar: function() {
// speeds up stuff, bypass jquery slowness and extra checks // speeds up stuff, bypass jquery slowness and extra checks

View File

@ -7,7 +7,8 @@ import { categoryBadgeHTML } from 'discourse/helpers/category-link';
const TopicView = Discourse.View.extend(AddCategoryClass, AddArchetypeClass, Discourse.Scrolling, { const TopicView = Discourse.View.extend(AddCategoryClass, AddArchetypeClass, Discourse.Scrolling, {
templateName: 'topic', templateName: 'topic',
topicBinding: 'controller.model', topicBinding: 'controller.model',
userFiltersBinding: 'controller.userFilters',
userFilters: Ember.computed.alias('controller.model.userFilters'),
classNameBindings: ['controller.multiSelect:multi-select', classNameBindings: ['controller.multiSelect:multi-select',
'topic.archetype', 'topic.archetype',
'topic.is_warning', 'topic.is_warning',
@ -19,7 +20,7 @@ const TopicView = Discourse.View.extend(AddCategoryClass, AddArchetypeClass, Dis
categoryFullSlug: Em.computed.alias('topic.category.fullSlug'), categoryFullSlug: Em.computed.alias('topic.category.fullSlug'),
postStream: Em.computed.alias('controller.postStream'), postStream: Em.computed.alias('controller.model.postStream'),
archetype: Em.computed.alias('topic.archetype'), archetype: Em.computed.alias('topic.archetype'),

View File

@ -136,7 +136,7 @@ module Tilt
def generate_source(scope) def generate_source(scope)
js_source = ::JSON.generate(data, quirks_mode: true) js_source = ::JSON.generate(data, quirks_mode: true)
js_source = "babel.transform(#{js_source}, {ast: false, whitelist: ['es6.constants', 'es6.properties.shorthand', 'es6.arrowFunctions', 'es6.blockScoping']})['code']" js_source = "babel.transform(#{js_source}, {ast: false, whitelist: ['es6.constants', 'es6.properties.shorthand', 'es6.arrowFunctions', 'es6.blockScoping', 'es6.destructuring']})['code']"
"new module.exports.Compiler(#{js_source}, '#{module_name(scope.root_path, scope.logical_path)}', #{compiler_options}).#{compiler_method}()" "new module.exports.Compiler(#{js_source}, '#{module_name(scope.root_path, scope.logical_path)}', #{compiler_options}).#{compiler_method}()"
end end

View File

@ -25,7 +25,7 @@ export default {
// listen for back-end to tell us when a post has a poll // listen for back-end to tell us when a post has a poll
messageBus.subscribe("/polls", data => { messageBus.subscribe("/polls", data => {
const post = container.lookup("controller:topic").get("postStream").findLoadedPost(data.post_id); const post = container.lookup("controller:topic").get('modee.postStream').findLoadedPost(data.post_id);
// HACK to trigger the "postViewUpdated" event // HACK to trigger the "postViewUpdated" event
Em.run.next(_ => post.set("cooked", post.get("cooked") + " ")); Em.run.next(_ => post.set("cooked", post.get("cooked") + " "));
}); });
@ -33,8 +33,7 @@ export default {
// overwrite polls // overwrite polls
PostView.reopen({ PostView.reopen({
_createPollViews: function($post) { _createPollViews: function($post) {
const self = this, const post = this.get("post"),
post = this.get("post"),
polls = post.get("polls"), polls = post.get("polls"),
votes = post.get("polls_votes") || {}; votes = post.get("polls_votes") || {};
@ -80,4 +79,4 @@ export default {
}.on("willClearRender") }.on("willClearRender")
}); });
} }
} };