mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 11:45:50 +00:00
Sidebar improvements for big pages, code expand/collapse tweaks
This commit is contained in:
@@ -17,6 +17,16 @@ var toggle_cs = function(eo) {
|
||||
$(eo.target).val(current_button_text == 'Expand' ? "Collapse" : "Expand");
|
||||
}
|
||||
|
||||
function has_scrollbars(e) {
|
||||
if ($(e).parents(".multicode").length > 0) {
|
||||
//TODO: figure out if we can detect scrollbars on non-default tabs of
|
||||
// multicode samples. For now, always consider multi-code sections to need
|
||||
// scrollbars.
|
||||
return true;
|
||||
}
|
||||
return (e.scrollHeight > e.clientHeight) || (e.scrollWidth > e.clientWidth);
|
||||
}
|
||||
|
||||
function make_code_expandable() {
|
||||
var newid = 0;
|
||||
$(".content > pre > code").parent().wrap(function() {
|
||||
@@ -24,14 +34,20 @@ function make_code_expandable() {
|
||||
return "<div class='code_sample' id='code_autoid_"+newid+"'>";
|
||||
});
|
||||
|
||||
var cs = $('.code_sample');
|
||||
cs.find("code").dblclick(toggle_cs);
|
||||
cs.find("code").attr('title', 'Double-click to expand/collapse');
|
||||
var newbtn = $("<input type='button' class='code_toggler' value='Expand' />");
|
||||
newbtn.appendTo(cs);
|
||||
var code_samples = $('.code_sample');
|
||||
code_samples.find("code").each(function() {
|
||||
let jqThis = $(this);
|
||||
if (has_scrollbars(this)) {
|
||||
jqThis.dblclick(toggle_cs);
|
||||
jqThis.attr('title', 'Double-click to expand/collapse');
|
||||
var newbtn = $("<input type='button' class='code_toggler' value='Expand' />");
|
||||
newbtn.appendTo(jqThis.parents(".code_sample"));
|
||||
}
|
||||
});
|
||||
|
||||
$(".code_toggler").click(toggle_cs);
|
||||
|
||||
|
||||
/* fix expand/collapse and tab click hierarchy */
|
||||
cs.css("position","relative");
|
||||
code_samples.css("position","relative");
|
||||
$(".multicode .code_sample").css("position","static");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user