This commit is contained in:
Sam
2014-12-04 09:35:11 +11:00
parent 665ff94ff7
commit 8977d5917b
15 changed files with 10667 additions and 13458 deletions

View File

@ -49,6 +49,12 @@ var Poll = Discourse.Model.extend({
var PollView = Ember.View.extend({
templateName: "poll",
classNames: ['poll-ui'],
replaceElement: function(target) {
this._insertElementLater(function() {
target.replaceWith(this.$());
});
}
});
function initializePollView(self) {
@ -64,9 +70,13 @@ function initializePollView(self) {
postController: self.get('controller')
});
return self.createChildView(PollView, { controller: pollController });
var pollView = self.createChildView(PollView, {
controller: pollController
});
return pollView;
}
export default {
name: 'poll',
@ -80,14 +90,13 @@ export default {
}
var view = initializePollView(this);
var pollContainer = $post.find(".poll-ui:first");
if (pollContainer.length === 0) {
pollContainer = $post.find("ul:first");
}
var $div = $('<div>');
pollContainer.replaceWith($div);
view.constructor.renderer.appendTo(view, $div[0]);
view.replaceElement(pollContainer);
this.set('pollView', view);
}.on('postViewInserted'),
@ -99,4 +108,4 @@ export default {
}.on('willClearRender')
});
}
};
}