ES6: ComposerView

This commit is contained in:
Robin Ward 2014-06-24 16:40:48 -04:00
parent 2d2e12fd08
commit 39c2c958e6
5 changed files with 14 additions and 8 deletions

View File

@ -1,6 +1,8 @@
export default Ember.TextArea.extend({ export default Ember.TextArea.extend({
elementId: 'wmd-input',
placeholder: function() { placeholder: function() {
return I18n.t(this.get('placeholderKey')); return I18n.t('composer.reply_placeholder');
}.property('placeholderKey'), }.property('placeholderKey'),
_signalParentInsert: function() { _signalParentInsert: function() {

View File

@ -93,7 +93,7 @@ Discourse.computed = {
/** /**
Returns whether properties end with a string Returns whether properties end with a string
@method i18n @method endWith
@params {String} properties* to check @params {String} properties* to check
@params {String} substring the substring @params {String} substring the substring
@return {Function} computedProperty function @return {Function} computedProperty function

View File

@ -59,7 +59,7 @@
<div class='textarea-wrapper'> <div class='textarea-wrapper'>
<div class='wmd-button-bar' id='wmd-button-bar'></div> <div class='wmd-button-bar' id='wmd-button-bar'></div>
<div id='wmd-preview-scroller'></div> <div id='wmd-preview-scroller'></div>
{{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}} {{popupInputTip validation=view.replyValidation shownAt=view.showReplyTip}}
</div> </div>
<div class='preview-wrapper'> <div class='preview-wrapper'>

View File

@ -8,7 +8,7 @@
@namespace Discourse @namespace Discourse
@module Discourse @module Discourse
**/ **/
Discourse.ComposerView = Discourse.View.extend(Ember.Evented, { var ComposerView = Discourse.View.extend(Ember.Evented, {
templateName: 'composer', templateName: 'composer',
elementId: 'reply-control', elementId: 'reply-control',
classNameBindings: ['model.creatingPrivateMessage:private-message', 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; if ($wmdInput.length === 0 || $wmdInput.data('init') === true) return;
$LAB.script(assetPath('defer/html-sanitizer-bundle')); $LAB.script(assetPath('defer/html-sanitizer-bundle'));
Discourse.ComposerView.trigger("initWmdEditor"); ComposerView.trigger("initWmdEditor");
var template = this.container.lookupFactory('view:user-selector').templateFunction(); var template = this.container.lookupFactory('view:user-selector').templateFunction();
$wmdInput.data('init', true); $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;

View File

@ -96,8 +96,10 @@
} }
}); });
if (Discourse && Discourse.ComposerView) { // TODO: Make this a proper ES6 import
Discourse.ComposerView.on("initWmdEditor", function(event){ var ComposerView = (Discourse && Discourse.ComposerView) || (typeof require !== "undefined" && require('discourse/views/composer').default);
if (ComposerView) {
ComposerView.on("initWmdEditor", function(event){
var baseUrl = Discourse.getURL("/"); var baseUrl = Discourse.getURL("/");