/* encoding: utf-8 * * Redmine plugin for Document Management System "Features" * * Copyright (C) 2011-16 Karel Pičman * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* Function to allow the projects to show up as a tree */ function dmsf_toggle(EL, PM) { var els = document.getElementsByTagName('tr'); var elsLen = els.length; var pattern = new RegExp("(^|\\s)" + EL + "(\\s|$)"); var cpattern = new RegExp('span'); var expand = new RegExp('dmsf_expanded'); var collapse = new RegExp('dmsf_collapsed'); var hide = new RegExp('dmsf_hidden'); var spanid = PM; var classid = new RegExp('junk'); var oddeventoggle = 0; for(i = 0; i < elsLen; i++) { if(cpattern.test(els[i].id)) { var tmpspanid = spanid; var tmpclassid = classid; spanid = els[i].id; classid = spanid; classid = classid.match(/(\w+)span/)[1]; classid = new RegExp(classid); if(tmpclassid.test(els[i].className) && (tmpspanid.toString() !== PM.toString())) { if(collapse.test(document.getElementById(tmpspanid).className)) { spanid = tmpspanid; classid = tmpclassid; } } } if(pattern.test(els[i].className)) { var cnames = els[i].className; cnames = cnames.replace(/dmsf_hidden/g,''); if(expand.test(document.getElementById(PM).className)) { cnames += ' dmsf_hidden'; } else { if((spanid.toString() !== PM.toString()) && (classid.test(els[i].className))) { if(collapse.test(document.getElementById(spanid).className)) { cnames += ' dmsf_hidden'; } } } els[i].className = cnames; } if(!(hide.test(els[i].className))) { var cnames = els[i].className; cnames = cnames.replace(/odd/g,''); cnames = cnames.replace(/even/g,''); if(oddeventoggle === 0) { cnames += ' odd'; } else { cnames += ' even'; } oddeventoggle ^= 1; els[i].className = cnames; } } if (collapse.test(document.getElementById(PM).className)) { var cnames = document.getElementById(PM).className; cnames = cnames.replace(/dmsf_collapsed/,'dmsf_expanded'); document.getElementById(PM).className = cnames; } else { var cnames = document.getElementById(PM).className; cnames = cnames.replace(/dmsf_expanded/,'dmsf_collapsed'); document.getElementById(PM).className = cnames; } }