From 39c2c958e68b80658b5677c481282a8a6f91309a Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 24 Jun 2014 16:40:48 -0400 Subject: [PATCH] ES6: ComposerView --- .../discourse/components/composer-text-area.js.es6 | 4 +++- app/assets/javascripts/discourse/lib/computed.js | 2 +- .../discourse/templates/composer.js.handlebars | 2 +- .../views/{composer/composer_view.js => composer.js.es6} | 8 +++++--- plugins/emoji/assets/javascripts/emoji.js.erb | 6 ++++-- 5 files changed, 14 insertions(+), 8 deletions(-) rename app/assets/javascripts/discourse/views/{composer/composer_view.js => composer.js.es6} (99%) diff --git a/app/assets/javascripts/discourse/components/composer-text-area.js.es6 b/app/assets/javascripts/discourse/components/composer-text-area.js.es6 index b6d66d2f0..fe213c2c6 100644 --- a/app/assets/javascripts/discourse/components/composer-text-area.js.es6 +++ b/app/assets/javascripts/discourse/components/composer-text-area.js.es6 @@ -1,6 +1,8 @@ export default Ember.TextArea.extend({ + elementId: 'wmd-input', + placeholder: function() { - return I18n.t(this.get('placeholderKey')); + return I18n.t('composer.reply_placeholder'); }.property('placeholderKey'), _signalParentInsert: function() { diff --git a/app/assets/javascripts/discourse/lib/computed.js b/app/assets/javascripts/discourse/lib/computed.js index 23bd4db75..374c72d27 100644 --- a/app/assets/javascripts/discourse/lib/computed.js +++ b/app/assets/javascripts/discourse/lib/computed.js @@ -93,7 +93,7 @@ Discourse.computed = { /** Returns whether properties end with a string - @method i18n + @method endWith @params {String} properties* to check @params {String} substring the substring @return {Function} computedProperty function diff --git a/app/assets/javascripts/discourse/templates/composer.js.handlebars b/app/assets/javascripts/discourse/templates/composer.js.handlebars index 7463c2eab..8280070fd 100644 --- a/app/assets/javascripts/discourse/templates/composer.js.handlebars +++ b/app/assets/javascripts/discourse/templates/composer.js.handlebars @@ -59,7 +59,7 @@
- {{composer-text-area tabindex="3" value=model.reply id="wmd-input" placeholderKey="composer.reply_placeholder"}} + {{composer-text-area tabindex="3" value=model.reply}} {{popupInputTip validation=view.replyValidation shownAt=view.showReplyTip}}
diff --git a/app/assets/javascripts/discourse/views/composer/composer_view.js b/app/assets/javascripts/discourse/views/composer.js.es6 similarity index 99% rename from app/assets/javascripts/discourse/views/composer/composer_view.js rename to app/assets/javascripts/discourse/views/composer.js.es6 index bcd13aea5..fedfe7f76 100644 --- a/app/assets/javascripts/discourse/views/composer/composer_view.js +++ b/app/assets/javascripts/discourse/views/composer.js.es6 @@ -8,7 +8,7 @@ @namespace Discourse @module Discourse **/ -Discourse.ComposerView = Discourse.View.extend(Ember.Evented, { +var ComposerView = Discourse.View.extend(Ember.Evented, { templateName: 'composer', elementId: 'reply-control', classNameBindings: ['model.creatingPrivateMessage:private-message', @@ -176,7 +176,7 @@ Discourse.ComposerView = Discourse.View.extend(Ember.Evented, { if ($wmdInput.length === 0 || $wmdInput.data('init') === true) return; $LAB.script(assetPath('defer/html-sanitizer-bundle')); - Discourse.ComposerView.trigger("initWmdEditor"); + ComposerView.trigger("initWmdEditor"); var template = this.container.lookupFactory('view:user-selector').templateFunction(); $wmdInput.data('init', true); @@ -513,4 +513,6 @@ Discourse.ComposerView = Discourse.View.extend(Ember.Evented, { } }); -RSVP.EventTarget.mixin(Discourse.ComposerView); +RSVP.EventTarget.mixin(ComposerView); + +export default ComposerView; diff --git a/plugins/emoji/assets/javascripts/emoji.js.erb b/plugins/emoji/assets/javascripts/emoji.js.erb index 7d2ed8e89..ccfbcfdff 100644 --- a/plugins/emoji/assets/javascripts/emoji.js.erb +++ b/plugins/emoji/assets/javascripts/emoji.js.erb @@ -96,8 +96,10 @@ } }); - if (Discourse && Discourse.ComposerView) { - Discourse.ComposerView.on("initWmdEditor", function(event){ + // TODO: Make this a proper ES6 import + var ComposerView = (Discourse && Discourse.ComposerView) || (typeof require !== "undefined" && require('discourse/views/composer').default); + if (ComposerView) { + ComposerView.on("initWmdEditor", function(event){ var baseUrl = Discourse.getURL("/");