From 94093098ecb9f16992bbf0f8e09fbebb7f0ed2b0 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 9 Nov 2013 15:03:49 +0400 Subject: [PATCH] started adding key bindings for systems w/o function keys... Signed-off-by: Alex A. Naanou --- ui/data.js | 11 ++++++++++- ui/keybindings.js | 30 ++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/ui/data.js b/ui/data.js index 2a1cc975..70b39c69 100755 --- a/ui/data.js +++ b/ui/data.js @@ -370,6 +370,7 @@ Array.prototype.linSearch = function(target, cmp, get){ // NOTE: this will return the object by default, to return position set // return_position to true. // NOTE: by default this will use cmp as a predicate. +// NOTE: this expects lst to be sorted in a check-compatible way... function binSearch(target, lst, check, return_position, get){ check = check == null ? lcmp : check var h = 0 @@ -471,6 +472,11 @@ function getGIDRibbonIndex(gid, data){ // Same as getImageBefore(...), but uses gids and searches in DATA... // +// Return: +// null - no image is before gid +// gid - the image before +// +// NOTE: if gid is present in the searched ribbon this will return it. // NOTE: this uses it's own predicate... function getGIDBefore(gid, ribbon, search, data){ gid = gid == null ? getImageGID() : gid @@ -1679,7 +1685,9 @@ function readImagesDatesQ(images){ } -// XXX after running this we need to re-save the images... +// XXX deleting images is not sported, we need to explicitly re-save... +// XXX need to reload the viewer... +// XXX not tested... function updateImageGID(gid, images, data){ images = images == null ? IMAGES : images var img = images[gid] @@ -1689,6 +1697,7 @@ function updateImageGID(gid, images, data){ // images... images[gid] = images[key] delete images[key] + IMAGES_UPDATED.push(gid) // data... if(data != null){ diff --git a/ui/keybindings.js b/ui/keybindings.js index 89d384d3..af0c7f9c 100755 --- a/ui/keybindings.js +++ b/ui/keybindings.js @@ -53,8 +53,29 @@ var KEYBOARD_CONFIG = { return false }), }, - F5: doc('Reload viewer', function(){ reload() }), - F12: doc('Show devTools', function(){ showDevTools() }), + F5: doc('Reload viewer', + function(){ + reload() + return false + }), + F12: doc('Show devTools', + function(){ + showDevTools() + return false + }), + // NOTE: these are for systems where F** keys are not available + // or do other stuff... + R: { + 'ctrl': doc('Reload viewer', + function(){ + reloadViewer() + return false + }), + 'ctrl+shift': 'F5', + }, + P: { + 'ctrl+shift': 'F12', + }, }, // info overlay... @@ -303,6 +324,7 @@ var KEYBOARD_CONFIG = { '#9': doc('Fit nine images', function(){ fitNImages(9) }), // cropping... + // XXX add a non FXX key for macs... F2: { shift: doc('Crop marked only images', function(){ @@ -313,6 +335,7 @@ var KEYBOARD_CONFIG = { }), }, + // XXX add a non FXX key for macs... F3: doc('Crop single ribbon', function(){ event.preventDefault() @@ -630,6 +653,7 @@ var KEYBOARD_CONFIG = { }, + // XXX add a non FXX key for macs... F2: doc('Toggle mark visibility', function(){ toggleMarkesView() }), // XXX should we be able to toggle crop modes from single image mode??? @@ -689,11 +713,13 @@ var KEYBOARD_CONFIG = { // NOTE: this is handled by the wrapper at this point, so we do // not have to do anything here... F11: doc('Toggle full screen view', function(){ toggleFullscreenMode() }), + F: 'F11', // Help and info... '?': doc('Show keyboard bindings', function(){ toggleKeyboardHelp() }), + // XXX add a non FXX key for macs... F1: doc('Show help', function(){ toggleHelp() }),