Support for sticky machines when using the Node web server (so that we have parity between the Node and Jekyll web environments)
This commit is contained in:
parent
61be09d54a
commit
0eccf30d3c
4 changed files with 89 additions and 15 deletions
|
|
@ -879,6 +879,7 @@ HTMLOut.prototype.findTokens = function(reTokens)
|
|||
aParms.push(aMatch[1]);
|
||||
}
|
||||
}
|
||||
//noinspection JSUnresolvedFunction
|
||||
fnToken.call(this, sToken, sIndent, aParms);
|
||||
}
|
||||
}
|
||||
|
|
@ -1968,6 +1969,12 @@ HTMLOut.prototype.processMachines = function(aMachines, buildOptions, done)
|
|||
}
|
||||
}
|
||||
this.addFilesToHTML(asFiles, sScriptEmbed);
|
||||
if (infoMachine['sticky']) {
|
||||
asFiles = [];
|
||||
asFiles.push("/modules/shared/lib/sticky.js");
|
||||
sScriptEmbed = '<script type="text/javascript">addStickyMachine("' + infoMachine['id'] + '")</script>';
|
||||
this.addFilesToHTML(asFiles, sScriptEmbed);
|
||||
}
|
||||
if (buildOptions.id) {
|
||||
asFiles = [];
|
||||
asFiles.push("/modules/build/lib/build.js");
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ MarkOut.aFMBooleanMachineProps = {
|
|||
'autopower': "autoPower",
|
||||
'autostart': "autoStart"
|
||||
};
|
||||
MarkOut.aFMReservedMachineProps = ['id', 'name', 'type', 'debugger', 'config', 'template', 'uncompiled', 'autoMount', 'drives', 'parms'];
|
||||
MarkOut.aFMReservedMachineProps = ['id', 'name', 'type', 'debugger', 'config', 'template', 'uncompiled', 'autoMount', 'drives', 'parms', 'sticky'];
|
||||
|
||||
/**
|
||||
* convertMD()
|
||||
|
|
@ -1167,6 +1167,7 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
|
|||
var machine = this.aMachineDefs[sMachineID];
|
||||
sMachineType = machine['type'] || "PCx86";
|
||||
sMachineOptions = ((sMachineType.indexOf("-dbg") > 0 || machine['debugger'] == "true")? "debugger" : "");
|
||||
if (machine['sticky']) sMachineOptions += (sMachineOptions? "," : "") + "sticky";
|
||||
sMachineType = sMachineType.replace("-dbg", "");
|
||||
sMachineXMLFile = machine['config'] || this.sMachineFile || "machine.xml";
|
||||
sMachineXSLFile = machine['template'] || "";
|
||||
|
|
@ -1204,6 +1205,7 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
|
|||
sMachineParms = aMachineParms[4] || "";
|
||||
var aMachineOptions = sMachineOptions.split(',');
|
||||
var fDebugger = (aMachineOptions.indexOf("debugger") >= 0);
|
||||
var fSticky = (aMachineOptions.indexOf("sticky") >= 0);
|
||||
|
||||
/*
|
||||
* TODO: Consider validating the existence of this XML file and generating a more meaningful error if not found
|
||||
|
|
@ -1247,6 +1249,7 @@ MarkOut.prototype.convertMDMachineLinks = function(sBlock)
|
|||
'xsl': sMachineXSLFile,
|
||||
'version': sMachineVersion,// eg, "1.10", "*" to select the current version, or "uncompiled"; "*" is the default
|
||||
'debugger': fDebugger, // eg, true or false; false is the default
|
||||
'sticky': fSticky, // eg, true or false; false is the default
|
||||
'parms': sMachineParms}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,31 +35,39 @@
|
|||
*/
|
||||
function addStickyMachine(idMachine)
|
||||
{
|
||||
var machine = document.getElementById(idMachine);
|
||||
if (machine) {
|
||||
var machineFooter = document.getElementById(idMachine + '.footer');
|
||||
if (machineFooter) {
|
||||
var topMachine = findTop(machine);
|
||||
var prevOnScroll = window.onscroll;
|
||||
window.onscroll = function() {
|
||||
var topMachine = -1;
|
||||
var prevOnScroll = window.onscroll;
|
||||
window.onscroll = function() {
|
||||
/*
|
||||
* TODO: Determine if/when we can cache the machine and machineSibling elements; we already
|
||||
* know we can't cache them when addStickyMachine() is first called, because that currently
|
||||
* happens *before* embed.js replaces the placeholder machine DIV with the *real* machine DIV.
|
||||
*/
|
||||
var machine = document.getElementById(idMachine);
|
||||
if (machine) {
|
||||
var machineSibling = machine.nextElementSibling;
|
||||
if (machineSibling) {
|
||||
if (topMachine < 0) {
|
||||
topMachine = findTop(machine);
|
||||
}
|
||||
if (window.pageYOffset <= topMachine) {
|
||||
machine.style.position = 'relative';
|
||||
machine.style.zIndex = 'auto';
|
||||
machine.style.backgroundColor = '';
|
||||
machine.style.paddingRight = 0;
|
||||
if (machineFooter) machineFooter.style.paddingTop = 0;
|
||||
if (machineSibling) machineSibling.style.paddingTop = 0;
|
||||
} else {
|
||||
machine.style.position = 'fixed';
|
||||
machine.style.zIndex = 1;
|
||||
machine.style.backgroundColor = 'white';
|
||||
machine.style.paddingRight = '30px';
|
||||
machine.style.backgroundColor = '#404040';
|
||||
machine.style.paddingRight = '16px';
|
||||
machine.style.top = 0;
|
||||
if (machineFooter) machineFooter.style.paddingTop = machine.offsetHeight + 'px';
|
||||
if (machineSibling) machineSibling.style.paddingTop = machine.offsetHeight + 'px';
|
||||
}
|
||||
};
|
||||
if (prevOnScroll) prevOnScroll();
|
||||
if (prevOnScroll) prevOnScroll();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
Loading…
Reference in a new issue