mirror of
https://github.com/GoogleChrome/chrome-extensions-samples.git
synced 2026-03-29 13:49:41 +07:00
* Remove docs folder. This was a redirect from a GitHub pages site that does not appear to be in use. * Rename api folder to api-samples. * Move examples to functional-samples folder. * Move cookbook sample to functional-samples. * Move tutorials to functional-samples folder. * Move mv2 and apps folders to _archive. * Rename tools folder to .repo. * Move reference folder to functional-samples. * Update README. Update README with new relative links for reorg. * Update README.md Co-authored-by: amysteamdev <37001393+AmySteam@users.noreply.github.com> --------- Co-authored-by: amysteamdev <37001393+AmySteam@users.noreply.github.com>
61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
var exitTool = (function() {
|
|
var containerElement = null;
|
|
var browserInstance = null;
|
|
var controller = null;
|
|
var yes = null; no = null;
|
|
function query(id) { return containerElement.querySelector(id);}
|
|
var ExitController = function(container, browser) {
|
|
containerElement = container;
|
|
browserInstance = browser;
|
|
controller = this;
|
|
yes = query('#exit-yes');
|
|
no = query('#exit-no');
|
|
var curr_focus = 'no';
|
|
yes.onclick = function() {
|
|
window.close();
|
|
};
|
|
no.onclick = deactivate;
|
|
this.overlay = document.createElement('div');
|
|
this.overlay.className = 'overlay-gray';
|
|
document.body.appendChild(this.overlay);
|
|
containerElement.onkeydown = function(e) {
|
|
if (containerElement.style.display === 'none') {
|
|
return;
|
|
}
|
|
e.preventDefault();
|
|
if (e.keyCode === 9) {
|
|
if (curr_focus === 'no') {
|
|
curr_focus = 'yes';
|
|
yes.focus();
|
|
} else {
|
|
curr_focus = 'no';
|
|
no.focus();
|
|
}
|
|
} else if (e.keyCode === 13) {
|
|
if (curr_focus === 'yes') {
|
|
window.close();
|
|
} else {
|
|
deactivate();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
ExitController.prototype.activate = function() {
|
|
containerElement.style.display = 'block';
|
|
this.overlay.style.display = 'block';
|
|
curr_focus = 'no';
|
|
no.focus();
|
|
};
|
|
|
|
function deactivate() {
|
|
containerElement.style.display = 'none';
|
|
controller.overlay.style.display = 'none';
|
|
yes.tabIndex = -1;
|
|
no.tabIndex = -1;
|
|
}
|
|
|
|
return {'ExitController': ExitController};
|
|
|
|
})();
|