summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/resources/settings/controls/controlled_button.html
blob: af328098f6282a6d0d883c1689b5d86859ad505a (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
<link rel="import" href="chrome://resources/html/polymer.html">

<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_behavior.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html">
<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="pref_control_behavior.html">
<link rel="import" href="../i18n_setup.html">
<link rel="import" href="../settings_shared_css.html">

<dom-module id="controlled-button">
  <template>
    <style include="settings-shared">
      :host {
        --justify-margin: 8px;
        align-items: center;
        display: flex;
      }

      :host([enforced_]) {
        /* Disable pointer events for this whole element, as outer on-tap gets
         * triggered when clicking/tapping anywhere in :host. */
        pointer-events: none;
      }

      cr-policy-pref-indicator {
        /* Enable pointer events for the indicator so :hover works. Disable
         * clicks/taps via onIndicatorTap_ so outer on-tap doesn't trigger. */
        pointer-events: all;
      }

      :host(:not([end-justified])) cr-policy-pref-indicator {
        margin-inline-start: var(--cr-controlled-by-spacing);
      }

      :host([end-justified]) cr-policy-pref-indicator {
        margin-inline-end: var(--cr-controlled-by-spacing);
        margin-inline-start: calc(
            var(--cr-controlled-by-spacing) - var(--justify-margin));
        order: -1;
      }
    </style>

    <cr-button class$="[[getClass_(actionButton)]]"
      disabled="[[!buttonEnabled_(enforced_, disabled)]]">
      [[label]]
    </cr-button>

    <template is="dom-if" if="[[hasPrefPolicyIndicator(pref.*)]]" restamp>
      <cr-policy-pref-indicator pref="[[pref]]" on-click="onIndicatorTap_"
          icon-aria-label="[[label]]">
      </cr-policy-pref-indicator>
    </template>

  </template>
  <script src="controlled_button.js"></script>
</dom-module>