Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/additional keyboard shortcuts for about dialog [e], toggling list view/ thumbnail view [f], add to library [p] #161

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion i18n/_locales/en_US/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
},
"about" : {
"message" : "About"
},
},

"add_epub_dialog" : {
"message" : "Add Epub to Library"
},

"list_view_thumbnail_view_toggle" : {
"message" : "Toggle List View and Thumbnail View"},

"preview" : {
"message" : "PREVIEW"
},
Expand Down
33 changes: 24 additions & 9 deletions lib/EpubLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,19 @@ define(['jquery', 'bootstrap', 'storage/StorageManager', 'storage/Settings', 'Ep
}

var loadLibraryUI = function(){

var listViewThumbnailViewToggle = function (){
if (document.body.className.indexOf("list-view") > -1)
{
$(document.body).removeClass('list-view');
setTimeout(function(){ $('.icon-list-view')[0].focus(); }, 50);
}
else
{
$(document.body).addClass('list-view');
setTimeout(function(){ $('.icon-thumbnails')[0].focus(); }, 50);
}
}

Dialogs.reset();

Expand Down Expand Up @@ -292,21 +305,23 @@ define(['jquery', 'bootstrap', 'storage/StorageManager', 'storage/Settings', 'Ep
$('nav').empty();
$('nav').attr("aria-label", Strings.i18n_toolbar);
$('nav').append(LibraryNavbar({strings: Strings, dialogs: Dialogs, keyboard: Keyboard}));
$('.icon-list-view').on('click', function(){
$(document.body).addClass('list-view');
setTimeout(function(){ $('.icon-thumbnails')[0].focus(); }, 50);
});
$('.icon-thumbnails').on('click', function(){
$(document.body).removeClass('list-view');
setTimeout(function(){ $('.icon-list-view')[0].focus(); }, 50);
});

$('.icon-list-view').on('click', listViewThumbnailViewToggle);
$('.icon-thumbnails').on('click', listViewThumbnailViewToggle);

Keyboard.on(Keyboard.ListViewThumbnailViewToggle, 'library', listViewThumbnailViewToggle);

findHeightRule();
setItemHeight();
StorageManager.initStorage(function(){
libraryManager.retrieveAvailableEpubs(loadLibraryItems);
}, showError);

Keyboard.on(Keyboard.ShowSettingsModal, 'library', function(){$('#settings-dialog').modal("show");});
Keyboard.on(Keyboard.ShowSettingsModal, 'library', function(){$('#settings-dialog').modal("show");});

Keyboard.on(Keyboard.AboutDialog, 'library', function (){$('#about-dialog').modal("show");});

Keyboard.on(Keyboard.AddEpubDialog, 'library' ,function (){$('#add-epub-dialog').modal("show");} );

$(window).trigger('libraryUIReady');
$(window).on('resize', setItemHeight);
Expand Down
2 changes: 2 additions & 0 deletions lib/EpubReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,8 @@ catch (e)

$(window).trigger('loadlibrary');
};

Keyboard.on(Keyboard.AboutDialog, 'reader', function (){$('#about-dialog').modal("show");});

Keyboard.on(Keyboard.SwitchToLibrary, 'reader', loadlibrary /* function(){setTimeout(, 30);} */ );

Expand Down
13 changes: 13 additions & 0 deletions lib/Keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,12 @@ define(['i18n/Strings', 'keymaster', 'storage/Settings'], function(Strings, key,
},
i18n:
{
AddEpubDialog: Strings.add_epub_dialog,

AboutDialog: Strings.about,

ListViewThumbnailViewToggle: Strings.list_view_thumbnail_view_toggle,

ShowSettingsModal: Strings.settings,

SettingsModalSave: Strings.settings + " - " + Strings.i18n_save_changes,
Expand Down Expand Up @@ -434,6 +440,13 @@ define(['i18n/Strings', 'keymaster', 'storage/Settings'], function(Strings, key,
},
defaultOptions: {},
accesskeys: {}, // single key strokes are dynamically populated, based on the full shortcuts below:

AboutDialog: 'e', //accesskey'ed

AddEpubDialog: 'p', //accesskey'ed

ListViewThumbnailViewToggle: 'f', //accesskey'ed

ShowSettingsModal: 'o', //accesskey'ed

SettingsModalSave: 's', //accesskey'ed
Expand Down
16 changes: 8 additions & 8 deletions templates/library-navbar.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<div class="btn-group navbar-left">
<button id="aboutButt1" tabindex="1" type="button" class="btn icon-logo" data-toggle="modal" data-target="#about-dialog" title="{{strings.about}}" aria-label="{{strings.about}}"></button>
<button id="aboutButt1" tabindex="1" type="button" class="btn icon-logo" data-toggle="modal" data-target="#about-dialog" title="{{strings.about}} [{{keyboard.AboutDialog}}]" aria-label="{{strings.about}} [{{keyboard.AboutDialog}}]" accesskey="{{keyboard.accesskeys.AboutDialog}}"></button>
</div>
<div class="btn-group navbar-right">
<button tabindex="1" type="button" class="btn icon-thumbnails" title="{{strings.thumbnail_view}}" aria-label="{{strings.thumbnail_view}}">
<span class="glyphicon glyphicon-th" aria-hidden="true"></span>
</button>
<button tabindex="1" type="button" class="btn icon-list-view" title="{{strings.list_view}}" aria-label="{{strings.list_view}}">
<span class="glyphicon glyphicon-align-justify" aria-hidden="true"></span>
</button>
<button id="addbutt" tabindex="1" type="button" class="btn icon-add-epub" title="{{strings.i18n_add_book}}" aria-label="{{strings.i18n_add_book}}" data-toggle="modal" data-target="#add-epub-dialog">
<button tabindex="1" type="button" class="btn icon-thumbnails" title="{{strings.thumbnail_view}} [{{keyboard.ListViewThumbnailViewToggle}}]" aria-label="{{strings.thumbnail_view}} [{{keyboard.ListViewThumbnailViewToggle}}]" accesskey="{{keyboard.ListViewThumbnailViewToggle}}">
<span class="glyphicon glyphicon-th" aria-hidden="true"></span>
</button>
<button tabindex="1" type="button" class="btn icon-list-view" title="{{strings.list_view}} [{{keyboard.ListViewThumbnailViewToggle}}]" aria-label="{{strings.list_view}} [{{keyboard.ListViewThumbnailViewToggle}}]" accesskey="{{keyboard.ListViewThumbnailViewToggle}}">
<span class="glyphicon glyphicon-align-justify" aria-hidden="true"></span>
</button>
<button id="addbutt" tabindex="1" type="button" class="btn icon-add-epub" title="{{strings.i18n_add_book}} [{{keyboard.AddEpubDialog}}]" aria-label="{{strings.i18n_add_book}} [{{keyboard.AddEpubDialog}}]" accesskey="{{keyboard.accesskeys.AddEpubDialog}}"data-toggle="modal" data-target="#add-epub-dialog">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
</button>
<button id="settbutt1" tabindex="1" type="button" class="btn icon-settings" title="{{strings.settings}} [{{keyboard.ShowSettingsModal}}]" aria-label="{{strings.settings}} [{{keyboard.ShowSettingsModal}}]" accesskey="{{keyboard.accesskeys.ShowSettingsModal}}" data-toggle="modal" data-target="#settings-dialog">
Expand Down
2 changes: 1 addition & 1 deletion templates/reader-navbar.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="btn-group navbar-left">
<!-- <button type="button" class="btn btn-default icon icon-show-hide"></button> -->
<button id="aboutButt1" tabindex="1" type="button" class="btn icon-logo" data-toggle="modal" data-target="#about-dialog" title="{{strings.about}}" aria-label="{{strings.about}}">
<button id="aboutButt1" tabindex="1" type="button" class="btn icon-logo" data-toggle="modal" data-target="#about-dialog" title="{{strings.about}} [{{keyboard.AboutDialog}}]" aria-label="{{strings.about}} [{{keyboard.AboutDialog}}]" accesskey="{{keyboard.accesskeys.AboutDialog}}">
<span class="icon-readium" aria-hidden="true"></span>
</button>

Expand Down