diff options
| -rw-r--r-- | background_scripts/commands.coffee | 6 | ||||
| -rw-r--r-- | background_scripts/completion.coffee | 4 | ||||
| -rw-r--r-- | background_scripts/main.coffee | 26 | ||||
| -rw-r--r-- | content_scripts/link_hints.coffee | 22 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 14 | ||||
| -rw-r--r-- | content_scripts/vomnibar.coffee | 1 | ||||
| -rw-r--r-- | lib/dom_utils.coffee | 3 | ||||
| -rw-r--r-- | test_harnesses/automated/automated.coffee | 19 |
8 files changed, 50 insertions, 45 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index e3001f4f..69c37ac4 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -43,9 +43,9 @@ Commands = # On the other hand, <c-a> and <c-A> are different named keys - for one of # them you have to press "shift" as well. normalizeKey: (key) -> - key.replace(/<[acm]-/ig, (match) -> match.toLowerCase()) - .replace(/<([acm]-)?([a-zA-Z0-9]{2,5})>/g, (match, optionalPrefix, keyName) -> - "<" + (if optionalPrefix then optionalPrefix else "") + keyName.toLowerCase() + ">") + key.replace(/<[acm]-/ig, (match) -> match.toLowerCase()) + .replace(/<([acm]-)?([a-zA-Z0-9]{2,5})>/g, (match, optionalPrefix, keyName) -> + "<" + (if optionalPrefix then optionalPrefix else "") + keyName.toLowerCase() + ">") parseCustomKeyMappings: (customKeyMappings) -> lines = customKeyMappings.split("\n") diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 5920db0b..5539f7c7 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -26,7 +26,7 @@ class Suggestion generateHtml: -> return @html if @html - relevancyHtml = if @showRelevancy then "<span class='relevancy'>#{@computeRelevancy() + ''}</span>" else "" + relevancyHtml = if @showRelevancy then "<span class='relevancy'>#{@computeRelevancy()}</span>" else "" # NOTE(philc): We're using these vimium-specific class names so we don't collide with the page's CSS. @html = "<div class='vimiumReset vomnibarTopHalf'> @@ -90,7 +90,7 @@ class BookmarkCompleter performSearch: -> results = @bookmarks.filter (bookmark) => - RankingUtils.matches(@currentSearch.queryTerms, bookmark.url, bookmark.title) + RankingUtils.matches(@currentSearch.queryTerms, bookmark.url, bookmark.title) suggestions = results.map (bookmark) => new Suggestion(@currentSearch.queryTerms, "bookmark", bookmark.url, bookmark.title, @computeRelevancy) onComplete = @currentSearch.onComplete diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 707febc9..5ae80235 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -265,17 +265,17 @@ selectTab = (callback, direction) -> chrome.tabs.getAllInWindow(null, (tabs) -> return unless tabs.length > 1 chrome.tabs.getSelected(null, (currentTab) -> - switch direction - when "next" - toSelect = tabs[(currentTab.index + 1 + tabs.length) % tabs.length] - when "previous" - toSelect = tabs[(currentTab.index - 1 + tabs.length) % tabs.length] - when "first" - toSelect = tabs[0] - when "last" - toSelect = tabs[tabs.length - 1] - selectionChangedHandlers.push(callback) - chrome.tabs.update(toSelect.id, { selected: true }))) + switch direction + when "next" + toSelect = tabs[(currentTab.index + 1 + tabs.length) % tabs.length] + when "previous" + toSelect = tabs[(currentTab.index - 1 + tabs.length) % tabs.length] + when "first" + toSelect = tabs[0] + when "last" + toSelect = tabs[tabs.length - 1] + selectionChangedHandlers.push(callback) + chrome.tabs.update(toSelect.id, { selected: true }))) updateOpenTabs = (tab) -> openTabs[tab.id] = { url: tab.url, positionIndex: tab.index, windowId: tab.windowId } @@ -367,7 +367,7 @@ updatePositionsAndWindowsForAllTabsInWindow = (windowId) -> splitKeyIntoFirstAndSecond = (key) -> if (key.search(namedKeyRegex) == 0) - { first: RegExp.$1, second: RegExp.$2 } + { first: RegExp.$1, second: RegExp.$2 } else { first: key[0], second: key.slice(1) } @@ -409,7 +409,7 @@ generateCompletionKeys = (keysToCheck) -> for key of Commands.keyToCommandRegistry splitKey = splitKeyIntoFirstAndSecond(key) if (splitKey.first == command) - completionKeys.push(splitKey.second) + completionKeys.push(splitKey.second) completionKeys diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 1d5d668a..831408e2 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -34,10 +34,10 @@ LinkHints = # We use translate() instead of lower-case() because Chrome only supports XPath 1.0. # clickableElementsXPath: DomUtils.makeXPath( - ["a", "area[@href]", "textarea", "button", "select", - "input[not(@type='hidden' or @disabled or @readonly)]", - "*[@onclick or @tabindex or @role='link' or @role='button' or contains(@class, 'button') or " + - "@contenteditable='' or translate(@contenteditable, 'TRUE', 'true')='true']"]) + ["a", "area[@href]", "textarea", "button", "select", + "input[not(@type='hidden' or @disabled or @readonly)]", + "*[@onclick or @tabindex or @role='link' or @role='button' or contains(@class, 'button') or " + + "@contenteditable='' or translate(@contenteditable, 'TRUE', 'true')='true']"]) # We need this as a top-level function because our command system doesn't yet support arguments. activateModeToOpenInNewTab: -> @activateMode(true, false, false) @@ -80,8 +80,8 @@ LinkHints = else if (withQueue) HUD.show("Open multiple links in a new tab") @linkActivator = (link) -> - # When "clicking" on a link, dispatch the event with the appropriate meta key (CMD on Mac, CTRL on windows) - # to open it in a new tab if necessary. + # When "clicking" on a link, dispatch the event with the appropriate meta key (CMD on Mac, CTRL on + # windows) to open it in a new tab if necessary. DomUtils.simulateClick(link, { metaKey: KeyboardUtils.platform == "Mac", ctrlKey: KeyboardUtils.platform != "Mac" }) @@ -211,7 +211,7 @@ LinkHints = # showMarker: (linkMarker, matchingCharCount) -> linkMarker.style.display = "" - # TODO(philc): + # TODO(philc): for j in [0...linkMarker.childNodes.length] if (j < matchingCharCount) linkMarker.childNodes[j].classList.add("matchingCharacter") @@ -269,8 +269,8 @@ alphabetHints = digitsNeeded = Math.ceil(@logXOfBase(linkCount, linkHintCharacters.length)) # Short hints are the number of hints we can possibly show which are (digitsNeeded - 1) digits in length. shortHintCount = Math.floor( - (Math.pow(linkHintCharacters.length, digitsNeeded) - linkCount) / - linkHintCharacters.length) + (Math.pow(linkHintCharacters.length, digitsNeeded) - linkCount) / + linkHintCharacters.length) longHintCount = linkCount - shortHintCount hintStrings = [] @@ -299,8 +299,8 @@ alphabetHints = result # - # Converts a number like "8" into a hint string like "JK". This is used to sequentially generate all of - # the hint text. The hint string will be "padded with zeroes" to ensure its length is equal to numHintDigits. + # Converts a number like "8" into a hint string like "JK". This is used to sequentially generate all of the + # hint text. The hint string will be "padded with zeroes" to ensure its length is equal to numHintDigits. # numberToHintString: (number, numHintDigits, characterSet) -> base = characterSet.length diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index ab3b1fbf..adec11c5 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -295,8 +295,8 @@ extend window, chrome.extension.sendRequest({ handler: "openUrlInNewTab", url: url, selected: true }) copyCurrentUrl: -> - # TODO(ilya): When the following bug is fixed, revisit this approach of sending back to the background page - # to copy. + # TODO(ilya): When the following bug is fixed, revisit this approach of sending back to the background + # page to copy. # http://code.google.com/p/chromium/issues/detail?id=55188 chrome.extension.sendRequest { handler: "getCurrentTabUrl" }, (url) -> chrome.extension.sendRequest { handler: "copyToClipboard", data: url } @@ -895,9 +895,9 @@ window.showHelpDialog = (html, fid) -> this.dialogElement.style.maxHeight = window.innerHeight - 80 this.showAdvancedCommands(this.getShowAdvancedCommands()) - # + # # Advanced commands are hidden by default so they don't overwhelm new and casual users. - # + # toggleAdvancedCommands: (event) -> event.preventDefault() showAdvanced = VimiumHelpDialog.getShowAdvancedCommands() @@ -958,9 +958,9 @@ HUD = HUD.displayElement().style.display = "" showUpgradeNotification: (version) -> - HUD.upgradeNotificationElement().innerHTML = "Vimium has been updated to " + - "<a class='vimiumReset' href='https://chrome.google.com/extensions/detail/dbepggeogbaibhgnhhndojpepiihcmeb'>" + - version + "</a>.<a class='vimiumReset close-button' href='#'>x</a>" + HUD.upgradeNotificationElement().innerHTML = "Vimium has been updated to + <a class='vimiumReset' href='https://chrome.google.com/extensions/detail/dbepggeogbaibhgnhhndojpepiihcmeb'> + #{version}</a>.<a class='vimiumReset close-button' href='#'>x</a>" links = HUD.upgradeNotificationElement().getElementsByTagName("a") links[0].addEventListener("click", HUD.onUpdateLinkClicked, false) links[1].addEventListener "click", (event) -> diff --git a/content_scripts/vomnibar.coffee b/content_scripts/vomnibar.coffee index 9c1e7a31..1b2af1c4 100644 --- a/content_scripts/vomnibar.coffee +++ b/content_scripts/vomnibar.coffee @@ -172,7 +172,6 @@ class VomnibarUI @input = document.querySelector("#vomnibar input") @input.addEventListener "input", => @update() - console.log("@input:", @input); @completionList = document.querySelector("#vomnibar ul") @completionList.style.display = "none" diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index d4a4d379..e7fa9c2f 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -85,7 +85,8 @@ DomUtils = if (clientRect.width == 0 || clientRect.height == 0) for child in element.children computedStyle = window.getComputedStyle(child, null) - # Ignore child elements which are not floated and not absolutely positioned for parent elements with zero width/height + # Ignore child elements which are not floated and not absolutely positioned for parent elements with + # zero width/height if (computedStyle.getPropertyValue('float') == 'none' && computedStyle.getPropertyValue('position') != 'absolute') continue childClientRect = @getVisibleClientRect(child) diff --git a/test_harnesses/automated/automated.coffee b/test_harnesses/automated/automated.coffee index b5e5af35..283e8004 100644 --- a/test_harnesses/automated/automated.coffee +++ b/test_harnesses/automated/automated.coffee @@ -2,7 +2,7 @@ # Dispatching keyboard events via the DOM would require async tests, # which tend to be more complicated. Here we create mock events and # invoke the handlers directly. -# +# mockKeyboardEvent = (keyChar) -> event = {} event.charCode = (if keyCodes[keyChar] isnt undefined then keyCodes[keyChar] else keyChar.charCodeAt(0)) @@ -14,14 +14,14 @@ mockKeyboardEvent = (keyChar) -> # # Retrieve the hint markers as an array object. -# +# getHintMarkers = -> Array::slice.call document.getElementsByClassName("vimiumHintMarker"), 0 # # Generate tests that are common to both default and filtered # link hinting modes. -# +# createGeneralHintTests = (isFilteredMode) -> context "Link hints", @@ -124,7 +124,8 @@ context "Filtered link hints", context "Image hints", setup -> - testContent = "<a><img alt='alt text'/></a>" + "<a><img alt='alt text' title='some title'/></a>" + "<a><img title='some title'/></a>" + "<a><img src='' width='320px' height='100px'/></a>" + testContent = "<a><img alt='alt text'/></a><a><img alt='alt text' title='some title'/></a> + <a><img title='some title'/></a>" + "<a><img src='' width='320px' height='100px'/></a>" document.getElementById("test-div").innerHTML = testContent LinkHints.activateMode() @@ -142,7 +143,10 @@ context "Filtered link hints", context "Input hints", setup -> - testContent = "<input type='text' value='some value'/>" + "<input type='password' value='some value'/>" + "<textarea>some text</textarea>" + "<label for='test-input'/>a label</label><input type='text' id='test-input' value='some value'/>" + "<label for='test-input-2'/>a label: </label><input type='text' id='test-input-2' value='some value'/>" + testContent = "<input type='text' value='some value'/><input type='password' value='some value'/> + <textarea>some text</textarea><label for='test-input'/>a label</label> + <input type='text' id='test-input' value='some value'/> + <label for='test-input-2'/>a label: </label><input type='text' id='test-input-2' value='some value'/>" document.getElementById("test-div").innerHTML = testContent LinkHints.activateMode() @@ -161,7 +165,8 @@ context "Filtered link hints", context "Input focus", setup -> - testContent = "<input type='text' id='first'/>" + "<input style='display:none;' id='second'/>" + "<input type='password' id='third' value='some value'/>" + testContent = "<input type='text' id='first'/><input style='display:none;' id='second'/> + <input type='password' id='third' value='some value'/>" document.getElementById("test-div").innerHTML = testContent tearDown -> @@ -182,7 +187,7 @@ Tests.outputMethod = (args...) -> # escape html newOutput = newOutput.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">") # highlight the source of the error - newOutput = newOutput.replace(/\/([^:/]+):([0-9]+):([0-9]+)/, "/<span class='errorPosition'>$1:$2</span>:$3") + newOutput = newOutput.replace /\/([^:/]+):([0-9]+):([0-9]+)/, "/<span class='errorPosition'>$1:$2</span>:$3" document.getElementById("output-div").innerHTML += "<div class='output-section'>" + newOutput + "</div>" console.log.apply console, args |
