Better table button for nicEdit
parent
37f3ca2f3c
commit
ceb4c90723
52
nicEdit.js
52
nicEdit.js
|
@ -272,7 +272,7 @@ var nicEditorConfig = bkClass.extend({
|
||||||
},
|
},
|
||||||
iconsPath : '../nicEditorIcons.gif',
|
iconsPath : '../nicEditorIcons.gif',
|
||||||
buttonList : ['save','bold','italic','underline','strikethrough','left','center','right','justify','ol','ul','fontSize','fontFamily','fontFormat','image','upload','link','unlink','removeformat','forecolor','bgcolor','indent','outdent','subscript','superscript','xhtml','table'],
|
buttonList : ['save','bold','italic','underline','strikethrough','left','center','right','justify','ol','ul','fontSize','fontFamily','fontFormat','image','upload','link','unlink','removeformat','forecolor','bgcolor','indent','outdent','subscript','superscript','xhtml','table'],
|
||||||
iconList : {"xhtml":1,"bgcolor":2,"forecolor":3,"bold":4,"center":5,"hr":6,"indent":7,"italic":8,"justify":9,"left":10,"ol":11,"outdent":12,"removeformat":13,"right":14,"save":25,"strikethrough":16,"subscript":17,"superscript":18,"ul":19,"underline":20,"image":21,"link":22,"unlink":23,"close":24,"arrow":26,"upload":27}
|
iconList : {"xhtml":1,"bgcolor":2,"forecolor":3,"bold":4,"center":5,"hr":6,"indent":7,"italic":8,"justify":9,"left":10,"ol":11,"outdent":12,"removeformat":13,"right":14,"save":25,"strikethrough":16,"subscript":17,"superscript":18,"ul":19,"underline":20,"image":21,"link":22,"unlink":23,"close":24,"arrow":26,"upload":27,"table":28}
|
||||||
|
|
||||||
});
|
});
|
||||||
/* END CONFIG */
|
/* END CONFIG */
|
||||||
|
@ -1622,44 +1622,68 @@ var nicTableOptions = {
|
||||||
var nicTableButton = nicEditorAdvancedButton.extend({
|
var nicTableButton = nicEditorAdvancedButton.extend({
|
||||||
addPane : function() {
|
addPane : function() {
|
||||||
this.t = this.ne.selectedInstance.selElm().parentTag('TABLE');
|
this.t = this.ne.selectedInstance.selElm().parentTag('TABLE');
|
||||||
|
var r = 3, c = 3, h = '';
|
||||||
|
if (this.t && (r = this.t.rows.length)) {
|
||||||
|
c = this.t.rows[0].cells.length;
|
||||||
|
if (this.t.rows[0].cells[c-1].nodeName == 'TH') h += 'top';
|
||||||
|
if (this.t.rows[r-1].cells[0].nodeName == 'TH') h += 'left';
|
||||||
|
}
|
||||||
this.addForm({
|
this.addForm({
|
||||||
'' : {type : 'title', txt : __('Add/Edit Table')},
|
'': {type: 'title', txt: __('Add/Edit Table')},
|
||||||
'cols' : {type : 'text', txt : __('Columns'), 'value' : '3', style : {width: '50px'}},
|
'cols': {type: 'text', txt: __('Columns'), value: c, style: {width: '50px'}},
|
||||||
'rows' : {type : 'text', txt : __('Rows'), 'value' : '3', style : {width: '50px'}},
|
'rows': {type: 'text', txt: __('Rows'), value: r, style: {width: '50px'}},
|
||||||
|
'header': {type: 'select', txt: __('Headers'), value: h, options: {'':__('None'), left:__('Left'), top:__('Top'), topleft:__('Top and Left')}}
|
||||||
},this.t);
|
},this.t);
|
||||||
},
|
},
|
||||||
|
|
||||||
submit : function(e) {
|
submit : function(e) {
|
||||||
var r = parseInt(this.inputs['rows'].value);
|
var r = parseInt(this.inputs['rows'].value);
|
||||||
var c = parseInt(this.inputs['cols'].value);
|
var c = parseInt(this.inputs['cols'].value);
|
||||||
|
var i, j;
|
||||||
if(!this.t) {
|
if(!this.t) {
|
||||||
var tmp = 'javascript:nicImTemp();', h = '';
|
var tmp = 'javascript:nicImTemp();', h = '';
|
||||||
for (var i = 0; i < r; i++) {
|
for (i = 0; i < r; i++) {
|
||||||
h += '<tr>'+(new Array(c+1)).join('<td>-</td>')+'</tr>';
|
h += '<tr>'+(new Array(c+1)).join('<td>-</td>')+'</tr>';
|
||||||
}
|
}
|
||||||
this.ne.nicCommand("insertHTML", '<table title="'+tmp+'">'+h+'</table>');
|
this.ne.nicCommand("insertHTML", '<table title="'+tmp+'">'+h+'</table>');
|
||||||
this.t = this.findElm('TABLE','title',tmp);
|
this.t = this.findElm('TABLE','title',tmp);
|
||||||
}
|
}
|
||||||
if(this.t) {
|
if(this.t) {
|
||||||
this.t.setAttributes({
|
this.t.title = '';
|
||||||
title: ''
|
for (i = r; i < this.t.rows.length; i++) {
|
||||||
});
|
|
||||||
for (var i = r; i < this.t.rows.length; i++) {
|
|
||||||
this.t.deleteRow(r);
|
this.t.deleteRow(r);
|
||||||
}
|
}
|
||||||
for (var i = this.t.rows.length; i < r; i++) {
|
for (i = this.t.rows.length; i < r; i++) {
|
||||||
this.t.insertRow(i).innerHTML = (new Array(c+1)).join('<td>-</td>');
|
this.t.insertRow(i).innerHTML = (new Array(c+1)).join('<td>-</td>');
|
||||||
}
|
}
|
||||||
if (this.t.rows.length && this.t.rows[0].cells.length != c) {
|
if (this.t.rows.length && this.t.rows[0].cells.length != c) {
|
||||||
for (var i = 0; i < r; i++) {
|
for (i = 0; i < r; i++) {
|
||||||
for (var j = this.t.rows[i].cells.length; j < c; j++) {
|
for (j = this.t.rows[i].cells.length; j < c; j++) {
|
||||||
this.t.rows[i].insertCell(j).innerHTML = '-';
|
this.t.rows[i].insertCell(j).innerHTML = '-';
|
||||||
}
|
}
|
||||||
for (var j = this.t.rows[i].cells.length-1; j >= c; j--) {
|
for (j = this.t.rows[i].cells.length-1; j >= c; j--) {
|
||||||
this.t.rows[i].deleteCell(c);
|
$BK(this.t.rows[i].cells[c]).remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.t.rows.length) {
|
||||||
|
var ht = this.inputs['header'].value;
|
||||||
|
var repl = function(node, name) {
|
||||||
|
var nn = document.createElement(name ? 'th' : 'td');
|
||||||
|
nn.innerHTML = node.innerHTML;
|
||||||
|
node.parentNode.insertBefore(nn, node);
|
||||||
|
node.parentNode.removeChild(node);
|
||||||
|
};
|
||||||
|
repl(this.t.rows[0].cells[0], ht != 'none');
|
||||||
|
j = ht == 'top' || ht == 'topleft';
|
||||||
|
for (i = 1; i < c; i++) {
|
||||||
|
repl(this.t.rows[0].cells[i], j);
|
||||||
|
}
|
||||||
|
j = ht == 'left' || ht == 'topleft';
|
||||||
|
for (i = 1; i < r; i++) {
|
||||||
|
repl(this.t.rows[i].cells[0], j);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.8 KiB |
6
nicRu.js
6
nicRu.js
|
@ -78,7 +78,11 @@ var nicRu = {
|
||||||
'Add Table': 'Вставить таблицу',
|
'Add Table': 'Вставить таблицу',
|
||||||
'Add/Edit Table': 'Таблица',
|
'Add/Edit Table': 'Таблица',
|
||||||
'Columns': 'Колонки',
|
'Columns': 'Колонки',
|
||||||
'Rows': 'Строки'
|
'Rows': 'Строки',
|
||||||
|
'Headers': 'Заголовок',
|
||||||
|
'None': 'Нет',
|
||||||
|
'Top': 'Сверху',
|
||||||
|
'Top and Left': 'Сверху и слева'
|
||||||
};
|
};
|
||||||
|
|
||||||
function __(s) {
|
function __(s) {
|
||||||
|
|
Loading…
Reference in New Issue