Merge from trunk

This commit is contained in:
Charles Haley 2012-06-19 17:31:07 +02:00
commit c888503ce0
4 changed files with 18 additions and 12 deletions

Binary file not shown.

View File

@ -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()

View File

@ -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):

View File

@ -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