mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 21:10:17 +08:00
Fix more deprecations for 1.9.0
This commit is contained in:
parent
5659b93c71
commit
02f3a2d115
|
@ -37,26 +37,12 @@ Em.Handlebars.helper('bound-avatar-template', function(avatarTemplate, size) {
|
|||
}));
|
||||
});
|
||||
|
||||
/**
|
||||
Nicely format a date without binding or returning HTML
|
||||
|
||||
@method raw-date
|
||||
@for Handlebars
|
||||
**/
|
||||
Handlebars.registerHelper('raw-date', function(property, options) {
|
||||
var dt = new Date(Ember.Handlebars.get(this, property, options));
|
||||
return Discourse.Formatter.longDate(dt);
|
||||
registerUnbound('raw-date', function(dt) {
|
||||
return Discourse.Formatter.longDate(new Date(dt));
|
||||
});
|
||||
|
||||
/**
|
||||
Live refreshing age helper, with a tooltip showing the date and time
|
||||
|
||||
@method age-with-tooltip
|
||||
@for Handlebars
|
||||
**/
|
||||
Handlebars.registerHelper('age-with-tooltip', function(property, options) {
|
||||
var dt = new Date(Ember.Handlebars.get(this, property, options));
|
||||
return new safe(Discourse.Formatter.autoUpdatingRelativeAge(dt, {title: true}));
|
||||
registerUnbound('age-with-tooltip', function(dt) {
|
||||
return new safe(Discourse.Formatter.autoUpdatingRelativeAge(new Date(dt), {title: true}));
|
||||
});
|
||||
|
||||
registerUnbound('number', function(orig, params) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { categoryLinkHTML } from 'discourse/lib/html-builder';
|
||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
||||
|
||||
Handlebars.registerHelper('category-badge', function(property, options) {
|
||||
options.hash.link = false;
|
||||
return categoryLinkHTML(Ember.Handlebars.get(this, property, options), options);
|
||||
registerUnbound('category-badge', function(cat, options) {
|
||||
options.link = false;
|
||||
return categoryLinkHTML(cat, options);
|
||||
});
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
Handlebars.registerHelper('format-age', function(property, options) {
|
||||
var dt = new Date(Ember.Handlebars.get(this, property, options));
|
||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
||||
|
||||
registerUnbound('format-age', function(dt) {
|
||||
dt = new Date(dt);
|
||||
return new Handlebars.SafeString(Discourse.Formatter.autoUpdatingRelativeAge(dt));
|
||||
});
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
export function categoryLinkHTML(category, options) {
|
||||
var categoryOptions = {};
|
||||
if (options.hash) {
|
||||
if (options.hash.allowUncategorized) { categoryOptions.allowUncategorized = true; }
|
||||
if (options.hash.showParent) { categoryOptions.showParent = true; }
|
||||
if (options.hash.onlyStripe) { categoryOptions.onlyStripe = true; }
|
||||
if (options.hash.link !== undefined) { categoryOptions.link = options.hash.link; }
|
||||
if (options.hash.extraClasses) { categoryOptions.extraClasses = options.hash.extraClasses; }
|
||||
if (options.hash.categories) {
|
||||
categoryOptions.categories = Em.Handlebars.get(this, options.hash.categories, options);
|
||||
|
||||
// TODO: This is a compatibility layer with the old helper structure.
|
||||
// Can be removed once we migrate to `registerUnbound` fully
|
||||
if (options && options.hash) { options = options.hash; }
|
||||
|
||||
if (options) {
|
||||
if (options.allowUncategorized) { categoryOptions.allowUncategorized = true; }
|
||||
if (options.showParent) { categoryOptions.showParent = true; }
|
||||
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));
|
||||
|
|
|
@ -3,16 +3,16 @@
|
|||
|
||||
<table class='badges-listing'>
|
||||
<tbody>
|
||||
{{#each badgeGroups}}
|
||||
{{#each bg in badgeGroups}}
|
||||
<tr class='title'>
|
||||
<td colspan=4><h3>{{this.badgeGrouping.displayName}}</h3></td>
|
||||
<td colspan=4><h3>{{bg.badgeGrouping.displayName}}</h3></td>
|
||||
</tr>
|
||||
{{#each this.badges}}
|
||||
{{#each b in bg.badges}}
|
||||
<tr>
|
||||
<td class='granted'>{{#if this.has_badge}}<i class='fa fa-check'></i>{{/if}}</td>
|
||||
<td class='badge'>{{user-badge badge=this}}</td>
|
||||
<td class='description'>{{{displayDescriptionHtml}}}</td>
|
||||
<td class='grant-count'><span title="{{i18n 'badges.granted' count=grant_count}}">{{grant_count}}</span></td>
|
||||
<td class='granted'>{{#if b.has_badge}}<i class='fa fa-check'></i>{{/if}}</td>
|
||||
<td class='badge'>{{user-badge badge=b}}</td>
|
||||
<td class='description'>{{{b.displayDescriptionHtml}}}</td>
|
||||
<td class='grant-count'><span title="{{i18n 'badges.granted' count=b.grant_count}}">{{b.grant_count}}</span></td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
|
|
|
@ -19,18 +19,18 @@
|
|||
|
||||
{{#if userBadges}}
|
||||
<div class={{unbound layoutClass}}>
|
||||
{{#each userBadges}}
|
||||
{{#each ub in userBadges}}
|
||||
<div class="badge-user">
|
||||
{{#link-to 'user' user classNames="badge-info"}}
|
||||
{{avatar user imageSize="large"}}
|
||||
{{#link-to 'user' ub.user classNames="badge-info"}}
|
||||
{{avatar ub.user imageSize="large"}}
|
||||
<div class="details">
|
||||
<span class="username">{{user.username}}</span>
|
||||
{{format-date granted_at}}
|
||||
<span class="username">{{ub.user.username}}</span>
|
||||
{{format-date ub.granted_at}}
|
||||
</div>
|
||||
{{/link-to}}
|
||||
|
||||
{{#if post_number}}
|
||||
<a class="post-link" href="{{unbound topic.url}}/{{unbound post_number}}">{{topic.title}}</a>
|
||||
<a class="post-link" href="{{unbound ub.topic.url}}/{{unbound ub.post_number}}">{{ub.topic.title}}</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/each}}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<div class='cat'><a {{bind-attr href=noCategoriesUrl}} data-drop-close="true" class='badge-category home'>{{i18n 'categories.no_subcategory'}}</a></div>
|
||||
{{/if}}
|
||||
{{#if renderCategories}}
|
||||
{{#each categories}}<div class='cat'>{{category-link this allowUncategorized=true}}</div>{{/each}}
|
||||
{{#each c in categories}}<div class='cat'>{{category-link c allowUncategorized=true}}</div>{{/each}}
|
||||
{{/if}}
|
||||
</section>
|
||||
{{/if}}
|
||||
|
|
|
@ -9,66 +9,66 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each categories}}
|
||||
<tr data-category_id='{{unbound id}}' {{bind-attr class="description_excerpt:has-description:no-description logo_url:has-logo:no-logo"}}>
|
||||
<td class='category' style="border-color: #{{unbound color}}">
|
||||
{{#each c in categories}}
|
||||
<tr data-category_id='{{unbound c.id}}' {{bind-attr class="c.description_excerpt:has-description:no-description c.logo_url:has-logo:no-logo"}}>
|
||||
<td class='category' style="border-color: #{{unbound c.color}}">
|
||||
<div>
|
||||
<div class="pull-left">
|
||||
{{category-title-link category=this}}
|
||||
{{#if unreadTopics}}
|
||||
<a href={{unbound unreadUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.unread_topics' count="unreadTopics"}}'>{{i18n 'filters.unread.lower_title_with_count' count="unreadTopics"}}</a>
|
||||
{{category-title-link category=c}}
|
||||
{{#if c.unreadTopics}}
|
||||
<a href={{unbound c.unreadUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.unread_topics' count=c.unreadTopics}}'>{{i18n 'filters.unread.lower_title_with_count' count=c.unreadTopics}}</a>
|
||||
{{/if}}
|
||||
{{#if newTopics}}
|
||||
<a href={{unbound newUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.new_topics' count="newTopics"}}'>{{i18n 'filters.new.lower_title_with_count' count="newTopics"}}</a>
|
||||
{{#if c.newTopics}}
|
||||
<a href={{unbound c.newUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.new_topics' count=c.newTopics}}'>{{i18n 'filters.new.lower_title_with_count' count=c.newTopics}}</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
{{#if description_excerpt}}
|
||||
{{#if c.description_excerpt}}
|
||||
<div class="category-description">
|
||||
{{{description_excerpt}}}
|
||||
{{{c.description_excerpt}}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if subcategories}}
|
||||
{{#if c.subcategories}}
|
||||
<div class='subcategories'>
|
||||
{{#each subcategories}}
|
||||
{{category-link this showParent=true onlyStripe=true}}
|
||||
{{#if unreadTopics}}
|
||||
<a href={{unbound unreadUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.unread_topics' count="unreadTopics"}}'>{{unbound unreadTopics}}</a>
|
||||
{{#each s in c.subcategories}}
|
||||
{{category-link s showParent=true onlyStripe=true}}
|
||||
{{#if s.unreadTopics}}
|
||||
<a href={{unbound s.unreadUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.unread_topics' count=s.unreadTopics}}'>{{unbound s.unreadTopics}}</a>
|
||||
{{/if}}
|
||||
{{#if newTopics}}
|
||||
<a href={{unbound newUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.new_topics' count="newTopics"}}'>{{unbound newTopics}}</a>
|
||||
{{#if s.newTopics}}
|
||||
<a href={{unbound s.newUrl}} class='badge new-posts badge-notification' title='{{i18n 'topic.new_topics' count=s.newTopics}}'>{{unbound s.newTopics}}</a>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</td>
|
||||
<td {{bind-attr class="archived :latest"}}>
|
||||
{{#each featuredTopics}}
|
||||
<td {{bind-attr class="c.archived :latest"}}>
|
||||
{{#each f in c.featuredTopics}}
|
||||
<div class="featured-topic">
|
||||
{{topic-status topic=this}}
|
||||
<a class='title' href="{{unbound lastUnreadUrl}}">{{{unbound fancy_title}}}</a>
|
||||
{{topic-post-badges newPosts=totalUnread unseen=unseen url=lastUnreadUrl}}
|
||||
{{topic-status topic=f}}
|
||||
<a class='title' href="{{unbound f.lastUnreadUrl}}">{{{unbound f.fancy_title}}}</a>
|
||||
{{topic-post-badges newPosts=f.totalUnread unseen=f.unseen url=f.lastUnreadUrl}}
|
||||
|
||||
{{#if controller.latestTopicOnly}}
|
||||
<div class='last-user-info'>
|
||||
{{i18n 'categories.latest_by'}} <a href="{{{unbound lastPosterUrl}}}">{{unbound last_poster.username}}</a>
|
||||
<a href="{{unbound lastPostUrl}}">{{format-age last_posted_at}}</a>
|
||||
{{i18n 'categories.latest_by'}} <a href="{{{unbound f.lastPosterUrl}}}">{{unbound f.last_poster.username}}</a>
|
||||
<a href="{{unbound f.lastPostUrl}}">{{format-age f.last_posted_at}}</a>
|
||||
</div>
|
||||
{{else}}
|
||||
|
||||
<a href="{{unbound lastPostUrl}}" class="last-posted-at">{{format-age last_posted_at}}</a>
|
||||
<a href="{{unbound f.lastPostUrl}}" class="last-posted-at">{{format-age f.last_posted_at}}</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/each}}
|
||||
</td>
|
||||
<td class='stats' {{bind-attr title="topicStatsTitle"}}>
|
||||
<td class='stats' {{bind-attr title="c.topicStatsTitle"}}>
|
||||
<table class="categoryStats">
|
||||
<tbody>
|
||||
{{#each topicCountStats}}
|
||||
{{#each s in c.topicCountStats}}
|
||||
<tr>
|
||||
<td class="value">{{value}}</td>
|
||||
<td class="unit"> / {{unit}}</td>
|
||||
<td class="value">{{s.value}}</td>
|
||||
<td class="unit"> / {{s.unit}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<div class="modal-body flag-modal">
|
||||
|
||||
<form>
|
||||
{{#each flagsAvailable itemController="flag-action-type"}}
|
||||
{{#each f in flagsAvailable itemController="flag-action-type"}}
|
||||
<div class='controls'>
|
||||
<label class='radio'>
|
||||
<input type='radio' id="radio_{{unbound name_key}}" {{action "changePostActionType" this}} name='post_action_type_index'> <strong>{{formattedName}}</strong>
|
||||
{{#if showDescription}}
|
||||
<div class='description'>{{{description}}}</div>
|
||||
<input type='radio' id="radio_{{unbound f.name_key}}" {{action "changePostActionType" f}} name='post_action_type_index'> <strong>{{f.formattedName}}</strong>
|
||||
{{#if f.showDescription}}
|
||||
<div class='description'>{{{f.description}}}</div>
|
||||
{{/if}}
|
||||
</label>
|
||||
{{#if showMessageInput}}
|
||||
{{textarea name="message" class="flag-message" placeholder=customPlaceholder value=message}}
|
||||
<div {{bind-attr class=":custom-message-length customMessageLengthClasses"}}>{{customMessageLength}}</div>
|
||||
{{#if f.showMessageInput}}
|
||||
{{textarea name="message" class="flag-message" placeholder=f.customPlaceholder value=f.message}}
|
||||
<div {{bind-attr class=":custom-message-length f.customMessageLengthClasses"}}>{{f.customMessageLength}}</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{else}}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
{{#loading-spinner condition=loadingNotifications}}
|
||||
{{#if content}}
|
||||
<ul>
|
||||
{{#each itemController="notification"}}
|
||||
{{notification-item notification=this scope=scope}}
|
||||
{{#each n in model itemController="notification"}}
|
||||
{{notification-item notification=n scope=n.scope}}
|
||||
{{/each}}
|
||||
<li class="read last">
|
||||
<a href="/my/notifications">{{i18n 'notifications.more'}}…</a>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<div class="share-for-touch"><div class="overflow-ellipsis"><a></a></div></div>
|
||||
</div>
|
||||
|
||||
{{each shareLinks itemView='share-link'}}
|
||||
{{each s in shareLinks itemView='share-link'}}
|
||||
|
||||
<div class='link'>
|
||||
<a href='#' {{action "close"}} title='{{i18n 'share.close'}}'><i class="fa fa-times-circle"></i></a>
|
||||
|
|
|
@ -41,16 +41,16 @@
|
|||
{{#link-to "discovery.categories"}}{{i18n 'filters.categories.title'}}{{/link-to}}
|
||||
</li>
|
||||
|
||||
{{#each categories itemController='site-map-category'}}
|
||||
{{#each c in categories itemController='site-map-category'}}
|
||||
<li class="category">
|
||||
{{category-link this allowUncategorized=true showParent=true}}
|
||||
{{category-link c allowUncategorized=true showParent=true}}
|
||||
|
||||
{{#if unreadTotal}}
|
||||
<a href={{unbound url}} class='badge badge-notification'>{{unreadTotal}}</a>
|
||||
{{#if c.unreadTotal}}
|
||||
<a href={{unbound c.url}} class='badge badge-notification'>{{c.unreadTotal}}</a>
|
||||
{{/if}}
|
||||
|
||||
{{#if showTopicCount}}
|
||||
<b class="topics-count">{{unbound topic_count}}</b>
|
||||
{{#if c.showTopicCount}}
|
||||
<b class="topics-count">{{unbound c.topic_count}}</b>
|
||||
{{/if}}
|
||||
</li>
|
||||
{{/each}}
|
||||
|
|
Loading…
Reference in New Issue
Block a user