diff --git a/resources/compiled_coffeescript.zip b/resources/compiled_coffeescript.zip index bb4bee87f8..6a24d85b2a 100644 Binary files a/resources/compiled_coffeescript.zip and b/resources/compiled_coffeescript.zip differ diff --git a/src/calibre/ebooks/oeb/display/paged.coffee b/src/calibre/ebooks/oeb/display/paged.coffee index 5fb8346540..39c7dc28e7 100644 --- a/src/calibre/ebooks/oeb/display/paged.coffee +++ b/src/calibre/ebooks/oeb/display/paged.coffee @@ -161,7 +161,7 @@ class PagedDisplay # The location of the left edge of the left most column currently # visible in the viewport x = window.pageXOffset + Math.max(10, this.current_margin_side) - edge = Math.floor(x/this.page_width) + edge = Math.floor(x/this.page_width) * this.page_width while edge < x edge += this.page_width return edge - this.page_width @@ -237,6 +237,18 @@ class PagedDisplay # selection this.scroll_to_xpos(left+5) + jump_to_cfi: (cfi) -> + # Jump to the position indicated by the specified conformal fragment + # indicator (requires the cfi.coffee library). When in paged mode, the + # scroll is performed so that the column containing the position + # pointed to by the cfi is the left most column in the viewport + window.cfi.scroll_to(cfi, (x, y) => + if this.in_paged_mode + this.scroll_to_xpos(x) + else + window.scrollTo(0, y) + ) + if window? window.paged_display = new PagedDisplay() diff --git a/src/calibre/gui2/viewer/position.py b/src/calibre/gui2/viewer/position.py index 99cd634a21..d213443388 100644 --- a/src/calibre/gui2/viewer/position.py +++ b/src/calibre/gui2/viewer/position.py @@ -37,17 +37,8 @@ class PagePosition(object): def scroll_to_cfi(self, cfi): if cfi: cfi = json.dumps(cfi) - self.document.mainFrame().evaluateJavaScript(''' - function fix_scroll() { - /* cfi.scroll_to() uses scrollIntoView() which can result - in scrolling along the x-axis. So we - explicitly scroll to x=0. - */ - scrollTo(0, window.pageYOffset) - } - - window.cfi.scroll_to(%s, fix_scroll); - '''%cfi) + self.document.mainFrame().evaluateJavaScript( + 'paged_display.jump_to_cfi(%s)'%cfi) @property def current_pos(self): diff --git a/src/calibre/library/prefs.py b/src/calibre/library/prefs.py index 8b2bb0c7fd..4bd39e20b2 100644 --- a/src/calibre/library/prefs.py +++ b/src/calibre/library/prefs.py @@ -65,6 +65,9 @@ class DBPrefs(dict): return default def set_namespaced(self, namespace, key, val): + if u':' in key: raise KeyError('Colons are not allowed in keys') + if u':' in namespace: raise KeyError('Colons are not allowed in' + ' the namespace') key = u'namespaced:%s:%s'%(namespace, key) self[key] = val