From 957bd0512feb771268f3258506c7037bf3a77421 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 19 Jun 2012 18:28:45 +0530 Subject: [PATCH 1/2] ... --- src/calibre/library/prefs.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/calibre/library/prefs.py b/src/calibre/library/prefs.py index 4514f4cf1e..56c1ba55db 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 From fc4309539b721bee6ba6b1c3eb113d80201540eb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 19 Jun 2012 19:03:01 +0530 Subject: [PATCH 2/2] Navigate to CFIs correctly in paged mode and fix typo in current_column_location() --- resources/compiled_coffeescript.zip | Bin 36851 -> 37150 bytes src/calibre/ebooks/oeb/display/paged.coffee | 14 +++++++++++++- src/calibre/gui2/viewer/position.py | 13 ++----------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/resources/compiled_coffeescript.zip b/resources/compiled_coffeescript.zip index bb4bee87f8d00a3ac20dc11d0a8f46da478f734a..6a24d85b2a30867b4e02dc07eac1c4e38b5a8917 100644 GIT binary patch delta 259 zcmex7pK0DACg}igW)=|!5YTJ9?4Wo}rS_&W0|N+4PuA&|+h{4MG`Uw)+%&5+w;;YG zKR!7vQ^8gttu!yWBr`ux1IX1>sOC}tgR;aTh4_+;%wnJl5M@32p@gU*P>Eh~a#4Ox z4p2WxgAPJ_g^ofcLcfASW}1RV{Nw}$xydq`oZ?`!5PIV)3i69JDl{km$(Nlhr^!B< zRYHKp0BFMGg}TB_wVIRl^+Y!ZD(%VPL-opJ>HbJ2A(hEx{a#G029po + # 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):