mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Use {{aceEditor}}
helper to display the ace editor
This commit is contained in:
parent
0601bb6d74
commit
fe3ac50aae
11 changed files with 50 additions and 74 deletions
14
app/assets/javascripts/admin/helpers/admin_helpers.js
Normal file
14
app/assets/javascripts/admin/helpers/admin_helpers.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
Inserts a rich code editor
|
||||
|
||||
@method aceEditor
|
||||
@for Handlebars
|
||||
**/
|
||||
Ember.Handlebars.registerHelper('aceEditor', function(options) {
|
||||
var hash = options.hash,
|
||||
types = options.hashTypes;
|
||||
|
||||
Discourse.Utilities.normalizeHash(hash, types);
|
||||
|
||||
return Ember.Handlebars.helpers.view.call(this, Discourse.AceEditorView, options);
|
||||
});
|
|
@ -26,10 +26,10 @@
|
|||
{{#with selectedItem}}
|
||||
{{textField class="style-name" value=name}}
|
||||
{{#if view.headerActive}}
|
||||
{{view Discourse.AceEditorView contentBinding="header" mode="html"}}
|
||||
{{aceEditor content=header mode="html"}}
|
||||
{{/if}}
|
||||
{{#if view.stylesheetActive}}
|
||||
{{view Discourse.AceEditorView contentBinding="stylesheet" mode="css"}}
|
||||
{{aceEditor content=stylesheet mode="css"}}
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
<br>
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
{{#unless loading}}
|
||||
{{ render 'admin_report_trust_levels' users_by_trust_level }}
|
||||
{{ render 'admin/templates/reports/trust_levels_report' users_by_trust_level tagName="tbody" }}
|
||||
{{/unless}}
|
||||
</table>
|
||||
</div>
|
||||
|
@ -162,14 +162,14 @@
|
|||
</tr>
|
||||
</thead>
|
||||
{{#unless loading}}
|
||||
{{ render 'admin_report_visits' visits }}
|
||||
{{ render 'admin/templates/reports/per_day_counts_report' visits tagName="tbody"}}
|
||||
{{/unless}}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-right">
|
||||
{{ render admin_github_commits githubCommits }}
|
||||
{{ render 'admin/templates/commits' githubCommits }}
|
||||
|
||||
<div class="dashboard-stats">
|
||||
<table class="table table-condensed table-hover">
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
{{/if}}
|
||||
|
||||
{{#if html}}
|
||||
{{view Discourse.AceEditorView contentBinding="model.content" mode="html"}}
|
||||
{{aceEditor content=model.content mode="html"}}
|
||||
{{/if}}
|
||||
|
||||
{{#if css}}
|
||||
{{view Discourse.AceEditorView contentBinding="model.content" mode="css"}}
|
||||
{{aceEditor content=model.content mode="css"}}
|
||||
{{/if}}
|
||||
|
||||
|
||||
|
|
|
@ -34,31 +34,25 @@ Discourse.AceEditorView = Discourse.View.extend({
|
|||
},
|
||||
|
||||
didInsertElement: function() {
|
||||
var initAce,
|
||||
_this = this;
|
||||
|
||||
initAce = function() {
|
||||
_this.editor = ace.edit(_this.$('.ace')[0]);
|
||||
_this.editor.setTheme("ace/theme/chrome");
|
||||
_this.editor.setShowPrintMargin(false);
|
||||
_this.editor.getSession().setMode("ace/mode/" + (_this.get('mode')));
|
||||
return _this.editor.on("change", function(e) {
|
||||
/* amending stuff as you type seems a bit out of scope for now - can revisit after launch
|
||||
changes = @get('changes')
|
||||
unless changes
|
||||
changes = []
|
||||
@set('changes', changes)
|
||||
changes.push e.data
|
||||
*/
|
||||
_this.skipContentChangeEvent = true;
|
||||
_this.set('content', _this.editor.getSession().getValue());
|
||||
_this.skipContentChangeEvent = false;
|
||||
var aceEditorView = this;
|
||||
|
||||
var initAce = function() {
|
||||
aceEditorView.editor = ace.edit(aceEditorView.$('.ace')[0]);
|
||||
aceEditorView.editor.setTheme("ace/theme/chrome");
|
||||
aceEditorView.editor.setShowPrintMargin(false);
|
||||
aceEditorView.editor.getSession().setMode("ace/mode/" + (aceEditorView.get('mode')));
|
||||
aceEditorView.editor.on("change", function(e) {
|
||||
aceEditorView.skipContentChangeEvent = true;
|
||||
aceEditorView.set('content', aceEditorView.editor.getSession().getValue());
|
||||
aceEditorView.skipContentChangeEvent = false;
|
||||
});
|
||||
};
|
||||
|
||||
if (window.ace) {
|
||||
return initAce();
|
||||
initAce();
|
||||
} else {
|
||||
return $LAB.script('http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js').wait(initAce);
|
||||
$LAB.script('http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js').wait(initAce);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
/**
|
||||
A view for showing commits to the discourse repo.
|
||||
|
||||
@class AdminGithubCommitsView
|
||||
@extends Discourse.View
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.AdminGithubCommitsView = Discourse.View.extend({
|
||||
templateName: 'admin/templates/commits'
|
||||
});
|
|
@ -1,4 +0,0 @@
|
|||
Discourse.AdminGroupsView = Discourse.View.extend({
|
||||
});
|
||||
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
/**
|
||||
The view that displays the number of users at each trust level
|
||||
on the admin dashboard.
|
||||
|
||||
@class AdminReportTrustLevelsView
|
||||
@extends Discourse.View
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.AdminReportTrustLevelsView = Discourse.View.extend({
|
||||
templateName: 'admin/templates/reports/trust_levels_report',
|
||||
tagName: 'tbody'
|
||||
});
|
|
@ -1,4 +0,0 @@
|
|||
Discourse.AdminReportVisitsView = Discourse.View.extend({
|
||||
templateName: 'admin/templates/reports/per_day_counts_report',
|
||||
tagName: 'tbody'
|
||||
});
|
|
@ -17,6 +17,18 @@ Discourse.Utilities = {
|
|||
return size;
|
||||
},
|
||||
|
||||
/**
|
||||
Allows us to supply bindings without "binding" to a helper.
|
||||
**/
|
||||
normalizeHash: function(hash, hashTypes) {
|
||||
for (var prop in hash) {
|
||||
if (hashTypes[prop] === 'ID') {
|
||||
hash[prop + 'Binding'] = hash[prop];
|
||||
delete hash[prop];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
categoryUrlId: function(category) {
|
||||
if (!category) return "";
|
||||
var id = Em.get(category, 'id');
|
||||
|
|
|
@ -1,15 +1,3 @@
|
|||
/**
|
||||
Allows us to supply bindings without "binding" to a helper.
|
||||
**/
|
||||
function normalizeHash(hash, hashTypes) {
|
||||
for (var prop in hash) {
|
||||
if (hashTypes[prop] === 'ID') {
|
||||
hash[prop + 'Binding'] = hash[prop];
|
||||
delete hash[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Breaks up a long string
|
||||
|
||||
|
@ -78,7 +66,7 @@ Ember.Handlebars.registerHelper('textField', function(options) {
|
|||
var hash = options.hash,
|
||||
types = options.hashTypes;
|
||||
|
||||
normalizeHash(hash, types);
|
||||
Discourse.Utilities.normalizeHash(hash, types);
|
||||
|
||||
return Ember.Handlebars.helpers.view.call(this, Discourse.TextField, options);
|
||||
});
|
||||
|
@ -93,7 +81,7 @@ Ember.Handlebars.registerHelper('inputTip', function(options) {
|
|||
var hash = options.hash,
|
||||
types = options.hashTypes;
|
||||
|
||||
normalizeHash(hash, types);
|
||||
Discourse.Utilities.normalizeHash(hash, types);
|
||||
|
||||
return Ember.Handlebars.helpers.view.call(this, Discourse.InputTipView, options);
|
||||
});
|
||||
|
@ -108,7 +96,7 @@ Ember.Handlebars.registerHelper('popupInputTip', function(options) {
|
|||
var hash = options.hash,
|
||||
types = options.hashTypes;
|
||||
|
||||
normalizeHash(hash, types);
|
||||
Discourse.Utilities.normalizeHash(hash, types);
|
||||
|
||||
return Ember.Handlebars.helpers.view.call(this, Discourse.PopupInputTipView, options);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue