OSDN Git Service

FIX:変数名の誤記を修正
[nucleus-jp/nucleus-next.git] / skins / admin / default / javascripts / templateEdit.js
1 /**
2   * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 
3   * Copyright (C) 2002-2009 The Nucleus Group
4   *
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)
10   *
11   *     Javascript code to hide empty textareas when editing templates.
12   *
13   * @require compatibility.js
14   *
15   * $Id: templateEdit.js 1888 2012-06-17 08:38:54Z sakamocchi $
16   */
17
18 var amountOfFields = 1;
19 var editText = 'empty field (click to edit)';
20
21 function hideUnused() {
22         while (document.getElementById('textarea' + amountOfFields)) 
23                 amountOfFields++;
24         amountOfFields--;
25
26         for (var i=1;i<=amountOfFields;i++) {
27                 var el = document.getElementById('textarea' + i);
28
29                 // hide textareas when empty, and add onclick event
30                 // to make them visible again
31                 if (el.value == '') {
32                         el.style.display = 'none';
33                         var tdEl = document.getElementById('td' + i);
34                         
35                         var aHref = createElement('a');
36                         aHref.href = '';
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));
43
44                         tdEl.appendChild(aHref);
45                         
46                 }
47         }
48
49 }
50
51 function setTemplateEditText(newText) {
52         editText = newText;
53 }
54
55 function makeVisible(i) {
56         var textareaEl = document.getElementById('textarea' + i);
57         var expandEl = document.getElementById('expandLink' + i);
58
59         textareaEl.style.display = 'block';
60         expandEl.style.display = 'none';
61
62         textareaEl.focus();
63         return false;
64 }
65
66 window.onload = hideUnused;