very basic thumbnail browser.

This commit is contained in:
Bala Clark 2013-11-26 23:47:23 +01:00
parent b820fa4c3e
commit 226c0e92c2
6 changed files with 55 additions and 4 deletions

View file

@ -17,7 +17,7 @@ build:
@cp lib/vendor/pixastic/license-mpl.txt comicbook/js/pixastic
@./node_modules/.bin/uglifyjs -nc comicbook/js/comicbook.js > comicbook/js/comicbook.min.js
@echo "Compiling CSS..."
@cat fonts/icomoon-toolbar/style.css css/reset.css css/styles.css css/toolbar.css > comicbook/comicbook.css
@cat fonts/icomoon-toolbar/style.css css/reset.css css/styles.css css/toolbar.css css/thumbnails.css > comicbook/comicbook.css
@echo "Copying assets..."
@cp -r css/img comicbook/img
@cp -r fonts/icomoon-toolbar/fonts comicbook

21
css/thumbnails.css Normal file
View file

@ -0,0 +1,21 @@
.thumbnails {
position: absolute;
color: white;
background-color: black;
background-image: linear-gradient(to bottom, rgb(80, 80, 80), rgb(17, 17, 17));
padding: 0.5em;
border-radius: 0.2em;
margin: 5em;
left: 0;
right: 0;
bottom: 0;
top: 0;
display: none;
overflow: auto;
}
.thumbnails img {
display: inline-block;
margin: 0.5em;
}

View file

@ -19,6 +19,7 @@
<link rel="stylesheet" href="../fonts/icomoon-toolbar/style.css">
<link rel="stylesheet" href="../css/styles.css">
<link rel="stylesheet" href="../css/toolbar.css">
<link rel="stylesheet" href="../css/thumbnails.css">
</head>
<body>

View file

@ -17,7 +17,6 @@
- make page draggable with the cursor
- enable menu items via config, allow for custom items
- split out classes into seperate files
- thumbnail browser
- refactor so we are not using all these loose shared variables and other nastyness
- use custom event emitters instead of hacky code
- properly bind 'this' so we don't have to keep using 'self'
@ -82,7 +81,8 @@ var ComicBook = (function ($) {
keyboard: {
next: 78,
previous: 80,
toggleLayout: 76
toggleLayout: 76,
thumbnails: 84
},
libPath: '/lib/',
forward_buffer: 3
@ -837,6 +837,11 @@ var ComicBook = (function ($) {
if (e.keyCode === options.keyboard.toggleLayout) {
self.toggleLayout();
}
// display thumbnail browser
if (e.keyCode === options.keyboard.thumbnails) {
self.toggleThumbnails();
}
break;
default:
@ -869,6 +874,28 @@ var ComicBook = (function ($) {
.find('.manga-' + !options.manga).hide();
};
ComicBook.prototype.toggleThumbnails = function () {
// TODO: show page numbers
// TODO: in double page mode merge both pages into a single link
// TODO: only load thumbnails when they are in view
// TODO: keyboard navigation (left / right / up / down / enter)
// TODO: highlight currently selected thumbnail
// TODO: focus on current page
// TODO: toolbar button
var $thumbnails = self.getControl('thumbnails');
$thumbnails.html('');
self.toggleControl('thumbnails');
$.each(pages, function (i, img) {
var $img = $(img).clone();
var $link = $('<a>').attr('href', '#' + i).append($img);
$img.attr('height', 150);
$link.on('click', function () {
self.hideControl('thumbnails');
});
$thumbnails.append($link);
});
};
ComicBook.prototype.destroy = function () {
$.each(this.controls, function (name, $control) {

View file

@ -39,7 +39,7 @@ $(function () {
});
test('all controls should be rendered', function () {
equal($('.cb-control, .toolbar').length, 5, 'All toolbar elements should have rendered after book.draw');
equal($('.cb-control, .toolbar').length, 6, 'All toolbar elements should have rendered after book.draw');
});
// navigate on keyboard

View file

@ -0,0 +1,2 @@
<div class="cb-control thumbnails"></div>