Blame templates/html/dynsections.js

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