Skip to content
Snippets Groups Projects
Commit 76cec6e7 authored by Chris Hallberg's avatar Chris Hallberg
Browse files

Merge branch 'release-4.1'

parents e64a4271 f112a554
No related merge requests found
/*global VuFind */ /*global VuFind */
var hierarchyID, recordID, htmlID, hierarchyContext; var hierarchyID, recordID, htmlID, hierarchyContext, hierarchySettings;
/* Utility functions */ /* Utility functions */
function htmlEncodeId(id) { function htmlEncodeId(id) {
...@@ -101,6 +101,24 @@ function doTreeSearch() { ...@@ -101,6 +101,24 @@ function doTreeSearch() {
} }
} }
function scrollToClicked() {
// Scroll to the current record
var hTree = $('#hierarchyTree');
hTree.animate({
scrollTop: $('.jstree-clicked').offset().top - hTree.offset().top + hTree.scrollTop() - 50
}, 1000);
}
function hideFullHierarchy() {
var $selected = $('.jstree-clicked');
// Hide all nodes
$('#hierarchyTree li').hide();
// Show the nodes on the current path
$selected.show().parents().show();
// Show the nodes below the current path
$selected.find("li").show();
}
function buildJSONNodes(xml) { function buildJSONNodes(xml) {
var jsonNode = []; var jsonNode = [];
$(xml).children('item').each(function xmlTreeChildren() { $(xml).children('item').each(function xmlTreeChildren() {
...@@ -146,6 +164,24 @@ $(document).ready(function hierarchyTreeReady() { ...@@ -146,6 +164,24 @@ $(document).ready(function hierarchyTreeReady() {
hierarchyContext = $("#hierarchyTree").find(".hiddenContext")[0].value; hierarchyContext = $("#hierarchyTree").find(".hiddenContext")[0].value;
var inLightbox = $("#hierarchyTree").parents("#modal").length > 0; var inLightbox = $("#hierarchyTree").parents("#modal").length > 0;
if (!hierarchySettings.fullHierarchy) {
// Set Up Partial Hierarchy View Toggle
$('#hierarchyTree').parent().prepend('<a href="#" id="toggleTree" class="closed">' + VuFind.translate("showTree") + '</a>');
$('#toggleTree').click(function toggleFullTree(e) {
e.preventDefault();
$(this).toggleClass("open");
if ($(this).hasClass("open")) {
$(this).html(VuFind.translate("hideTree"));
$('#hierarchyTree li').show();
} else {
$(this).html(VuFind.translate("showTree"));
hideFullHierarchy();
}
scrollToClicked();
$("#hierarchyTree").jstree("toggle_dots");
});
}
$("#hierarchyLoading").removeClass('hide'); $("#hierarchyLoading").removeClass('hide');
$("#hierarchyTree") $("#hierarchyTree")
...@@ -167,11 +203,13 @@ $(document).ready(function hierarchyTreeReady() { ...@@ -167,11 +203,13 @@ $(document).ready(function hierarchyTreeReady() {
} }
}); });
// Scroll to the current record if (!hierarchySettings.fullHierarchy) {
var hTree = $('#hierarchyTree'); // Initial hide of nodes outside current path
hTree.animate({ hideFullHierarchy();
scrollTop: $('.jstree-clicked').offset().top - hTree.offset().top + hTree.scrollTop() - 50 $("#hierarchyTree").jstree("toggle_dots");
}, 1000); }
scrollToClicked();
}) })
.jstree({ .jstree({
plugins: ['search', 'types'], plugins: ['search', 'types'],
......
...@@ -4,8 +4,17 @@ ...@@ -4,8 +4,17 @@
$hierarchyTreeList = $this->tab->getTreeList(); $hierarchyTreeList = $this->tab->getTreeList();
$activeTree = $this->tab->getActiveTree(); $activeTree = $this->tab->getActiveTree();
$this->jsTranslations()->addStrings( $this->inlineScript(
['showTree' => 'hierarchy_show_tree', 'hideTree' => 'hierarchy_hide_tree'] \Zend\View\Helper\HeadScript::SCRIPT,
"var hierarchySettings = {\n"
. " lightboxMode: " . ($this->layout()->getTemplate() == 'layout/lightbox' ? 'true' : 'false') . ",\n"
. " fullHierarchy: false\n" // . ($this->tab->isFullHierarchyVisible() ? 'true' : 'false') . "\n"
. "};\n"
. "VuFind.addTranslations({\n"
. " 'showTree': '" . $this->transEsc('hierarchy_show_tree') . "',\n"
. " 'hideTree': '" . $this->transEsc('hierarchy_hide_tree') . "'}\n"
. ");\n",
'SET'
); );
$this->inlineScript(\Zend\View\Helper\HeadScript::FILE, 'vendor/jsTree/jstree.min.js'); $this->inlineScript(\Zend\View\Helper\HeadScript::FILE, 'vendor/jsTree/jstree.min.js');
$this->inlineScript(\Zend\View\Helper\HeadScript::FILE, 'hierarchyTree.js'); $this->inlineScript(\Zend\View\Helper\HeadScript::FILE, 'hierarchyTree.js');
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment