Deprecation: Use `Ember.Helper` for later versions of Ember
This commit is contained in:
parent
b3c24e50e3
commit
7c0fb41ec0
|
@ -1,3 +1,3 @@
|
||||||
Em.Handlebars.helper('human-size', function(size) {
|
import { htmlHelper } from 'discourse/lib/helpers';
|
||||||
return new Handlebars.SafeString(I18n.toHumanSize(size));
|
|
||||||
});
|
export default htmlHelper(size => I18n.toHumanSize(size));
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
Em.Handlebars.helper('preserve-newlines', str => {
|
import { htmlHelper } from 'discourse/lib/helpers';
|
||||||
return new Handlebars.SafeString(Discourse.Utilities.escapeExpression(str).replace(/\n/g, "<br>"));
|
|
||||||
});
|
export default htmlHelper(str => Discourse.Utilities.escapeExpression(str).replace(/\n/g, "<br>"));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
registerUnbound('value-at-tl', function(data, params) {
|
registerUnbound('value-at-tl', function(data, params) {
|
||||||
var tl = parseInt(params.level, 10);
|
var tl = parseInt(params.level, 10);
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
</li>
|
</li>
|
||||||
<li class='toggle-maximize'>
|
<li class='toggle-maximize'>
|
||||||
<a {{action "toggleMaximize"}}>
|
<a {{action "toggleMaximize"}}>
|
||||||
{{fa-icon-bound maximizeIcon}}
|
<i class="fa fa-{{maximizeIcon}}"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -16,7 +16,6 @@ function customTagArray(fieldName) {
|
||||||
export default Ember.Controller.extend(ModalFunctionality, {
|
export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
loading: true,
|
loading: true,
|
||||||
viewMode: "side_by_side",
|
viewMode: "side_by_side",
|
||||||
revisionsTextKey: "post.revisions.controls.comparing_previous_to_current_out_of_total",
|
|
||||||
|
|
||||||
_changeViewModeOnMobile: function() {
|
_changeViewModeOnMobile: function() {
|
||||||
if (this.site.mobileView) { this.set("viewMode", "inline"); }
|
if (this.site.mobileView) { this.set("viewMode", "inline"); }
|
||||||
|
@ -25,6 +24,13 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
previousTagChanges: customTagArray('model.tags_changes.previous'),
|
previousTagChanges: customTagArray('model.tags_changes.previous'),
|
||||||
currentTagChanges: customTagArray('model.tags_changes.current'),
|
currentTagChanges: customTagArray('model.tags_changes.current'),
|
||||||
|
|
||||||
|
@computed('previousVersion', 'model.current_version', 'model.version_count')
|
||||||
|
revisionsText(previous, current, total) {
|
||||||
|
return I18n.t("post.revisions.controls.comparing_previous_to_current_out_of_total", {
|
||||||
|
previous, current, total
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
refresh(postId, postVersion) {
|
refresh(postId, postVersion) {
|
||||||
this.set("loading", true);
|
this.set("loading", true);
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,8 @@
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
import { longDate, autoUpdatingRelativeAge, number } from 'discourse/lib/formatter';
|
import { longDate, autoUpdatingRelativeAge, number } from 'discourse/lib/formatter';
|
||||||
|
|
||||||
const safe = Handlebars.SafeString;
|
const safe = Handlebars.SafeString;
|
||||||
|
|
||||||
Em.Handlebars.helper('bound-avatar', (user, size) => {
|
|
||||||
if (Em.isEmpty(user)) {
|
|
||||||
return new safe("<div class='avatar-placeholder'></div>");
|
|
||||||
}
|
|
||||||
|
|
||||||
const avatar = Em.get(user, 'avatar_template');
|
|
||||||
return new safe(Discourse.Utilities.avatarImg({ size: size, avatarTemplate: avatar }));
|
|
||||||
}, 'username', 'avatar_template');
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Used when we only have a template
|
|
||||||
*/
|
|
||||||
Em.Handlebars.helper('bound-avatar-template', (at, size) => {
|
|
||||||
return new safe(Discourse.Utilities.avatarImg({ size: size, avatarTemplate: at }));
|
|
||||||
});
|
|
||||||
|
|
||||||
registerUnbound('raw-date', dt => longDate(new Date(dt)));
|
registerUnbound('raw-date', dt => longDate(new Date(dt)));
|
||||||
|
|
||||||
registerUnbound('age-with-tooltip', dt => new safe(autoUpdatingRelativeAge(new Date(dt), {title: true})));
|
registerUnbound('age-with-tooltip', dt => new safe(autoUpdatingRelativeAge(new Date(dt), {title: true})));
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
export default Ember.Handlebars.makeBoundHelper(function(value) {
|
import { htmlHelper } from 'discourse/lib/helpers';
|
||||||
return ("border-color: #" + value).htmlSafe();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
export default htmlHelper(color => `border-color: #${color}`);
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { htmlHelper } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
|
export default htmlHelper((avatarTemplate, size) => {
|
||||||
|
return Discourse.Utilities.avatarImg({ size, avatarTemplate });
|
||||||
|
});
|
|
@ -0,0 +1,10 @@
|
||||||
|
import { htmlHelper } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
|
export default htmlHelper((user, size) => {
|
||||||
|
if (Ember.isEmpty(user)) {
|
||||||
|
return "<div class='avatar-placeholder'></div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
const avatarTemplate = Em.get(user, 'avatar_template');
|
||||||
|
return Discourse.Utilities.avatarImg({ size, avatarTemplate });
|
||||||
|
});
|
|
@ -0,0 +1,4 @@
|
||||||
|
import { htmlHelper } from 'discourse/lib/helpers';
|
||||||
|
import { categoryLinkHTML } from 'discourse/helpers/category-link';
|
||||||
|
|
||||||
|
export default htmlHelper(categoryLinkHTML);
|
|
@ -1,5 +1,4 @@
|
||||||
import { autoUpdatingRelativeAge } from 'discourse/lib/formatter';
|
import { autoUpdatingRelativeAge } from 'discourse/lib/formatter';
|
||||||
|
import { htmlHelper } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
export default Ember.Handlebars.makeBoundHelper(function(dt) {
|
export default htmlHelper(dt => autoUpdatingRelativeAge(new Date(dt), {format: 'medium', title: true }));
|
||||||
return new Handlebars.SafeString(autoUpdatingRelativeAge(new Date(dt), {format: 'medium', title: true }));
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
Ember.Handlebars.registerBoundHelper("boundI18n", function(property, options) {
|
|
||||||
return new Handlebars.SafeString(I18n.t(property, options.hash));
|
|
||||||
});
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
import { htmlHelper } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
|
export default htmlHelper(str => str[0].toUpperCase() + str.slice(1));
|
|
@ -1,3 +0,0 @@
|
||||||
Ember.Handlebars.registerBoundHelper("capitalize", function(str) {
|
|
||||||
return str[0].toUpperCase() + str.slice(1);
|
|
||||||
});
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { categoryLinkHTML } from 'discourse/helpers/category-link';
|
import { categoryLinkHTML } from 'discourse/helpers/category-link';
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
registerUnbound('category-badge', function(cat, options) {
|
registerUnbound('category-badge', function(cat, options) {
|
||||||
options.link = false;
|
options.link = false;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||||
|
|
||||||
var get = Em.get,
|
var get = Em.get,
|
||||||
|
@ -94,4 +94,3 @@ export function categoryLinkHTML(category, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
registerUnbound('category-link', categoryLinkHTML);
|
registerUnbound('category-link', categoryLinkHTML);
|
||||||
Ember.Handlebars.helper('bound-category-link', categoryLinkHTML);
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
function daysSinceEpoch(dt) {
|
function daysSinceEpoch(dt) {
|
||||||
// 1000 * 60 * 60 * 24 = days since epoch
|
// 1000 * 60 * 60 * 24 = days since epoch
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
registerUnbound('cook-text', function(text) {
|
registerUnbound('cook-text', function(text) {
|
||||||
return new Handlebars.SafeString(Discourse.Markdown.cook(text, {sanitize: true}));
|
return new Handlebars.SafeString(Discourse.Markdown.cook(text, {sanitize: true}));
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { registerHelper } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
const _customizations = {};
|
const _customizations = {};
|
||||||
|
|
||||||
export function getCustomHTML(key) {
|
export function getCustomHTML(key) {
|
||||||
|
@ -17,13 +19,14 @@ export function setCustomHTML(key, html) {
|
||||||
_customizations[key] = html;
|
_customizations[key] = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ember.HTMLBars._registerHelper('custom-html', function(params, hash, options, env) {
|
registerHelper('custom-html', function(params, hash, options, env) {
|
||||||
const name = params[0];
|
const name = params[0];
|
||||||
const html = getCustomHTML(name);
|
const html = getCustomHTML(name);
|
||||||
if (html) { return html; }
|
if (html) { return html; }
|
||||||
|
|
||||||
const contextString = params[1];
|
const contextString = params[1];
|
||||||
const container = (env || contextString).data.view.container;
|
const target = (env || contextString);
|
||||||
|
const container = target.container || target.data.view.container;
|
||||||
if (container.lookup('template:' + name)) {
|
if (container.lookup('template:' + name)) {
|
||||||
return env.helpers.partial.helperFunction.apply(this, arguments);
|
return env.helpers.partial.helperFunction.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
export default Ember.Handlebars.makeBoundHelper(function(str) {
|
import { htmlHelper } from 'discourse/lib/helpers';
|
||||||
return Ember.isEmpty(str) ? new Handlebars.SafeString('—') : str;
|
|
||||||
});
|
export default htmlHelper(str => Ember.isEmpty(str) ? '—' : str);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
import renderTag from 'discourse/lib/render-tag';
|
import renderTag from 'discourse/lib/render-tag';
|
||||||
|
|
||||||
export default registerUnbound('discourse-tag', function(name, params) {
|
export default registerUnbound('discourse-tag', function(name, params) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { h } from 'virtual-dom';
|
import { h } from 'virtual-dom';
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
function iconClasses(icon, params) {
|
function iconClasses(icon, params) {
|
||||||
var classes = "fa fa-" + icon;
|
var classes = "fa fa-" + icon;
|
||||||
|
@ -37,11 +37,6 @@ export function iconNode(icon, params) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Ember.Handlebars.helper('fa-icon-bound', function(value, options) {
|
|
||||||
return new Handlebars.SafeString(iconHTML(value, options));
|
|
||||||
});
|
|
||||||
|
|
||||||
registerUnbound('fa-icon', function(icon, params) {
|
registerUnbound('fa-icon', function(icon, params) {
|
||||||
return new Handlebars.SafeString(iconHTML(icon, params));
|
return new Handlebars.SafeString(iconHTML(icon, params));
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { autoUpdatingRelativeAge } from 'discourse/lib/formatter';
|
import { autoUpdatingRelativeAge } from 'discourse/lib/formatter';
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
registerUnbound('format-age', function(dt) {
|
registerUnbound('format-age', function(dt) {
|
||||||
dt = new Date(dt);
|
dt = new Date(dt);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
import { autoUpdatingRelativeAge } from 'discourse/lib/formatter';
|
import { autoUpdatingRelativeAge } from 'discourse/lib/formatter';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
registerUnbound('i18n', function(key, params) {
|
registerUnbound('i18n', function(key, params) {
|
||||||
return I18n.t(key, params);
|
return I18n.t(key, params);
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
export default Ember.Handlebars.makeBoundHelper(function(str) {
|
import { htmlHelper } from 'discourse/lib/helpers';
|
||||||
if (Ember.isEmpty(str)) { return ""; }
|
|
||||||
|
|
||||||
if (str.indexOf('fa-') === 0) {
|
export default htmlHelper(function(str) {
|
||||||
return new Handlebars.SafeString("<i class='fa " + str + "'></i>");
|
if (Ember.isEmpty(str)) { return ""; }
|
||||||
} else {
|
return (str.indexOf('fa-') === 0) ? `<i class='fa ${str}'></i>` : `<img src='${str}'>`;
|
||||||
return new Handlebars.SafeString("<img src='" + str + "'>");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { htmlHelper } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
function renderSpinner(cssClass) {
|
function renderSpinner(cssClass) {
|
||||||
var html = "<div class='spinner";
|
var html = "<div class='spinner";
|
||||||
if (cssClass) { html += ' ' + cssClass; }
|
if (cssClass) { html += ' ' + cssClass; }
|
||||||
|
@ -5,9 +7,9 @@ function renderSpinner(cssClass) {
|
||||||
}
|
}
|
||||||
var spinnerHTML = renderSpinner();
|
var spinnerHTML = renderSpinner();
|
||||||
|
|
||||||
Ember.Handlebars.registerHelper('loading-spinner', function(params) {
|
export default htmlHelper(params => {
|
||||||
const hash = params.hash;
|
const hash = params.hash;
|
||||||
return new Handlebars.SafeString(renderSpinner((hash && hash.size) ? hash.size : undefined));
|
return renderSpinner((hash && hash.size) ? hash.size : undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
export { spinnerHTML, renderSpinner };
|
export { spinnerHTML, renderSpinner };
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
registerUnbound('max-usernames', function(usernames, params) {
|
registerUnbound('max-usernames', function(usernames, params) {
|
||||||
var maxLength = parseInt(params.max) || 3;
|
var maxLength = parseInt(params.max) || 3;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { htmlHelper } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
const TITLE_SUBS = {
|
const TITLE_SUBS = {
|
||||||
all: 'all_time',
|
all: 'all_time',
|
||||||
yearly: 'this_year',
|
yearly: 'this_year',
|
||||||
|
@ -6,7 +8,7 @@ const TITLE_SUBS = {
|
||||||
daily: 'today',
|
daily: 'today',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Ember.Handlebars.makeBoundHelper(function (period, options) {
|
export default htmlHelper((period, options) => {
|
||||||
const title = I18n.t('filters.top.' + (TITLE_SUBS[period] || 'this_week'));
|
const title = I18n.t('filters.top.' + (TITLE_SUBS[period] || 'this_week'));
|
||||||
if (options.hash.showDateRange) {
|
if (options.hash.showDateRange) {
|
||||||
var dateString = "";
|
var dateString = "";
|
||||||
|
@ -27,8 +29,9 @@ export default Ember.Handlebars.makeBoundHelper(function (period, options) {
|
||||||
dateString = moment().format(I18n.t('dates.full_no_year_no_time'));
|
dateString = moment().format(I18n.t('dates.full_no_year_no_time'));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return new Handlebars.SafeString(title + " <span class='top-date-string'>" + dateString + "</span>");
|
|
||||||
|
return `${title} <span class='top-date-string'>${dateString}</span>`;
|
||||||
} else {
|
} else {
|
||||||
return new Handlebars.SafeString(title);
|
return title;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -46,13 +46,7 @@
|
||||||
The list of disabled plugins is returned via the `Site` singleton.
|
The list of disabled plugins is returned via the `Site` singleton.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
import { registerHelper } from 'discourse/lib/helpers';
|
||||||
// TODO: Add all plugin-outlet names dynamically
|
|
||||||
const rewireableOutlets = [
|
|
||||||
'hamburger-admin'
|
|
||||||
];
|
|
||||||
|
|
||||||
const _rewires = {};
|
|
||||||
|
|
||||||
let _connectorCache, _rawCache;
|
let _connectorCache, _rawCache;
|
||||||
|
|
||||||
|
@ -73,14 +67,6 @@ function findOutlets(collection, callback) {
|
||||||
let outletName = segments[segments.length-2];
|
let outletName = segments[segments.length-2];
|
||||||
const uniqueName = segments[segments.length-1];
|
const uniqueName = segments[segments.length-1];
|
||||||
|
|
||||||
const outletRewires = _rewires[outletName];
|
|
||||||
if (outletRewires) {
|
|
||||||
const newOutlet = outletRewires[uniqueName];
|
|
||||||
if (newOutlet) {
|
|
||||||
outletName = newOutlet;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(outletName, res, uniqueName);
|
callback(outletName, res, uniqueName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -144,7 +130,6 @@ function viewInjections(container) {
|
||||||
|
|
||||||
// unbound version of outlets, only has a template
|
// unbound version of outlets, only has a template
|
||||||
Handlebars.registerHelper('plugin-outlet', function(name){
|
Handlebars.registerHelper('plugin-outlet', function(name){
|
||||||
|
|
||||||
if (!_rawCache) { buildConnectorCache(); }
|
if (!_rawCache) { buildConnectorCache(); }
|
||||||
|
|
||||||
const functions = _rawCache[name];
|
const functions = _rawCache[name];
|
||||||
|
@ -160,7 +145,7 @@ Handlebars.registerHelper('plugin-outlet', function(name){
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Ember.HTMLBars._registerHelper('plugin-outlet', function(params, hash, options, env) {
|
registerHelper('plugin-outlet', function(params, hash, options, env) {
|
||||||
const connectionName = params[0];
|
const connectionName = params[0];
|
||||||
|
|
||||||
if (!_connectorCache) { buildConnectorCache(); }
|
if (!_connectorCache) { buildConnectorCache(); }
|
||||||
|
@ -190,11 +175,5 @@ Ember.HTMLBars._registerHelper('plugin-outlet', function(params, hash, options,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Allow plugins to rewire outlets to new outlets if they exist. For example, the akismet
|
// No longer used
|
||||||
// plugin will use `hamburger-admin` if it exists, otherwise `site-menu-links`
|
export function rewire() { }
|
||||||
export function rewire(uniqueName, outlet, wantedOutlet) {
|
|
||||||
if (rewireableOutlets.indexOf(wantedOutlet) !== -1) {
|
|
||||||
_rewires[outlet] = _rewires[outlet] || {};
|
|
||||||
_rewires[outlet][uniqueName] = wantedOutlet;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
// see: https://github.com/emberjs/ember.js/issues/12634
|
// see: https://github.com/emberjs/ember.js/issues/12634
|
||||||
var missingViews = {};
|
var missingViews = {};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
registerUnbound('shorten-url', function(url) {
|
registerUnbound('shorten-url', function(url) {
|
||||||
var matches = url.match(/\//g);
|
var matches = url.match(/\//g);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
registerUnbound('topic-link', function(topic) {
|
registerUnbound('topic-link', function(topic) {
|
||||||
var title = topic.get('fancyTitle');
|
var title = topic.get('fancyTitle');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
import { registerUnbound } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
function renderAvatar(user, options) {
|
function renderAvatar(user, options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
import { iconHTML } from 'discourse/helpers/fa-icon';
|
import { iconHTML } from 'discourse/helpers/fa-icon';
|
||||||
|
import { htmlHelper } from 'discourse/lib/helpers';
|
||||||
|
|
||||||
const Safe = Handlebars.SafeString;
|
export default htmlHelper((user, args) => {
|
||||||
|
|
||||||
export default Ember.Handlebars.makeBoundHelper(function(user, args) {
|
|
||||||
if (!user) { return; }
|
if (!user) { return; }
|
||||||
|
|
||||||
const name = Discourse.Utilities.escapeExpression(user.get('name'));
|
const name = Discourse.Utilities.escapeExpression(user.get('name'));
|
||||||
const currentUser = args.hash.currentUser;
|
const currentUser = args.hash.currentUser;
|
||||||
|
|
||||||
if (currentUser && user.get('admin') && currentUser.get('staff')) {
|
if (currentUser && user.get('admin') && currentUser.get('staff')) {
|
||||||
return new Safe(iconHTML('shield', { label: I18n.t('user.admin', { user: name }) }));
|
return iconHTML('shield', { label: I18n.t('user.admin', { user: name }) });
|
||||||
}
|
}
|
||||||
if (user.get('moderator')) {
|
if (user.get('moderator')) {
|
||||||
return new Safe(iconHTML('shield', { label: I18n.t('user.moderator', { user: name }) }));
|
return iconHTML('shield', { label: I18n.t('user.moderator', { user: name }) });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -148,7 +148,8 @@
|
||||||
|
|
||||||
RawHandlebars.get = function(ctx, property, options){
|
RawHandlebars.get = function(ctx, property, options){
|
||||||
if (options.types && options.data.view) {
|
if (options.types && options.data.view) {
|
||||||
return options.data.view.getStream(property).value();
|
var view = options.data.view;
|
||||||
|
return view.getStream ? view.getStream(property).value() : view.getAttr(property);
|
||||||
} else {
|
} else {
|
||||||
return Ember.get(ctx, property);
|
return Ember.get(ctx, property);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,20 @@
|
||||||
|
// `Ember.Helper` is only available in versions after 1.12
|
||||||
|
export function htmlHelper(fn) {
|
||||||
|
if (Ember.Helper) {
|
||||||
|
return Ember.Helper.helper(function() {
|
||||||
|
return new Handlebars.SafeString(fn.apply(this, Array.prototype.slice.call(arguments)));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return Ember.Handlebars.makeBoundHelper(function() {
|
||||||
|
return new Handlebars.SafeString(fn.apply(this, Array.prototype.slice.call(arguments)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function registerHelper(name, fn) {
|
||||||
|
Ember.HTMLBars._registerHelper(name, fn);
|
||||||
|
}
|
||||||
|
|
||||||
const get = Discourse.EmberCompatHandlebars.get;
|
const get = Discourse.EmberCompatHandlebars.get;
|
||||||
|
|
||||||
function resolveParams(ctx, options) {
|
function resolveParams(ctx, options) {
|
||||||
|
@ -21,7 +38,7 @@ function resolveParams(ctx, options) {
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function registerUnbound(name, fn) {
|
export function registerUnbound(name, fn) {
|
||||||
const func = function(property, options) {
|
const func = function(property, options) {
|
||||||
if (options.types && (options.types[0] === "ID" || options.types[0] === "PathExpression")) {
|
if (options.types && (options.types[0] === "ID" || options.types[0] === "PathExpression")) {
|
||||||
property = get(this, property, options);
|
property = get(this, property, options);
|
|
@ -5,7 +5,7 @@
|
||||||
{{d-button action="loadPreviousVersion" icon="backward" title="post.revisions.controls.previous" disabled=loadPreviousDisabled}}
|
{{d-button action="loadPreviousVersion" icon="backward" title="post.revisions.controls.previous" disabled=loadPreviousDisabled}}
|
||||||
<div id="revision-numbers" class="{{unless displayRevisions 'invisible'}}">
|
<div id="revision-numbers" class="{{unless displayRevisions 'invisible'}}">
|
||||||
{{#conditional-loading-spinner condition=loading size="small"}}
|
{{#conditional-loading-spinner condition=loading size="small"}}
|
||||||
{{boundI18n revisionsTextKey previous=previousVersion current=model.current_version total=model.version_count}}
|
{{{revisionsText}}}
|
||||||
{{/conditional-loading-spinner}}
|
{{/conditional-loading-spinner}}
|
||||||
</div>
|
</div>
|
||||||
{{d-button action="loadNextVersion" icon="forward" title="post.revisions.controls.next" disabled=loadNextDisabled}}
|
{{d-button action="loadNextVersion" icon="forward" title="post.revisions.controls.next" disabled=loadNextDisabled}}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<li>
|
<li>
|
||||||
{{#link-to 'userPrivateMessages.group' group.name}}
|
{{#link-to 'userPrivateMessages.group' group.name}}
|
||||||
<i class='glyph fa fa-group'></i>
|
<i class='glyph fa fa-group'></i>
|
||||||
{{capitalize group.name}}
|
{{capitalize-string group.name}}
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
</li>
|
</li>
|
||||||
<li class='archive'>
|
<li class='archive'>
|
||||||
|
|
|
@ -14,14 +14,14 @@
|
||||||
//= require ./discourse/lib/debounce
|
//= require ./discourse/lib/debounce
|
||||||
//= require ./discourse/lib/quote
|
//= require ./discourse/lib/quote
|
||||||
//= require ./discourse/lib/key-value-store
|
//= require ./discourse/lib/key-value-store
|
||||||
|
//= require ./discourse/lib/helpers
|
||||||
//= require ./discourse/helpers/i18n
|
//= require ./discourse/helpers/i18n
|
||||||
//= require ./discourse/helpers/fa-icon
|
//= require ./discourse/helpers/fa-icon
|
||||||
//= require ./discourse/helpers/register-unbound
|
|
||||||
//= require ./discourse/lib/ember_compat_handlebars
|
//= require ./discourse/lib/ember_compat_handlebars
|
||||||
|
//= require ./discourse/lib/helpers
|
||||||
//= require ./discourse/lib/computed
|
//= require ./discourse/lib/computed
|
||||||
//= require ./discourse/lib/formatter
|
//= require ./discourse/lib/formatter
|
||||||
//= require ./discourse/lib/eyeline
|
//= require ./discourse/lib/eyeline
|
||||||
//= require ./discourse/helpers/register-unbound
|
|
||||||
//= require ./discourse/mixins/scrolling
|
//= require ./discourse/mixins/scrolling
|
||||||
//= require ./discourse/models/model
|
//= require ./discourse/models/model
|
||||||
//= require ./discourse/models/rest
|
//= require ./discourse/models/rest
|
||||||
|
@ -88,7 +88,6 @@
|
||||||
//= require ./discourse/components/conditional-loading-spinner
|
//= require ./discourse/components/conditional-loading-spinner
|
||||||
//= require ./discourse/helpers/user-avatar
|
//= require ./discourse/helpers/user-avatar
|
||||||
//= require ./discourse/helpers/cold-age-class
|
//= require ./discourse/helpers/cold-age-class
|
||||||
//= require ./discourse/helpers/capitalize
|
|
||||||
//= require ./discourse/helpers/loading-spinner
|
//= require ./discourse/helpers/loading-spinner
|
||||||
//= require ./discourse/helpers/category-link
|
//= require ./discourse/helpers/category-link
|
||||||
//= require ./discourse/lib/export-result
|
//= require ./discourse/lib/export-result
|
||||||
|
|
|
@ -24,7 +24,7 @@ export default Em.Component.extend({
|
||||||
|
|
||||||
options.forEach((option, i) => {
|
options.forEach((option, i) => {
|
||||||
const percentage = percentages[i];
|
const percentage = percentages[i];
|
||||||
const style = new Ember.Handlebars.SafeString(`width: ${percentage}%`);
|
const style = new Handlebars.SafeString(`width: ${percentage}%`);
|
||||||
|
|
||||||
option.setProperties({
|
option.setProperties({
|
||||||
percentage,
|
percentage,
|
||||||
|
|
Loading…
Reference in New Issue