2 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
3 * Copyright (C) 2002-2012 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 * compatibility.js is required.
16 var amountOfFields = 1;
17 var editText = 'empty field (click to edit)';
19 function hideUnused() {
20 while (document.getElementById('textarea' + amountOfFields))
24 for (var i=1;i<=amountOfFields;i++) {
25 var el = document.getElementById('textarea' + i);
27 // hide textareas when empty, and add onclick event
28 // to make them visible again
30 el.style.display = 'none';
31 var tdEl = document.getElementById('td' + i);
33 var aHref = createElement('a');
35 aHref.className = "expandLink";
36 aHref.id = "expandLink" + i;
37 aHref.onclick = new Function("return makeVisible("+i+")");
38 aHref.tabIndex = el.tabIndex;
39 aHref.title = editText;
40 aHref.appendChild(document.createTextNode(editText));
42 tdEl.appendChild(aHref);
49 function setTemplateEditText(newText) {
53 function makeVisible(i) {
54 var textareaEl = document.getElementById('textarea' + i);
55 var expandEl = document.getElementById('expandLink' + i);
57 textareaEl.style.display = 'block';
58 expandEl.style.display = 'none';
64 window.onload = hideUnused;