diff options
Diffstat (limited to 'options')
| -rw-r--r-- | options/options.coffee | 109 | ||||
| -rw-r--r-- | options/options.html | 357 |
2 files changed, 0 insertions, 466 deletions
diff --git a/options/options.coffee b/options/options.coffee deleted file mode 100644 index abe3fee7..00000000 --- a/options/options.coffee +++ /dev/null @@ -1,109 +0,0 @@ -$ = (id) -> document.getElementById id - -bgSettings = chrome.extension.getBackgroundPage().Settings - -editableFields = [ "scrollStepSize", "excludedUrls", "linkHintCharacters", "linkHintNumbers", - "userDefinedLinkHintCss", "keyMappings", "filterLinkHints", "previousPatterns", - "nextPatterns", "hideHud", "regexFindMode", "searchUrl"] - -canBeEmptyFields = ["excludedUrls", "keyMappings", "userDefinedLinkHintCss"] - -postSaveHooks = keyMappings: (value) -> - commands = chrome.extension.getBackgroundPage().Commands - commands.clearKeyMappingsAndSetDefaults() - commands.parseCustomKeyMappings value - chrome.extension.getBackgroundPage().refreshCompletionKeysAfterMappingSave() - -document.addEventListener "DOMContentLoaded", -> - populateOptions() - - for field in editableFields - $(field).addEventListener "keyup", onOptionKeyup, false - $(field).addEventListener "change", enableSaveButton, false - $(field).addEventListener "change", onDataLoaded, false - - $("advancedOptionsLink").addEventListener "click", toggleAdvancedOptions, false - $("showCommands").addEventListener "click", (-> - showHelpDialog chrome.extension.getBackgroundPage().helpDialogHtml(true, true, "Command Listing"), frameId - ), false - document.getElementById("restoreSettings").addEventListener "click", restoreToDefaults - document.getElementById("saveOptions").addEventListener "click", saveOptions - -window.onbeforeunload = -> "You have unsaved changes to options." unless $("saveOptions").disabled - -onOptionKeyup = (event) -> - if (event.target.getAttribute("type") isnt "checkbox" and - event.target.getAttribute("savedValue") isnt event.target.value) - enableSaveButton() - -onDataLoaded = -> - hide = (el) -> el.parentNode.parentNode.style.display = "none" - show = (el) -> el.parentNode.parentNode.style.display = "table-row" - if $("filterLinkHints").checked - hide $("linkHintCharacters") - show $("linkHintNumbers") - else - show $("linkHintCharacters") - hide $("linkHintNumbers") - -enableSaveButton = -> - $("saveOptions").removeAttribute "disabled" - -# Saves options to localStorage. -saveOptions = -> - - # If the value is unchanged from the default, delete the preference from localStorage; this gives us - # the freedom to change the defaults in the future. - for fieldName in editableFields - field = $(fieldName) - switch field.getAttribute("type") - when "checkbox" - fieldValue = field.checked - when "number" - fieldValue = parseFloat field.value - else - fieldValue = field.value.trim() - field.value = fieldValue - - # If it's empty and not a field that we allow to be empty, restore to the default value - if not fieldValue and canBeEmptyFields.indexOf(fieldName) is -1 - bgSettings.clear fieldName - fieldValue = bgSettings.get(fieldName) - else - bgSettings.set fieldName, fieldValue - $(fieldName).value = fieldValue - $(fieldName).setAttribute "savedValue", fieldValue - postSaveHooks[fieldName] fieldValue if postSaveHooks[fieldName] - - $("saveOptions").disabled = true - -# Restores select box state to saved value from localStorage. -populateOptions = -> - for field in editableFields - val = bgSettings.get(field) or "" - setFieldValue $(field), val - onDataLoaded() - -restoreToDefaults = -> - for field in editableFields - val = bgSettings.defaults[field] or "" - setFieldValue $(field), val - onDataLoaded() - enableSaveButton() - -setFieldValue = (field, value) -> - unless field.getAttribute("type") is "checkbox" - field.value = value - field.setAttribute "savedValue", value - else - field.checked = value - -toggleAdvancedOptions = do (advancedMode=false) -> (event) -> - if advancedMode - $("advancedOptions").style.display = "table-row-group" - $("advancedOptionsLink").innerHTML = "Show advanced options…" - else - $("advancedOptions").style.display = "table-row-group" - $("advancedOptionsLink").innerHTML = "Hide advanced options" - advancedMode = !advancedMode - event.preventDefault() diff --git a/options/options.html b/options/options.html deleted file mode 100644 index f6059618..00000000 --- a/options/options.html +++ /dev/null @@ -1,357 +0,0 @@ -<html> - <head> - <title>Vimium Options</title> - <script src="../lib/utils.js"></script> - <script src="../lib/keyboard_utils.js"></script> - <script src="../lib/dom_utils.js"></script> - <script src="../lib/handler_stack.js"></script> - <script src="../lib/clipboard.js"></script> - <script src="../content_scripts/link_hints.js"></script> - <script src="../content_scripts/vomnibar.js"></script> - <script src="../content_scripts/scroller.js"></script> - <script src="../content_scripts/vimium_frontend.js"></script> - <style type="text/css" media="screen"> - body { - font: 14px "DejaVu Sans", "Arial", sans-serif; - color: #303942; - width: 680px; - margin: 0 auto; - } - a, a:visited { color: #15c; } - a:active { color: #052577; } - div#wrapper { width: 500px; } - header { - font-size: 18px; - font-weight: normal; - border-bottom: 1px solid #eee; - padding: 20px 0 15px 0; - width: 100%; - } - button { - -webkit-user-select: none; - -webkit-appearance: none; - background-image: -webkit-linear-gradient(#ededed, #ededed 38%, #dedede); - border: 1px solid rgba(0, 0, 0, 0.25); - border-radius: 2px; - box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08), inset 0 1px 2px rgba(255, 255, 255, 0.75); - color: #444; - font: inherit; - text-shadow: 0 1px 0 #f0f0f0; - height: 24px; - font-size: 12px; - padding: 0 10px; - } - button:hover { - background-image: -webkit-linear-gradient(#f0f0f0, #f0f0f0 38%, #e0e0e0); - border-color: rgba(0, 0, 0, 0.3); - box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12), inset 0 1px 2px rgba(255, 255, 255, 0.95); - color: black; - } - button:active { - background-image: -webkit-linear-gradient(#e7e7e7, #e7e7e7 38%, #d7d7d7); - box-shadow: none; - text-shadow: none; - } - button[disabled], button[disabled]:hover, button[disabled]:active { - background-image: -webkit-linear-gradient(#ededed, #ededed 38%, #dedede); - border: 1px solid rgba(0, 0, 0, 0.25); - box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08), inset 0 1px 2px rgba(255, 255, 255, 0.75); - text-shadow: 0 1px 0 #f0f0f0; - color: #888; - } - input[type="checkbox"] { - -webkit-user-select: none; - } - label:hover { - color: black; - } - pre, code, .code { - font-family: Consolas, "Liberation Mono", Courier, monospace; - } - pre { - margin: 5px; - border-left: 1px solid #eee; - padding-left: 5px; - - } - input, textarea { - box-sizing: border-box; - } - textarea { - /* Horizontal resizing is pretty screwy-looking. */ - resize: vertical; - } - table#options{ - width: 100%; - font-size: 14px; - position: relative; - border-spacing: 0 23px; - } - .example { - font-size: 12px; - line-height: 16px; - color: #979ca0; - margin-left: 20px; - } - .caption { - margin-right: 10px; - min-width: 130px; - } - td { padding: 0; } - div#exampleKeyMapping { - margin-left: 10px; - margin-top: 5px; - } - input#linkHintCharacters { - width: 160px; - } - input#scrollStepSize { - width: 40px; - margin-right: 3px; - } - textarea#excludedUrls { - margin-top: 5px; - width: 100%; - min-height: 100px; - } - textarea#userDefinedLinkHintCss { - width: 100%;; - min-height: 100px; - } - textarea#keyMappings { - width: 100%; - min-height: 135px; - } - input#previousPatterns, input#nextPatterns { - width: 100%; - } - input#searchUrl { - width: 100%; - } - #status { - margin-left: 10px; - font-size: 80%; - } - /* Make the caption in the settings table as small as possible, to pull the other fields to the right. */ - td:first-child { - width: 1px; - white-space: nowrap; - } - #buttonsPanel { width: 100%; } - #advancedOptions { display: none; } - #advancedOptionsLink { line-height: 24px; } - #buttonContainer { float: right; } - #buttonContainer button:last-child { - margin-right: 0; - } - #showHelpDialogMessage { width: 100%; } - .help { - position: absolute; - right: -320px; - width: 320px; - } - input:read-only { - background-color: #eee; - color: #666; - pointer-events: none; - -webkit-user-select: none; - } - input[type="text"], textarea { - border: 1px solid #bfbfbf; - border-radius: 2px; - color: #444; - font: inherit; - padding: 3px; - } - button:focus, input[type="text"]:focus, textarea:focus { - -webkit-transition: border-color 200ms; - border-color: #4d90fe; - outline: none; - } - /* Boolean options have a tighter form representation than text options. */ - td.booleanOption { font-size: 12px; } - footer { - padding: 15px 0; - border-top: 1px solid #eee; - } - </style> - <link rel="stylesheet" type="text/css" href="../vimium.css" /> - - <script type="text/javascript" src="options.js"></script> - - </head> - - <body> - <div id="wrapper"> - <header>Vimium options</header> - <table id="options"> - <tr> - <td class="caption">Scroll step size</td> - <td> - <input id="scrollStepSize" type="number" />px - </td> - </tr> - <tr> - <td colspan="3"> - Excluded URLs<br/> - <div class="help"> - <div class="example"> - e.g. http*://mail.google.com/*<br/> - This will disable Vimium on Gmail.<br/><br/> - Enter one URL per line.<br/> - </div> - </div> - <textarea id="excludedUrls"></textarea> - </td> - </tr> - <tbody id='advancedOptions'> - <tr> - <td class="caption">Custom key<br/>mappings</td> - <td id="mappingsHelp" verticalAlign="top"> - <div class="help"> - <div class="example"> - <!-- TODO(ilya/philc): Expand this and style it better. --> - Enter commands to remap your keys. Available commands:<br/> - <pre id="exampleKeyMapping"> -map j scrollDown -unmap j -unmapAll -" this is a comment -# this is also a comment</pre> - <a href="#" id="showCommands">Show available commands.</a> - </div> - </div> - <textarea id="keyMappings" type="text"></textarea> - </td> - </tr> - <tr> - <td class="caption">CSS for link hints</td> - <td verticalAlign="top"> - <div class="help"> - <div class="example"> - The CSS used to style the characters next to each link hint.<br/><br/> - Note: these styles are used in addition to and take precedence over Vimium's - default styles. - </div> - </div> - <textarea id="userDefinedLinkHintCss" class="code" type="text"></textarea> - </td> - </tr> - <tr> - <td class="caption">Characters used<br/> for link hints</td> - <td verticalAlign="top"> - <div class="help"> - <div class="example"> - The characters placed next to each link after typing "F" to enter link hinting mode. - </div> - </div> - <input id="linkHintCharacters" type="text" /> - </td> - </tr> - <tr> - <td class="caption">Numbers used<br/> for filtered link hints</td> - <td verticalAlign="top"> - <div class="help"> - <div class="example"> - The numbers placed next to each link after typing "F" to enter link hinting mode. - </div> - </div> - <input id="linkHintNumbers" type="text" /> - </td> - </tr> - <tr> - <td class="caption"></td> - <td verticalAlign="top" class="booleanOption"> - <div class="help"> - <div class="example"> - After typing "F" to enter link hinting mode, this option lets you type the text of a link - to select it. - </div> - </div> - <label> - <input id="filterLinkHints" type="checkbox"/> - Use the link's name and numbers for link hint filtering - </label> - </td> - </tr> - <tr> - <td class="caption"></td> - <td verticalAlign="top" class="booleanOption"> - <div class="help"> - <div class="example"> - The Heads-Up Display appears when typing into text boxes. - </div> - </div> - <label> - <input id="hideHud" type="checkbox"/> - Hide the Heads Up Display (HUD) - </label> - </td> - </tr> - <tr> - <td class="caption"></td> - <td verticalAlign="top" class="booleanOption"> - <div class="help"> - <div class="example"> - Switch back to plain find mode by using the <code>\R</code> escape sequence. - </div> - </div> - <label> - <input id="regexFindMode" type="checkbox"/> - Treat find queries as regular expressions. - </label> - </td> - </tr> - <tr> - <td class="caption">Previous Patterns</td> - <td verticalAlign="top"> - <div class="help"> - <div class="example"> - Vimium will match against these patterns when using the "navigate to the previous page" - command. - </div> - </div> - <input id="previousPatterns" type="text" /> - </td> - </tr> - <tr> - <td class="caption">Next Patterns</td> - <td verticalAlign="top"> - <div class="help"> - <div class="example"> - Vimium will match against these patterns when using the "navigate to the next page" command. - </div> - </div> - <input id="nextPatterns" type="text" /> - </td> - </tr> - <tr> - <td class="caption">Search</td> - <td verticalAlign="top"> - <div class="help"> - <div class="example"> - Set which search engine is used when searching from the Vomnibar (examples: "http://duckduckgo.com/?q=", "http://www.google.com/search?q="). - </div> - </div> - <input id="searchUrl" type="text" /> - </td> - </tr> - </tbody> - </table> - - <div id="buttonsPanel"> - <a href="#" id="advancedOptionsLink">Show advanced options…</a> - <div id="buttonContainer"> - <button id="restoreSettings">Restore to Defaults</button> - <button id="saveOptions" disabled="true">Save Options</button> - </div> - </div> - - <br/> - - <footer id="showHelpDialogMessage"> - To view all available shortcuts, type <strong>?</strong> to show the Vimium help dialog. - </footer> - </div> - </body> -</html> |
