Skip to content

Commit

Permalink
Allow specifying resize direction
Browse files Browse the repository at this point in the history
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
  • Loading branch information
madhuracj committed Jun 15, 2015
1 parent e3449c9 commit c2e9118
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion js/db_qbe.js
Expand Up @@ -28,7 +28,7 @@ AJAX.registerTeardown('db_qbe.js', function () {

AJAX.registerOnload('db_qbe.js', function () {

PMA_getSQLEditor($('#textSqlquery'));
PMA_getSQLEditor($('#textSqlquery'), {}, 'both');

/**
* Ajax event handlers for 'Select saved search'
Expand Down
20 changes: 17 additions & 3 deletions js/functions.js
Expand Up @@ -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
Expand All @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion js/transformations/sql_editor.js
Expand Up @@ -7,6 +7,6 @@
AJAX.registerOnload('transformations/sql_editor.js', function() {

$('textarea.transform_sql_editor').each(function () {
PMA_getSQLEditor($(this));
PMA_getSQLEditor($(this), {}, 'both');
});
});

0 comments on commit c2e9118

Please sign in to comment.