2 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
\r
3 * Copyright (C) 2002-2004 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.1.1.1 2005-02-28 07:14:02 kimitake Exp $
\r
18 var amountOfFields = 1;
\r
19 var editText = 'empty field (click to edit)';
\r
21 function hideUnused() {
\r
22 while (document.getElementById('textarea' + amountOfFields))
\r
26 for (var i=1;i<=amountOfFields;i++) {
\r
27 var el = document.getElementById('textarea' + i);
\r
29 // hide textareas when empty, and add onclick event
\r
30 // to make them visible again
\r
31 if (el.value == '') {
\r
32 el.style.display = 'none';
\r
33 var tdEl = document.getElementById('td' + i);
\r
35 var aHref = createElement('a');
\r
37 aHref.className = "expandLink";
\r
38 aHref.id = "expandLink" + i;
\r
39 aHref.onclick = new Function("return makeVisible("+i+")");
\r
40 aHref.tabIndex = el.tabIndex;
\r
41 aHref.title = editText;
\r
42 aHref.appendChild(document.createTextNode(editText));
\r
44 tdEl.appendChild(aHref);
\r
51 function setTemplateEditText(newText) {
\r
55 function makeVisible(i) {
\r
56 var textareaEl = document.getElementById('textarea' + i);
\r
57 var expandEl = document.getElementById('expandLink' + i);
\r
59 textareaEl.style.display = 'block';
\r
60 expandEl.style.display = 'none';
\r
66 window.onload = hideUnused;