2 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
3 * Copyright (C) 2002-2009 The Nucleus Group
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * (see nucleus/documentation/index.html#license for more info)
11 * Javascript code to hide empty textareas when editing templates.
13 * @require compatibility.js
16 * $NucleusJP: templateEdit.js,v 1.4 2006/07/12 07:11:47 kimitake Exp $
19 var amountOfFields = 1;
20 var editText = 'empty field (click to edit)';
22 function hideUnused() {
23 while (document.getElementById('textarea' + amountOfFields))
27 for (var i=1;i<=amountOfFields;i++) {
28 var el = document.getElementById('textarea' + i);
30 // hide textareas when empty, and add onclick event
31 // to make them visible again
33 el.style.display = 'none';
34 var tdEl = document.getElementById('td' + i);
36 var aHref = createElement('a');
38 aHref.className = "expandLink";
39 aHref.id = "expandLink" + i;
40 aHref.onclick = new Function("return makeVisible("+i+")");
41 aHref.tabIndex = el.tabIndex;
42 aHref.title = editText;
43 aHref.appendChild(document.createTextNode(editText));
45 tdEl.appendChild(aHref);
52 function setTemplateEditText(newText) {
56 function makeVisible(i) {
57 var textareaEl = document.getElementById('textarea' + i);
58 var expandEl = document.getElementById('expandLink' + i);
60 textareaEl.style.display = 'block';
61 expandEl.style.display = 'none';
67 window.onload = hideUnused;