Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
250 lines (219 loc) · 7.62 KB
/
Copy pathindex.html
File metadata and controls
250 lines (219 loc) · 7.62 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script defer src="index.js"></script>
<link rel="stylesheet" href="../third-party/awsm/awsm.css" />
<link rel="stylesheet" href="index.css" />
</head>
<body>
<main>
<section>
<h1>Action API Demo</h1>
<p>
Before experimenting with these APIs, we recommend you pin the
extension's action button to your toolbar in order to make it easier
to see the changes.
</p>
<img src="../images/pin-action.png" />
</section>
<section id="toggle-state">
<h2>enable / disable</h2>
<p>
Clicking the below <em>toggle enabled state</em> button will enable or
disable the extensions' action button in Chrome's toolbar and
extensions menu.
</p>
<p>
When disabled, clicking the action will not open a popup or trigger
<a
href="https://developer.chrome.com/docs/extensions/reference/action/#event-onClicked"
><code>action.onClicked</code></a
>
events.
</p>
<button id="toggle-state-button">toggle enabled state</button>
<div class="flex">
<figure>
<img src="../images/action-enabled.png" />
<figcaption>Action enabled</figcaption>
</figure>
<figure>
<img src="../images/action-disabled.png" />
<figcaption>Action disabled</figcaption>
</figure>
</div>
</section>
<section id="popup">
<h2>Popup</h2>
<p>
This demo's <a href="manifest.json">manifest.json</a> file sets the
value of <code>action.default_popup</code> to
<code>popups/popup.html</code>. We can change that behavior at runtime
using
<a
href="https://developer.chrome.com/docs/extensions/reference/action/#method-setPopup"
><code>action.setPopup</code></a
>.
</p>
<label>
Change popup page<br />
<select id="popup-options">
<option value="/popups/popup.html">Hello world (default)</option>
<option value="/popups/a.html">A</option>
<option value="/popups/b.html">B</option>
<option value="">onClicked handler</option>
</select>
</label>
<div class="spaced">
<label>
Current popup value
<input type="text" id="current-popup-value" disabled />
</label>
</div>
<p>
Register a handler to change how the action button behaves. Once
changed, clicking the action will open your new favorite website.
</p>
<button id="onclicked-button">Change action click behavior</button>
<button id="onclicked-reset-button">reset</button>
</section>
<!-- badge -->
<section id="badge-text">
<h2>Badge Text</h2>
<p>
The action's badge text is a text overlay with a solid background
color. This provides a passive UI surface to share information with
the user. It is most commonly used to show a notification count or
number of actions taken on the current page.
</p>
<div class="spaced">
<label>
Enter badge text (live update)<br />
<input type="text" id="badge-text-input" />
</label>
</div>
<div class="flex">
<label class="full-width">
Current badge text
<input type="text" id="current-badge-text" disabled />
</label>
<button id="clear-badge-button">clear badge text</button>
</div>
<div class="spaced">
<button id="set-badge-background-color-button">
Randomize badge background color
</button>
</div>
<div class="flex">
<label class="full-width">
Current badge color
<input type="text" id="current-badge-bg-color" disabled />
</label>
<button id="reset-badge-background-color-button">
Reset badge color
</button>
</div>
</section>
<!-- Badge Text Color !-->
<section>
<h2>Badge Text Color</h2>
<p>
The
<a
href="https://developer.chrome.com/docs/extensions/reference/action/#method-setBadgeTextColor"
><code>action.setBadgeTextColor</code></a
>
method allows you to change the color of the badge text.
</p>
<div class="spaced">
<button id="set-badge-txt-color-button">
Randomize badge text color
</button>
</div>
<p>
The
<a
href="https://developer.chrome.com/docs/extensions/reference/action/#method-getBadgeTextColor"
><code>action.getBadgeTextColor</code></a
>
method allows you to read the current color of the badge text.
</p>
<div class="flex">
<label class="full-width">
Current badge text color
<input type="text" id="current-badge-txt-color" disabled />
</label>
<button id="reset-badge-txt-color-button">
Reset badge text color
</button>
</div>
</section>
<!-- badge - icon -->
<section id="setIcon">
<h2>Icon</h2>
<p>
The
<a
href="https://developer.chrome.com/docs/extensions/reference/action/#method-setIcon"
><code>action.setIcon</code></a
>
method allows you to change the action button's icon by either
providing the path of an image or the raw
<a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageData"
>ImageData</a
>.
</p>
<button id="set-icon-button">set a new action icon</button>
<button id="reset-icon-button">reset action icon</button>
</section>
<!-- badge - hover text (title) -->
<section id="title">
<h2>Hover Text</h2>
<p>
The action's title is visible when mousing over the extension's action
button.
</p>
<p>
This value can be read and changed at runtime using the
<a
href="https://developer.chrome.com/docs/extensions/reference/action/#method-getTitle"
><code>action.getTitle</code></a
>
and
<a
href="https://developer.chrome.com/docs/extensions/reference/action/#method-setTitle"
><code>action.setTitle</code></a
>
methods, respectively.
</p>
<div class="spaced">
<label>
Enter a new title (debounced)<br />
<input type="text" id="title-input" />
</label>
</div>
<div class="flex">
<label class="full-width">
Current title
<input type="text" id="current-title" disabled />
</label>
<button id="reset-title-button">reset title</button>
</div>
<div class="flex">
<figure>
<img src="../images/title-no-hover.png" />
<figcaption>Default appearance</figcaption>
</figure>
<figure>
<img src="../images/title-hover.png" />
<figcaption>Title appears on hover</figcaption>
</figure>
</div>
</section>
</main>
</body>
</html>