Skip to content

Commit

Permalink
Merge branch 'hotfix/0.106.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjgeiger committed Mar 20, 2017
2 parents b8eff0b + fc06334 commit cd515a5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
17 changes: 8 additions & 9 deletions app/controllers/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default Ember.Controller.extend(Analytics, {
expandedAuthors: true,
showLicenseText: false,
fileDownloadURL: '',
expandedAbstract: false,
expandedAbstract: navigator.userAgent.includes('Prerender'),
isAdmin: Ember.computed('node', function() {
// True if the current user has admin permissions for the node that contains the preprint
return (this.get('node.currentUserPermissions') || []).includes(permissions.ADMIN);
Expand Down Expand Up @@ -145,19 +145,18 @@ export default Ember.Controller.extend(Analytics, {
});
}),

useShortenedDescription: Ember.computed('node.description', function() {
return this.get('node.description') ? this.get('node.description').length > 350 : false;
hasShortenedDescription: Ember.computed('node.description', function() {
const nodeDescription = this.get('node.description');

return nodeDescription && nodeDescription.length > 350;
}),

description: Ember.computed('node.description', 'expandedAbstract', function() {
// Get a shortened version of the abstract, but doesnt cut in the middle of word by going
// to the last space.
if (this.get('expandedAbstract')) {
return this.get('node.description');
}
let text = this.get('node.description').slice(0, 350).split(' ');
text.pop();
return text.join(' ') + ' ...';
return this.get('node.description')
.slice(0, 350)
.replace(/\s+\S*$/, '');
}),

actions: {
Expand Down
2 changes: 2 additions & 0 deletions app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export default {
download_file: `Download file`,
download_preprint: `Download preprint`
},
see_more: 'See more',
see_less: 'See less',
version: 'Version',
article_doi: `Article DOI`,
citations: `Citations`,
Expand Down
3 changes: 3 additions & 0 deletions app/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ ul.preprints-block-list {
.abstract {
white-space: pre-line;
}
.abstract-truncated:after {
content: ' \2026';
}
.project-box {
div {
min-height: 100px;
Expand Down
8 changes: 2 additions & 6 deletions app/templates/content.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,8 @@
</div>
<div class="p-t-xs">
<h4 class="p-v-md f-w-md"><strong>{{t "global.abstract"}}</strong></h4>
{{#if useShortenedDescription}}
<p class="abstract">{{description}}</p>
<button class='btn-link' {{action 'expandAbstract'}}>{{if expandedAbstract 'See less' 'See more'}}</button>
{{else}}
<p class="abstract">{{node.description}}</p>
{{/if}}
<p class="abstract {{unless expandedAbstract 'abstract-truncated'}}">{{if expandedAbstract node.description description}}</p>
<button class='btn-link' hidden={{not hasShortenedDescription}} {{action 'expandAbstract'}}>{{t (if expandedAbstract 'content.see_less' 'content.see_more')}}</button>
</div>

{{#if model.doi}}
Expand Down

0 comments on commit cd515a5

Please sign in to comment.