From 6e0d150a58584232039da5bc4b11250e4ce80c76 Mon Sep 17 00:00:00 2001 From: "andreas.rudolph" Date: Tue, 12 Aug 2014 13:50:27 +0200 Subject: [PATCH 1/3] added accesskeys for: - aboutdialog [e] - list view / library view toggle [f] - add to library [p] --- i18n/_locales/en_US/messages.json | 10 +++++++++- lib/EpubLibrary.js | 29 ++++++++++++++++++++++------- lib/EpubReader.js | 2 ++ lib/Keyboard.js | 13 +++++++++++++ templates/library-navbar.html | 11 ++++++----- templates/reader-navbar.html | 5 +++-- 6 files changed, 55 insertions(+), 15 deletions(-) diff --git a/i18n/_locales/en_US/messages.json b/i18n/_locales/en_US/messages.json index caac753d4..958edd03a 100644 --- a/i18n/_locales/en_US/messages.json +++ b/i18n/_locales/en_US/messages.json @@ -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" }, diff --git a/lib/EpubLibrary.js b/lib/EpubLibrary.js index c2b49bda3..692419e35 100644 --- a/lib/EpubLibrary.js +++ b/lib/EpubLibrary.js @@ -292,14 +292,25 @@ 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(){ + + $('.icon-list-view').on('click', function(){listViewThumbnailViewToggle()}); + $('.icon-thumbnails').on('click', function(){listViewThumbnailViewToggle()}); + + Keyboard.on(Keyboard.ListViewThumbnailViewToggle, 'library', function (){listViewThumbnailViewToggle()}); + + 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); - }); - $('.icon-thumbnails').on('click', function(){ - $(document.body).removeClass('list-view'); - setTimeout(function(){ $('.icon-list-view')[0].focus(); }, 50); - }); + setTimeout(function(){ $('.icon-thumbnails')[0].focus(); }, 50); + } + } + + findHeightRule(); setItemHeight(); StorageManager.initStorage(function(){ @@ -307,6 +318,10 @@ define(['jquery', 'bootstrap', 'storage/StorageManager', 'storage/Settings', 'Ep }, showError); 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); diff --git a/lib/EpubReader.js b/lib/EpubReader.js index b065f024d..53d4b3473 100644 --- a/lib/EpubReader.js +++ b/lib/EpubReader.js @@ -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);} */ ); diff --git a/lib/Keyboard.js b/lib/Keyboard.js index 6aa7d69fb..af950248d 100644 --- a/lib/Keyboard.js +++ b/lib/Keyboard.js @@ -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, @@ -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 diff --git a/templates/library-navbar.html b/templates/library-navbar.html index 28ffea6f9..db4c86cff 100644 --- a/templates/library-navbar.html +++ b/templates/library-navbar.html @@ -1,14 +1,15 @@