Skip to content

Commit

Permalink
- Allows to collapse / expand extracted item fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
duendex committed Apr 4, 2014
1 parent c1cf26a commit 2a235ca
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
8 changes: 8 additions & 0 deletions slyd/media/js/templates/collapsible-text.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{view.displayedText}}
{{#if view.collapsible}}
{{#if view.collapsed}}
<span class="blue-label collapse-button"> [+] </span>
{{else}}
<span class="blue-label collapse-button"> [-] </span>
{{/if}}
{{/if}}
6 changes: 5 additions & 1 deletion slyd/media/js/templates/topbar-browse.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@
{{#each view.textFields}}
<div style="margin-bottom:5px">
<span class="small-label blue-label">{{this.name}}:</span>
<span style="color:white;word-wrap:break-word;">{{this.value}}</span>
{{#each this.value}}
<span style="color:white;word-wrap:break-word;">
{{view ASTool.CollapsibleText fullText=this}}
</span>
{{/each}}
</div>
{{/each}}
{{#each view.imageFields}}
Expand Down
24 changes: 24 additions & 0 deletions slyd/media/js/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,30 @@ ASTool.ImageView = Em.View.extend({
attributeBindings: ['src', 'width'],
});

ASTool.CollapsibleText = Em.View.extend({
fullText: null,
tagName: 'span',
collapsed: true,
trimTo: 400,
templateName: 'collapsible-text',

collapsible: function() {
return this.get('fullText').length > this.get('trimTo');
}.property('fullText', 'trimTo'),

displayedText: function() {
if (!this.get('collapsed')) {
return this.get('fullText');
} else {
return trim(this.get('fullText'), this.get('trimTo'));
}
}.property('collapsed', 'fullText', 'trimTo'),

click: function() {
this.set('collapsed', !this.get('collapsed'));
},
});


var ToolboxViewMixin = ASTool.ToolboxViewMixin;

Expand Down
1 change: 1 addition & 0 deletions slyd/media/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
compile('js/templates/annotation-widget.handlebars');
compile('js/templates/floating-annotation-widget.handlebars');
compile('js/templates/edit-item.handlebars');
compile('js/templates/collapsible-text.handlebars');
compile('js/templates/item.handlebars');
compile('js/templates/navigation.handlebars');
compile('js/templates/toolbox.handlebars');
Expand Down

0 comments on commit 2a235ca

Please sign in to comment.