Skip to content

Commit 40b6a60

Browse files
microbit-sammicrobit-carlos
authored andcommitted
Add floating help panel (#115)
1 parent e544299 commit 40b6a60

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

editor.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,10 @@ <h2><i class="fa fa-unlock-alt"></i> <strong>{{ title }}</strong></h2>
193193
</a>
194194
<div class="helpsupport_container">
195195
<div class="helpsupport_lhs">
196-
<div class="helpsupport"><a id="docs-link" title="View the documentation for MicroPython" href="https://microbit-micropython.readthedocs.io/" target="_blank">Documentation</a></div>
197-
<div class="helpsupport"><a id="help-link" title="Open help for this editor in a new tab" href="help.html" target="_blank" >Help</a></div>
198-
<div class="helpsupport"><a title="Get support for your micro:bit in a new tab" href="https://support.microbit.org/support/home" target="_blank">Support</a></div>
196+
<div class="helpsupport"><a id="docs-link" class="action" title="View the documentation for MicroPython" href="https://microbit-micropython.readthedocs.io/" target="_blank">Documentation</a></div>
197+
<div class="helpsupport"><a id="help-link" class="action" title="Open help for this editor in a new tab" href="help.html" target="_blank" >Help</a></div>
198+
<div class="helpsupport"><a id="support-link" class="action" title="Get support for your micro:bit in a new tab" href="https://support.microbit.org/support/home" target="_blank">Support</a></div>
199+
<div class="helpsupport hidden" id="known-issues"><a id="issues-link" class="action" title="View open issues for the Python Editor in GitHub" href="https://github.com/bbcmicrobit/PythonEditor/issues" target="_blank">Issue Tracker</a></div>
199200
</div>
200201
<div class="helpsupport_rhs">
201202
<div class="helpsupport">Editor Version: <script>document.write(EDITOR_VERSION);</script></div>

python-main.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ function web_editor(config) {
345345
// If configured as experimental update editor background to indicate it
346346
if(config.flags.experimental) {
347347
EDITOR.ACE.renderer.scroller.style.backgroundImage = "url('static/img/experimental.png')";
348+
$("#known-issues").removeClass('hidden');
348349
}
349350
// Configure the zoom related buttons.
350351
$("#zoom-in").click(function (e) {
@@ -693,14 +694,45 @@ function web_editor(config) {
693694
$("#command-share").click(function () {
694695
doShare();
695696
});
696-
$("#command-help").click(function () {
697+
698+
function formatHelpPanel(){
699+
if($(".helpsupport_container").offset().left !== $("#command-help").offset().left && $(window).width() > 620){
700+
$(".helpsupport_container").css("top", $("#command-help").offset().top + $("#toolbox").height() + 10);
701+
$(".helpsupport_container").css("left", $("#command-help").offset().left);
702+
}
703+
else if($(window).width() < 620){
704+
$(".helpsupport_container").css("left", $("#command-help").offset().left - 200);
705+
$(".helpsupport_container").css("top", $("#command-help").offset().top + $("#toolbox").height() + 10);
706+
}
707+
};
708+
709+
$("#command-help").click(function (e) {
710+
// Show help
711+
formatHelpPanel();
712+
// Toggle visibility
697713
if($(".helpsupport_container").css("display") == "none"){
698714
$(".helpsupport_container").css("display", "flex");
715+
$(".helpsupport_container").css("display", "-ms-flexbox"); // IE10 support
699716
} else {
700717
$(".helpsupport_container").css("display", "none");
701718
}
719+
720+
// Stop immediate closure
721+
e.stopImmediatePropagation();
722+
});
723+
724+
window.addEventListener('resize', function(){
725+
if($(".helpsupport_container").is(":visible")){
726+
formatHelpPanel();
727+
}
728+
});
729+
730+
// Add document click listener
731+
document.body.addEventListener('click',function(event) {
732+
// Close helpsupport if the click isn't on a descendent of #command-help
733+
if($(event.target).closest('.helpsupport_container').length == 0 || $(event.target).prop("tagName").toLowerCase() === 'a')
734+
$(".helpsupport_container").css("display", "none");
702735
});
703-
$(".helpsupport_container").hide();
704736
}
705737

706738
// Extracts the query string and turns it into an object of key/value

static/css/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,9 +456,13 @@ div.load-form {
456456
}
457457

458458
.helpsupport_container {
459+
position: absolute;
459460
margin: auto auto auto auto;
460461
display: none;
461462
padding-right: 1em;
463+
z-index: 999;
464+
background-color: #f2f2f2;
465+
border-radius: 0.5rem;
462466
}
463467

464468
.helpsupport {

0 commit comments

Comments
 (0)