summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/tab_modal_confirm_dialog.html
blob: 8637543beaff7e976460777ded1ed1569dd4a6f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html i18n-values="dir:textdirection">
<head>
  <link rel="stylesheet" href="dialog.css">
  <style>
    body {
      -webkit-user-select: none;
      margin: 10px 10px 0 10px;
    }

    form {
      margin: 0;
    }

    #explanation {
      cursor: default;
    }

    #buttons {
      padding: 10px 0;
      text-align: end;
    }

  </style>
  <script src="chrome://resources/js/i18n_template.js"></script>
  <script>
    function $(o) {
      return document.getElementById(o);
    }

    function disableControls() {
      $('cancel').disabled = true;
      $('accept').disabled = true;
    }

    function cancel() {
      disableControls();
      chrome.send('DialogClose', [JSON.stringify(false)]);
    }

    function handleSubmit(e) {
      disableControls();
      e.preventDefault();
      chrome.send('DialogClose', [JSON.stringify(true)]);
    }

    function handleKeyDown(e) {
      if (e.keyCode == 27) {  // Escape
        e.preventDefault();
        cancel();
      }
    }

    function load() {
      i18nTemplate.process(document, JSON.parse(chrome.dialogArguments));
      document.addEventListener('keydown', handleKeyDown);
      $('form').onsubmit = handleSubmit;
      $('cancel').onclick = cancel;
      $('cancel').focus();
    }

    document.addEventListener('DOMContentLoaded', load);
  </script>
</head>
<body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
  <div id="explanation" i18n-content="message"></div>
  <form id="form">
    <div id="buttons">
      <input id="cancel" type="reset" i18n-values="value:cancel" autofocus>
      <input id="accept" type="submit" i18n-values="value:accept">
    </div>
  </form>
</body>
</html>