mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
ES6: Convert {{pagedown}} to {{pagedown-editor}} with deprecations
This commit is contained in:
parent
1df3214773
commit
7adb545168
10 changed files with 29 additions and 26 deletions
|
@ -39,6 +39,7 @@
|
||||||
"_",
|
"_",
|
||||||
"alert",
|
"alert",
|
||||||
"controllerFor",
|
"controllerFor",
|
||||||
|
"viewClassFor",
|
||||||
"testController",
|
"testController",
|
||||||
"containsInstance",
|
"containsInstance",
|
||||||
"parseHTML",
|
"parseHTML",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<p class='description'>{{model.description}}</p>
|
<p class='description'>{{model.description}}</p>
|
||||||
|
|
||||||
{{#if model.markdown}}
|
{{#if model.markdown}}
|
||||||
{{pagedown value=model.content}}
|
{{pagedown-editor value=model.content}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if model.plainText}}
|
{{#if model.plainText}}
|
||||||
{{textarea value=model.content class="plain"}}
|
{{textarea value=model.content class="plain"}}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
var deprecatedViewHelpers = {
|
var deprecatedViewHelpers = {
|
||||||
inputTip: 'input-tip'
|
inputTip: 'input-tip',
|
||||||
|
pagedown: 'pagedown-editor'
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -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
|
Creates view helpers for some views. Many of these should probably be converted
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">{{i18n user.bio}}</label>
|
<label class="control-label">{{i18n user.bio}}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
{{pagedown value=bio_raw}}
|
{{pagedown-editor value=bio_raw}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">{{i18n user.bio}}</label>
|
<label class="control-label">{{i18n user.bio}}</label>
|
||||||
<div class="controls bio-composer">
|
<div class="controls bio-composer">
|
||||||
{{pagedown value=bio_raw}}
|
{{pagedown-editor value=bio_raw}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,9 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.PagedownEditor = Discourse.ContainerView.extend({
|
import PagedownPreviewView from 'discourse/views/pagedown-preview';
|
||||||
|
|
||||||
|
export default Discourse.ContainerView.extend({
|
||||||
elementId: 'pagedown-editor',
|
elementId: 'pagedown-editor',
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
|
@ -20,7 +22,7 @@ Discourse.PagedownEditor = Discourse.ContainerView.extend({
|
||||||
this.pushObject(Em.View.create({ elementId: 'wmd-button-bar' }));
|
this.pushObject(Em.View.create({ elementId: 'wmd-button-bar' }));
|
||||||
this.pushObject(Em.TextArea.create({ valueBinding: 'parentView.value', elementId: 'wmd-input' }));
|
this.pushObject(Em.TextArea.create({ valueBinding: 'parentView.value', elementId: 'wmd-input' }));
|
||||||
|
|
||||||
this.attachViewClass(Discourse.PagedownPreviewView);
|
this.attachViewClass(PagedownPreviewView);
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement: function() {
|
didInsertElement: function() {
|
||||||
|
@ -36,19 +38,3 @@ Discourse.PagedownEditor = Discourse.ContainerView.extend({
|
||||||
}.observes('value')
|
}.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')
|
|
||||||
});
|
|
|
@ -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')
|
||||||
|
});
|
|
@ -43,6 +43,10 @@ function controllerFor(controller, model) {
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function viewClassFor(name) {
|
||||||
|
return Discourse.__container__.lookupFactory('view:' + name);
|
||||||
|
}
|
||||||
|
|
||||||
function asyncTestDiscourse(text, func) {
|
function asyncTestDiscourse(text, func) {
|
||||||
asyncTest(text, function () {
|
asyncTest(text, function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
module("Discourse.HeaderView");
|
module("Discourse.HeaderView");
|
||||||
|
|
||||||
import HeaderView from 'discourse/views/header';
|
|
||||||
|
|
||||||
test("showNotifications", function() {
|
test("showNotifications", function() {
|
||||||
var controllerSpy = {
|
var controllerSpy = {
|
||||||
send: sinon.spy()
|
send: sinon.spy()
|
||||||
};
|
};
|
||||||
var view = HeaderView.create({
|
var view = viewClassFor('header').create({
|
||||||
controller: controllerSpy
|
controller: controllerSpy
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue