diff options
| author | Ilya | 2011-05-06 11:02:39 -0700 | 
|---|---|---|
| committer | Ilya | 2011-05-06 11:02:39 -0700 | 
| commit | 9fa550086afb0e3bb944721f0422f60ec50b69b7 (patch) | |
| tree | 6d3b50850bb0e0a3401ec0a7f2d0e2994c7a9474 | |
| parent | b6261a10dd10f7b864b849e49c5cf1e5c02a2134 (diff) | |
| parent | 870183f4b2e755a9e4ae58194d1cd5d03579980b (diff) | |
| download | vimium-9fa550086afb0e3bb944721f0422f60ec50b69b7.tar.bz2 | |
Merge pull request #341 from mcantor/master
Make "gf" (nextFrame) work with count given (eg. 2gf)
| -rw-r--r-- | background_page.html | 38 | ||||
| -rw-r--r-- | commands.js | 2 | ||||
| -rw-r--r-- | vimiumFrontend.js | 6 | 
3 files changed, 28 insertions, 18 deletions
| diff --git a/background_page.html b/background_page.html index 4763c0d6..5849bde3 100644 --- a/background_page.html +++ b/background_page.html @@ -369,6 +369,8 @@    function updateOpenTabs(tab) {      openTabs[tab.id] = { url: tab.url, positionIndex: tab.index, windowId: tab.windowId }; +    // Frames are recreated on refresh +    delete framesForTab[tab.id];    }    function handleUpdateScrollPosition(request, sender) { @@ -575,7 +577,11 @@          refreshedCompletionKeys = true;        } else { -        repeatFunction(this[registryEntry.command], count, 0, frameId); +        if(registryEntry.passCountToFunction){ +          this[registryEntry.command](count); +        } else { +          repeatFunction(this[registryEntry.command], count, 0, frameId); +        }        }        newKeyQueue = ""; @@ -647,7 +653,7 @@      if (!framesForTab[sender.tab.id])        framesForTab[sender.tab.id] = { frames: [] }; -    if (request.top) { +    if (request.is_top) {        focusedFrame = request.frameId;        framesForTab[sender.tab.id].total = request.total;      } @@ -680,25 +686,29 @@      focusedFrame = request.frameId;    } -  function nextFrame(callback, frameId) { +  function nextFrame(count) {      chrome.tabs.getSelected(null, function(tab) { -      var index;        var frames = framesForTab[tab.id].frames; +      var curr_index = getCurrFrameIndex(frames); -      for (index=0; index < frames.length; index++) { -        if (frames[index].id == focusedFrame) -            break; -      } +      // TODO: Skip the "top" frame (which doesn't actually have a <frame> tag), +      // since it exists only to contain the other frames. +      var new_index = (curr_index + count) % frames.length; -      if (index >= frames.length-1) -        index = 0; -      else -        index++; - -      chrome.tabs.sendRequest(tab.id, { name: "focusFrame", frameId: frames[index].id, highlight: true }); +      chrome.tabs.sendRequest(tab.id, { name: "focusFrame", frameId: frames[new_index].id, highlight: true });      });    } +  function getCurrFrameIndex(frames) { +    var index; +    for (index=0; index < frames.length; index++) { +      if (frames[index].id == focusedFrame) +          break; +    } +    return index; +  } + +    function init() {      clearKeyMappingsAndSetDefaults(); diff --git a/commands.js b/commands.js index be01a180..c360729b 100644 --- a/commands.js +++ b/commands.js @@ -200,7 +200,7 @@ var commandDescriptions = {    removeTab: ["Close current tab", { background: true }],    restoreTab: ["Restore closed tab", { background: true }], -  nextFrame: ["Cycle forward to the next frame on the page", { background: true }] +  nextFrame: ["Cycle forward to the next frame on the page", { background: true, passCountToFunction: true }]  };  for (var command in commandDescriptions) diff --git a/vimiumFrontend.js b/vimiumFrontend.js index cc97da93..c9c81381 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -182,12 +182,12 @@ function initializeOnDomReady() {  };  // This is a little hacky but sometimes the size wasn't available on domReady? -function registerFrameIfSizeAvailable (top) { +function registerFrameIfSizeAvailable (is_top) {    if (innerWidth != undefined && innerWidth != 0 && innerHeight != undefined && innerHeight != 0)      chrome.extension.sendRequest({ handler: "registerFrame", frameId: frameId, -        area: innerWidth * innerHeight, top: top, total: frames.length + 1 }); +        area: innerWidth * innerHeight, is_top: is_top, total: frames.length + 1 });    else -    setTimeout(function () { registerFrameIfSizeAvailable(top); }, 100); +    setTimeout(function () { registerFrameIfSizeAvailable(is_top); }, 100);  }  /* | 
