Remove Ember 1.x specific code
This commit is contained in:
parent
3765ee84e5
commit
6aa5722d2b
|
@ -27,18 +27,10 @@ export function bufferedRender(obj) {
|
|||
|
||||
const caller = { };
|
||||
|
||||
// True in 1.13 or greater
|
||||
if (Ember.Helper) {
|
||||
caller.didRender = function() {
|
||||
this._super();
|
||||
this._customRender();
|
||||
};
|
||||
} else {
|
||||
caller.didInsertElement = function() {
|
||||
this._super();
|
||||
this._customRender();
|
||||
};
|
||||
}
|
||||
|
||||
const triggers = obj.rerenderTriggers;
|
||||
if (triggers) {
|
||||
|
|
|
@ -1,27 +1,16 @@
|
|||
import { get } from 'discourse-common/lib/raw-handlebars';
|
||||
|
||||
// `Ember.Helper` is only available in versions after 1.12
|
||||
export function htmlHelper(fn) {
|
||||
if (Ember.Helper) {
|
||||
return Ember.Helper.helper(function(...args) {
|
||||
args = (args.length > 1) ? args[0].concat({ hash: args[args.length-1] }) : args;
|
||||
return new Handlebars.SafeString(fn.apply(this, args) || '');
|
||||
});
|
||||
} else {
|
||||
return Ember.Handlebars.makeBoundHelper(function() {
|
||||
return new Handlebars.SafeString(fn.apply(this, Array.prototype.slice.call(arguments)) || '');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const _helpers = {};
|
||||
|
||||
export function registerHelper(name, fn) {
|
||||
if (Ember.Helper) {
|
||||
_helpers[name] = Ember.Helper.helper(fn);
|
||||
} else {
|
||||
return Ember.HTMLBars._registerHelper(name, fn);
|
||||
}
|
||||
}
|
||||
|
||||
export function findHelper(name) {
|
||||
|
@ -65,14 +54,8 @@ export function registerUnbound(name, fn) {
|
|||
return fn.call(this, property, resolveParams(this, options));
|
||||
};
|
||||
|
||||
if (Ember.Helper) {
|
||||
_helpers[name] = Ember.Helper.extend({
|
||||
compute: (params, args) => fn(params[0], args)
|
||||
});
|
||||
Handlebars.registerHelper(name, func);
|
||||
return;
|
||||
}
|
||||
|
||||
Handlebars.registerHelper(name, func);
|
||||
Ember.Handlebars.registerHelper(name, func);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ export default Ember.Component.extend({
|
|||
classNameBindings: [':composer-popup', ':hidden', 'message.extraClass'],
|
||||
|
||||
@computed('message.templateName')
|
||||
defaultLayout(templateName) {
|
||||
layout(templateName) {
|
||||
return getOwner(this).lookup(`template:composer/${templateName}`);
|
||||
},
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
import { registerHelper } from 'discourse-common/lib/helpers';
|
||||
|
||||
// Note: Later versions of ember include `hash`
|
||||
registerHelper('as-hash', function(_, params) {
|
||||
if (Ember.Helper) { return params; }
|
||||
|
||||
const hash = {};
|
||||
Object.keys(params).forEach(k => {
|
||||
hash[k] = params[k].value();
|
||||
});
|
||||
return hash;
|
||||
});
|
|
@ -1,15 +1,11 @@
|
|||
|
||||
export const TARGET_NAME = (Ember.VERSION[0] === "2") ? 'actions' : '_actions';
|
||||
|
||||
export default Ember.Mixin.create({
|
||||
|
||||
delegateAll(actionNames) {
|
||||
actionNames = actionNames || [];
|
||||
|
||||
this[TARGET_NAME] = this[TARGET_NAME] || {};
|
||||
this.actions = this.actions || {};
|
||||
|
||||
actionNames.forEach(m => {
|
||||
this[TARGET_NAME][m] = function() { this.sendAction(m); };
|
||||
this.actions[m] = function() { this.sendAction(m); };
|
||||
this.set(m, m);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -10,10 +10,7 @@ export default {
|
|||
// HACK to fix: https://github.com/emberjs/ember.js/issues/10310
|
||||
const originalBuildInstance = originalBuildInstance || Ember.Application.prototype.buildInstance;
|
||||
Ember.Application.prototype.buildInstance = function() {
|
||||
const registry = this.buildRegistry();
|
||||
if (Ember.VERSION[0] === "1") {
|
||||
this.registry = registry;
|
||||
}
|
||||
this.buildRegistry();
|
||||
return originalBuildInstance.apply(this);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
<h3>{{i18n 'composer.similar_topics'}}</h3>
|
||||
|
||||
<ul class='topics'>
|
||||
{{mount-widget widget="search-result-topic" args=(as-hash results=message.similarTopics)}}
|
||||
{{mount-widget widget="search-result-topic" args=(hash results=message.similarTopics)}}
|
||||
</ul>
|
||||
|
|
|
@ -6,7 +6,7 @@ moduleForWidget('post-stream');
|
|||
|
||||
function postStreamTest(name, attrs) {
|
||||
widgetTest(name, {
|
||||
template: `{{mount-widget widget="post-stream" args=(as-hash posts=posts)}}`,
|
||||
template: `{{mount-widget widget="post-stream" args=(hash posts=posts)}}`,
|
||||
setup() {
|
||||
this.set('posts', attrs.posts.call(this));
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue