diff --git a/IPython/html/static/notebook/js/cell.js b/IPython/html/static/notebook/js/cell.js index ffe72cc..67f4eb4 100644 --- a/IPython/html/static/notebook/js/cell.js +++ b/IPython/html/static/notebook/js/cell.js @@ -230,6 +230,34 @@ var IPython = (function (IPython) { }; /** + * @method at_top + * @return {Boolean} + */ + Cell.prototype.at_top = function () { + var cm = this.code_mirror + var cursor = cm.getCursor(); + if (cursor.line === 0 && cm.findPosV(cursor, -1, 'line').hitSide) { + console.log('at top'); + return true; + } else { + return false; + } + }; + + /** + * @method at_bottom + * @return {Boolean} + * */ + Cell.prototype.at_bottom = function () { + var cm = this.code_mirror + var cursor = cm.getCursor(); + if (cursor.line === (cm.lineCount()-1) && cm.findPosV(cursor, 1, 'line').hitSide) { + return true; + } else { + return false; + } + }; + /** * enter the command mode for the cell * @method command_mode * @return is the action being taken diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index 3ef98ff..44541ec 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -501,26 +501,6 @@ var IPython = (function (IPython) { }; - CodeCell.prototype.at_top = function () { - var cursor = this.code_mirror.getCursor(); - if (cursor.line === 0 && cursor.ch === 0) { - return true; - } else { - return false; - } - }; - - - CodeCell.prototype.at_bottom = function () { - var cursor = this.code_mirror.getCursor(); - if (cursor.line === (this.code_mirror.lineCount()-1) && cursor.ch === this.code_mirror.getLine(cursor.line).length) { - return true; - } else { - return false; - } - }; - - CodeCell.prototype.clear_output = function (wait) { this.output_area.clear_output(wait); this.set_input_prompt(); diff --git a/IPython/html/static/notebook/js/textcell.js b/IPython/html/static/notebook/js/textcell.js index 038dee4..db69d2d 100644 --- a/IPython/html/static/notebook/js/textcell.js +++ b/IPython/html/static/notebook/js/textcell.js @@ -242,40 +242,6 @@ var IPython = (function (IPython) { this.element.find('div.text_cell_render').html(text); }; - /** - * @method at_top - * @return {Boolean} - */ - TextCell.prototype.at_top = function () { - if (this.rendered) { - return true; - } else { - var cursor = this.code_mirror.getCursor(); - if (cursor.line === 0 && cm.findPosV(cm.getCursor(), -1, 'line', cm.charCoords(cm.getCursor(),'div').left).hitSide) { - console.log('at top'); - return true; - } else { - return false; - } - } - }; - - /** - * @method at_bottom - * @return {Boolean} - * */ - TextCell.prototype.at_bottom = function () { - if (this.rendered) { - return true; - } else { - var cursor = this.code_mirror.getCursor(); - if (cursor.line === (this.code_mirror.lineCount()-1) && cursor.ch === this.code_mirror.getLine(cursor.line).length) { - return true; - } else { - return false; - } - } - }; /** * Create Text cell from JSON