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({
elementId: 'wmd-input',
placeholder: function() {
return I18n.t(this.get('placeholderKey'));
return I18n.t('composer.reply_placeholder');
}.property('placeholderKey'),
_signalParentInsert: function() {

View file

@ -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

View file

@ -59,7 +59,7 @@
<div class='textarea-wrapper'>
<div class='wmd-button-bar' id='wmd-button-bar'></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}}
</div>
<div class='preview-wrapper'>

View file

@ -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;

View file

@ -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("/");