beautify_js
This commit is contained in:
parent
0febe4f5fd
commit
5c2f32e184
208 changed files with 3891 additions and 1474 deletions
|
@ -1,4 +1,3 @@
|
|||
|
||||
var table = document.getElementById('bagua-table');
|
||||
|
||||
var editingTd;
|
||||
|
@ -7,22 +6,22 @@ table.onclick = function(event) {
|
|||
|
||||
var target = event.target;
|
||||
|
||||
while(target != table) {
|
||||
while (target != table) {
|
||||
if (target.className == 'edit-cancel') {
|
||||
finishTdEdit(editingTd.elem, false);
|
||||
return;
|
||||
finishTdEdit(editingTd.elem, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.className == 'edit-ok') {
|
||||
finishTdEdit(editingTd.elem, true);
|
||||
return;
|
||||
finishTdEdit(editingTd.elem, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.nodeName == 'TD') {
|
||||
if (editingTd) return; // already editing
|
||||
|
||||
makeTdEditable(target);
|
||||
return;
|
||||
makeTdEditable(target);
|
||||
return;
|
||||
}
|
||||
|
||||
target = target.parentNode;
|
||||
|
@ -30,15 +29,15 @@ table.onclick = function(event) {
|
|||
}
|
||||
|
||||
function makeTdEditable(td) {
|
||||
editingTd = {
|
||||
elem: td,
|
||||
data: td.innerHTML
|
||||
editingTd = {
|
||||
elem: td,
|
||||
data: td.innerHTML
|
||||
};
|
||||
|
||||
td.classList.add('edit-td'); // td, not textarea! the rest of rules will cascade
|
||||
|
||||
var textArea = document.createElement('textarea');
|
||||
textArea.style.width = td.clientWidth + 'px';
|
||||
textArea.style.width = td.clientWidth + 'px';
|
||||
textArea.style.height = td.clientHeight + 'px';
|
||||
textArea.className = 'edit-area';
|
||||
|
||||
|
@ -47,7 +46,7 @@ function makeTdEditable(td) {
|
|||
td.appendChild(textArea);
|
||||
textArea.focus();
|
||||
|
||||
td.insertAdjacentHTML("beforeEnd",
|
||||
td.insertAdjacentHTML("beforeEnd",
|
||||
'<div class="edit-controls"><button class="edit-ok">OK</button><button class="edit-cancel">CANCEL</button></div>'
|
||||
);
|
||||
}
|
||||
|
@ -60,5 +59,4 @@ function finishTdEdit(td, isOk) {
|
|||
}
|
||||
td.classList.remove('edit-td'); // remove edit class
|
||||
editingTd = null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
var table = document.getElementById('bagua-table');
|
||||
|
||||
/* ваш код */
|
Loading…
Add table
Add a link
Reference in a new issue