From ceb0638ccd3b78ea3971401ec222f3f55cadb702 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 25 Jan 2012 14:34:21 +0530 Subject: [PATCH] ... --- src/calibre/ebooks/oeb/display/cfi.coffee | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/oeb/display/cfi.coffee b/src/calibre/ebooks/oeb/display/cfi.coffee index efb68a37c0..260c0b71f1 100644 --- a/src/calibre/ebooks/oeb/display/cfi.coffee +++ b/src/calibre/ebooks/oeb/display/cfi.coffee @@ -626,8 +626,16 @@ class CanonicalFragmentIdentifier return cfi cury += delta - # TODO: Return the CFI corresponding to the tag - null + # Use a spatial offset on the html element, since we could not find a + # normal CFI + [x, y] = window_scroll_pos() + de = document.documentElement + rect = de.getBoundingClientRect() + px = (x*100)/rect.width + py = (y*100)/rect.height + cfi = "/2@#{ fstr px }:#{ fstr py }" + + return cfi # }}}