mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 08:43:25 +08:00
a524194a46
`templateName` instead of `layoutName` in an `Em.Component`. This fixes that and backs out other "fixes"
54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
/**
|
|
The topic map underneath the first post of a topic.
|
|
|
|
@class TopicMapComponent
|
|
@extends Ember.Component
|
|
@namespace Discourse
|
|
@module Discourse
|
|
**/
|
|
|
|
var LINKS_SHOWN = 5;
|
|
|
|
Discourse.TopicMapComponent = Ember.Component.extend({
|
|
mapCollapsed: true,
|
|
layoutName: 'components/topic-map',
|
|
details: Em.computed.alias('topic.details'),
|
|
allLinksShown: false,
|
|
|
|
init: function() {
|
|
this._super();
|
|
|
|
// If the topic has a summary, expand the map by default
|
|
this.set('mapCollapsed', Discourse.Mobile.mobileView || (!this.get('topic.has_summary')));
|
|
},
|
|
|
|
toggleMapClass: function() {
|
|
return this.get('mapCollapsed') ? 'fa fa-chevron-down' : 'fa fa-chevron-up';
|
|
}.property('mapCollapsed'),
|
|
|
|
showAllLinksControls: function() {
|
|
if (this.get('allLinksShown')) return false;
|
|
if ((this.get('details.links.length') || 0) <= LINKS_SHOWN) return false;
|
|
return true;
|
|
}.property('allLinksShown', 'topic.details.links'),
|
|
|
|
infoLinks: function() {
|
|
var allLinks = this.get('details.links');
|
|
if (Em.isNone(allLinks)) return [];
|
|
|
|
if (this.get('allLinksShown')) return allLinks;
|
|
return allLinks.slice(0, LINKS_SHOWN);
|
|
|
|
}.property('details.links', 'allLinksShown'),
|
|
|
|
actions: {
|
|
toggleMap: function() {
|
|
this.toggleProperty('mapCollapsed');
|
|
},
|
|
|
|
showAllLinks: function() {
|
|
this.set('allLinksShown', true);
|
|
}
|
|
}
|
|
});
|