mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Merge from trunk
This commit is contained in:
commit
c888503ce0
Binary file not shown.
@ -161,7 +161,7 @@ class PagedDisplay
|
|||||||
# The location of the left edge of the left most column currently
|
# The location of the left edge of the left most column currently
|
||||||
# visible in the viewport
|
# visible in the viewport
|
||||||
x = window.pageXOffset + Math.max(10, this.current_margin_side)
|
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
|
while edge < x
|
||||||
edge += this.page_width
|
edge += this.page_width
|
||||||
return edge - this.page_width
|
return edge - this.page_width
|
||||||
@ -237,6 +237,18 @@ class PagedDisplay
|
|||||||
# selection
|
# selection
|
||||||
this.scroll_to_xpos(left+5)
|
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?
|
if window?
|
||||||
window.paged_display = new PagedDisplay()
|
window.paged_display = new PagedDisplay()
|
||||||
|
|
||||||
|
@ -37,17 +37,8 @@ class PagePosition(object):
|
|||||||
def scroll_to_cfi(self, cfi):
|
def scroll_to_cfi(self, cfi):
|
||||||
if cfi:
|
if cfi:
|
||||||
cfi = json.dumps(cfi)
|
cfi = json.dumps(cfi)
|
||||||
self.document.mainFrame().evaluateJavaScript('''
|
self.document.mainFrame().evaluateJavaScript(
|
||||||
function fix_scroll() {
|
'paged_display.jump_to_cfi(%s)'%cfi)
|
||||||
/* 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)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_pos(self):
|
def current_pos(self):
|
||||||
|
@ -65,6 +65,9 @@ class DBPrefs(dict):
|
|||||||
return default
|
return default
|
||||||
|
|
||||||
def set_namespaced(self, namespace, key, val):
|
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)
|
key = u'namespaced:%s:%s'%(namespace, key)
|
||||||
self[key] = val
|
self[key] = val
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user