This commit is contained in:
gorhill 2017-10-04 11:14:24 -04:00
parent a19efa4ebe
commit a6b01cb0e5
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -1416,7 +1416,7 @@ var stopPicker = function() {
svgRoot.removeEventListener('touchend', onSvgTouchStartStop); svgRoot.removeEventListener('touchend', onSvgTouchStartStop);
pickerStyle.parentNode.removeChild(pickerStyle); pickerStyle.parentNode.removeChild(pickerStyle);
pickerRoot.parentNode.removeChild(pickerRoot); pickerRoot.parentNode.removeChild(pickerRoot);
pickerRoot.onload = null; pickerRoot.removeEventListener('load', stopPicker);
pickerRoot = pickerRoot =
pickerBody = pickerBody =
dialog = dialog =
@ -1429,7 +1429,7 @@ var stopPicker = function() {
/******************************************************************************/ /******************************************************************************/
var startPicker = function(details) { var startPicker = function(details) {
pickerRoot.onload = stopPicker; pickerRoot.addEventListener('load', stopPicker);
var frameDoc = pickerRoot.contentDocument; var frameDoc = pickerRoot.contentDocument;
var parsedDom = (new DOMParser()).parseFromString( var parsedDom = (new DOMParser()).parseFromString(
@ -1534,6 +1534,18 @@ var startPicker = function(details) {
/******************************************************************************/ /******************************************************************************/
var bootstrapPicker = function() {
pickerRoot.removeEventListener('load', bootstrapPicker);
vAPI.shutdown.add(stopPicker);
vAPI.messaging.send(
'elementPicker',
{ what: 'elementPickerArguments' },
startPicker
);
};
/******************************************************************************/
pickerRoot = document.createElement('iframe'); pickerRoot = document.createElement('iframe');
pickerRoot.id = vAPI.sessionId; pickerRoot.id = vAPI.sessionId;
pickerRoot.style.cssText = [ pickerRoot.style.cssText = [
@ -1581,19 +1593,9 @@ if ( vAPI.userCSS ) {
vAPI.userCSS.add(pickerStyle.textContent); vAPI.userCSS.add(pickerStyle.textContent);
} }
pickerRoot.onload = function() { pickerRoot.addEventListener('load', bootstrapPicker);
vAPI.shutdown.add(stopPicker);
vAPI.messaging.send(
'elementPicker',
{ what: 'elementPickerArguments' },
startPicker
);
};
document.documentElement.appendChild(pickerRoot); document.documentElement.appendChild(pickerRoot);
// https://www.youtube.com/watch?v=sociXdKnyr8
/******************************************************************************/ /******************************************************************************/
})(); })();