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",
|
||||
"controllerFor",
|
||||
"viewClassFor",
|
||||
"testController",
|
||||
"containsInstance",
|
||||
"parseHTML",
|
||||
|
|
|
@ -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"}}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var deprecatedViewHelpers = {
|
||||
inputTip: 'input-tip'
|
||||
inputTip: 'input-tip',
|
||||
pagedown: 'pagedown-editor'
|
||||
};
|
||||
|
||||
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
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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')
|
||||
});
|
|
@ -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;
|
||||
}
|
||||
|
||||
function viewClassFor(name) {
|
||||
return Discourse.__container__.lookupFactory('view:' + name);
|
||||
}
|
||||
|
||||
function asyncTestDiscourse(text, func) {
|
||||
asyncTest(text, function () {
|
||||
var self = this;
|
||||
|
|
|
@ -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
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue