diff --git a/.jshintrc b/.jshintrc
index e1f5f6e59..fc38f5c37 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -39,6 +39,7 @@
"_",
"alert",
"controllerFor",
+ "viewClassFor",
"testController",
"containsInstance",
"parseHTML",
diff --git a/app/assets/javascripts/admin/templates/site_content_edit.js.handlebars b/app/assets/javascripts/admin/templates/site_content_edit.js.handlebars
index cd35dd0c5..d0e1e22af 100644
--- a/app/assets/javascripts/admin/templates/site_content_edit.js.handlebars
+++ b/app/assets/javascripts/admin/templates/site_content_edit.js.handlebars
@@ -2,7 +2,7 @@
{{model.description}}
{{#if model.markdown}}
- {{pagedown value=model.content}}
+ {{pagedown-editor value=model.content}}
{{/if}}
{{#if model.plainText}}
{{textarea value=model.content class="plain"}}
diff --git a/app/assets/javascripts/discourse/initializers/deprecations.js.es6 b/app/assets/javascripts/discourse/initializers/deprecations.js.es6
index f25c7ec10..2850b6da4 100644
--- a/app/assets/javascripts/discourse/initializers/deprecations.js.es6
+++ b/app/assets/javascripts/discourse/initializers/deprecations.js.es6
@@ -1,5 +1,6 @@
var deprecatedViewHelpers = {
- inputTip: 'input-tip'
+ inputTip: 'input-tip',
+ pagedown: 'pagedown-editor'
};
export default {
diff --git a/app/assets/javascripts/discourse/initializers/view-helpers.js.es6 b/app/assets/javascripts/discourse/initializers/view-helpers.js.es6
index 97ab6e911..d4014b32f 100644
--- a/app/assets/javascripts/discourse/initializers/view-helpers.js.es6
+++ b/app/assets/javascripts/discourse/initializers/view-helpers.js.es6
@@ -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
diff --git a/app/assets/javascripts/discourse/templates/user/about.js.handlebars b/app/assets/javascripts/discourse/templates/user/about.js.handlebars
index d47df3d3a..c1c1e3286 100644
--- a/app/assets/javascripts/discourse/templates/user/about.js.handlebars
+++ b/app/assets/javascripts/discourse/templates/user/about.js.handlebars
@@ -17,7 +17,7 @@
- {{pagedown value=bio_raw}}
+ {{pagedown-editor value=bio_raw}}
diff --git a/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars b/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars
index 965111b3b..037efc9c3 100644
--- a/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars
+++ b/app/assets/javascripts/discourse/templates/user/preferences.js.handlebars
@@ -123,7 +123,7 @@
- {{pagedown value=bio_raw}}
+ {{pagedown-editor value=bio_raw}}
diff --git a/app/assets/javascripts/discourse/views/pagedown_editor.js b/app/assets/javascripts/discourse/views/pagedown-editor.js.es6
similarity index 62%
rename from app/assets/javascripts/discourse/views/pagedown_editor.js
rename to app/assets/javascripts/discourse/views/pagedown-editor.js.es6
index dd3ba8b99..3fe2c3d62 100644
--- a/app/assets/javascripts/discourse/views/pagedown_editor.js
+++ b/app/assets/javascripts/discourse/views/pagedown-editor.js.es6
@@ -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')
-});
\ No newline at end of file
diff --git a/app/assets/javascripts/discourse/views/pagedown-preview.js.es6 b/app/assets/javascripts/discourse/views/pagedown-preview.js.es6
new file mode 100644
index 000000000..dfe20937a
--- /dev/null
+++ b/app/assets/javascripts/discourse/views/pagedown-preview.js.es6
@@ -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')
+});
diff --git a/test/javascripts/helpers/qunit_helpers.js b/test/javascripts/helpers/qunit_helpers.js
index b5b96263d..9e576dd6d 100644
--- a/test/javascripts/helpers/qunit_helpers.js
+++ b/test/javascripts/helpers/qunit_helpers.js
@@ -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;
diff --git a/test/javascripts/views/header_view_test.js b/test/javascripts/views/header_view_test.js
index 41d3ee322..6491306c4 100644
--- a/test/javascripts/views/header_view_test.js
+++ b/test/javascripts/views/header_view_test.js
@@ -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
});