ES6: Convert {{pagedown}} to {{pagedown-editor}} with deprecations

This commit is contained in:
Robin Ward 2014-06-09 12:16:27 -04:00
parent 1df3214773
commit 7adb545168
10 changed files with 29 additions and 26 deletions

View file

@ -39,6 +39,7 @@
"_",
"alert",
"controllerFor",
"viewClassFor",
"testController",
"containsInstance",
"parseHTML",

View file

@ -2,7 +2,7 @@
<p class='description'>{{model.description}}</p>
{{#if model.markdown}}
{{pagedown value=model.content}}
{{pagedown-editor value=model.content}}
{{/if}}
{{#if model.plainText}}
{{textarea value=model.content class="plain"}}

View file

@ -1,5 +1,6 @@
var deprecatedViewHelpers = {
inputTip: 'input-tip'
inputTip: 'input-tip',
pagedown: 'pagedown-editor'
};
export default {

View file

@ -1,4 +1,4 @@
var helpers = ['input-tip'];
var helpers = ['input-tip', 'pagedown-editor'];
/**
Creates view helpers for some views. Many of these should probably be converted

View file

@ -17,7 +17,7 @@
<div class="control-group">
<label class="control-label">{{i18n user.bio}}</label>
<div class="controls">
{{pagedown value=bio_raw}}
{{pagedown-editor value=bio_raw}}
</div>
</div>

View file

@ -123,7 +123,7 @@
<div class="control-group">
<label class="control-label">{{i18n user.bio}}</label>
<div class="controls bio-composer">
{{pagedown value=bio_raw}}
{{pagedown-editor value=bio_raw}}
</div>
</div>

View file

@ -8,7 +8,9 @@
@namespace Discourse
@module Discourse
**/
Discourse.PagedownEditor = Discourse.ContainerView.extend({
import PagedownPreviewView from 'discourse/views/pagedown-preview';
export default Discourse.ContainerView.extend({
elementId: 'pagedown-editor',
init: function() {
@ -20,7 +22,7 @@ Discourse.PagedownEditor = Discourse.ContainerView.extend({
this.pushObject(Em.View.create({ elementId: 'wmd-button-bar' }));
this.pushObject(Em.TextArea.create({ valueBinding: 'parentView.value', elementId: 'wmd-input' }));
this.attachViewClass(Discourse.PagedownPreviewView);
this.attachViewClass(PagedownPreviewView);
},
didInsertElement: function() {
@ -36,19 +38,3 @@ Discourse.PagedownEditor = Discourse.ContainerView.extend({
}.observes('value')
});
Discourse.View.registerHelper('pagedown', Discourse.PagedownEditor);
/**
A helper view to display a preview of the pagedown content
@class PagedownPreviewView
@extends Discourse.View
@namespace Discourse
@module Discourse
**/
Discourse.PagedownPreviewView = Discourse.View.extend({
elementId: 'wmd-preview',
classNameBindings: [':preview', 'hidden'],
hidden: Em.computed.empty('parentView.value')
});

View file

@ -0,0 +1,13 @@
/**
A helper view to display a preview of the pagedown content
@class PagedownPreviewView
@extends Discourse.View
@namespace Discourse
@module Discourse
**/
export default Discourse.View.extend({
elementId: 'wmd-preview',
classNameBindings: [':preview', 'hidden'],
hidden: Em.computed.empty('parentView.value')
});

View file

@ -43,6 +43,10 @@ function controllerFor(controller, model) {
return controller;
}
function viewClassFor(name) {
return Discourse.__container__.lookupFactory('view:' + name);
}
function asyncTestDiscourse(text, func) {
asyncTest(text, function () {
var self = this;

View file

@ -1,12 +1,10 @@
module("Discourse.HeaderView");
import HeaderView from 'discourse/views/header';
test("showNotifications", function() {
var controllerSpy = {
send: sinon.spy()
};
var view = HeaderView.create({
var view = viewClassFor('header').create({
controller: controllerSpy
});