From 94371b23381ed8fbab4664b1464068dbc3dd8d9f Mon Sep 17 00:00:00 2001 From: taoyuan Date: Wed, 24 Feb 2016 14:45:41 +0800 Subject: [PATCH] Allows "enter" pressed to change the text box to a text area. --- src/main/html/index.html | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main/html/index.html b/src/main/html/index.html index d95471a1247..56751f06fdc 100644 --- a/src/main/html/index.html +++ b/src/main/html/index.html @@ -68,6 +68,8 @@ } addApiKeyAuthorization(); + + toTextareas('input.parameter', 'body-textarea'); }, onFailure: function(data) { log("Unable to Load SwaggerUI"); @@ -79,6 +81,30 @@ showRequestHeaders: false }); + function toTextareas(q, cls) { + $(q).keypress(function (e) { + if (e.which == 13) { + toTextarea(e.target, cls); + return false; + } + }); + } + + function toTextarea(el, cls) { + var $el = $(el); + var $ta = $(document.createElement('textarea')); + var attributes = $el.prop("attributes"); + $.each(attributes, function() { + $ta.attr(this.name, this.value); + }); + var v = $el.val(); + if (v) v = v + '\n'; + $ta.val(v); + $ta.addClass(cls); + $el.replaceWith($ta); + $ta.focus(); + } + function addApiKeyAuthorization(){ var key = encodeURIComponent($('#input_apiKey')[0].value); if(key && key.trim() != "") {