Skip to content

Commit

Permalink
MDL-50304 atto/plugins/table: Fixed _addRowAfter function
Browse files Browse the repository at this point in the history
  • Loading branch information
jinhofer committed May 28, 2015
1 parent 0c6faf4 commit aa65ece
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit aa65ece

Please sign in to comment.