tijian_tieying/web/Web/UEditor/dialogs/table/table.html

253 lines
11 KiB
HTML
Raw Permalink Normal View History

2025-02-20 12:14:39 +08:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><EFBFBD><EFBFBD><EFBFBD><EFBFBD></title>
<meta http-equiv="Content-Type" content="text/html;charset=gbk"/>
<style type="text/css">
*{margin: 0;padding: 0;font-size: 12px;}
.wrapper{margin-left: 2px;}
.base{width: 472px;height: 70px; margin-left: 10px;margin-top:10px;border: 1px solid #ddd;}
legend{margin-left: 5px; font-weight: bold;font-size: 12px;color: #0066cc;}
fieldset table{margin-left: 5px;float: left;}
select{width: 50px}
.base table{margin-left: 10px;}
.base table tr{height: 25px;}
input{ width: 50px;border:1px solid #ccc;}
.extend {width: 300px;height: 160px;margin:10px;;float: left;border: 1px solid #ddd;}
.extend table{height: 135px;}
#preview{width: 160px;height: 155px;float: left;border: 1px solid #ccc;margin: 16px 0;background-color: #eee}
span.bold{font-weight: bold}
#preview table {margin:3px 5px;}
#preview table td{width: 30px;height: 20px;}
#message{float: left;width: 110px;margin-left: 10px;font-size: 10px;color: red;line-height: 15px}
#messageContent{color: green;margin-top: 5px;}
.extend select{width: 90px}
#bgColor{width: 85px;}
</style>
</head>
<body>
<div class="wrapper">
<fieldset class="base">
<legend><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ</legend>
<table>
<tr>
<td width="120"><label for="numRows"><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: </label><input id="numRows" type="text" /> <20><></td>
<td>
<label for="width"><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: </label><input id="width" type="text" />
<label for="widthUnit"><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ: </label>
<select id="widthUnit">
<option value="%">%</option>
<option value="px">px</option>
</select>
</td>
</tr>
<tr>
<td><label for="numCols"><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: </label><input id="numCols" type="text" /> <20><></td>
<td>
<label for="height"><EFBFBD>߶<EFBFBD>: </label><input id="height" type="text" />
<label for="heightUnit"><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ: </label>
<select id="heightUnit">
<option value="%">%</option>
<option value="px">px</option>
</select>
</td>
</tr>
</table>
<div id="message" style="display: none">
<p><EFBFBD><EFBFBD>ܰ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD></p>
<p id="messageContent"><EFBFBD>߾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><EFBFBD><EFBFBD>13px<EFBFBD><EFBFBD></p>
</div>
</fieldset>
<div>
<fieldset class="extend">
<legend><EFBFBD><EFBFBD>չ<EFBFBD><EFBFBD>Ϣ<span style="font-weight: normal;">(<28><>Ԥ<EFBFBD><D4A4>)</span></legend>
<table>
<tr>
<td width="60"><span class="bold"><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߿<EFBFBD></span>:</td>
<td><label for="border"><EFBFBD><EFBFBD>С: </label><input id="border" type="text" /> px&nbsp;</td>
<td><label for="borderColor"><EFBFBD><EFBFBD>ɫ: </label><input id="borderColor" type="text" /></td>
</tr>
<tr style="border-bottom: 1px solid #ddd">
<td><span class="bold"><EFBFBD>߾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></span>:</td>
<td><label for="cellPadding"><EFBFBD>߾<EFBFBD>: </label><input id="cellPadding" type="text" /> px&nbsp;</td>
<td><label for="cellSpacing"><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: </label><input id="cellSpacing" type="text" /> px </td>
</tr>
<tr>
<td colspan="3"><span class="bold"><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ</span>:
<input id="bgColor" type="text" />
</td>
</tr>
<tr>
<td colspan="3"><span class="bold"><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD>ʽ</span>:
<select id="align">
<option value="">Ĭ<EFBFBD><EFBFBD></option>
<option value="center"><EFBFBD><EFBFBD><EFBFBD><EFBFBD></option>
<option value="left"><EFBFBD><EFBFBD><EFBFBD><EFBFBD></option>
<option value="right"><EFBFBD><EFBFBD><EFBFBD><EFBFBD></option>
</select>
</td>
</tr>
<tr>
<td colspan="3">
<span class="bold"><EFBFBD>߿<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></span>:
<select id="borderType">
<option value="0"><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></option>
<option value="1"><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>Ԫ<EFBFBD><EFBFBD></option>
</select>
</td>
</tr>
</table>
</fieldset>
<div id="preview">
<table border="1" borderColor="#000" cellpadding="0" cellspacing="0" style="border-collapse: collapse;">
<tr><td><EFBFBD><EFBFBD></td><td><EFBFBD><EFBFBD></td><td><EFBFBD><EFBFBD></td></tr>
<tr><td><EFBFBD><EFBFBD></td><td>Ԥ</td><td><EFBFBD><EFBFBD></td></tr>
<tr><td><EFBFBD><EFBFBD></td><td></td><td></td></tr>
</table>
</div>
</div>
</div>
<script type="text/javascript" src="../internal.js"></script>
<script type="text/javascript" src="table.js"></script>
<script type="text/javascript">
var inputs = document.getElementsByTagName('input'),
selects=document.getElementsByTagName('select');
//ie<69><65><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ
for(var i=0,ci;ci=inputs[i++];){
switch (ci.id){
case 'numRows':
case 'numCols':
ci.value = 5;
break;
case 'bgColor':
ci.value = '#FFFFFF';
break;
case 'borderColor':
ci.value = '#000000';
break;
case 'border':
ci.value = 1;
break;
case 'cellSpacing':
case 'cellPadding':
ci.value = '0';
break;
default:
}
}
for(var i=0,ci;ci=selects[i++];){
ci.options[0].selected = true;
}
var state = editor.queryCommandState("edittable");
if(state == 0){
var range = editor.selection.getRange(),
table = domUtils.findParentByTagName(range.startContainer,'table',true);
if(table){
var numRows = table.rows.length,cellCount=0;
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(var i=0,ri;ri=table.rows[i++];){
var tmpCellCount = 0;
for(var j=0,cj;cj=ri.cells[j++];){
if(cj.style.display != 'none'){
tmpCellCount++;
}
}
cellCount = Math.max(tmpCellCount,cellCount)
}
domUtils.setAttributes($G('numRows'),{
'value':numRows,
'disabled':true
});
domUtils.setAttributes($G('numCols'),{
'value':cellCount,
'disabled':true
});
$G("cellPadding").value = table.getAttribute("cellPadding") || '0';
$G("cellSpacing").value = table.getAttribute("cellSpacing") || '0';
var value = table.getAttribute('width');
value = !value ? ['',table.offsetWidth]:/%$/.test(value) ? value.match(/(\d+)(%)?/) : ['',value.replace(/px/i,'')];
$G("width").value = value[1];
$G('widthUnit').options[value[2] ? 0:1].selected = true;
value = table.getAttribute('height');
value = !value ? ['','']:/%$/.test(value) ? value.match(/(\d+)(%)?/) : ['',value.replace(/px/i,'')];
$G("height").value = value[1];
$G('heightUnit').options[value[2]?0:1].selected = true;
$G('borderColor').value = (table.getAttribute('borderColor')||"#000000").toUpperCase();
$G("border").value = table.getAttribute("border");
for(var i=0,ip,opts= $G("align").options;ip=opts[i++];){
if(ip.value == table.getAttribute('align')){
ip.selected = true;
break;
}
}
$G("borderType").options[table.getAttribute('borderType') == '1' ? 1: 0].selected = true;
$G("bgColor").value = (table.getAttribute("bgColor")||"#FFFFFF").toUpperCase();
createTable();
}
}else{
$focus($G("numRows"));
}
init();
domUtils.on($G("width"),"keyup",function(){
var value = this.value;
if(value>100){
$G("widthUnit").value="px";
}
});
domUtils.on($G("height"),"keyup",function(){
var value = this.value;
if(value>100){
$G("heightUnit").value="px";
}
});
dialog.onok = function(){
for(var i=0,opt={},ci;ci=inputs[i++];){
switch (ci.id){
case 'numRows':
case 'numCols':
case 'height':
case 'width':
if(ci.value && !/^[1-9]+[0-9]*$/.test(ci.value)){
alert("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>");
$focus(ci);
return false;
}
break;
case 'cellspacing':
case 'cellpadding':
case 'border':
if(ci.value && !/^[0-9]*$/.test(ci.value)){
alert("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>");
$focus(ci);
return false;
}
break;
case 'bgColor':
case 'borderColor':
if(ci.value && !/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(ci.value)){
alert("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>ɫֵ");
$focus(ci);
return false;
}
break;
default:
}
opt[ci.id] = ci.value || (ci.id == 'border' ? 0 : '')
}
for(var i=0,ci;ci=selects[i++];){
opt[ci.id] = ci.value.toUpperCase()
}
editor.execCommand(state == -1 ? 'inserttable' : 'edittable',opt );
};
</script>
</body>
</html>