| Index: chrome/test/data/extensions/subscribe_page_action/options.js
|
| ===================================================================
|
| --- chrome/test/data/extensions/subscribe_page_action/options.js (revision 137495)
|
| +++ chrome/test/data/extensions/subscribe_page_action/options.js (working copy)
|
| @@ -1,128 +1,19 @@
|
| -<!--
|
| - * Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
|
| +/*
|
| + * Copyright (c) 2012 The Chromium Authors. All rights reserved. Use of this
|
| * source code is governed by a BSD-style license that can be found in the
|
| * LICENSE file.
|
| --->
|
| -<html>
|
| -<head>
|
| -<title></title>
|
| -<link rel="stylesheet" href="style.css" type="text/css" />
|
| -<style>
|
| -body {
|
| - display:-webkit-box;
|
| - -webkit-box-orient:vertical;
|
| -}
|
| + */
|
|
|
| -body>* {
|
| - display:-webkit-box;
|
| -}
|
| +// Various text messages within the edit dialog.
|
| +var assistText = chrome.i18n.getMessage("rss_subscription_feed_url_assist");
|
|
|
| -#dialogBackground {
|
| - background-color: rgba(0, 0, 0, .2);
|
| - display: none;
|
| - height: 100%;
|
| - left: 0;
|
| - position: fixed;
|
| - top: 0;
|
| - width: 100%;
|
| - z-index: 1;
|
| - -webkit-box-orient: vertical;
|
| - -webkit-user-select:none;
|
| -}
|
| +// Specifies the index of the item we are editing or -1 if adding new.
|
| +var editingIndex = -1;
|
| +// Whether we are currently editing the default item.
|
| +var editingDefault = false;
|
|
|
| -#dialogHBackground {
|
| - height: 100%;
|
| - -webkit-box-orient: horizontal;
|
| -}
|
| -
|
| -#dialog {
|
| - background-color: #5296DE;
|
| - border: 1px solid #3A75BD;
|
| - border-radius: 6px 6px;
|
| - font-size: 12px;
|
| - width: 355px;
|
| - -webkit-box-orient: vertical;
|
| -}
|
| -
|
| -#dialogHeader {
|
| - background-color: rgba(0,0,0,0);
|
| - color: white;
|
| - font-weight: bold;
|
| - margin: 4px;
|
| - width: 100%;
|
| -}
|
| -
|
| -#dialogBody {
|
| - background-color: rgb(240, 240, 240);
|
| - border: 1px solid #3A75BD;
|
| - border-bottom-left-radius: 4px 4px;
|
| - border-bottom-right-radius: 4px 4px;
|
| - margin: 0px 2px 2px 2px;
|
| - padding-bottom: 10px;
|
| - padding-right: 10px;
|
| - padding-top: 10px;
|
| - -webkit-box-orient: vertical;
|
| - width: 340px;
|
| -}
|
| -
|
| -#dialogBackground, #dialogBackground div {
|
| - display: -webkit-box;
|
| - -webkit-box-align: center;
|
| -}
|
| -
|
| -#dialog input[type="button"] {
|
| - font-size: 12px;
|
| - height: 25px;
|
| - width: 100px;
|
| -}
|
| -
|
| -#dialog input[type="text"] {
|
| - font-size: 12px;
|
| - font-family: Arial, Helvetica, sans-serif;
|
| - width: 220px;
|
| -}
|
| -
|
| -.dialogRow {
|
| - margin-left: -24px;
|
| - width: 100%;
|
| - -webkit-box-orient: horizontal;
|
| - -webkit-box-pack: end;
|
| -}
|
| -
|
| -.dialogRow>* {
|
| - margin: 2px
|
| -}
|
| -
|
| -#dialogContentFooter {
|
| - margin-bottom: 6px;
|
| - margin-left: -12px;
|
| - margin-top: 20px;
|
| - padding-right: 10px;
|
| -}
|
| -
|
| -.urlAssist {
|
| - padding-left: 30px;
|
| -}
|
| -
|
| -.status {
|
| - background-color: #FFF18A;
|
| -}
|
| -
|
| -</style>
|
| -<script type="text/javascript" src="common.js"></script>
|
| -<script>
|
| -
|
| - // Various text messages within the edit dialog.
|
| - var assistText = chrome.i18n.getMessage("rss_subscription_feed_url_assist");
|
| -
|
| - // Specifies the index of the item we are editing or -1 if adding new.
|
| - var editingIndex = -1;
|
| - // Whether we are currently editing the default item.
|
| - var editingDefault = false;
|
| -
|
| function main() {
|
| - document.title =
|
| - chrome.i18n.getMessage("rss_subscription_edit_dialog_title");
|
| + document.title = chrome.i18n.getMessage("rss_subscription_edit_dialog_title");
|
|
|
| // Make sure the dialog is not visible.
|
| document.getElementById('dialogBackground').style.display = "none";
|
| @@ -188,8 +79,7 @@
|
| }
|
|
|
| function resetList() {
|
| - if (!confirm(chrome.i18n.getMessage(
|
| - "rss_subscription_reset_list_confirm"))) {
|
| + if (!confirm(chrome.i18n.getMessage("rss_subscription_reset_list_confirm"))) {
|
| return;
|
| }
|
|
|
| @@ -256,8 +146,8 @@
|
| }
|
|
|
| /**
|
| -* Shows the Edit Feed Reader dialog.
|
| -*/
|
| + * Shows the Edit Feed Reader dialog.
|
| + */
|
| function showDialog() {
|
| document.getElementById('urlAssist').innerText = assistText;
|
| document.getElementById('save').disabled = true;
|
| @@ -267,32 +157,32 @@
|
| }
|
|
|
| /**
|
| -* Hides the Edit Feed Reader dialog.
|
| -*/
|
| + * Hides the Edit Feed Reader dialog.
|
| + */
|
| function hideDialog() {
|
| document.getElementById('dialogBackground').style.display = "none";
|
| }
|
|
|
| /**
|
| -* Validates the input in the form (making sure something is entered in both
|
| -* fields and that %s is not missing from the url field.
|
| -*/
|
| + * Validates the input in the form (making sure something is entered in both
|
| + * fields and that %s is not missing from the url field.
|
| + */
|
| function validateInput() {
|
| document.getElementById('statusMsg').innerText = "";
|
|
|
| var description = document.getElementById('descriptionText');
|
| var url = document.getElementById('urlText');
|
|
|
| - var valid = description.value.length > 0 &&
|
| - url.value.length > 0 &&
|
| - url.value.indexOf("%s") > -1;
|
| + var valid = (description.value.length > 0 &&
|
| + url.value.length > 0 &&
|
| + url.value.indexOf("%s") > -1);
|
|
|
| document.getElementById('save').disabled = !valid;
|
| }
|
|
|
| /**
|
| -* Handler for saving the values.
|
| -*/
|
| + * Handler for saving the values.
|
| + */
|
| function save() {
|
| // Get the old list.
|
| var feedReaderList = JSON.parse(window.localStorage.readerList);
|
| @@ -328,7 +218,12 @@
|
| main();
|
| }
|
|
|
| -function init() {
|
| +function listen(id, eventType, method) {
|
| + document.getElementById(id).addEventListener(eventType, method);
|
| +}
|
| +
|
| +document.addEventListener('DOMContentLoaded', function () {
|
| + // Localize.
|
| i18nReplace('rss_subscription_options');
|
| i18nReplaceImpl('addReader', 'rss_subscription_add_reader');
|
| i18nReplaceImpl('editReader', 'rss_subscription_edit_reader');
|
| @@ -342,98 +237,19 @@
|
| i18nReplaceImpl('save', 'rss_subscription_save_button', 'value');
|
| i18nReplaceImpl('rss_subscription_close_button',
|
| 'rss_subscription_close_button', 'value');
|
| - main();
|
| -}
|
| -</script>
|
| -</head>
|
| -<body onload="init()">
|
| - <table border="0">
|
| - <tr>
|
| - <td valign="top" width="16">
|
| - <img src="feed-icon-16x16.png" />
|
| - </td>
|
| - <td valign="middle">
|
| - <strong id="rss_subscription_options"></strong>
|
| - </td>
|
| - <td colspan="2">
|
| - </td>
|
| - </tr>
|
| - <tr>
|
| - <td colspan="2">
|
| - <select id="readerListbox" size="8" style="width:300;"
|
| - onchange="onSelectionChanged()"></select>
|
| - </td>
|
| - <td valign="top">
|
| - <button style="width:100%;" id="addReader" onclick="editReader(-1)"
|
| - ></button><br />
|
| - <button style="width:100%;" id="editReader" onclick="editReader(0)"
|
| - ></button><br />
|
| - <button style="width:100%;" id="removeReader" onclick="removeReader()"
|
| - ></button><br />
|
| - <button style="width:100%;" id="setDefault" onclick="setDefault()"
|
| - ></button><br />
|
| - <button style="width:100%;" id="resetList" onclick="resetList()"
|
| - ></button><br />
|
| - </td>
|
| - <td style="width: 200px;">
|
| - </td>
|
| - </tr>
|
| - <tr>
|
| - <td colspan="4">
|
| - <input type="checkbox" id="alwaysUseDefault"
|
| - value="alwaysUseDefault" onchange="toggleFeedPreview()"
|
| - ><span id="rss_subscription_always_use_default"></span>
|
| - </td>
|
| - </tr>
|
| - </table>
|
| + // Init event listeners.
|
| + listen('readerListbox', 'change', onSelectionChanged);
|
| + listen('addReader', 'click', function () { editReader(-1); });
|
| + listen('editReader', 'click', function () { editReader(0); });
|
| + listen('removeReader', 'click', removeReader);
|
| + listen('setDefault', 'click', setDefault);
|
| + listen('resetList', 'click', resetList);
|
| + listen('alwaysUseDefault', 'change', toggleFeedPreview);
|
| + listen('descriptionText', 'keyup', validateInput);
|
| + listen('urlText', 'keyup', validateInput);
|
| + listen('save', 'click', save);
|
| + listen('rss_subscription_close_button', 'click', hideDialog);
|
|
|
| - <div id="dialogBackground">
|
| - <div id="dialogHBackground">
|
| - <div id="dialog">
|
| -
|
| - <div id="dialogHeader"></div>
|
| -
|
| - <div id="dialogBody">
|
| -
|
| - <div class="dialogRow">
|
| - <div class="status" id="statusMsg"></div>
|
| - </div>
|
| -
|
| - <div class="dialogRow">
|
| - <div id="rss_subscription_feed_description"></div>
|
| - <div>
|
| - <input type="text" id="descriptionText" onkeyup="validateInput()">
|
| - </div>
|
| - </div>
|
| -
|
| - <div class="dialogRow">
|
| - <div id="rss_subscription_feed_url"></div>
|
| - <div>
|
| - <input type="text" id="urlText" onkeyup="validateInput()">
|
| - </div>
|
| - </div>
|
| -
|
| - <div class="dialogRow">
|
| - <div id="urlAssist" class="urlAssist"></div>
|
| - </div>
|
| -
|
| - <div class="dialogRow" id="dialogContentFooter">
|
| - <div>
|
| - <input type="button" id="save"
|
| - onclick="save()">
|
| - </div>
|
| - <div>
|
| - <input type="button"
|
| - id="rss_subscription_close_button"
|
| - onclick="hideDialog()">
|
| - </div>
|
| - </div>
|
| -
|
| - </div> <!-- /dialogBody -->
|
| -
|
| - </div>
|
| - </div>
|
| - </div>
|
| -
|
| -</body>
|
| -</html>
|
| + // Reload the values from scratch.
|
| + main();
|
| +});
|
|
|