.
*
* Placement of the addStickyMachine() call is irrelevant, because embed.js asynchronously
* reads all the XML files that define the machine *before* replacing the
.
*/
var machine = document.getElementById(idMachine);
if (machine) {
var machineSibling = machine.nextElementSibling;
if (machineSibling) {
if (topMachine < 0) {
topMachine = findTop(machine);
}
machine.className = machine.className.replace(/pcjs-machine-(floating|sticky) /g, '');
if (window.pageYOffset <= topMachine) {
machine.className = 'pcjs-machine-floating ' + machine.className;
if (machineSibling) machineSibling.style.paddingTop = 0;
} else {
machine.className = 'pcjs-machine-sticky ' + machine.className;
if (machineSibling) machineSibling.style.paddingTop = machine.offsetHeight + 'px';
}
if (prevOnScroll) prevOnScroll();
}
}
};
}
/**
* commandMachine(idMachine, typeComponent, sCommand, sValue)
*
* @param {string} idMachine
* @param {string} typeComponent
* @param {string} sCommand
* @param {string} [sValue]
*/
function commandMachine(idMachine, typeComponent, sCommand, sValue)
{
console.log("commandMachine('" + idMachine + "','" + typeComponent + "','" + sCommand + "','" + sValue + "')");
}
/**
* findTop(obj)
*
* @param {Object} obj
*/
function findTop(obj)
{
var curTop = 0;
if (typeof obj.offsetParent != 'undefined' && obj.offsetParent) {
while (obj.offsetParent) {
curTop += obj.offsetTop;
obj = obj.offsetParent;
}
curTop += obj.offsetTop;
}
else if (obj.y) {
curTop += obj.y;
}
return curTop;
}