From 94371b23381ed8fbab4664b1464068dbc3dd8d9f Mon Sep 17 00:00:00 2001 From: taoyuan Date: Wed, 24 Feb 2016 14:45:41 +0800 Subject: [PATCH 1/3] 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() != "") { From 4366719fb2925357844d98c4c372f669831a2f92 Mon Sep 17 00:00:00 2001 From: taoyuan Date: Sat, 5 Mar 2016 15:34:39 +0800 Subject: [PATCH 2/3] Using ctrl + enter to switch text editor to multiline --- src/main/html/index.html | 45 +++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/main/html/index.html b/src/main/html/index.html index 56751f06fdc..e32beda040e 100644 --- a/src/main/html/index.html +++ b/src/main/html/index.html @@ -69,7 +69,7 @@ addApiKeyAuthorization(); - toTextareas('input.parameter', 'body-textarea'); + multilinable('input.parameter', 'body-textarea'); }, onFailure: function(data) { log("Unable to Load SwaggerUI"); @@ -81,29 +81,26 @@ 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 multilinable(q, cls) { + $(q).keypress(function (e) { + if (e.ctrlKey && e.keyCode == 13) { + var $el = $(e.target); + 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(); + return false; + } + }); + // $(q).attr('placeholder', 'Press to make multiline'); + } function addApiKeyAuthorization(){ var key = encodeURIComponent($('#input_apiKey')[0].value); From e8ace9e982bf4044bf5bdba72d5dc60263c74092 Mon Sep 17 00:00:00 2001 From: taoyuan Date: Sat, 5 Mar 2016 15:43:53 +0800 Subject: [PATCH 3/3] Added `Press "ctrl + enter" to make multiline` note after text editor --- src/main/html/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/html/index.html b/src/main/html/index.html index e32beda040e..4a5ae241d25 100644 --- a/src/main/html/index.html +++ b/src/main/html/index.html @@ -82,6 +82,7 @@ }); function multilinable(q, cls) { + $('').insertAfter($(q)); $(q).keypress(function (e) { if (e.ctrlKey && e.keyCode == 13) { var $el = $(e.target); @@ -99,7 +100,6 @@ return false; } }); - // $(q).attr('placeholder', 'Press to make multiline'); } function addApiKeyAuthorization(){