From 5631528017747941ca8152d1d112dc611989b197 2013-04-25 21:18:21 From: MinRK Date: 2013-04-25 21:18:21 Subject: [PATCH] cleanup stdin event submission follow example in rename notebook: remove form, bind keydown for enter, avoiding shift-enter submitting the cell again. --- diff --git a/IPython/frontend/html/notebook/static/js/outputarea.js b/IPython/frontend/html/notebook/static/js/outputarea.js index 18c8c8f..4329391 100644 --- a/IPython/frontend/html/notebook/static/js/outputarea.js +++ b/IPython/frontend/html/notebook/static/js/outputarea.js @@ -74,7 +74,6 @@ var IPython = (function (IPython) { OutputArea.prototype.bind_events = function () { var that = this; - this._submit_raw_input_proxy = $.proxy(this._submit_raw_input, this); this.prompt_overlay.dblclick(function () { that.toggle_output(); }); this.prompt_overlay.click(function () { that.toggle_scroll(); }); @@ -451,29 +450,34 @@ var IPython = (function (IPython) { }; OutputArea.prototype.append_raw_input = function (content) { + var that = this; this.expand(); this.flush_clear_timeout(); var area = this.create_output_area(); + area.append( $("
") .addClass("box-flex1 output_subarea raw_input") .append( - $("
") - .attr("action", "javascript:$([IPython.events]).trigger('submit_raw_input.OutputArea');") - .append( - $("") - .addClass("input_prompt") - .text(content.prompt) - ).append( - $("") - .attr("size", 80) - .addClass("raw_input") - ) + $("") + .addClass("input_prompt") + .text(content.prompt) + ) + .append( + $("") + .addClass("raw_input") + .attr('type', 'text') + .attr("size", 80) + .keydown(function (event, ui) { + // make sure we submit on enter, + // and don't re-execute the *cell* on shift-enter + if (event.which === utils.keycodes.ENTER) { + that._submit_raw_input(); + return false; + } + }) ) - ) - // clear events first - $([IPython.events]).off('submit_raw_input.OutputArea'); - $([IPython.events]).on('submit_raw_input.OutputArea', this._submit_raw_input_proxy); + ); this.element.append(area); area.find("input.raw_input").focus(); } @@ -491,7 +495,6 @@ var IPython = (function (IPython) { container.parent().remove(); // replace with plaintext version in stdout this.append_output(content, false); - $([IPython.events]).off('submit_raw_input.OutputArea', this._submit_raw_input_proxy); $([IPython.events]).trigger('send_input_reply.Kernel', value); }