diff options
| author | Jez Ng | 2012-08-20 00:45:01 -0700 |
|---|---|---|
| committer | Jez Ng | 2012-08-21 00:25:29 -0700 |
| commit | 3cbe7758d7ca4cfac70c931c4c3fa58c50841d90 (patch) | |
| tree | 99f7b46a18bccbc2f2c129d6e9d6cd7e1a475826 | |
| parent | 872e8391feda36642d36a4c0813bcb053d808fd3 (diff) | |
| download | vimium-3cbe7758d7ca4cfac70c931c4c3fa58c50841d90.tar.bz2 | |
Style input hints as number-less overlays.
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 39 | ||||
| -rw-r--r-- | vimium.css | 27 |
2 files changed, 42 insertions, 24 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 5d31b67a..3f73919b 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -301,12 +301,13 @@ extend window, HUD.showForDuration("Yanked URL", 1000) focusInput: (count) -> - xpathResult = DomUtils.evaluateXPath(textInputXPath, XPathResult.ORDERED_NODE_ITERATOR_TYPE) + resultSet = DomUtils.evaluateXPath(textInputXPath, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE) visibleInputs = - while (currentInputBox = xpathResult.iterateNext()) - rect = DomUtils.getVisibleClientRect(currentInputBox) + for i in [0...resultSet.snapshotLength] by 1 + element = resultSet.snapshotItem(i) + rect = DomUtils.getVisibleClientRect(element) continue if rect == null - { element: currentInputBox, rect: rect } + { element: element, rect: rect } return if visibleInputs.length == 0 @@ -316,28 +317,36 @@ extend window, return if visibleInputs.length == 1 - hintMarkers = (LinkHints.createMarkerFor(el) for el in visibleInputs) + hints = for tuple in visibleInputs + hint = document.createElement("div") + hint.className = "vimiumReset internalVimiumInputHint vimiumInputHint" - hintMarkers[0].classList.add 'internalVimiumSelectedHintMarker' + # minus 1 for the border + hint.style.left = (tuple.rect.left - 1) + window.scrollX + "px" + hint.style.top = (tuple.rect.top - 1) + window.scrollY + "px" + hint.style.width = tuple.rect.width + "px" + hint.style.height = tuple.rect.height + "px" - for marker, idx in hintMarkers - marker.innerHTML = "<span>#{idx + 1}</span>" + hint - hintMarkerContainingDiv = LinkHints.displayHints(hintMarkers) + hints[0].classList.add 'internalVimiumSelectedInputHint' + + hintContainingDiv = DomUtils.addElementList(hints, + { id: "vimiumInputMarkerContainer", className: "vimiumReset" }) handlerStack.push keydown: (event) -> if event.keyCode == KeyboardUtils.keyCodes.tab - hintMarkers[selectedInputIndex].classList.remove 'internalVimiumSelectedHintMarker' + hints[selectedInputIndex].classList.remove 'internalVimiumSelectedInputHint' if event.shiftKey if --selectedInputIndex == -1 - selectedInputIndex = hintMarkers.length - 1 + selectedInputIndex = hints.length - 1 else - if ++selectedInputIndex == hintMarkers.length + if ++selectedInputIndex == hints.length selectedInputIndex = 0 - hintMarkers[selectedInputIndex].classList.add 'internalVimiumSelectedHintMarker' - hintMarkers[selectedInputIndex].clickableItem.focus() + hints[selectedInputIndex].classList.add 'internalVimiumSelectedInputHint' + visibleInputs[selectedInputIndex].element.focus() else unless event.keyCode == KeyboardUtils.keyCodes.shiftKey - DomUtils.removeElement hintMarkerContainingDiv + DomUtils.removeElement hintContainingDiv handlerStack.pop() # @@ -74,15 +74,6 @@ div.internalVimiumHintMarker { box-shadow: 0px 3px 7px 0px rgba(0, 0, 0, 0.3); } -div.internalVimiumSelectedHintMarker { - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#FF6666), color-stop(100%,#FF3333)) !important; - border: solid 1px #993333 !important; -} - -div.internalVimiumSelectedHintMarker span { - color: white !important; -} - div.internalVimiumHintMarker span { color: #302505; font-family: Helvetica, Arial, sans-serif; @@ -95,6 +86,24 @@ div.internalVimiumHintMarker > .matchingCharacter { color: #D4AC3A; } +/* Input hints CSS */ + +div.internalVimiumInputHint { + position: absolute; + display: block; + background-color: rgba(255, 247, 133, 0.3); + border: solid 1px #C38A22; +} + +div.internalVimiumSelectedInputHint { + background-color: rgba(255, 102, 102, 0.3); + border: solid 1px #993333 !important; +} + +div.internalVimiumSelectedInputHint span { + color: white !important; +} + /* Help Dialog CSS */ div#vimiumHelpDialog { |
