* task #8234, bug #3565, fix stripedRows setting of table not work in kindeditor, see http://pms.zentao.net/bug-view-3565.html
This commit is contained in:
@@ -318,6 +318,7 @@
|
||||
'.text-align', '.color', '.background-color', '.font-size', '.font-family', '.font-weight',
|
||||
'.font-style', '.text-decoration', '.vertical-align', '.background', '.border'
|
||||
],
|
||||
tr: ['id', 'class', '.background-color'],
|
||||
a: ['id', 'class', 'href', 'target', 'name'],
|
||||
embed: ['id', 'class', 'src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
|
||||
audio: ['id', 'class', 'width', 'src', 'height', 'loop', 'preload', 'autoplay', 'controls', 'crossorigin', 'currentTime', 'duration', 'muted'],
|
||||
@@ -330,7 +331,7 @@
|
||||
],
|
||||
pre: ['id', 'class'],
|
||||
hr: ['id', 'class', '.page-break-after'],
|
||||
'br,tbody,tr,strong,b,sub,sup,em,i,u,strike,s,del': ['id', 'class'],
|
||||
'br,tbody,strong,b,sub,sup,em,i,u,strike,s,del': ['id', 'class'],
|
||||
iframe: ['id', 'class', 'src', 'frameborder', 'width', 'height', '.width', '.height']
|
||||
},
|
||||
layout: '<div class="container ke-loading"><div class="toolbar"></div><div class="edit"></div><div class="statusbar"></div></div>'
|
||||
@@ -1042,6 +1043,8 @@
|
||||
'<', mediaType, ' '
|
||||
];
|
||||
var srcs = (attrs.src || '').split(',');
|
||||
var autoPlayEnabled;
|
||||
var mutedSetted;
|
||||
_each(attrs, function(key, val) {
|
||||
if (key === 'src' || val === false) {
|
||||
return;
|
||||
@@ -1049,11 +1052,16 @@
|
||||
if (val === true || /^(controls|autoplay|loop|muted)$/i.test(key)) {
|
||||
if (val !== 'false') {
|
||||
htmls.push(key + ' ');
|
||||
if (key === 'autoplay') autoPlayEnabled = true;
|
||||
else if (key === 'muted') mutedSetted = true;
|
||||
}
|
||||
} else {
|
||||
htmls.push(key, '="', val, '" ');
|
||||
}
|
||||
});
|
||||
if (autoPlayEnabled && !mutedSetted) {
|
||||
htmls.push('muted ');
|
||||
}
|
||||
if (srcs.length > 1) {
|
||||
htmls.push('>');
|
||||
_each(srcs, function(_, val) {
|
||||
@@ -1063,7 +1071,7 @@
|
||||
htmls.push('</', mediaType, '>');
|
||||
} else {
|
||||
if(srcs.length) htmls.push('src="', srcs[0], '" ');
|
||||
htmls.push('/>');
|
||||
htmls.push('></', mediaType, '>');
|
||||
}
|
||||
} else {
|
||||
htmls = ['<embed '];
|
||||
@@ -8229,7 +8237,7 @@ KindEditor.plugin('media', function(K) {
|
||||
'<input type="text" id="keHeight" class="ke-input-text ke-input-number" name="height" value="400" maxlength="4" />',
|
||||
'</div>',
|
||||
//controls
|
||||
'<div class="ke-dialog-row">',
|
||||
'<div class="ke-dialog-row hidden">',
|
||||
'<label for="keControls">' + lang.controls + '</label>',
|
||||
'<input type="checkbox" id="keControls" checked name="controls" value="true" /> ',
|
||||
'</div>',
|
||||
@@ -8243,7 +8251,7 @@ KindEditor.plugin('media', function(K) {
|
||||
var dialog = self.createDialog({
|
||||
name: name,
|
||||
width: 450,
|
||||
height: 270,
|
||||
height: 240,
|
||||
title: self.lang(name),
|
||||
body: html,
|
||||
yesBtn: {
|
||||
@@ -8284,8 +8292,8 @@ KindEditor.plugin('media', function(K) {
|
||||
viewServerBtn = K('[name="viewServer"]', div),
|
||||
widthBox = K('[name="width"]', div),
|
||||
heightBox = K('[name="height"]', div),
|
||||
controlsBox = K('[name="controls"]', div),
|
||||
autostartBox = K('[name="autostart"]', div);
|
||||
controlsBox = K('[name="controls"]', div);
|
||||
urlBox.val('http://');
|
||||
|
||||
if(allowMediaUpload) {
|
||||
@@ -10593,28 +10601,36 @@ KindEditor.plugin('table', function (K) {
|
||||
});
|
||||
}
|
||||
|
||||
function getTableSetting($table, setting)
|
||||
{
|
||||
if (!$table) {
|
||||
var table = self.plugin.getSelectedTable();
|
||||
$table = $(table[0]);
|
||||
}
|
||||
var setting = $.extend({
|
||||
borderColor: defaultTableBorderColor
|
||||
}, $table.data('tableSetting'), setting);
|
||||
if (setting.autoWidth === undefined) {
|
||||
setting.autoWidth = $table[0].style.width === 'auto';
|
||||
}
|
||||
if (setting.stripedRows === undefined) {
|
||||
var $rows = $table.find('tbody>tr');
|
||||
var coloredRowsLength = $rows.filter(function () {
|
||||
return !!this.style.backgroundColor;
|
||||
}).length;
|
||||
setting.stripedRows = coloredRowsLength >= Math.floor($rows.length / 2);
|
||||
}
|
||||
return setting;
|
||||
}
|
||||
|
||||
function updateTable(setting, $table, onUpdateSetting) {
|
||||
if (!$table) {
|
||||
var table = self.plugin.getSelectedTable();
|
||||
$table = $(table[0]);
|
||||
}
|
||||
if (!$table || !$table.length) return;
|
||||
if (!setting) {
|
||||
setting = $.extend({
|
||||
borderColor: defaultTableBorderColor
|
||||
}, self.tableSetting, setting);
|
||||
if (setting.autoWidth === undefined) {
|
||||
setting.autoWidth = $table[0].style.width === 'auto';
|
||||
}
|
||||
if (setting.stripedRows === undefined) {
|
||||
var $rows = $table.find('tbody>tr');
|
||||
var coloredRowsLength = $rows.filter(function () {
|
||||
return !!this.style.backgroundColor;
|
||||
}).length;
|
||||
setting.stripedRows = coloredRowsLength >= Math.floor($rows / 2);
|
||||
}
|
||||
}
|
||||
self.tableSetting = setting;
|
||||
setting = getTableSetting($table, setting);
|
||||
$table.data('tableSetting', setting);
|
||||
if (setting.header !== undefined) {
|
||||
if ($table.is('.ke-plugin-table-example')) {
|
||||
$table.find('thead').toggleClass('hidden', !setting.header);
|
||||
@@ -10646,7 +10662,7 @@ KindEditor.plugin('table', function (K) {
|
||||
if (setting.stripedRows !== undefined) {
|
||||
var $rows = $table.find('tbody>tr');
|
||||
$rows.each(function (index) {
|
||||
$(this).css('background-color', (setting.stripedRows && (index % 2 === 0)) ? '#f9f9f9' : 'none');
|
||||
$(this).css('background-color', (setting.stripedRows && (index % 2 === 0)) ? '#f9f9f9' : '');
|
||||
});
|
||||
onUpdateSetting && onUpdateSetting('stripedRows', setting.stripedRows);
|
||||
}
|
||||
@@ -10785,7 +10801,7 @@ KindEditor.plugin('table', function (K) {
|
||||
updateTable({ borderColor: color }, $exampleTable);
|
||||
});
|
||||
|
||||
updateTable(self.tableSetting, $exampleTable, function (name, value) {
|
||||
updateTable(getTableSetting($table), $exampleTable, function (name, value) {
|
||||
switch (name) {
|
||||
case 'borderColor':
|
||||
_setColor(colorBox, value || defaultTableBorderColor);
|
||||
@@ -11026,6 +11042,7 @@ KindEditor.plugin('table', function (K) {
|
||||
row = self.plugin.getSelectedRow()[0],
|
||||
cell = self.plugin.getSelectedCell()[0],
|
||||
index = cell.cellIndex + offset;
|
||||
var tableSetting = getTableSetting($(table));
|
||||
// 取得第一行的index
|
||||
index += table.rows[0].cells.length - row.cells.length;
|
||||
|
||||
@@ -11033,7 +11050,7 @@ KindEditor.plugin('table', function (K) {
|
||||
var newRow = table.rows[i],
|
||||
newCell = newRow.insertCell(index),
|
||||
isThead = newRow.parentNode.tagName === 'THEAD';
|
||||
newCell.outerHTML = '<' + (isThead ? 'th' : 'td') + (newCell.rowSpan > 1 ? ' rowspan="' + newCell.rowSpan + '"' : '') + (newCell.colSpan > 1 ? ' colspan="' + newCell.colSpan + '"' : '') + ' style="' + (isThead ? 'background-color: #f1f1f1;' : '') + 'border: 1px solid ' + ((self.tableSetting && self.tableSetting.borderColor) || defaultTableBorderColor) + '">' + (K.IE ? ' ' : '<br />') + '</' + (isThead ? 'th' : 'td') + '>';
|
||||
newCell.outerHTML = '<' + (isThead ? 'th' : 'td') + (newCell.rowSpan > 1 ? ' rowspan="' + newCell.rowSpan + '"' : '') + (newCell.colSpan > 1 ? ' colspan="' + newCell.colSpan + '"' : '') + ' style="' + (isThead ? 'background-color: #f1f1f1;' : '') + 'border: 1px solid ' + ((tableSetting && tableSetting.borderColor) || defaultTableBorderColor) + '">' + (K.IE ? ' ' : '<br />') + '</' + (isThead ? 'th' : 'td') + '>';
|
||||
newCell = newRow.cells[index];
|
||||
// 调整下一行的单元格index
|
||||
index = _getCellIndex(table, newRow, newCell);
|
||||
@@ -11054,6 +11071,7 @@ KindEditor.plugin('table', function (K) {
|
||||
row = self.plugin.getSelectedRow()[0],
|
||||
cell = self.plugin.getSelectedCell()[0],
|
||||
firstRow = table.rows[0];
|
||||
var tableSetting = getTableSetting($(table));
|
||||
var rowIndex = row.rowIndex;
|
||||
if (offset === 1) {
|
||||
rowIndex = row.rowIndex + (cell.rowSpan - 1) + offset;
|
||||
@@ -11072,7 +11090,7 @@ KindEditor.plugin('table', function (K) {
|
||||
// if (offset === 1 && currentCell.colSpan > 1) {
|
||||
// newCell.colSpan = currentCell.colSpan;
|
||||
// }
|
||||
newCell.outerHTML = '<' + (isThead ? 'th' : 'td') + (newCell.rowSpan > 1 ? ' rowspan="' + newCell.rowSpan + '"' : '') + (newCell.colSpan > 1 ? ' colspan="' + newCell.colSpan + '"' : '') + ' style="' + (isThead ? 'background-color: #f1f1f1;' : '') + 'border: 1px solid ' + ((self.tableSetting && self.tableSetting.borderColor) || defaultTableBorderColor) + '">' + (K.IE ? ' ' : '<br />') + '</' + (isThead ? 'th' : 'td') + '>';
|
||||
newCell.outerHTML = '<' + (isThead ? 'th' : 'td') + (newCell.rowSpan > 1 ? ' rowspan="' + newCell.rowSpan + '"' : '') + (newCell.colSpan > 1 ? ' colspan="' + newCell.colSpan + '"' : '') + ' style="' + (isThead ? 'background-color: #f1f1f1;' : '') + 'border: 1px solid ' + ((tableSetting && tableSetting.borderColor) || defaultTableBorderColor) + '">' + (K.IE ? ' ' : '<br />') + '</' + (isThead ? 'th' : 'td') + '>';
|
||||
}
|
||||
// 调整rowspan
|
||||
for (var j = rowIndex; j >= 0; j--) {
|
||||
@@ -11086,6 +11104,7 @@ KindEditor.plugin('table', function (K) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
updateTable(null, $(table));
|
||||
self.cmd.range.selectNodeContents(cell).collapse(true);
|
||||
// self.cmd.select();
|
||||
self.addBookmark();
|
||||
@@ -11142,6 +11161,9 @@ KindEditor.plugin('table', function (K) {
|
||||
}
|
||||
cell.colSpan += nextCell.colSpan;
|
||||
row.deleteCell(nextCellIndex);
|
||||
|
||||
updateTable(null, $(table));
|
||||
|
||||
self.cmd.range.selectNodeContents(cell).collapse(true);
|
||||
// self.cmd.select();
|
||||
self.addBookmark();
|
||||
@@ -11174,6 +11196,7 @@ KindEditor.plugin('table', function (K) {
|
||||
colspan: right - left + 1,
|
||||
});
|
||||
$table.find('.ke-cell-removed').remove();
|
||||
updateTable(null, $table);
|
||||
self.cmd.range.selectNodeContents($firstCell[0]).collapse(true);
|
||||
// self.cmd.select();
|
||||
self.addBookmark();
|
||||
@@ -11185,6 +11208,7 @@ KindEditor.plugin('table', function (K) {
|
||||
row = self.plugin.getSelectedRow()[0],
|
||||
cell = self.plugin.getSelectedCell()[0],
|
||||
rowIndex = row.rowIndex;
|
||||
var tableSetting = getTableSetting($(table));
|
||||
// 不是可分割单元格
|
||||
if (cell.rowSpan === 1) {
|
||||
return;
|
||||
@@ -11195,7 +11219,7 @@ KindEditor.plugin('table', function (K) {
|
||||
newCell = newRow.insertCell(cellIndex);
|
||||
var isThead = newRow.parentNode.tagName === 'THEAD';
|
||||
var colSpan = cell.colSpan > 1 ? cell.colSpan : newCell.colSpan;
|
||||
newCell.outerHTML = '<' + (isThead ? 'th' : 'td') + (newCell.rowSpan > 1 ? ' rowspan="' + newCell.rowSpan + '"' : '') + (colSpan > 1 ? ' colspan="' + colSpan + '"' : '') + ' style="' + (isThead ? 'background-color: #f1f1f1;' : '') + 'border: 1px solid ' + ((self.tableSetting && self.tableSetting.borderColor) || defaultTableBorderColor) + '">' + (K.IE ? ' ' : '<br />') + '</' + (isThead ? 'th' : 'td') + '>';
|
||||
newCell.outerHTML = '<' + (isThead ? 'th' : 'td') + (newCell.rowSpan > 1 ? ' rowspan="' + newCell.rowSpan + '"' : '') + (colSpan > 1 ? ' colspan="' + colSpan + '"' : '') + ' style="' + (isThead ? 'background-color: #f1f1f1;' : '') + 'border: 1px solid ' + ((tableSetting && tableSetting.borderColor) || defaultTableBorderColor) + '">' + (K.IE ? ' ' : '<br />') + '</' + (isThead ? 'th' : 'td') + '>';
|
||||
if (cell.colSpan > 1) {
|
||||
newCell.colSpan = cell.colSpan;
|
||||
}
|
||||
@@ -11203,6 +11227,7 @@ KindEditor.plugin('table', function (K) {
|
||||
cellIndex = _getCellIndex(table, newRow, newCell);
|
||||
}
|
||||
K(cell).removeAttr('rowSpan');
|
||||
updateTable(null, $(table));
|
||||
self.cmd.range.selectNodeContents(cell).collapse(true);
|
||||
// self.cmd.select();
|
||||
self.addBookmark();
|
||||
@@ -11213,6 +11238,7 @@ KindEditor.plugin('table', function (K) {
|
||||
row = self.plugin.getSelectedRow()[0],
|
||||
cell = self.plugin.getSelectedCell()[0],
|
||||
cellIndex = cell.cellIndex;
|
||||
var tableSetting = getTableSetting($(table));
|
||||
// 不是可分割单元格
|
||||
if (cell.colSpan === 1) {
|
||||
return;
|
||||
@@ -11222,9 +11248,10 @@ KindEditor.plugin('table', function (K) {
|
||||
var newCell = row.insertCell(cellIndex + i);
|
||||
var rowSpan = cell.rowSpan > 1 ? cell.rowSpan : newCell.rowSpan;
|
||||
var colSpan = newCell.colSpan;
|
||||
newCell.outerHTML = '<' + (isThead ? 'th' : 'td') + (rowSpan > 1 ? ' rowspan="' + rowSpan + '"' : '') + (colSpan > 1 ? ' colspan="' + colSpan + '"' : '') + ' style="' + (isThead ? 'background-color: #f1f1f1;' : '') + 'border: 1px solid ' + ((self.tableSetting && self.tableSetting.borderColor) || defaultTableBorderColor) + '">' + (K.IE ? ' ' : '<br />') + '</' + (isThead ? 'th' : 'td') + '>';
|
||||
newCell.outerHTML = '<' + (isThead ? 'th' : 'td') + (rowSpan > 1 ? ' rowspan="' + rowSpan + '"' : '') + (colSpan > 1 ? ' colspan="' + colSpan + '"' : '') + ' style="' + (isThead ? 'background-color: #f1f1f1;' : '') + 'border: 1px solid ' + ((tableSetting && tableSetting.borderColor) || defaultTableBorderColor) + '">' + (K.IE ? ' ' : '<br />') + '</' + (isThead ? 'th' : 'td') + '>';
|
||||
}
|
||||
K(cell).removeAttr('colSpan');
|
||||
updateTable(null, $(table));
|
||||
self.cmd.range.selectNodeContents(cell).collapse(true);
|
||||
// self.cmd.select();
|
||||
self.addBookmark();
|
||||
@@ -11287,6 +11314,7 @@ KindEditor.plugin('table', function (K) {
|
||||
// self.cmd.select();
|
||||
K(table).remove();
|
||||
} else {
|
||||
updateTable(null, $(table));
|
||||
self.cmd.selection(true);
|
||||
}
|
||||
self.addBookmark();
|
||||
|
||||
Vendored
+7
-7
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user