mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-17 04:01:29 -05:00
Refactor: Adds Discourse.Utilities.registerViewHelper
to register view helpers
This commit is contained in:
parent
3d0587d8ce
commit
4d5c145198
12 changed files with 23 additions and 66 deletions
|
@ -1,14 +0,0 @@
|
|||
/**
|
||||
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);
|
||||
});
|
|
@ -57,4 +57,4 @@ Discourse.AceEditorView = Discourse.View.extend({
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
Discourse.Utilities.registerViewHelper('aceEditor', Discourse.AceEditorView);
|
|
@ -29,6 +29,19 @@ Discourse.Utilities = {
|
|||
}
|
||||
},
|
||||
|
||||
/*
|
||||
Register a view class as a helper
|
||||
*/
|
||||
registerViewHelper: function(helperName, helperClass) {
|
||||
Ember.Handlebars.registerHelper(helperName, function(options) {
|
||||
var hash = options.hash,
|
||||
types = options.hashTypes;
|
||||
|
||||
Discourse.Utilities.normalizeHash(hash, types);
|
||||
return Ember.Handlebars.helpers.view.call(this, helperClass, options);
|
||||
});
|
||||
},
|
||||
|
||||
// Create a badge like category link
|
||||
categoryLink: function(category) {
|
||||
if (!category) return "";
|
||||
|
|
|
@ -56,51 +56,6 @@ Handlebars.registerHelper('categoryLink', function(property, options) {
|
|||
return new Handlebars.SafeString(Discourse.Utilities.categoryLink(category));
|
||||
});
|
||||
|
||||
/**
|
||||
Inserts a Discourse.TextField to allow the user to enter information.
|
||||
|
||||
@method textField
|
||||
@for Handlebars
|
||||
**/
|
||||
Ember.Handlebars.registerHelper('textField', function(options) {
|
||||
var hash = options.hash,
|
||||
types = options.hashTypes;
|
||||
|
||||
Discourse.Utilities.normalizeHash(hash, types);
|
||||
|
||||
return Ember.Handlebars.helpers.view.call(this, Discourse.TextField, options);
|
||||
});
|
||||
|
||||
/**
|
||||
Inserts a Discourse.InputTipView
|
||||
|
||||
@method inputTip
|
||||
@for Handlebars
|
||||
**/
|
||||
Ember.Handlebars.registerHelper('inputTip', function(options) {
|
||||
var hash = options.hash,
|
||||
types = options.hashTypes;
|
||||
|
||||
Discourse.Utilities.normalizeHash(hash, types);
|
||||
|
||||
return Ember.Handlebars.helpers.view.call(this, Discourse.InputTipView, options);
|
||||
});
|
||||
|
||||
/**
|
||||
Inserts a Discourse.PopupInputTipView
|
||||
|
||||
@method popupInputTip
|
||||
@for Handlebars
|
||||
**/
|
||||
Ember.Handlebars.registerHelper('popupInputTip', function(options) {
|
||||
var hash = options.hash,
|
||||
types = options.hashTypes;
|
||||
|
||||
Discourse.Utilities.normalizeHash(hash, types);
|
||||
|
||||
return Ember.Handlebars.helpers.view.call(this, Discourse.PopupInputTipView, options);
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
Produces a bound link to a category
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<tr {{bindAttr class="archived"}}>
|
||||
<td class='main-link'>
|
||||
<div class='topic-inset'>
|
||||
{{view Discourse.TopicStatusView topicBinding="this"}}
|
||||
{{topicStatus topic=this}}
|
||||
{{{topicLink this}}
|
||||
{{#if unread}}
|
||||
<a href="{{unbound lastReadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts unread="unread"}}'>{{unbound unread}}</a>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{view Discourse.TopicStatusView topicBinding="this"}}
|
||||
{{topicStatus topic=this}}
|
||||
{{{topicLink this}}}
|
||||
{{#if unread}}
|
||||
<a href="{{lastReadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts unread="unread"}}'>{{unread}}</a>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
{{else}}
|
||||
<h1>
|
||||
{{#if view.topic.fancy_title}}
|
||||
{{view Discourse.TopicStatusView topicBinding="view.topic"}}
|
||||
{{topicStatus topic=view.topic}}
|
||||
<a href='{{unbound view.topic.url}}'>{{{view.topic.fancy_title}}}</a>
|
||||
{{else}}
|
||||
{{#if view.topic.errorLoading}}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<h1>
|
||||
{{#if view.topic.fancy_title}}
|
||||
{{view Discourse.TopicStatusView topicBinding="view.topic"}}
|
||||
{{topicStatus topic=view.topic}}
|
||||
<a class='topic-link' href='{{unbound view.topic.url}}'>{{{view.topic.fancy_title}}}</a>
|
||||
{{else}}
|
||||
{{#if view.topic.errorLoading}}
|
||||
|
|
|
@ -19,4 +19,4 @@ Discourse.TextField = Ember.TextField.extend({
|
|||
|
||||
});
|
||||
|
||||
|
||||
Discourse.Utilities.registerViewHelper('textField', Discourse.TextField);
|
|
@ -30,4 +30,4 @@ Discourse.InputTipView = Discourse.View.extend({
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
Discourse.Utilities.registerViewHelper('inputTip', Discourse.InputTipView);
|
|
@ -55,3 +55,5 @@ Discourse.PopupInputTipView = Discourse.View.extend({
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
Discourse.Utilities.registerViewHelper('popupInputTip', Discourse.PopupInputTipView);
|
|
@ -48,3 +48,4 @@ Discourse.TopicStatusView = Discourse.View.extend({
|
|||
});
|
||||
|
||||
|
||||
Discourse.Utilities.registerViewHelper('topicStatus', Discourse.TopicStatusView);
|
Loading…
Reference in a new issue