Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: chrome/common/extensions/docs/server2/templates/articles/options.html

Issue 10832042: Extensions Docs Server: Doc conversion script (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment in converter.py Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <h1 class="page_title">Options</h1>
2 <div id="pageData-showTOC" class="pageData">true</div>
3 <p>To allow users to customize the behavior of your extension, you may wish to p rovide an options page. If you do, a link to it will be provided from the extens ions management page at chrome://extensions. Clicking the Options link opens a n ew tab pointing at your options page.
4 <h2>Step 1: Declare your options page in the manifest</h2>
5 <pre>{
6 "name": "My extension",
7 ...
8 <b>"options_page": "options.html"</b>,
9 ...
10 }</pre>
11 <h2>Step 2: Write your options page</h2>
12 Here is an example options page:
13 <pre>// Save this script as `options.js`
14 // Saves options to localStorage.
15 function save_options() {
16 var select = document.getElementById("color");
17 var color = select.children[select.selectedIndex].value;
18 localStorage["favorite_color"] = color;
19 // Update status to let user know options were saved.
20 var status = document.getElementById("status");
21 status.innerHTML = "Options Saved.";
22 setTimeout(function() {
23 status.innerHTML = "";
24 }, 750);
25 }
26 // Restores select box state to saved value from localStorage.
27 function restore_options() {
28 var favorite = localStorage["favorite_color"];
29 if (!favorite) {
30 return;
31 }
32 var select = document.getElementById("color");
33 for (var i = 0; i &lt; select.children.length; i++) {
34 var child = select.children[i];
35 if (child.value == favorite) {
36 child.selected = "true";
37 break;
38 }
39 }
40 }
41 document.addEventListener('DOMContentReady', restore_options);
42 document.querySelector('#save').addEventListener('click', save_options);
43 </pre>
44 <pre>
45 &lt;html>
46 &lt;head>&lt;title>My Test Extension Options&lt;/title>&lt;/head>
47 &lt;script src="options.js">
48 &lt;body>
49 Favorite Color:
50 &lt;select id="color">
51 &lt;option value="red">red&lt;/option>
52 &lt;option value="green">green&lt;/option>
53 &lt;option value="blue">blue&lt;/option>
54 &lt;option value="yellow">yellow&lt;/option>
55 &lt;/select>
56 &lt;br>
57 &lt;div id="status">&lt;/div>
58 &lt;button id="save">Save&lt;/button>
59 &lt;/body>
60 &lt;/html>
61 </pre>
62 <h2>Important notes</h2>
63 <ul>
64 <li>We plan on providing some default css styles to encourage a consistent look across different extensions' options pages. You can star <a href="http://crbug.c om/25317">crbug.com/25317</a> to be notified of updates.</li>
65 </ul>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698