Commit 9dc7c12c authored by Hugh Davenport's avatar Hugh Davenport
Browse files

Navigation menu in collections should stay open



Adds a parameter showmore to specify whether all views are
displayed.

Changes the showmore button to show << when expanded, and back
to ... when not expanded

When Javascript is disabled, it defaults to showing all with
no button to hide

Bug #640937

Change-Id: I7d2db3813620e554cfd3e41be4fbb49ec34aa8f9
Signed-off-by: default avatarHugh Davenport <hugh@catalyst.net.nz>
parent bc4cc476
<div id="collectionnavwrap"> <div id="collectionnavwrap">
{foreach from=$collection item=chunk name=cchunk} {foreach from=$collection item=chunk name=cchunk}
<div class="{if $dwoo.foreach.cchunk.first}colnav1{else}colnav-extra hidden{/if}"> <div class="{if $dwoo.foreach.cchunk.first}colnav1{else}colnav-extra{/if}">
<ul class="colnav"> <ul class="colnav">
{foreach from=$chunk item=view} {foreach from=$chunk item=view}
<li{if $view->view == $viewid} class="selected"{/if}> <li{if $view->view == $viewid} class="selected"{/if}>
{if $view->view != $viewid} {if $view->view != $viewid}
<a href="{$WWWROOT}view/view.php?id={$view->view}">{$view->title|str_shorten_text:30:true}</a> <a class="colnav" href="{$WWWROOT}view/view.php?id={$view->view}">{$view->title|str_shorten_text:30:true}</a>
{else} {else}
<span>{$view->title|str_shorten_text:30:true}</span> <span>{$view->title|str_shorten_text:30:true}</span>
{/if} {/if}
</li> </li>
{/foreach} {/foreach}
{if $dwoo.foreach.cchunk.first && !$dwoo.foreach.cchunk.last} {if $dwoo.foreach.cchunk.first && !$dwoo.foreach.cchunk.last}{$haslots=true}{/if}
<li id="colnav-more" class="nojs-hidden"><a href=""></a></li>
{/if}
</ul> </ul>
</div> </div>
{/foreach} {/foreach}
<div id="colnav-showmore-div" class="colnav-showmore"></div>
{if $dwoo.foreach.cchunk.index > 1} {if $dwoo.foreach.cchunk.index > 1}
<script>{literal} <script>{literal}
function toggleShowmore() {
forEach (getElementsByTagAndClassName('div', 'colnav-extra', null), partial(toggleElementClass, 'hidden'));
var elem = document.getElementById('colnav-more-a');
if (showmore) {
document.getElementById('colnav-more-a').innerHTML = '«';
} else {
document.getElementById('colnav-more-a').innerHTML = '';
}
var links = getElementsByTagAndClassName('a', 'colnav', null);
if (showmore) {
for (var index = 0; index < links.length; index ++) {
links[index].href = links[index].href + '&showmore=1';
}
} else {
for (var index = 0; index < links.length; index ++) {
links[index].href = links[index].href.replace('&showmore=1', '');
}
}
}
addLoadEvent(function() { addLoadEvent(function() {
{/literal}{if $haslots}{literal}
var a = document.createElement('a');
a.setAttribute('id', 'colnav-more-a');
a.setAttribute('href', '');
a.appendChild(document.createTextNode('«'));
var li = document.createElement('li');
li.setAttribute('id', 'colnav-more');
li.setAttribute('class', 'nojs-hidden');
li.appendChild(a);
var ul = document.createElement('ul');
ul.setAttribute('class', 'colnav');
ul.appendChild(li);
var div = document.getElementById('colnav-showmore-div');
div.appendChild(ul);
{/literal}{/if}{literal}
if (!showmore) {
toggleShowmore();
} else {
var links = getElementsByTagAndClassName('a', 'colnav', null);
for (var index = 0; index < links.length; index ++) {
links[index].href = links[index].href + '&showmore=1';
}
}
connect('colnav-more', 'onclick', function(e) { connect('colnav-more', 'onclick', function(e) {
e.stop(); e.stop();
forEach (getElementsByTagAndClassName('div', 'colnav-extra', null), partial(toggleElementClass, 'hidden')); showmore = !showmore;
toggleShowmore();
return false;
}); });
});{/literal} });{/literal}
</script> </script>
......
...@@ -707,6 +707,10 @@ ul.artefactchooser-subtabs li.current a:active { ...@@ -707,6 +707,10 @@ ul.artefactchooser-subtabs li.current a:active {
margin: 0; margin: 0;
float: left; float: left;
} }
#containerX div.colnav-showmore {
margin: 0;
float: left;
}
/* Collection navigation normal header */ /* Collection navigation normal header */
#collectionnavwrap { #collectionnavwrap {
background: #EEE; background: #EEE;
......
...@@ -59,6 +59,10 @@ else { ...@@ -59,6 +59,10 @@ else {
} }
$new = param_boolean('new'); $new = param_boolean('new');
$showmore = param_boolean('showmore');
if (!$showmore) {
$showmore = 0;
}
if (!can_view_view($viewid)) { if (!can_view_view($viewid)) {
throw new AccessDeniedException(get_string('accessdenied', 'error')); throw new AccessDeniedException(get_string('accessdenied', 'error'));
...@@ -185,6 +189,7 @@ $smarty = smarty( ...@@ -185,6 +189,7 @@ $smarty = smarty(
$javascript = <<<EOF $javascript = <<<EOF
var viewid = {$viewid}; var viewid = {$viewid};
var showmore = {$showmore};
addLoadEvent(function () { addLoadEvent(function () {
paginator = {$feedback->pagination_js} paginator = {$feedback->pagination_js}
}); });
......
Markdown is supported
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