* Added "rtehtmlarea" as a system extension
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / htmlarea / popups / insert_table.html
1 <html class="popupwin">
2 <head>
3 <title>Insert Table</title>
4 <meta http-equiv="Content-Style-Type" content="text/css" />
5 <script type="text/javascript" src="popup.js"></script>
6 <script type="text/javascript">
7 HTMLArea = window.opener.HTMLArea;
8 _editor_CSS = window.opener._editor_CSS;
9 __dlg_loadStyle(_editor_CSS);
10 var i18n = window.opener.HTMLArea.I18N.dialogs;
11 var editor = window.opener.Dialog._arguments;
12
13 function Init() {
14 var content = document.getElementById("content");
15 buildTitle(i18n, content, "Insert Table");
16 var form = document.createElement("form");
17 form.action = "";
18 form.method = "get";
19 buildDimensionFieldset(i18n,form);
20 if (!editor.config.disableBordersFieldsetInTableOperations) buildBordersFieldset(i18n, form);
21 if (!editor.config.disableSpacingFieldsetInTableOperations) buildSpacingFieldset(i18n, form);
22 addButtons(i18n, form, ["ok","cancel"], ["OK","Cancel"]);
23 content.appendChild(form);
24 __dlg_init();
25 document.getElementById("f_rows").focus();
26 };
27 function onOK() {
28 var required = { "f_rows": "", "f_cols": "" };
29 required["f_rows"] = i18n["You must enter a number of rows"];
30 required["f_cols"] = i18n["You must enter a number of columns"];
31 for (var i in required) {
32 var el = document.getElementById(i);
33 if (!el.value) {
34 alert(required[i]);
35 el.focus();
36 return false;
37 }
38 }
39 var fields = ["f_rows", "f_cols", "f_width", "f_unit", "f_border", "f_spacing", "f_padding", "f_float"];
40 var param = new Object();
41 for (var i in fields) {
42 var id = fields[i];
43 var el = document.getElementById(id);
44 if(el) param[id] = el.value;
45 }
46 __dlg_close(param);
47 return false;
48 };
49 function onCancel() {
50 __dlg_close(null);
51 return false;
52 };
53 function buildTitle(i18n,content,title) {
54 var div = document.createElement("div");
55 div.className = "title";
56 div.innerHTML = i18n[title];
57 content.appendChild(div);
58 document.title = i18n[title];
59 };
60 function buildDimensionFieldset(i18n,content) {
61 var fieldset = document.createElement("fieldset");
62 insertLegend(i18n, fieldset, "Dimension");
63 buildInput(i18n, fieldset, "f_rows", ["Rows:"], ["Number of rows"], "5", "2");
64 buildInput(i18n, fieldset, "f_cols", ["Cols:"], ["Number of columns"], "5", "4");
65 if (!editor.config.disableLayoutFieldsetInTableOperations) {
66 buildInput(i18n, fieldset, "f_width", ["Width:"], ["Width of the table"], "5", "100");
67 buildUnitField(i18n, fieldset);
68 }
69 content.appendChild(fieldset);
70 };
71 function buildBordersFieldset(i18n,content) {
72 var fieldset = document.createElement("fieldset");
73 fieldset.className = "floating";
74 insertLegend(i18n, fieldset, "Border");
75 var ul = document.createElement("ul");
76 fieldset.appendChild(ul);
77 var li = document.createElement("li");
78 ul.appendChild(li);
79 buildInput(i18n, li, "f_border", ["Border thickness:"], ["Leave empty for no border"], "5", "1", "fl", "");
80 content.appendChild(fieldset);
81 };
82 function buildSpacingFieldset(i18n,content) {
83 var fieldset = document.createElement("fieldset");
84 insertLegend(i18n, fieldset, "Spacing and padding");
85 var ul = document.createElement("ul");
86 fieldset.appendChild(ul);
87 var li = document.createElement("li");
88 ul.appendChild(li);
89 buildInput(i18n, li, "f_spacing", ["Cell spacing:"], ["Space between adjacent cells"], "5", "1", "fr", "");
90 var li = document.createElement("li");
91 ul.appendChild(li);
92 buildInput(i18n, li, "f_padding", ["Cell padding:"], ["Space between content and border in cell"], "5", "1", "fr", "");
93 content.appendChild(fieldset);
94 };
95 function buildUnitField(i18n, fieldset) {
96 // Unit Select Box
97 var select = document.createElement("select");
98 select.id = "f_unit";
99 select.name = "f_unit";
100 select.title= i18n["Width unit"];
101 buildSelect(i18n, select, ["Percent", "Pixels", "Em"], ["%", "px", "em"], new RegExp("%", "i"));
102 fieldset.appendChild(select);
103 };
104 function buildTableFloatField(i18n, fieldset) {
105 // Table Float Label
106 var label = document.createElement("label");
107 label.className = "fl";
108 label.innerHTML = i18n["Float:"];
109 label.htmlFor = "f_float";
110 fieldset.appendChild(label);
111 // Table Float Select Box
112 var select = document.createElement("select");
113 select.id = "f_float";
114 select.name = "f_float";
115 select.title= i18n["Where the table should float"];
116 buildSelect(i18n, select, ["Not set", "Non-floating", "Left", "Right"], ["not set", "none", "left", "right"], new RegExp("not set", "i"));
117 fieldset.appendChild(select);
118 };
119 function insertLegend(i18n, fieldset,legend) {
120 var legendNode = document.createElement("legend");
121 legendNode.innerHTML = i18n[legend];
122 fieldset.appendChild(legendNode);
123 };
124 function buildInput(i18n, fieldset,fieldName,fieldLabel,fieldTitle, fieldSize, fieldValue, labelClass, inputClass) {
125 // Field label
126 var label = document.createElement("label");
127 if(labelClass) label.className = labelClass;
128 label.innerHTML = i18n[fieldLabel];
129 label.htmlFor = fieldName;
130 fieldset.appendChild(label);
131 // Input field
132 var input = document.createElement("input");
133 input.type = "text";
134 input.id = fieldName;
135 input.name = fieldName;
136 if(inputClass) input.className = inputClass;
137 input.title = i18n[fieldTitle];
138 input.size = fieldSize;
139 input.value = fieldValue;
140 fieldset.appendChild(input);
141 };
142 function buildSelect(i18n, select,options,values,selected) {
143 var option;
144 for (var i = 0; i < options.length; ++i) {
145 option = document.createElement("option");
146 option.value = values[i];
147 option.innerHTML = i18n[options[i]];
148 option.selected = selected.test(option.value);
149 select.appendChild(option);
150 }
151 };
152 function addButtons(i18n,content,buttons,labels) {
153 var space = document.createElement("div");
154 space.className = "space";
155 content.appendChild(space);
156 var div = document.createElement("div");
157 content.appendChild(div);
158 div.className = "buttons";
159 for (var i = 0; i < buttons.length; ++i) {
160 var button = document.createElement("button");
161 button.innerHTML = i18n[labels[i]];
162 switch (buttons[i]) {
163 case "ok":
164 button.onclick = onOK;
165 break;
166 case "cancel":
167 button.onclick = onCancel;
168 break;
169 }
170 div.appendChild(button);
171 }
172 };
173 </script>
174 </head>
175 <body class="popupwin" onload="Init();">
176 <div id="content"></div>
177 </body>
178 </html>