mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make the cover grid re-useable
This commit is contained in:
parent
f360a7affa
commit
905c038b57
@ -2,17 +2,15 @@
|
|||||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
from __python__ import hash_literals, bound_methods
|
from __python__ import hash_literals, bound_methods
|
||||||
|
|
||||||
from dom import clear, set_css, build_rule, unique_id
|
from dom import clear, set_css, build_rule
|
||||||
from elementmaker import E
|
from elementmaker import E
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
THUMBNAIL_MAX_WIDTH = 300
|
THUMBNAIL_MAX_WIDTH = 300
|
||||||
THUMBNAIL_MAX_HEIGHT = 400
|
THUMBNAIL_MAX_HEIGHT = 400
|
||||||
|
|
||||||
COVER_GRID = unique_id('cover-grid')
|
|
||||||
|
|
||||||
def cover_grid_css():
|
def cover_grid_css():
|
||||||
sel = '#' + COVER_GRID
|
sel = '#' + this
|
||||||
ans = build_rule(sel, display='flex', flex_wrap='wrap', justify_content='space-around', align_items='flex-end', align_content='flex-start', user_select='none', overflow='hidden')
|
ans = build_rule(sel, display='flex', flex_wrap='wrap', justify_content='space-around', align_items='flex-end', align_content='flex-start', user_select='none', overflow='hidden')
|
||||||
|
|
||||||
sel += ' > div'
|
sel += ' > div'
|
||||||
@ -29,7 +27,7 @@ def cover_grid_css():
|
|||||||
|
|
||||||
def init(container):
|
def init(container):
|
||||||
clear(container)
|
clear(container)
|
||||||
container.appendChild(E.div(id=COVER_GRID))
|
container.appendChild(E.div(id=this))
|
||||||
|
|
||||||
def on_img_load_error(err):
|
def on_img_load_error(err):
|
||||||
img = err.target
|
img = err.target
|
||||||
|
@ -4,7 +4,7 @@ from __python__ import hash_literals
|
|||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
from ajax import ajax_send
|
from ajax import ajax_send
|
||||||
from dom import set_css, add_extra_css
|
from dom import set_css, add_extra_css, unique_id
|
||||||
from elementmaker import E
|
from elementmaker import E
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from modals import error_dialog, ajax_progress_dialog
|
from modals import error_dialog, ajax_progress_dialog
|
||||||
@ -16,9 +16,10 @@ from widgets import create_button, create_spinner
|
|||||||
bv_counter = 0
|
bv_counter = 0
|
||||||
|
|
||||||
CLASS_NAME = 'books-main-list'
|
CLASS_NAME = 'books-main-list'
|
||||||
|
COVER_GRID = unique_id('cover-grid')
|
||||||
|
|
||||||
add_extra_css(def():
|
add_extra_css(def():
|
||||||
ans = cover_grid_css()
|
ans = cover_grid_css.call(COVER_GRID)
|
||||||
return ans
|
return ans
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ class BooksView:
|
|||||||
self.mode = mode
|
self.mode = mode
|
||||||
if mode is 'cover_grid':
|
if mode is 'cover_grid':
|
||||||
self.render_book = create_cover_grid_item
|
self.render_book = create_cover_grid_item
|
||||||
self.init_grid = init_cover_grid
|
self.init_grid = init_cover_grid.bind(COVER_GRID)
|
||||||
self.append_item = cover_grid_append_item
|
self.append_item = cover_grid_append_item
|
||||||
self.clear()
|
self.clear()
|
||||||
self.render_ids()
|
self.render_ids()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user