Blame templates/html/dynsections.js

Packit 1c1d7e
/*
Packit 1c1d7e
 @licstart  The following is the entire license notice for the
Packit 1c1d7e
 JavaScript code in this file.
Packit 1c1d7e
Packit 1c1d7e
 Copyright (C) 1997-2017 by Dimitri van Heesch
Packit 1c1d7e
Packit 1c1d7e
 This program is free software; you can redistribute it and/or modify
Packit 1c1d7e
 it under the terms of the GNU General Public License as published by
Packit 1c1d7e
 the Free Software Foundation; either version 2 of the License, or
Packit 1c1d7e
 (at your option) any later version.
Packit 1c1d7e
Packit 1c1d7e
 This program is distributed in the hope that it will be useful,
Packit 1c1d7e
 but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 1c1d7e
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 1c1d7e
 GNU General Public License for more details.
Packit 1c1d7e
Packit 1c1d7e
 You should have received a copy of the GNU General Public License along
Packit 1c1d7e
 with this program; if not, write to the Free Software Foundation, Inc.,
Packit 1c1d7e
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Packit 1c1d7e
Packit 1c1d7e
 @licend  The above is the entire license notice
Packit 1c1d7e
 for the JavaScript code in this file
Packit 1c1d7e
 */
Packit 1c1d7e
function toggleVisibility(linkObj)
Packit 1c1d7e
{
Packit 1c1d7e
 var base = $(linkObj).attr('id');
Packit 1c1d7e
 var summary = $('#'+base+'-summary');
Packit 1c1d7e
 var content = $('#'+base+'-content');
Packit 1c1d7e
 var trigger = $('#'+base+'-trigger');
Packit 1c1d7e
 var src=$(trigger).attr('src');
Packit 1c1d7e
 if (content.is(':visible')===true) {
Packit 1c1d7e
   content.hide();
Packit 1c1d7e
   summary.show();
Packit 1c1d7e
   $(linkObj).addClass('closed').removeClass('opened');
Packit 1c1d7e
   $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png');
Packit 1c1d7e
 } else {
Packit 1c1d7e
   content.show();
Packit 1c1d7e
   summary.hide();
Packit 1c1d7e
   $(linkObj).removeClass('closed').addClass('opened');
Packit 1c1d7e
   $(trigger).attr('src',src.substring(0,src.length-10)+'open.png');
Packit 1c1d7e
 }
Packit 1c1d7e
 return false;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
function updateStripes()
Packit 1c1d7e
{
Packit 1c1d7e
  $('table.directory tr').
Packit 1c1d7e
       removeClass('even').filter(':visible:even').addClass('even');
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
function toggleLevel(level)
Packit 1c1d7e
{
Packit 1c1d7e
  $('table.directory tr').each(function() {
Packit 1c1d7e
    var l = this.id.split('_').length-1;
Packit 1c1d7e
    var i = $('#img'+this.id.substring(3));
Packit 1c1d7e
    var a = $('#arr'+this.id.substring(3));
Packit 1c1d7e
    if (l
Packit 1c1d7e
      i.removeClass('iconfopen iconfclosed').addClass('iconfopen');
Packit 1c1d7e
      a.html('▼');
Packit 1c1d7e
      $(this).show();
Packit 1c1d7e
    } else if (l==level+1) {
Packit 1c1d7e
      i.removeClass('iconfclosed iconfopen').addClass('iconfclosed');
Packit 1c1d7e
      a.html('▶');
Packit 1c1d7e
      $(this).show();
Packit 1c1d7e
    } else {
Packit 1c1d7e
      $(this).hide();
Packit 1c1d7e
    }
Packit 1c1d7e
  });
Packit 1c1d7e
  updateStripes();
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
function toggleFolder(id)
Packit 1c1d7e
{
Packit 1c1d7e
  // the clicked row
Packit 1c1d7e
  var currentRow = $('#row_'+id);
Packit 1c1d7e
Packit 1c1d7e
  // all rows after the clicked row
Packit 1c1d7e
  var rows = currentRow.nextAll("tr");
Packit 1c1d7e
Packit 1c1d7e
  var re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub
Packit 1c1d7e
Packit 1c1d7e
  // only match elements AFTER this one (can't hide elements before)
Packit 1c1d7e
  var childRows = rows.filter(function() { return this.id.match(re); });
Packit 1c1d7e
Packit 1c1d7e
  // first row is visible we are HIDING
Packit 1c1d7e
  if (childRows.filter(':first').is(':visible')===true) {
Packit 1c1d7e
    // replace down arrow by right arrow for current row
Packit 1c1d7e
    var currentRowSpans = currentRow.find("span");
Packit 1c1d7e
    currentRowSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
Packit 1c1d7e
    currentRowSpans.filter(".arrow").html('▶');
Packit 1c1d7e
    rows.filter("[id^=row_"+id+"]").hide(); // hide all children
Packit 1c1d7e
  } else { // we are SHOWING
Packit 1c1d7e
    // replace right arrow by down arrow for current row
Packit 1c1d7e
    var currentRowSpans = currentRow.find("span");
Packit 1c1d7e
    currentRowSpans.filter(".iconfclosed").removeClass("iconfclosed").addClass("iconfopen");
Packit 1c1d7e
    currentRowSpans.filter(".arrow").html('▼');
Packit 1c1d7e
    // replace down arrows by right arrows for child rows
Packit 1c1d7e
    var childRowsSpans = childRows.find("span");
Packit 1c1d7e
    childRowsSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
Packit 1c1d7e
    childRowsSpans.filter(".arrow").html('▶');
Packit 1c1d7e
    childRows.show(); //show all children
Packit 1c1d7e
  }
Packit 1c1d7e
  updateStripes();
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
Packit 1c1d7e
function toggleInherit(id)
Packit 1c1d7e
{
Packit 1c1d7e
  var rows = $('tr.inherit.'+id);
Packit 1c1d7e
  var img = $('tr.inherit_header.'+id+' img');
Packit 1c1d7e
  var src = $(img).attr('src');
Packit 1c1d7e
  if (rows.filter(':first').is(':visible')===true) {
Packit 1c1d7e
    rows.css('display','none');
Packit 1c1d7e
    $(img).attr('src',src.substring(0,src.length-8)+'closed.png');
Packit 1c1d7e
  } else {
Packit 1c1d7e
    rows.css('display','table-row'); // using show() causes jump in firefox
Packit 1c1d7e
    $(img).attr('src',src.substring(0,src.length-10)+'open.png');
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
/* @license-end */