📄 script.js.php
字号:
else tTable.removeAttribute('height',0); tTable.style.height = (ntProps.height)?ntProps.height:''; if (ntProps.border) tTable.border = ntProps.border; else tTable.removeAttribute('border',0); if (ntProps.cellPadding) tTable.cellPadding = ntProps.cellPadding; else tTable.removeAttribute('cellpadding',0); if (ntProps.cellSpacing) tTable.cellSpacing = ntProps.cellSpacing; else tTable.removeAttribute('cellspacing',0); if (ntProps.bgColor) tTable.bgColor = ntProps.bgColor; else tTable.removeAttribute('bgcolor',0); if (ntProps.background) tTable.background = ntProps.background; else tTable.removeAttribute('background',0); if (ntProps.className) tTable.className = ntProps.className; else tTable.removeAttribute('className',0); SPAW_toggle_borders(editor, tTable, null); } SPAW_update_toolbar(editor, true); //SPAW_updateField(editor,""); } // edits table cell properties function SPAW_table_cell_prop_click(editor, sender) { var cd = SPAW_getTD(editor); // current cell if (cd) { var cProps = {}; cProps.width = (cd.style.width)?cd.style.width:cd.width; cProps.height = (cd.style.height)?cd.style.height:cd.height; cProps.bgColor = cd.bgColor; cProps.background = cd.background; cProps.align = cd.align; cProps.vAlign = cd.vAlign; cProps.className = cd.className; cProps.noWrap = cd.noWrap; cProps.styleOptions = new Array(); if (document.all['SPAW_'+editor+'_tb_style'] != null) { cProps.styleOptions = document.all['SPAW_'+editor+'_tb_style'].options; } var ncProps = showModalDialog('<?php echo $spaw_dir?>dialogs/td.php?lang=' + document.all['SPAW_'+editor+'_lang'].value + '&theme=' + document.all['SPAW_'+editor+'_theme'].value+'&request_uri='+escape(window.location.href), cProps, 'dialogHeight:220px; dialogWidth:366px; resizable:no; status:no'); if (ncProps) { if (ncProps.align) cd.align = ncProps.align; else cd.removeAttribute('align',0); if (ncProps.vAlign) cd.vAlign = ncProps.vAlign; else cd.removeAttribute('valign',0); if (ncProps.width) cd.width = ncProps.width; else cd.removeAttribute('width',0); cd.style.width = (ncProps.width)?ncProps.width:''; if (ncProps.height) cd.height = ncProps.height; else cd.removeAttribute('height',0); cd.style.height = (ncProps.height)?ncProps.height:''; if (ncProps.bgColor) cd.bgColor = ncProps.bgColor; else cd.removeAttribute('bgcolor',0); if (ncProps.background) cd.background = ncProps.background; else cd.removeAttribute('background',0); if (ncProps.className) cd.className = ncProps.className; else cd.removeAttribute('className',0); if (ncProps.noWrap) cd.noWrap = ncProps.noWrap; else cd.removeAttribute('nowrap',0); } } SPAW_update_toolbar(editor, true); //SPAW_updateField(editor,""); } // returns current table cell function SPAW_getTD(editor) { if (window.frames[editor+'_rEdit'].document.selection.type != "Control") { var tControl = window.frames[editor+'_rEdit'].document.selection.createRange(); tControl = tControl.parentElement(); while ((tControl.tagName != 'TD') && (tControl.tagName != 'TH') && (tControl.tagName != 'TABLE') && (tControl.tagName != 'BODY')) { tControl = tControl.parentElement; } if ((tControl.tagName == 'TD') || (tControl.tagName == 'TH')) return(tControl); else return(null); } else { return(null); } } // returns current table row function SPAW_getTR(editor) { if (window.frames[editor+'_rEdit'].document.selection.type != "Control") { var tControl = window.frames[editor+'_rEdit'].document.selection.createRange(); tControl = tControl.parentElement(); while ((tControl.tagName != 'TR') && (tControl.tagName != 'TABLE') && (tControl.tagName != 'BODY')) { tControl = tControl.parentElement; } if (tControl.tagName == 'TR') return(tControl); else return(null); } else { return(null); } } // returns current table function SPAW_getTable(editor) { if (window.frames[editor+'_rEdit'].document.selection.type == "Control") { var tControl = window.frames[editor+'_rEdit'].document.selection.createRange(); if (tControl(0).tagName == 'TABLE') return(tControl(0)); else return(null); } else { var tControl = window.frames[editor+'_rEdit'].document.selection.createRange(); tControl = tControl.parentElement(); while ((tControl.tagName != 'TABLE') && (tControl.tagName != 'BODY')) { tControl = tControl.parentElement; } if (tControl.tagName == 'TABLE') return(tControl); else return(null); } } // returns selected image function SPAW_getImg(editor) { if (window.frames[editor+'_rEdit'].document.selection.type == "Control") { var tControl = window.frames[editor+'_rEdit'].document.selection.createRange(); if (tControl(0).tagName == 'IMG') return(tControl(0)); else return(null); } else { return(null); } } function SPAW_table_row_insert_click(editor, sender) { var ct = SPAW_getTable(editor); // current table var cr = SPAW_getTR(editor); // current row if (ct && cr) { var newr = ct.insertRow(cr.rowIndex+1); for (var i=0; i<cr.cells.length; i++) { if (cr.cells(i).rowSpan > 1) { // increase rowspan cr.cells(i).rowSpan++; } else { var newc = cr.cells(i).cloneNode(); newr.appendChild(newc); } } // increase rowspan for cells that were spanning through current row for (var i=0; i<cr.rowIndex; i++) { var tempr = ct.rows(i); for (var j=0; j<tempr.cells.length; j++) { if (tempr.cells(j).rowSpan > (cr.rowIndex - i)) tempr.cells(j).rowSpan++; } } } SPAW_update_toolbar(editor, true); } // insertRow function SPAW_formCellMatrix(ct) { var tm = new Array(); for (var i=0; i<ct.rows.length; i++) tm[i]=new Array(); for (var i=0; i<ct.rows.length; i++) { jr=0; for (var j=0; j<ct.rows(i).cells.length;j++) { while (tm[i][jr] != undefined) jr++; for (var jh=jr; jh<jr+(ct.rows(i).cells(j).colSpan?ct.rows(i).cells(j).colSpan:1);jh++) { for (var jv=i; jv<i+(ct.rows(i).cells(j).rowSpan?ct.rows(i).cells(j).rowSpan:1);jv++) { if (jv==i) { tm[jv][jh]=ct.rows(i).cells(j).cellIndex; } else { tm[jv][jh]=-1; } } } } } return(tm); } function SPAW_table_column_insert_click(editor, sender) { var ct = SPAW_getTable(editor); // current table var cr = SPAW_getTR(editor); // current row var cd = SPAW_getTD(editor); // current row if (cd && cr && ct) { // get "real" cell position and form cell matrix var tm = SPAW_formCellMatrix(ct); for (var j=0; j<tm[cr.rowIndex].length; j++) { if (tm[cr.rowIndex][j] == cd.cellIndex) { realIndex=j; break; } } // insert column based on real cell matrix for (var i=0; i<ct.rows.length; i++) { if (tm[i][realIndex] != -1) { if (ct.rows(i).cells(tm[i][realIndex]).colSpan > 1) { ct.rows(i).cells(tm[i][realIndex]).colSpan++; } else { var newc = ct.rows(i).insertCell(tm[i][realIndex]+1) var nc = ct.rows(i).cells(tm[i][realIndex]).cloneNode(); newc.replaceNode(nc); } } } } SPAW_update_toolbar(editor, true); } // insertColumn function SPAW_table_cell_merge_right_click(editor, sender) { var ct = SPAW_getTable(editor); // current table var cr = SPAW_getTR(editor); // current row var cd = SPAW_getTD(editor); // current row if (cd && cr && ct) { // get "real" cell position and form cell matrix var tm = SPAW_formCellMatrix(ct); for (var j=0; j<tm[cr.rowIndex].length; j++) { if (tm[cr.rowIndex][j] == cd.cellIndex) { realIndex=j; break; } } if (cd.cellIndex+1<cr.cells.length) { ccrs = cd.rowSpan?cd.rowSpan:1; cccs = cd.colSpan?cd.colSpan:1; ncrs = cr.cells(cd.cellIndex+1).rowSpan?cr.cells(cd.cellIndex+1).rowSpan:1; nccs = cr.cells(cd.cellIndex+1).colSpan?cr.cells(cd.cellIndex+1).colSpan:1; // check if theres nothing between these 2 cells j=realIndex; while(tm[cr.rowIndex][j] == cd.cellIndex) j++; if (tm[cr.rowIndex][j] == cd.cellIndex+1) { // proceed only if current and next cell rowspans are equal if (ccrs == ncrs) { // increase colspan of current cell and append content of the next cell to current cd.colSpan = cccs+nccs; cd.innerHTML += cr.cells(cd.cellIndex+1).innerHTML; cr.deleteCell(cd.cellIndex+1); } } } } SPAW_update_toolbar(editor, true); } // mergeRight function SPAW_table_cell_merge_down_click(editor, sender) { var ct = SPAW_getTable(editor); // current table var cr = SPAW_getTR(editor); // current row var cd = SPAW_getTD(editor); // current row if (cd && cr && ct) { // get "real" cell position and form cell matrix var tm = SPAW_formCellMatrix(ct); for (var j=0; j<tm[cr.rowIndex].length; j++) { if (tm[cr.rowIndex][j] == cd.cellIndex) { crealIndex=j; break; } } ccrs = cd.rowSpan?cd.rowSpan:1; cccs = cd.colSpan?cd.colSpan:1; if (cr.rowIndex+ccrs<ct.rows.length) { ncellIndex = tm[cr.rowIndex+ccrs][crealIndex]; if (ncellIndex != -1 && (crealIndex==0 || (crealIndex>0 && (tm[cr.rowIndex+ccrs][crealIndex-1]!=tm[cr.rowIndex+ccrs][crealIndex])))) { ncrs = ct.rows(cr.rowIndex+ccrs).cells(ncellIndex).rowSpan?ct.rows(cr.rowIndex+ccrs).cells(ncellIndex).rowSpan:1; nccs = ct.rows(cr.rowIndex+ccrs).cells(ncellIndex).colSpan?ct.rows(cr.rowIndex+ccrs).cells(ncellIndex).colSpan:1; // proceed only if current and next cell colspans are equal if (cccs == nccs) { // increase rowspan of current cell and append content of the next cell to current cd.innerHTML += ct.rows(cr.rowIndex+ccrs).cells(ncellIndex).innerHTML; ct.rows(cr.rowIndex+ccrs).deleteCell(ncellIndex); cd.rowSpan = ccrs+ncrs; } } } } SPAW_update_toolbar(editor, true); } // mergeDown function SPAW_table_row_delete_click(editor, sender) { var ct = SPAW_getTable(editor); // current table var cr = SPAW_getTR(editor); // current row var cd = SPAW_getTD(editor); // current cell if (cd && cr && ct) { // if there's only one row just remove the table if (ct.rows.length<=1) { ct.removeNode(true); } else { // get "real" cell position and form cell matrix var tm = SPAW_formCellMatrix(ct); // decrease rowspan for cells that were spanning through current row for (var i=0; i<cr.rowIndex; i++) { var tempr = ct.rows(i); for (var j=0; j<tempr.cells.length; j++) { if (tempr.cells(j).rowSpan > (cr.rowIndex - i))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -