1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
5 <title>openWYSIWYG | Create or Modify Table</title>
7 <style type="text/css">
9 font-family: arial, verdana, helvetica;
13 select, input, button {
18 background-color: #F7F7F7;
19 border: 2px solid #FFFFFF;
25 <script type="text/javascript" src="../scripts/wysiwyg-popup.js"></script>
26 <script type="text/javascript" src="../scripts/wysiwyg-color.js"></script>
28 <script type="text/javascript">
29 var n = WYSIWYG_Popup.getParam('wysiwyg');
31 // add stylesheet file
32 if(n) document.write('<link rel="stylesheet" type="text/css" href="../' + WYSIWYG.config[n].CSSFile +'">\n');
34 /* ---------------------------------------------------------------------- *\
35 Function : buildTable()
36 Description : Builds a table and inserts it into the WYSIWYG.
37 \* ---------------------------------------------------------------------- */
38 function buildTable() {
40 var WYSIWYG_Table = window.opener.WYSIWYG_Table;
41 var doc = WYSIWYG.getEditorWindow(n).document;
42 // create a table object
43 var table = doc.createElement("TABLE");
45 WYSIWYG_Core.setAttribute(table, "tmpcols", document.getElementById("cols").value);
46 WYSIWYG_Core.setAttribute(table, "tmprows", document.getElementById("rows").value);
48 if(document.getElementById("alignment").value != "")
49 WYSIWYG_Core.setAttribute(table, "align", document.getElementById("alignment").value);
54 style += "padding:" + document.getElementById("padding").value + "px;";
56 style += "width:" + document.getElementById("width").value + document.getElementById("widthType").value + ";";
58 style += "border:" + document.getElementById("border").value + "px;";
60 if(document.getElementById("borderstyle").value != "none")
61 style += "border-style:" + document.getElementById("borderstyle").value + ";";
63 if(document.getElementById("bordercolor").value != "none")
64 style += "border-color:" + document.getElementById("bordercolor").value + ";";
66 var collapse = document.getElementById("bordercollapse").checked ? "true" : "separate";
67 style += "border-collapse:" + collapse + ";";
69 if(document.getElementById("backgroundcolor").value != "none")
70 style += "background-color:" + document.getElementById("backgroundcolor").value + ";";
72 WYSIWYG_Core.setAttribute(table, "style", style);
75 WYSIWYG_Table.create(n, table);
79 // Checks if the table border will use the BORDER-COLLAPSE CSS attribute
81 if (document.getElementById('borderCollapse').checked == true) {
82 collapse = document.getElementById('borderCollapse').value;
85 collapse = "separate";
88 // Builds a table based on the data input into the form
89 var table = '<table border="0" cellpadding="0" cellspacing="0" style="';
90 table += 'BORDER-COLLAPSE: ' + collapse + ';';
91 table += ' border: ' + document.getElementById('borderWidth').value + ' ' + document.getElementById('borderStyle').value + ' ' + document.getElementById('borderColor').value + ';';
92 table += ' width: ' + document.getElementById('tableWidth').value + document.getElementById('widthType').value + ';';
93 table += ' background-color: ' + document.getElementById('shadingColor').value + ';"';
94 table += ' alignment="' + document.getElementById('alignment').value + '">\n';
96 // Creates the number of rows and cols the table will have
97 for (var i = 0; i < document.getElementById('rows').value; i++) {
99 for (var j = 0; j < document.getElementById('cols').value; j++) {
100 table += '<td style="border: ' + document.getElementById('borderWidth').value + ' ' + document.getElementById('borderStyle').value + ' ' + document.getElementById('borderColor').value + '; padding: ' + document.getElementById('padding').value + ';"> </td>\n';
104 table += '</table>\n';
107 // Inserts the table code into the WYSIWYG editor
108 WYSIWYG.insertHTML(table, n);
113 <body bgcolor="#EEEEEE" marginwidth="0" marginheight="0" topmargin="0" leftmargin="0" onload="WYSIWYG_ColorInst.init();">
115 <table border="0" cellpadding="0" cellspacing="0" style="width:100%;padding: 10px;">
118 <span style=" font-weight: bold;">Table Properties:</span>
120 <table style="width:100%;" border="0" cellpadding="1" cellspacing="0"
121 class="table-settings">
123 <td style="width: 20%;">
126 <td style="width: 25%;">
127 <input type="text" size="4" id="rows" name="rows" value="2" style="width: 50px;">
129 <td style="width: 25%;">
132 <td style="width: 30%;">
133 <input type="text" name="width" id="width" value="100" size="10" style="width: 50px;">
134 <select name="widthType" id="widthType"
135 style="margin-right: 10px; font-size: 10px;">
136 <option value="%">%</option>
137 <option value="px">px</option>
146 <input type="text" size="4" id="cols" name="cols" value="2" style="width: 50px;">
152 <select name="alignment" id="alignment" style="margin-right: 10px; width: 95px;">
153 <option value="">Not Set</option>
154 <option value="left">Left</option>
155 <option value="right">Right</option>
156 <option value="center">Center</option>
165 <input type="text" id="padding" name="padding" value="2" style="width: 50px;">
171 <table border="0" cellpadding="0" cellspacing="0">
174 <table border="0" cellpadding="0" cellspacing="0">
177 <input type="text" name="backgroundcolor" id="backgroundcolor" value="none" style="width:50px;">
183 <button style="margin-left: 2px;" onClick="WYSIWYG_ColorInst.choose('backgroundcolor');">
196 <input type="text" size="4" id="border" name="border" value="0" style="width: 50px;">
202 <table border="0" cellpadding="0" cellspacing="0">
205 <table border="0" cellpadding="0" cellspacing="0">
208 <input type="text" name="bordercolor" id="bordercolor" value="none" style="width:50px;">
214 <button style="margin-left: 2px;" onClick="WYSIWYG_ColorInst.choose('bordercolor');">
227 <select id="borderstyle" name="borderstyle" style="width: 80px;">
228 <option value="none">none</option>
229 <option value="solid">solid</option>
230 <option value="double">double</option>
231 <option value="dotted">dotted</option>
232 <option value="dashed">dashed</option>
233 <option value="groove">groove</option>
234 <option value="ridge">ridge</option>
235 <option value="inset">inset</option>
236 <option value="outset">outset</option>
243 <input type="checkbox" name="bordercollapse" id="bordercollapse">
251 <input type="submit" value=" Submit " onClick="buildTable();"
252 style="font-size: 12px;">
254 <input type="submit" value=" Cancel " onClick="window.close();"
255 style="font-size: 12px; margin-right: 15px;">