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
15 * $Id: templateEdit.js 1888 2012-06-17 08:38:54Z sakamocchi $
18 var amountOfFields = 1;
19 var editText = 'empty field (click to edit)';
21 function hideUnused() {
22 while (document.getElementById('textarea' + amountOfFields))
26 for (var i=1;i<=amountOfFields;i++) {
27 var el = document.getElementById('textarea' + i);
29 // hide textareas when empty, and add onclick event
30 // to make them visible again
32 el.style.display = 'none';
33 var tdEl = document.getElementById('td' + i);
35 var aHref = createElement('a');
37 aHref.className = "expandLink";
38 aHref.id = "expandLink" + i;
39 aHref.onclick = new Function("return makeVisible("+i+")");
40 aHref.tabIndex = el.tabIndex;
41 aHref.title = editText;
42 aHref.appendChild(document.createTextNode(editText));
44 tdEl.appendChild(aHref);
51 function setTemplateEditText(newText) {
55 function makeVisible(i) {
56 var textareaEl = document.getElementById('textarea' + i);
57 var expandEl = document.getElementById('expandLink' + i);
59 textareaEl.style.display = 'block';
60 expandEl.style.display = 'none';
66 window.onload = hideUnused;