Refactor: Convert repeated {{view Discourse.xyz}} to registered view helpers
This commit is contained in:
parent
57d5355ce8
commit
5ae7707000
|
@ -58,4 +58,4 @@ Discourse.AceEditorView = Discourse.View.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Discourse.Utilities.registerViewHelper('aceEditor', Discourse.AceEditorView);
|
Discourse.View.registerHelper('aceEditor', Discourse.AceEditorView);
|
|
@ -29,19 +29,6 @@ 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
|
// Create a badge like category link
|
||||||
categoryLink: function(category) {
|
categoryLink: function(category) {
|
||||||
if (!category) return "";
|
if (!category) return "";
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
</li>
|
</li>
|
||||||
{{#if view.topic.fewParticipants}}
|
{{#if view.topic.fewParticipants}}
|
||||||
<li class='avatars'>
|
<li class='avatars'>
|
||||||
{{#each view.topic.fewParticipants}}{{view Discourse.ParticipantView participantBinding="this"}}{{/each}}
|
{{#each view.topic.fewParticipants}}{{participant participant=this}}{{/each}}
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
|
|
||||||
{{#if view.topic.participants}}
|
{{#if view.topic.participants}}
|
||||||
<section class='avatars clearfix'>
|
<section class='avatars clearfix'>
|
||||||
{{#each view.topic.participants}}{{view Discourse.ParticipantView participantBinding="this"}}{{/each}}
|
{{#each view.topic.participants}}{{participant participant=this}}{{/each}}
|
||||||
</section>
|
</section>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
<div class='clearfix'></div>
|
<div class='clearfix'></div>
|
||||||
|
|
||||||
<ul class='action-list nav-stacked side-nav'>
|
<ul class='action-list nav-stacked side-nav'>
|
||||||
{{view Discourse.ActivityFilterView countBinding="statsCountNonPM"}}
|
{{activityFilter count=statsCountNonPM}}
|
||||||
{{#each statsExcludingPms}}
|
{{#each statsExcludingPms}}
|
||||||
{{view Discourse.ActivityFilterView contentBinding="this"}}
|
{{activityFilter content=this}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
<div class='show'>
|
<div class='show'>
|
||||||
|
@ -51,4 +51,4 @@
|
||||||
</div>
|
</div>
|
||||||
{{/with}}
|
{{/with}}
|
||||||
|
|
||||||
{{view Discourse.UserStreamView streamBinding="model"}}
|
{{userStream stream=model}}
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
|
|
||||||
{{#if email_digests}}
|
{{#if email_digests}}
|
||||||
<div class='control-indent'>
|
<div class='control-indent'>
|
||||||
{{view Discourse.ComboboxView valueAttribute="value" contentBinding="digestFrequencies" valueBinding="digest_after_days"}}
|
{{combobox valueAttribute="value" content=digestFrequencies value="digest_after_days"}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<label>{{view Ember.Checkbox checkedBinding="email_private_messages"}}
|
<label>{{view Ember.Checkbox checkedBinding="email_private_messages"}}
|
||||||
|
@ -88,12 +88,12 @@
|
||||||
<label class="control-label">{{i18n user.other_settings}}</label>
|
<label class="control-label">{{i18n user.other_settings}}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<label>{{i18n user.auto_track_topics}}</label>
|
<label>{{i18n user.auto_track_topics}}</label>
|
||||||
{{view Discourse.ComboboxView valueAttribute="value" contentBinding="autoTrackDurations" valueBinding="auto_track_topics_after_msecs"}}
|
{{combobox valueAttribute="value" content=autoTrackDurations value="auto_track_topics_after_msecs"}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<label>{{i18n user.new_topic_duration.label}}</label>
|
<label>{{i18n user.new_topic_duration.label}}</label>
|
||||||
{{view Discourse.ComboboxView valueAttribute="value" contentBinding="considerNewTopicOptions" valueBinding="new_topic_duration_minutes"}}
|
{{combobox valueAttribute="value" content=considerNewTopicOptions value="new_topic_duration_minutes"}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
|
|
@ -16,9 +16,10 @@
|
||||||
|
|
||||||
<ul class='action-list nav-stacked side-nav'>
|
<ul class='action-list nav-stacked side-nav'>
|
||||||
{{#each statsPmsOnly}}
|
{{#each statsPmsOnly}}
|
||||||
{{view Discourse.ActivityFilterView contentBinding="this"}}
|
{{activityFilter content=this}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
{{/with}}
|
{{/with}}
|
||||||
</div>
|
</div>
|
||||||
{{view Discourse.UserStreamView streamBinding="model"}}
|
{{userStream stream=model}}
|
||||||
|
|
||||||
|
|
|
@ -20,4 +20,4 @@ Discourse.AutoCloseFormView = Ember.View.extend({
|
||||||
}.observes('autoCloseDays')
|
}.observes('autoCloseDays')
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.Utilities.registerViewHelper('autoCloseForm', Discourse.AutoCloseFormView);
|
Discourse.View.registerHelper('autoCloseForm', Discourse.AutoCloseFormView);
|
|
@ -34,4 +34,4 @@ Discourse.CategoryChooserView = Discourse.ComboboxView.extend({
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.Utilities.registerViewHelper('categoryChooser', Discourse.CategoryChooserView);
|
Discourse.View.registerHelper('categoryChooser', Discourse.CategoryChooserView);
|
|
@ -75,4 +75,4 @@ Discourse.ComboboxView = Discourse.View.extend({
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Discourse.View.registerHelper('combobox', Discourse.ComboboxView);
|
|
@ -19,4 +19,4 @@ Discourse.TextField = Ember.TextField.extend({
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.Utilities.registerViewHelper('textField', Discourse.TextField);
|
Discourse.View.registerHelper('textField', Discourse.TextField);
|
|
@ -30,4 +30,4 @@ Discourse.InputTipView = Discourse.View.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.Utilities.registerViewHelper('inputTip', Discourse.InputTipView);
|
Discourse.View.registerHelper('inputTip', Discourse.InputTipView);
|
|
@ -36,4 +36,4 @@ Discourse.ColorPickerView = Ember.ContainerView.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.Utilities.registerViewHelper('colorPicker', Discourse.ColorPickerView);
|
Discourse.View.registerHelper('colorPicker', Discourse.ColorPickerView);
|
|
@ -44,4 +44,4 @@ Discourse.PagedownEditor = Ember.ContainerView.extend({
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.Utilities.registerViewHelper('pagedown', Discourse.PagedownEditor);
|
Discourse.View.registerHelper('pagedown', Discourse.PagedownEditor);
|
|
@ -16,3 +16,4 @@ Discourse.ParticipantView = Discourse.View.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Discourse.View.registerHelper('participant', Discourse.ParticipantView);
|
|
@ -56,4 +56,4 @@ Discourse.PopupInputTipView = Discourse.View.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.Utilities.registerViewHelper('popupInputTip', Discourse.PopupInputTipView);
|
Discourse.View.registerHelper('popupInputTip', Discourse.PopupInputTipView);
|
|
@ -48,4 +48,4 @@ Discourse.TopicStatusView = Discourse.View.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Discourse.Utilities.registerViewHelper('topicStatus', Discourse.TopicStatusView);
|
Discourse.View.registerHelper('topicStatus', Discourse.TopicStatusView);
|
|
@ -47,4 +47,4 @@ Discourse.ActivityFilterView = Discourse.View.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Discourse.View.registerHelper('activityFilter', Discourse.ActivityFilterView);
|
|
@ -50,3 +50,4 @@ Discourse.UserStreamView = Discourse.View.extend(Discourse.Scrolling, {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Discourse.View.registerHelper('userStream', Discourse.UserStreamView);
|
|
@ -64,4 +64,4 @@ Discourse.UserSelector.reopenClass({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.Utilities.registerViewHelper('userSelector', Discourse.UserSelector);
|
Discourse.View.registerHelper('userSelector', Discourse.UserSelector);
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/**
|
||||||
A base view that gives us common functionality, for example `present` and `blank`
|
A base view that gives us common functionality, for example `present` and `blank`
|
||||||
|
|
||||||
@class View
|
@class View
|
||||||
|
@ -6,5 +6,27 @@
|
||||||
@uses Discourse.Presence
|
@uses Discourse.Presence
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.View = Ember.View.extend(Discourse.Presence, {});
|
||||||
|
|
||||||
|
|
||||||
|
Discourse.View.reopenClass({
|
||||||
|
|
||||||
|
/**
|
||||||
|
Register a view helper for ease of use
|
||||||
|
|
||||||
|
@method registerHElper
|
||||||
|
@param {String} helperName the name of the helper
|
||||||
|
@param {Ember.View} helperClass the view that will be inserted by the helper
|
||||||
**/
|
**/
|
||||||
Discourse.View = Ember.View.extend(Discourse.Presence, {});
|
registerHelper: 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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue