mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 05:03:39 +08:00
ES6: Convert a view, adds a backwards compatibility layer with
deprecations for the old view helper names.
This commit is contained in:
parent
2f706d084f
commit
e65283ecf5
|
@ -0,0 +1,21 @@
|
|||
var deprecatedViewHelpers = {
|
||||
inputTip: 'input-tip'
|
||||
};
|
||||
|
||||
export default {
|
||||
name: 'deprecations',
|
||||
initialize: function(container) {
|
||||
Ember.keys(deprecatedViewHelpers).forEach(function(old) {
|
||||
var newName = deprecatedViewHelpers[old];
|
||||
Ember.Handlebars.registerHelper(old, function(options) {
|
||||
Em.warn("The `" + old +"` helper is deprecated. Use `" + newName + "` instead.");
|
||||
var helper = container.lookupFactory('view:' + newName);
|
||||
var hash = options.hash,
|
||||
types = options.hashTypes;
|
||||
|
||||
Discourse.Utilities.normalizeHash(hash, types);
|
||||
return Ember.Handlebars.helpers.view.call(this, helper, options);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
|
@ -0,0 +1,21 @@
|
|||
var helpers = ['input-tip'];
|
||||
|
||||
/**
|
||||
Creates view helpers for some views. Many of these should probably be converted
|
||||
into components in the long term as it's a better fit.
|
||||
**/
|
||||
export default {
|
||||
name: 'view-hlpers',
|
||||
initialize: function(container) {
|
||||
helpers.forEach(function(h) {
|
||||
Ember.Handlebars.registerHelper(h, function(options) {
|
||||
var helper = container.lookupFactory('view:' + h);
|
||||
var hash = options.hash,
|
||||
types = options.hashTypes;
|
||||
|
||||
Discourse.Utilities.normalizeHash(hash, types);
|
||||
return Ember.Handlebars.helpers.view.call(this, helper, options);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
|
@ -7,7 +7,7 @@
|
|||
<td style="width:80px" class="label"><label for='new-account-name'>{{i18n user.name.title}}</label></td>
|
||||
<td style="width:496px">
|
||||
{{textField value=accountName id="new-account-name" autofocus="autofocus"}}
|
||||
{{inputTip validation=nameValidation}}
|
||||
{{input-tip validation=nameValidation}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="instructions">
|
||||
|
@ -19,7 +19,7 @@
|
|||
<td class="label"><label for='new-account-email'>{{i18n user.email.title}}</label></td>
|
||||
<td>
|
||||
{{input value=accountEmail id="new-account-email" disabled=emailValidated}}
|
||||
{{inputTip validation=emailValidation}}
|
||||
{{input-tip validation=emailValidation}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="instructions">
|
||||
|
@ -31,7 +31,7 @@
|
|||
<td class="label"><label for='new-account-username'>{{i18n user.username.title}}</label></td>
|
||||
<td>
|
||||
{{input value=accountUsername id="new-account-username" maxlength="15"}}
|
||||
{{inputTip validation=usernameValidation}}
|
||||
{{input-tip validation=usernameValidation}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="instructions">
|
||||
|
@ -44,7 +44,7 @@
|
|||
<td class="label"><label for='new-account-password'>{{i18n user.password.title}}</label></td>
|
||||
<td>
|
||||
{{input type="password" value=accountPassword id="new-account-password"}}
|
||||
{{inputTip validation=passwordValidation}}
|
||||
{{input-tip validation=passwordValidation}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="instructions">
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.InputTipView = Discourse.View.extend({
|
||||
export default Discourse.View.extend({
|
||||
classNameBindings: [':tip', 'good', 'bad'],
|
||||
|
||||
shouldRerender: Discourse.View.renderIfChanged('validation'),
|
||||
|
@ -21,5 +21,3 @@ Discourse.InputTipView = Discourse.View.extend({
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
Discourse.View.registerHelper('inputTip', Discourse.InputTipView);
|
Loading…
Reference in New Issue
Block a user