test: 1
This commit is contained in:
BIN
public/UEditorPlus/dialogs/table/dragicon.png
Normal file
BIN
public/UEditorPlus/dialogs/table/dragicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 304 B |
85
public/UEditorPlus/dialogs/table/edittable.css
Normal file
85
public/UEditorPlus/dialogs/table/edittable.css
Normal file
@ -0,0 +1,85 @@
|
||||
body {
|
||||
overflow: hidden;
|
||||
width: 540px;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
margin: 10px auto 0;
|
||||
font-size: 12px;
|
||||
overflow: hidden;
|
||||
width: 520px;
|
||||
height: 315px;
|
||||
}
|
||||
|
||||
.clear {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.wrapper .left {
|
||||
float: left;
|
||||
margin-left: 10px;;
|
||||
}
|
||||
|
||||
.wrapper .right {
|
||||
float: right;
|
||||
border-left: 2px dotted #EDEDED;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-bottom: 15px;
|
||||
width: 240px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.section h3 {
|
||||
font-weight: bold;
|
||||
padding: 5px 0;
|
||||
margin-bottom: 10px;
|
||||
border-bottom: 1px solid #EDEDED;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.section ul {
|
||||
list-style: none;
|
||||
overflow: hidden;
|
||||
clear: both;
|
||||
|
||||
}
|
||||
|
||||
.section li {
|
||||
float: left;
|
||||
width: 120px;;
|
||||
}
|
||||
|
||||
.section .tone {
|
||||
width: 80px;;
|
||||
}
|
||||
|
||||
.section .preview {
|
||||
width: 220px;
|
||||
}
|
||||
|
||||
.section .preview table {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.section .preview caption {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.section .preview td {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
.section .preview th {
|
||||
border-style: solid;
|
||||
border-color: #DDD;
|
||||
border-width: 2px 1px 1px 1px;
|
||||
height: 22px;
|
||||
background-color: #F7F7F7;
|
||||
}
|
69
public/UEditorPlus/dialogs/table/edittable.html
Normal file
69
public/UEditorPlus/dialogs/table/edittable.html
Normal file
@ -0,0 +1,69 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<script type="text/javascript" src="../internal.js?aea0c61c"></script>
|
||||
<link rel="stylesheet" type="text/css" href="edittable.css?effbbe30">
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<div class="left">
|
||||
<div class="section">
|
||||
<h3><var id="lang_tableStyle"></var></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<label onselectstart="return false"><input type="checkbox" id="J_title" name="style"/><var
|
||||
id="lang_insertTitle"></var></label>
|
||||
</li>
|
||||
<li>
|
||||
<label onselectstart="return false"><input type="checkbox" id="J_titleCol" name="style"/><var
|
||||
id="lang_insertTitleCol"></var></label>
|
||||
</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>
|
||||
<label onselectstart="return false"><input type="checkbox" id="J_caption" name="style"/><var
|
||||
id="lang_insertCaption"></var></label>
|
||||
</li>
|
||||
<li>
|
||||
<label onselectstart="return false"><input type="checkbox" id="J_sorttable" name="style"/><var
|
||||
id="lang_orderbycontent"></var></label>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h3><var id="lang_tableSize"></var></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<label><input type="radio" id="J_autoSizeContent" name="size"/><var id="lang_autoSizeContent"></var></label>
|
||||
</li>
|
||||
<li>
|
||||
<label><input type="radio" id="J_autoSizePage" name="size"/><var
|
||||
id="lang_autoSizePage"></var></label>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h3><var id="lang_borderStyle"></var></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<span><var id="lang_color"></var></span>
|
||||
<input type="text" class="tone" id="J_tone" readonly='readonly'/>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right">
|
||||
<div class="section">
|
||||
<h3><var id="lang_example"></var></h3>
|
||||
<div class="preview" id="J_preview">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="edittable.js?6b7a0dd4"></script>
|
||||
</body>
|
||||
</html>
|
241
public/UEditorPlus/dialogs/table/edittable.js
Normal file
241
public/UEditorPlus/dialogs/table/edittable.js
Normal file
@ -0,0 +1,241 @@
|
||||
/**
|
||||
* Created with JetBrains PhpStorm.
|
||||
* User: xuheng
|
||||
* Date: 12-12-19
|
||||
* Time: 下午4:55
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
(function () {
|
||||
var title = $G("J_title"),
|
||||
titleCol = $G("J_titleCol"),
|
||||
caption = $G("J_caption"),
|
||||
sorttable = $G("J_sorttable"),
|
||||
autoSizeContent = $G("J_autoSizeContent"),
|
||||
autoSizePage = $G("J_autoSizePage"),
|
||||
tone = $G("J_tone"),
|
||||
me,
|
||||
preview = $G("J_preview");
|
||||
|
||||
var editTable = function () {
|
||||
me = this;
|
||||
me.init();
|
||||
};
|
||||
editTable.prototype = {
|
||||
init: function () {
|
||||
var colorPiker = new UE.ui.ColorPicker({
|
||||
editor: editor
|
||||
}),
|
||||
colorPop = new UE.ui.Popup({
|
||||
editor: editor,
|
||||
content: colorPiker
|
||||
});
|
||||
|
||||
title.checked = editor.queryCommandState("inserttitle") == -1;
|
||||
titleCol.checked = editor.queryCommandState("inserttitlecol") == -1;
|
||||
caption.checked = editor.queryCommandState("insertcaption") == -1;
|
||||
sorttable.checked = editor.queryCommandState("enablesort") == 1;
|
||||
|
||||
var enablesortState = editor.queryCommandState("enablesort"),
|
||||
disablesortState = editor.queryCommandState("disablesort");
|
||||
|
||||
sorttable.checked = !!(enablesortState < 0 && disablesortState >= 0);
|
||||
sorttable.disabled = !!(enablesortState < 0 && disablesortState < 0);
|
||||
sorttable.title = enablesortState < 0 && disablesortState < 0 ? lang.errorMsg : '';
|
||||
|
||||
me.createTable(title.checked, titleCol.checked, caption.checked);
|
||||
me.setAutoSize();
|
||||
me.setColor(me.getColor());
|
||||
|
||||
domUtils.on(title, "click", me.titleHanler);
|
||||
domUtils.on(titleCol, "click", me.titleColHanler);
|
||||
domUtils.on(caption, "click", me.captionHanler);
|
||||
domUtils.on(sorttable, "click", me.sorttableHanler);
|
||||
domUtils.on(autoSizeContent, "click", me.autoSizeContentHanler);
|
||||
domUtils.on(autoSizePage, "click", me.autoSizePageHanler);
|
||||
|
||||
domUtils.on(tone, "click", function () {
|
||||
colorPop.showAnchor(tone);
|
||||
});
|
||||
domUtils.on(document, 'mousedown', function () {
|
||||
colorPop.hide();
|
||||
});
|
||||
colorPiker.addListener("pickcolor", function () {
|
||||
me.setColor(arguments[1]);
|
||||
colorPop.hide();
|
||||
});
|
||||
colorPiker.addListener("picknocolor", function () {
|
||||
me.setColor("");
|
||||
colorPop.hide();
|
||||
});
|
||||
},
|
||||
|
||||
createTable: function (hasTitle, hasTitleCol, hasCaption) {
|
||||
var arr = [],
|
||||
sortSpan = '<span>^</span>';
|
||||
arr.push("<table id='J_example'>");
|
||||
if (hasCaption) {
|
||||
arr.push("<caption>" + lang.captionName + "</caption>")
|
||||
}
|
||||
if (hasTitle) {
|
||||
arr.push("<tr>");
|
||||
if (hasTitleCol) {
|
||||
arr.push("<th>" + lang.titleName + "</th>");
|
||||
}
|
||||
for (var j = 0; j < 5; j++) {
|
||||
arr.push("<th>" + lang.titleName + "</th>");
|
||||
}
|
||||
arr.push("</tr>");
|
||||
}
|
||||
for (var i = 0; i < 6; i++) {
|
||||
arr.push("<tr>");
|
||||
if (hasTitleCol) {
|
||||
arr.push("<th>" + lang.titleName + "</th>")
|
||||
}
|
||||
for (var k = 0; k < 5; k++) {
|
||||
arr.push("<td>" + lang.cellsName + "</td>")
|
||||
}
|
||||
arr.push("</tr>");
|
||||
}
|
||||
arr.push("</table>");
|
||||
preview.innerHTML = arr.join("");
|
||||
this.updateSortSpan();
|
||||
},
|
||||
titleHanler: function () {
|
||||
var example = $G("J_example"),
|
||||
frg = document.createDocumentFragment(),
|
||||
color = domUtils.getComputedStyle(domUtils.getElementsByTagName(example, "td")[0], "border-color"),
|
||||
colCount = example.rows[0].children.length;
|
||||
|
||||
if (title.checked) {
|
||||
example.insertRow(0);
|
||||
for (var i = 0, node; i < colCount; i++) {
|
||||
node = document.createElement("th");
|
||||
node.innerHTML = lang.titleName;
|
||||
frg.appendChild(node);
|
||||
}
|
||||
example.rows[0].appendChild(frg);
|
||||
|
||||
} else {
|
||||
domUtils.remove(example.rows[0]);
|
||||
}
|
||||
me.setColor(color);
|
||||
me.updateSortSpan();
|
||||
},
|
||||
titleColHanler: function () {
|
||||
var example = $G("J_example"),
|
||||
color = domUtils.getComputedStyle(domUtils.getElementsByTagName(example, "td")[0], "border-color"),
|
||||
colArr = example.rows,
|
||||
colCount = colArr.length;
|
||||
|
||||
if (titleCol.checked) {
|
||||
for (var i = 0, node; i < colCount; i++) {
|
||||
node = document.createElement("th");
|
||||
node.innerHTML = lang.titleName;
|
||||
colArr[i].insertBefore(node, colArr[i].children[0]);
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < colCount; i++) {
|
||||
domUtils.remove(colArr[i].children[0]);
|
||||
}
|
||||
}
|
||||
me.setColor(color);
|
||||
me.updateSortSpan();
|
||||
},
|
||||
captionHanler: function () {
|
||||
var example = $G("J_example");
|
||||
if (caption.checked) {
|
||||
var row = document.createElement('caption');
|
||||
row.innerHTML = lang.captionName;
|
||||
example.insertBefore(row, example.firstChild);
|
||||
} else {
|
||||
domUtils.remove(domUtils.getElementsByTagName(example, 'caption')[0]);
|
||||
}
|
||||
},
|
||||
sorttableHanler: function () {
|
||||
me.updateSortSpan();
|
||||
},
|
||||
autoSizeContentHanler: function () {
|
||||
var example = $G("J_example");
|
||||
example.removeAttribute("width");
|
||||
},
|
||||
autoSizePageHanler: function () {
|
||||
var example = $G("J_example");
|
||||
var tds = example.getElementsByTagName(example, "td");
|
||||
utils.each(tds, function (td) {
|
||||
td.removeAttribute("width");
|
||||
});
|
||||
example.setAttribute('width', '100%');
|
||||
},
|
||||
updateSortSpan: function () {
|
||||
var example = $G("J_example"),
|
||||
row = example.rows[0];
|
||||
|
||||
var spans = domUtils.getElementsByTagName(example, "span");
|
||||
utils.each(spans, function (span) {
|
||||
span.parentNode.removeChild(span);
|
||||
});
|
||||
if (sorttable.checked) {
|
||||
utils.each(row.cells, function (cell, i) {
|
||||
var span = document.createElement("span");
|
||||
span.innerHTML = "^";
|
||||
cell.appendChild(span);
|
||||
});
|
||||
}
|
||||
},
|
||||
getColor: function () {
|
||||
var start = editor.selection.getStart(), color,
|
||||
cell = domUtils.findParentByTagName(start, ["td", "th", "caption"], true);
|
||||
color = cell && domUtils.getComputedStyle(cell, "border-color");
|
||||
if (!color) color = "#DDDDDD";
|
||||
return color;
|
||||
},
|
||||
setColor: function (color) {
|
||||
var example = $G("J_example"),
|
||||
arr = domUtils.getElementsByTagName(example, "td").concat(
|
||||
domUtils.getElementsByTagName(example, "th"),
|
||||
domUtils.getElementsByTagName(example, "caption")
|
||||
);
|
||||
|
||||
tone.value = color;
|
||||
utils.each(arr, function (node) {
|
||||
node.style.borderColor = color;
|
||||
});
|
||||
|
||||
},
|
||||
setAutoSize: function () {
|
||||
var me = this;
|
||||
autoSizePage.checked = true;
|
||||
me.autoSizePageHanler();
|
||||
}
|
||||
};
|
||||
|
||||
new editTable;
|
||||
|
||||
dialog.onok = function () {
|
||||
editor.__hasEnterExecCommand = true;
|
||||
|
||||
var checks = {
|
||||
title: "inserttitle deletetitle",
|
||||
titleCol: "inserttitlecol deletetitlecol",
|
||||
caption: "insertcaption deletecaption",
|
||||
sorttable: "enablesort disablesort"
|
||||
};
|
||||
editor.fireEvent('saveScene');
|
||||
for (var i in checks) {
|
||||
var cmds = checks[i].split(" "),
|
||||
input = $G("J_" + i);
|
||||
if (input["checked"]) {
|
||||
editor.queryCommandState(cmds[0]) != -1 && editor.execCommand(cmds[0]);
|
||||
} else {
|
||||
editor.queryCommandState(cmds[1]) != -1 && editor.execCommand(cmds[1]);
|
||||
}
|
||||
}
|
||||
|
||||
editor.execCommand("edittable", tone.value);
|
||||
autoSizeContent.checked ? editor.execCommand('adaptbytext') : "";
|
||||
autoSizePage.checked ? editor.execCommand("adaptbywindow") : "";
|
||||
editor.fireEvent('saveScene');
|
||||
|
||||
editor.__hasEnterExecCommand = false;
|
||||
};
|
||||
})();
|
62
public/UEditorPlus/dialogs/table/edittd.html
Normal file
62
public/UEditorPlus/dialogs/table/edittd.html
Normal file
@ -0,0 +1,62 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<script type="text/javascript" src="../internal.js?aea0c61c"></script>
|
||||
<style type="text/css">
|
||||
.section {
|
||||
text-align: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.section input {
|
||||
margin-left: 5px;
|
||||
width: 70px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="section">
|
||||
<span><var id="lang_tdBkColor"></var></span>
|
||||
<input type="text" id="J_tone"/>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var tone = $G("J_tone"),
|
||||
colorPiker = new UE.ui.ColorPicker({
|
||||
editor: editor
|
||||
}),
|
||||
colorPop = new UE.ui.Popup({
|
||||
editor: editor,
|
||||
content: colorPiker
|
||||
});
|
||||
domUtils.on(tone, "click", function () {
|
||||
colorPop.showAnchor(tone);
|
||||
});
|
||||
domUtils.on(document, 'mousedown', function () {
|
||||
colorPop.hide();
|
||||
});
|
||||
colorPiker.addListener("pickcolor", function () {
|
||||
tone.value = arguments[1];
|
||||
colorPop.hide();
|
||||
});
|
||||
colorPiker.addListener("picknocolor", function () {
|
||||
tone.value = "";
|
||||
colorPop.hide();
|
||||
});
|
||||
dialog.onok = function () {
|
||||
editor.execCommand("edittd", tone.value);
|
||||
};
|
||||
|
||||
var start = editor.selection.getStart(),
|
||||
cell = start && domUtils.findParentByTagName(start, ["td", "th"], true);
|
||||
if (cell) {
|
||||
var color = domUtils.getComputedStyle(cell, 'background-color');
|
||||
if (/^#/.test(color)) {
|
||||
tone.value = color
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
33
public/UEditorPlus/dialogs/table/edittip.html
Normal file
33
public/UEditorPlus/dialogs/table/edittip.html
Normal file
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>表格删除提示</title>
|
||||
<script type="text/javascript" src="../internal.js?aea0c61c"></script>
|
||||
<style type="text/css">
|
||||
.section {
|
||||
width: 200px;
|
||||
margin: 10px auto 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.item {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="section">
|
||||
<div class="item">
|
||||
<label><input type="radio" id="J_delRow" name="cmd" checked/><var id="lang_delRow"></var></label>
|
||||
</div>
|
||||
<div class="item">
|
||||
<label><input type="radio" id="J_delCol" name="cmd"/><var id="lang_delCol"></var></label>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
dialog.onok = function () {
|
||||
$G("J_delRow").checked ? editor.execCommand("deleterow") : editor.execCommand("deletecol");
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user