-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display file preview for readme, metadata and json files, grouped in …
…their tab
- Loading branch information
1 parent
23dd10a
commit 91f3712
Showing
8 changed files
with
141 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,31 @@ | ||
Blacklight.onLoad(function() { | ||
function showFile(evt, file_id) { | ||
// Declare all variables | ||
var i, tabcontent, tablinks; | ||
$(function() { | ||
$("div.vertical-tab-menu>div.list-group>a").click(function (e) { | ||
e.preventDefault(); | ||
$(this).siblings('a.active').removeClass("active"); | ||
$("div.vertical-tab>div.vertical-tab-content").removeClass("active"); | ||
$(this).addClass("active"); | ||
var ele_id = $(this).attr("href"); | ||
$(ele_id).addClass("active"); | ||
}); | ||
}); | ||
}); | ||
|
||
// Get all elements with class="vertical-tab-content" and hide them | ||
tabcontent = document.getElementsByClassName("vertical-tab-content"); | ||
for (i = 0; i < tabcontent.length; i++) { | ||
tabcontent[i].style.display = "none"; | ||
} | ||
|
||
// Get all elements with class="tablinks" and remove the class "active" | ||
tablinks = document.getElementsByClassName("vertical-tab-links"); | ||
for (i = 0; i < tablinks.length; i++) { | ||
tablinks[i].className = tablinks[i].className.replace(" active", ""); | ||
Blacklight.onLoad(function() { | ||
$(function() { | ||
$(".preview_file_types").click(function(e) { | ||
// e.preventDefault(); | ||
var ele_id = $(this).attr("href"); | ||
var ele = $(ele_id); | ||
var active_inner_tab = ele.find(".list-group-item.active"); | ||
if(active_inner_tab.length === 1) { | ||
$(active_inner_tab[0]).trigger('click'); | ||
} else { | ||
var inner_tab = ele.find(".list-group-item:first"); | ||
if(inner_tab.length === 1) { | ||
$(inner_tab[0]).trigger('click'); | ||
} | ||
} | ||
|
||
// Show the current tab, and add an "active" class to the link that opened the tab | ||
document.getElementById(file_id).style.display = "block"; | ||
evt.currentTarget.className += " active"; | ||
} | ||
} ); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 57 additions & 13 deletions
70
hyrax/app/views/hyrax/base/_preview_same_file_types.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,62 @@ | ||
<div class="vertical-tab"> | ||
<% file_presenters.each do |p| %> | ||
<button class="vertical-tab-links" id="<%= p.id %>" | ||
onclick="showFile(event, 'tab-content-<%= p.id %>')"> | ||
<%= p.link_name %> | ||
</button> | ||
<% end %> | ||
</div> | ||
<% this_active_class = active_class %> | ||
|
||
<% file_presenters.each do |p| %> | ||
<div id="tab-content-<%= p.id %>" class="vertical-tab-content"> | ||
File content should be here | ||
<%#= nims_media_display(p, content: true) %> | ||
<div class="files-preview panel panel-default <%= active_class %>"> | ||
<a id="<%= file_group %>-preview-panel"></a> | ||
<div class="panel-heading" data-toggle="collapse" data-target="#<%= file_group %>-preview"> | ||
<h4 class="panel-title"> | ||
<a class="<%= file_group %>-preview-title accordion-toggle">Preview <%= file_group %> files</a> | ||
</h4> | ||
</div> | ||
<% end %> | ||
<div id="<%= file_group %>-preview" class="panel-collapse collapse in"> | ||
<div class="panel-body overflow-scroll"> | ||
|
||
<div class="col-lg-3 col-md-3 vertical-tab-menu"> | ||
<div class="list-group"> | ||
<% file_presenters.each do |p| %> | ||
<a href="#type-preview-<%= p.id %>" aria-controls="preview <%= p.link_name %>" | ||
class="list-group-item <%= this_active_class %> text-center"> | ||
<%= p.link_name %> | ||
</a> | ||
<% this_active_class = '' %> | ||
<% end %> | ||
</div> | ||
</div> | ||
|
||
<% this_active_class = active_class %> | ||
<div class="col-lg-9 col-md-9 vertical-tab"> | ||
<% file_presenters.each do |p| %> | ||
<% if p.json? %> | ||
<% member_type = "graph" %> | ||
<% member_class = "json-preview" %> | ||
<% elsif p.markdown? %> | ||
<% member_type = "content" %> | ||
<% member_class = "md-preview" %> | ||
<% else # should be text %> | ||
<% member_type = "content" %> | ||
<% member_class = "txt-preview" %> | ||
<% end %> | ||
<div class="vertical-tab-content <%= member_class %> <%= this_active_class %>" id="type-preview-<%= p.id %>" | ||
aria-labelledby="preview <%= p.link_name %>" | ||
data-url="<%= main_app.export_file_path(p.id)%>" | ||
data-ele="<%= member_class %>-<%= member_type %>-<%= p.id %>" | ||
data-title="<%= p.link_name %>"> | ||
<% if member_type == "graph" %> | ||
<%= nims_media_display(p, graph: true) %> | ||
<% else %> | ||
<%= nims_media_display(p, content: true) %> | ||
<% end %> | ||
</div> | ||
<% this_active_class = '' %> | ||
<% end %> | ||
</div> | ||
</div> | ||
<div class="panel-footer <%= file_group %>-preview-size" style="display: none;"> | ||
<!-- size --> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
|
||
|
23 changes: 2 additions & 21 deletions
23
hyrax/app/views/hyrax/file_sets/media_display/_json.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 2 additions & 21 deletions
23
hyrax/app/views/hyrax/file_sets/media_display/_md.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 2 additions & 21 deletions
23
hyrax/app/views/hyrax/file_sets/media_display/_txt.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters