From c2e91186d280230a84cf44fb94d47ff95478170d Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 15 Jun 2015 15:19:27 +0530 Subject: Allow specifying resize direction Signed-off-by: Madhura Jayaratne --- js/functions.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'js/functions.js') diff --git a/js/functions.js b/js/functions.js index 662cc0ffea..44e37cb7de 100644 --- a/js/functions.js +++ b/js/functions.js @@ -102,8 +102,9 @@ $.ajaxPrefilter(function (options, originalOptions, jqXHR) { * * @param $textarea jQuery object wrapping the textarea to be made the editor * @param options optional options for CodeMirror + * @param resize optional resizing ('vertical', 'horizontal', 'both') */ -function PMA_getSQLEditor($textarea, options) { +function PMA_getSQLEditor($textarea, options, resize) { if ($textarea.length > 0 && typeof CodeMirror !== 'undefined') { // merge options for CodeMirror @@ -121,10 +122,23 @@ function PMA_getSQLEditor($textarea, options) { // create CodeMirror editor var codemirrorEditor = CodeMirror.fromTextArea($textarea[0], defaults); // allow resizing + if (! resize) { + resize = 'vertical'; + } + var handles = ''; + if (resize == 'vertical') { + handles = 'n, s'; + } + if (resize == 'both') { + handles = 'all'; + } + if (resize == 'horizontal') { + handles = 'e, w'; + } $(codemirrorEditor.getWrapperElement()) - .css('resize', 'vertical') + .css('resize', resize) .resizable({ - handles: 'n, s', + handles: handles, resize: function() { codemirrorEditor.setSize($(this).width(), $(this).height()); } -- cgit v1.2.3