Home | History | Annotate | Download | only in html
      1 /*
      2  @licstart  The following is the entire license notice for the
      3  JavaScript code in this file.
      4 
      5  Copyright (C) 1997-2017 by Dimitri van Heesch
      6 
      7  This program is free software; you can redistribute it and/or modify
      8  it under the terms of the GNU General Public License as published by
      9  the Free Software Foundation; either version 2 of the License, or
     10  (at your option) any later version.
     11 
     12  This program is distributed in the hope that it will be useful,
     13  but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15  GNU General Public License for more details.
     16 
     17  You should have received a copy of the GNU General Public License along
     18  with this program; if not, write to the Free Software Foundation, Inc.,
     19  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
     20 
     21  @licend  The above is the entire license notice
     22  for the JavaScript code in this file
     23  */
     24 function toggleVisibility(linkObj)
     25 {
     26  var base = $(linkObj).attr('id');
     27  var summary = $('#'+base+'-summary');
     28  var content = $('#'+base+'-content');
     29  var trigger = $('#'+base+'-trigger');
     30  var src=$(trigger).attr('src');
     31  if (content.is(':visible')===true) {
     32    content.hide();
     33    summary.show();
     34    $(linkObj).addClass('closed').removeClass('opened');
     35    $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png');
     36  } else {
     37    content.show();
     38    summary.hide();
     39    $(linkObj).removeClass('closed').addClass('opened');
     40    $(trigger).attr('src',src.substring(0,src.length-10)+'open.png');
     41  }
     42  return false;
     43 }
     44 
     45 function updateStripes()
     46 {
     47   $('table.directory tr').
     48        removeClass('even').filter(':visible:even').addClass('even');
     49 }
     50 
     51 function toggleLevel(level)
     52 {
     53   $('table.directory tr').each(function() {
     54     var l = this.id.split('_').length-1;
     55     var i = $('#img'+this.id.substring(3));
     56     var a = $('#arr'+this.id.substring(3));
     57     if (l<level+1) {
     58       i.removeClass('iconfopen iconfclosed').addClass('iconfopen');
     59       a.html('&#9660;');
     60       $(this).show();
     61     } else if (l==level+1) {
     62       i.removeClass('iconfclosed iconfopen').addClass('iconfclosed');
     63       a.html('&#9654;');
     64       $(this).show();
     65     } else {
     66       $(this).hide();
     67     }
     68   });
     69   updateStripes();
     70 }
     71 
     72 function toggleFolder(id)
     73 {
     74   // the clicked row
     75   var currentRow = $('#row_'+id);
     76 
     77   // all rows after the clicked row
     78   var rows = currentRow.nextAll("tr");
     79 
     80   var re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub
     81 
     82   // only match elements AFTER this one (can't hide elements before)
     83   var childRows = rows.filter(function() { return this.id.match(re); });
     84 
     85   // first row is visible we are HIDING
     86   if (childRows.filter(':first').is(':visible')===true) {
     87     // replace down arrow by right arrow for current row
     88     var currentRowSpans = currentRow.find("span");
     89     currentRowSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
     90     currentRowSpans.filter(".arrow").html('&#9654;');
     91     rows.filter("[id^=row_"+id+"]").hide(); // hide all children
     92   } else { // we are SHOWING
     93     // replace right arrow by down arrow for current row
     94     var currentRowSpans = currentRow.find("span");
     95     currentRowSpans.filter(".iconfclosed").removeClass("iconfclosed").addClass("iconfopen");
     96     currentRowSpans.filter(".arrow").html('&#9660;');
     97     // replace down arrows by right arrows for child rows
     98     var childRowsSpans = childRows.find("span");
     99     childRowsSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
    100     childRowsSpans.filter(".arrow").html('&#9654;');
    101     childRows.show(); //show all children
    102   }
    103   updateStripes();
    104 }
    105 
    106 
    107 function toggleInherit(id)
    108 {
    109   var rows = $('tr.inherit.'+id);
    110   var img = $('tr.inherit_header.'+id+' img');
    111   var src = $(img).attr('src');
    112   if (rows.filter(':first').is(':visible')===true) {
    113     rows.css('display','none');
    114     $(img).attr('src',src.substring(0,src.length-8)+'closed.png');
    115   } else {
    116     rows.css('display','table-row'); // using show() causes jump in firefox
    117     $(img).attr('src',src.substring(0,src.length-10)+'open.png');
    118   }
    119 }
    120 /* @license-end */
    121