aboutsummaryrefslogtreecommitdiffstats
path: root/pages
diff options
context:
space:
mode:
authormrmr19932015-05-28 22:22:40 +0100
committermrmr19932015-06-10 17:21:22 +0100
commit91077b021e24f5ed6a8505e4e2afb97cdc2cbbb0 (patch)
treeba06aa6626669158d06524bf968b40db8dc07bef /pages
parent85aa76ec68167ea0ac08cc627b3f12e1077b1b1f (diff)
downloadvimium-91077b021e24f5ed6a8505e4e2afb97cdc2cbbb0.tar.bz2
Make all find mode updates go via the HUD in preparation to use an input
Diffstat (limited to 'pages')
-rw-r--r--pages/hud.coffee28
1 files changed, 14 insertions, 14 deletions
diff --git a/pages/hud.coffee b/pages/hud.coffee
index a1eef836..3f8eaa93 100644
--- a/pages/hud.coffee
+++ b/pages/hud.coffee
@@ -15,26 +15,26 @@ handlers =
hud.innerText = "/"
inputElement = document.createElement "span"
- inputElement.innerText = data.text
+ inputElement.textContent = data.text
inputElement.id = "hud-find-input"
hud.appendChild inputElement
- updateMatchesCount: ({matchCount, showMatchText}) ->
- inputElement = document.getElementById "hud-find-input"
- return unless inputElement? # Don't do anything if we're not in find mode.
- nodeAfter = inputElement.nextSibling # The node containing the old match text.
+ countElement = document.createElement "span"
+ countElement.id = "hud-match-count"
+ hud.appendChild countElement
- if showMatchText
- plural = if matchCount == 1 then "" else "es"
- countText = if matchCount > 0
- " (" + matchCount + " Match#{plural})"
- else
- " (No matches)"
+ UIComponentServer.postMessage {name: "search", query: inputElement.textContent}
- # Replace the old count (if there was one) with the new one.
- document.getElementById("hud").insertBefore document.createTextNode(countText), nodeAfter
+ updateMatchesCount: ({matchCount, showMatchText}) ->
+ countElement = document.getElementById "hud-match-count"
+ return unless countElement? # Don't do anything if we're not in find mode.
- nodeAfter?.remove() # Remove the old match text.
+ plural = if matchCount == 1 then "" else "es"
+ countText = if matchCount > 0
+ " (" + matchCount + " Match#{plural})"
+ else
+ " (No matches)"
+ countElement.textContent = if showMatchText then countText else ""
UIComponentServer.registerHandler (event) ->
{data} = event