Fix more deprecated helpers
This commit is contained in:
parent
7aaf2fcb65
commit
3e408f9caa
|
@ -1,3 +1,3 @@
|
|||
import { categoryLinkHTML } from 'discourse/lib/html-builder';
|
||||
|
||||
Em.Handlebars.helper('bound-category-link', categoryLinkHTML);
|
||||
Ember.Handlebars.helper('bound-category-link', categoryLinkHTML);
|
||||
|
|
|
@ -1,22 +1,16 @@
|
|||
import registerUnbound from 'discourse/helpers/register-unbound';
|
||||
|
||||
export function daysSinceEpoch(dt) {
|
||||
// 1000 * 60 * 60 * 24 = days since epoch
|
||||
return dt.getTime() / 86400000;
|
||||
}
|
||||
|
||||
/**
|
||||
Converts a date to a coldmap class
|
||||
**/
|
||||
function coldAgeClass(property, options) {
|
||||
var dt = Discourse.EmberCompatHandlebars.get(this, property, options);
|
||||
var className = (options && options.hash && options.hash.class !== undefined) ? options.hash.class : 'age';
|
||||
registerUnbound('cold-age-class', function(dt, params) {
|
||||
var className = params['class'] || 'age';
|
||||
|
||||
if (!dt) { return className; }
|
||||
|
||||
var startDate = (options && options.hash && options.hash.startDate) || new Date();
|
||||
|
||||
if (typeof startDate === "string") {
|
||||
startDate = Discourse.EmberCompatHandlebars.get(this, startDate, options);
|
||||
}
|
||||
var startDate = params.startDate || new Date();
|
||||
|
||||
// Show heat on age
|
||||
var nowDays = daysSinceEpoch(startDate),
|
||||
|
@ -27,7 +21,4 @@ function coldAgeClass(property, options) {
|
|||
if (nowDays - epochDays > Discourse.SiteSettings.cold_age_days_low) return className + ' coldmap-low';
|
||||
|
||||
return className;
|
||||
}
|
||||
|
||||
Handlebars.registerHelper('cold-age-class', coldAgeClass);
|
||||
export default coldAgeClass;
|
||||
});
|
||||
|
|
|
@ -11,12 +11,13 @@ export default function registerUnbound(name, fn) {
|
|||
hash = options.hash;
|
||||
|
||||
if (hash) {
|
||||
var self = this;
|
||||
Ember.keys(options.hash).forEach(function(k) {
|
||||
var type = options.hashTypes[k];
|
||||
if (type === "STRING") {
|
||||
params[k] = hash[k];
|
||||
} else if (type === "ID") {
|
||||
params[k] = get(this, hash[k], options);
|
||||
params[k] = get(self, hash[k], options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
Handlebars.registerHelper('shorten-text', function(property, options) {
|
||||
return Ember.Handlebars.get(this, property, options).substring(0,35);
|
||||
});
|
|
@ -1,6 +1,7 @@
|
|||
Handlebars.registerHelper('shorten-url', function(property, options) {
|
||||
var url = Ember.Handlebars.get(this, property, options),
|
||||
matches = url.match(/\//g);
|
||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
||||
|
||||
registerUnbound('shorten-url', function(url) {
|
||||
var matches = url.match(/\//g);
|
||||
|
||||
if (matches && matches.length === 3) {
|
||||
url = url.replace(/\/$/, '');
|
||||
|
|
|
@ -11,9 +11,6 @@ export function categoryLinkHTML(category, options) {
|
|||
if (options.onlyStripe) { categoryOptions.onlyStripe = true; }
|
||||
if (options.link !== undefined) { categoryOptions.link = options.link; }
|
||||
if (options.extraClasses) { categoryOptions.extraClasses = options.extraClasses; }
|
||||
if (options.categories) {
|
||||
categoryOptions.categories = Em.Handlebars.get(this, options.categories, options);
|
||||
}
|
||||
}
|
||||
return new Handlebars.SafeString(Discourse.HTML.categoryBadge(category, categoryOptions));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue