mirror of
https://github.com/moodle/moodle.git
synced 2025-04-17 22:45:54 +02:00
MDL-50304 atto/plugins/table: Fixed _addRowAfter function
This commit is contained in:
parent
0c6faf4b51
commit
aa65ecea98
@ -950,13 +950,11 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
* @private
|
||||
*/
|
||||
_addRowAfter: function() {
|
||||
var rowindex = this._getRowIndex(this._lastTarget);
|
||||
|
||||
var tablebody = this._lastTarget.ancestor('table').one('tbody');
|
||||
var target = this._lastTarget.ancestor('tr'),
|
||||
tablebody = this._lastTarget.ancestor('table').one('tbody');
|
||||
if (!tablebody) {
|
||||
// Not all tables have tbody.
|
||||
tablebody = this._lastTarget.ancestor('table');
|
||||
rowindex += 1;
|
||||
}
|
||||
|
||||
var firstrow = tablebody.one('tr');
|
||||
@ -979,7 +977,12 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
tablecell.setHTML(' ');
|
||||
});
|
||||
|
||||
tablebody.insert(newrow, rowindex);
|
||||
if (target.ancestor('thead')) {
|
||||
target = firstrow;
|
||||
tablebody.insert(newrow, target);
|
||||
} else {
|
||||
target.insert(newrow, 'after');
|
||||
}
|
||||
|
||||
// Clean the HTML.
|
||||
this.markUpdated();
|
||||
|
File diff suppressed because one or more lines are too long
@ -950,13 +950,11 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
* @private
|
||||
*/
|
||||
_addRowAfter: function() {
|
||||
var rowindex = this._getRowIndex(this._lastTarget);
|
||||
|
||||
var tablebody = this._lastTarget.ancestor('table').one('tbody');
|
||||
var target = this._lastTarget.ancestor('tr'),
|
||||
tablebody = this._lastTarget.ancestor('table').one('tbody');
|
||||
if (!tablebody) {
|
||||
// Not all tables have tbody.
|
||||
tablebody = this._lastTarget.ancestor('table');
|
||||
rowindex += 1;
|
||||
}
|
||||
|
||||
var firstrow = tablebody.one('tr');
|
||||
@ -979,7 +977,12 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
tablecell.setHTML(' ');
|
||||
});
|
||||
|
||||
tablebody.insert(newrow, rowindex);
|
||||
if (target.ancestor('thead')) {
|
||||
target = firstrow;
|
||||
tablebody.insert(newrow, target);
|
||||
} else {
|
||||
target.insert(newrow, 'after');
|
||||
}
|
||||
|
||||
// Clean the HTML.
|
||||
this.markUpdated();
|
||||
|
@ -948,13 +948,11 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
* @private
|
||||
*/
|
||||
_addRowAfter: function() {
|
||||
var rowindex = this._getRowIndex(this._lastTarget);
|
||||
|
||||
var tablebody = this._lastTarget.ancestor('table').one('tbody');
|
||||
var target = this._lastTarget.ancestor('tr'),
|
||||
tablebody = this._lastTarget.ancestor('table').one('tbody');
|
||||
if (!tablebody) {
|
||||
// Not all tables have tbody.
|
||||
tablebody = this._lastTarget.ancestor('table');
|
||||
rowindex += 1;
|
||||
}
|
||||
|
||||
var firstrow = tablebody.one('tr');
|
||||
@ -977,7 +975,12 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
tablecell.setHTML(' ');
|
||||
});
|
||||
|
||||
tablebody.insert(newrow, rowindex);
|
||||
if (target.ancestor('thead')) {
|
||||
target = firstrow;
|
||||
tablebody.insert(newrow, target);
|
||||
} else {
|
||||
target.insert(newrow, 'after');
|
||||
}
|
||||
|
||||
// Clean the HTML.
|
||||
this.markUpdated();
|
||||
|
Loading…
x
Reference in New Issue
Block a user