Commit b015d168 authored by Leigh B Stoller's avatar Leigh B Stoller

Add a double click handler so render the instructions

when editing/creating a profile.
parent 8eacc948
...@@ -2,7 +2,7 @@ window.APT_OPTIONS.config(); ...@@ -2,7 +2,7 @@ window.APT_OPTIONS.config();
require(['jquery', 'js/quickvm_sup', require(['jquery', 'js/quickvm_sup',
// jQuery modules // jQuery modules
'bootstrap','filestyle'], 'bootstrap','filestyle','marked'],
function ($, sup) function ($, sup)
{ {
'use strict'; 'use strict';
...@@ -118,6 +118,17 @@ function ($, sup) ...@@ -118,6 +118,17 @@ function ($, sup)
ChangeHandlerAux("description"); ChangeHandlerAux("description");
}); });
/*
* A double click handler that will render the instructions
* in a modal.
*/
$('#profile_instructions').dblclick(function() {
var text = $(this).val();
var marked = require("marked");
$('#renderer_modal_div').html(marked(text));
sup.ShowModal("#renderer_modal");
});
/* /*
* If editing, need to suck the description and instructions * If editing, need to suck the description and instructions
* out of the rspec and put them into the text boxes. But * out of the rspec and put them into the text boxes. But
...@@ -136,7 +147,7 @@ function ($, sup) ...@@ -136,7 +147,7 @@ function ($, sup)
else { else {
/* /*
* Not editing, so disable the text boxes until we get * Not editing, so disable the text boxes until we get
* an rspec. * an rspec via the file chooser.
*/ */
$('#profile_instructions').prop("disabled", true); $('#profile_instructions').prop("disabled", true);
$('#profile_description').prop("disabled", true); $('#profile_description').prop("disabled", true);
......
...@@ -273,7 +273,8 @@ function SPITFORM($formfields, $errors) ...@@ -273,7 +273,8 @@ function SPITFORM($formfields, $errors)
class='form-control' class='form-control'
placeholder='' placeholder=''
type='textarea'></textarea>", type='textarea'></textarea>",
"Briefly describe how to use this profile after it starts"); "Briefly describe how to use this profile after it starts. ".
"Double click to see it rendered.");
$formatter("profile_listed", "Listed?", $formatter("profile_listed", "Listed?",
"<div class='checkbox'> "<div class='checkbox'>
...@@ -369,6 +370,28 @@ function SPITFORM($formfields, $errors) ...@@ -369,6 +370,28 @@ function SPITFORM($formfields, $errors)
</div> </div>
</div>\n"; </div>\n";
echo "<!-- This is the renderer modal -->
<div id='renderer_modal' class='modal fade'>
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'
aria-hidden='true'>
&times;</button>
<h3>Markdown Renderer</h3>
</div>
<div class='modal-body'>
<!-- This rendering goes inside this div -->
<div class='panel panel-default'>
<div class='panel-body'>
<div id='renderer_modal_div'></div>
</div>
</div>
</div>
</div>
</div>
</div>\n";
echo "<script type='text/javascript'>\n"; echo "<script type='text/javascript'>\n";
echo " window.EDITING = $editing;\n"; echo " window.EDITING = $editing;\n";
echo "</script>\n"; echo "</script>\n";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment