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