Last active
December 20, 2017 11:01
-
-
Save bjoerntx/bc0bc3c2491767b57f246b02c9ed8695 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function drawOverlay() { | |
_divOvr = document.getElementById("divOvr"); | |
var sParams = ""; | |
// create the options based on the drop down items | |
for (let param of _currentField.parameters) { | |
if (param.startsWith("w:listEntry")) { | |
var arrStr = param.split(/["]/); | |
sParams += "<option>" + arrStr[1] + "</option>"; | |
} | |
} | |
// create a new html select object | |
if (!_divOvr) { | |
_divOvr = document.createElement("select"); | |
_divOvr.className = "overlay"; | |
_divOvr.id = "divOvr"; | |
_divOvr.innerHTML = sParams; | |
_container.appendChild(_divOvr); | |
} | |
// retrieve the field location in the document | |
var fldPos = _currentField.bounds.location; | |
// and calculate the offset location and zoom factor | |
var x = _textView.offsetLeft + (fldPos.x - _txtViewLoc.x) * _zoom; | |
var y = _textView.offsetTop + (fldPos.y - _txtViewLoc.y) * _zoom; | |
// set position and size | |
_divOvr.style.fontSize = (8 * _zoom) + "pt"; | |
_divOvr.style.zIndex = _textView.style.zIndex + 10; | |
_divOvr.style.left = x + "px"; | |
_divOvr.style.width = (_currentField.bounds.size.width * _zoom) + "px"; | |
_divOvr.style.minHeight = (_currentField.bounds.size.height * _zoom) + "px"; | |
_divOvr.style.top = y + "px"; | |
// add change event to change text of the field | |
// when an option has been selected | |
$('#divOvr').change(function () { | |
var val = $("#divOvr option:selected").val(); | |
_currentField.text = val; | |
removeElement(); | |
}); | |
$('#divOvr').focus(function () { | |
this.selectedIndex = -1; | |
this.focus(); | |
}); | |
_divOvr.focus(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment