diff --git a/app/assets/javascripts/discourse/initializers/deprecations.js.es6 b/app/assets/javascripts/discourse/initializers/deprecations.js.es6 new file mode 100644 index 00000000000..f25c7ec1002 --- /dev/null +++ b/app/assets/javascripts/discourse/initializers/deprecations.js.es6 @@ -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); + }); + }); + } +}; diff --git a/app/assets/javascripts/discourse/initializers/view-helpers.js.es6 b/app/assets/javascripts/discourse/initializers/view-helpers.js.es6 new file mode 100644 index 00000000000..97ab6e9116f --- /dev/null +++ b/app/assets/javascripts/discourse/initializers/view-helpers.js.es6 @@ -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); + }); + }); + } +}; diff --git a/app/assets/javascripts/discourse/templates/modal/create_account.js.handlebars b/app/assets/javascripts/discourse/templates/modal/create_account.js.handlebars index 0c0ecf277a4..4dfa9d191ae 100644 --- a/app/assets/javascripts/discourse/templates/modal/create_account.js.handlebars +++ b/app/assets/javascripts/discourse/templates/modal/create_account.js.handlebars @@ -7,7 +7,7 @@ {{textField value=accountName id="new-account-name" autofocus="autofocus"}} -  {{inputTip validation=nameValidation}} +  {{input-tip validation=nameValidation}} @@ -19,7 +19,7 @@ {{input value=accountEmail id="new-account-email" disabled=emailValidated}} -  {{inputTip validation=emailValidation}} +  {{input-tip validation=emailValidation}} @@ -31,7 +31,7 @@ {{input value=accountUsername id="new-account-username" maxlength="15"}} -  {{inputTip validation=usernameValidation}} +  {{input-tip validation=usernameValidation}} @@ -44,7 +44,7 @@ {{input type="password" value=accountPassword id="new-account-password"}} -  {{inputTip validation=passwordValidation}} +  {{input-tip validation=passwordValidation}} diff --git a/app/assets/javascripts/discourse/views/input_tip_view.js b/app/assets/javascripts/discourse/views/input-tip.js.es6 similarity index 83% rename from app/assets/javascripts/discourse/views/input_tip_view.js rename to app/assets/javascripts/discourse/views/input-tip.js.es6 index 5976092051f..b2d0709c912 100644 --- a/app/assets/javascripts/discourse/views/input_tip_view.js +++ b/app/assets/javascripts/discourse/views/input-tip.js.es6 @@ -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); \ No newline at end of file