Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' into JENKINS-29705
Originally-Committed-As: b25572639b743005a1b2b18473912286ba1d59e6
  • Loading branch information
jglick committed Nov 22, 2015
2 parents 69810b1 + 09a10e0 commit ff8f9ca
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cps/gulpfile.js
Expand Up @@ -8,5 +8,5 @@ var builder = require('jenkins-js-builder');
// See https://github.com/tfennelly/jenkins-js-builder#bundling
//
builder.bundle('src/main/js/workflow-editor.js')
.withExternalModuleMapping('jquery-detached', 'jquery-detached:jquery2')
.withExternalModuleMapping('jqueryui-detached', 'jquery-detached:jqueryui1')
.inDir('target/generated-resources/adjuncts/org/jenkinsci/plugins/workflow/cps');
2 changes: 1 addition & 1 deletion cps/package.json
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"jenkins-js-modules": "1.3.0",
"jquery-detached": "^2.1.4-v2",
"jqueryui-detached": "^1.11.4-v9",
"window-handle": "0.0.6"
}
}
2 changes: 1 addition & 1 deletion cps/src/main/js/samples.js
@@ -1,7 +1,7 @@
var samples = [];

exports.addSamplesWidget = function(editor) {
var $ = require('jquery-detached').getJQuery();
var $ = require('jqueryui-detached').getJQueryUI();

if ($('#workflow-editor-wrapper .samples').length) {
// Already there.
Expand Down
19 changes: 16 additions & 3 deletions cps/src/main/js/workflow-editor.js
@@ -1,4 +1,4 @@
var $ = require('jquery-detached').getJQuery();
var $ = require('jqueryui-detached').getJQueryUI();
var jenkinsJSModules = require('jenkins-js-modules');
var wrapper = $('#workflow-editor-wrapper');
var textarea = $('textarea', wrapper);
Expand All @@ -21,7 +21,8 @@ jenkinsJSModules.import('ace-editor:ace-editor-122')
var editor = this.editor;

// Attach the ACE editor instance to the element. Useful for testing.
$('#workflow-editor').get(0).aceEditor = editor;
var $wfEditor = $('#workflow-editor');
$wfEditor.get(0).aceEditor = editor;

acePack.addPackOverride('snippets/groovy.js', '../workflow-cps/snippets/workflow.js');

Expand All @@ -33,7 +34,6 @@ jenkinsJSModules.import('ace-editor:ace-editor-122')
editor.setTheme("ace/theme/tomorrow");
editor.setAutoScrollEditorIntoView(true);
editor.setOption("minLines", 20);
editor.setOption("maxLines", 20);
// enable autocompletion and snippets
editor.setOptions({
enableBasicAutocompletion: true,
Expand All @@ -57,6 +57,19 @@ jenkinsJSModules.import('ace-editor:ace-editor-122')
}
showSamplesWidget();
});

// Make the editor resizable using jQuery UI resizable (http://api.jqueryui.com/resizable).
// ACE Editor doesn't have this as a config option.
$wfEditor.wrap('<div class="jquery-ui-1"></div>');
$wfEditor.resizable({
handles: "s", // Only allow vertical resize off the bottom/south border
resize: function() {
editor.resize();
}
});
// Make the bottom border a bit thicker as a visual cue.
// May not be enough for some people's taste.
$wfEditor.css('border-bottom-width', '0.4em');
});
});

Expand Down

0 comments on commit ff8f9ca

Please sign in to comment.