diff --git a/.gitignore b/.gitignore index 4a6c9eef420..da3495325ae 100644 --- a/.gitignore +++ b/.gitignore @@ -40,9 +40,10 @@ config/discourse.conf log/ # Ignore plugins except for the bundled ones. -/plugins -!/plugins/emoji -!/plugins/poll +/plugins/* +!/plugins/emoji/ +!/plugins/poll/ +/plugins/*/auto_generated/ /spec/fixtures/plugins/my_plugin/auto_generated diff --git a/plugins/poll/assets/javascripts/poll_ui.js b/plugins/poll/assets/javascripts/initializers/poll.js.es6 similarity index 69% rename from plugins/poll/assets/javascripts/poll_ui.js rename to plugins/poll/assets/javascripts/initializers/poll.js.es6 index ed5c810bb27..2e7e2eaa6ba 100644 --- a/plugins/poll/assets/javascripts/poll_ui.js +++ b/plugins/poll/assets/javascripts/initializers/poll.js.es6 @@ -1,3 +1,5 @@ +import PollController from "discourse/plugins/poll/controllers/poll"; + var Poll = Discourse.Model.extend({ post: null, options: [], @@ -41,8 +43,6 @@ var Poll = Discourse.Model.extend({ } }); -var PollController = require("discourse/plugins/poll/controllers/poll").default; - var PollView = Ember.View.extend({ templateName: "poll", classNames: ['poll-ui'], @@ -73,29 +73,36 @@ function initializePollView(self) { return pollView; } -Discourse.PostView.reopen({ - createPollUI: function($post) { - var post = this.get('post'); - if (!post.get('poll_details')) { - return; - } +export default { + name: 'poll', - var view = initializePollView(this); + initialize: function() { + Discourse.PostView.reopen({ + createPollUI: function($post) { + var post = this.get('post'); - var pollContainer = $post.find(".poll-ui:first"); - if (pollContainer.length === 0) { - pollContainer = $post.find("ul:first"); - } + if (!post.get('poll_details')) { + return; + } - view.replaceElement(pollContainer); - this.set('pollView', view); + var view = initializePollView(this); - }.on('postViewInserted'), + var pollContainer = $post.find(".poll-ui:first"); + if (pollContainer.length === 0) { + pollContainer = $post.find("ul:first"); + } - clearPollView: function() { - if (this.get('pollView')) { - this.get('pollView').destroy(); - } - }.on('willClearRender') -}); + view.replaceElement(pollContainer); + this.set('pollView', view); + + }.on('postViewInserted'), + + clearPollView: function() { + if (this.get('pollView')) { + this.get('pollView').destroy(); + } + }.on('willClearRender') + }); + } +} diff --git a/plugins/poll/plugin.rb b/plugins/poll/plugin.rb index 9a3b152b8b5..3ff6902ca75 100644 --- a/plugins/poll/plugin.rb +++ b/plugins/poll/plugin.rb @@ -144,7 +144,7 @@ end # Poll UI. register_asset "javascripts/controllers/poll.js.es6" register_asset "javascripts/discourse/templates/poll.js.handlebars" -register_asset "javascripts/poll_ui.js" +register_asset "javascripts/initializers/poll.js.es6" register_asset "javascripts/poll_bbcode.js", :server_side register_css <