From 8159a274071ca4e76883eed11bcadcefb0e00028 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 9 Jun 2013 02:26:22 +0400 Subject: [PATCH] brute-force killed a bug with toggleImageProportions(...), fixed a trailing '//////' explosion in BASE_URL, minor tweaks and fixes... Signed-off-by: Alex A. Naanou --- ui/TODO.otl | 16 +++++++++------- ui/base.js | 5 ++++- ui/data.js | 1 + ui/keybindings.js | 2 ++ ui/localstorage.js | 2 ++ ui/modes.js | 11 ++++++++++- ui/setup.js | 17 +++++++++-------- 7 files changed, 37 insertions(+), 17 deletions(-) diff --git a/ui/TODO.otl b/ui/TODO.otl index f0d49fcb..981ed3aa 100755 --- a/ui/TODO.otl +++ b/ui/TODO.otl @@ -90,8 +90,11 @@ Roadmap -[_] 24% Gen 3 current todo - [_] 49% High priority +[_] 26% Gen 3 current todo + [_] 53% High priority + BUG: scaling is again broken with rotated images + | - rotate an image + | - scale it to 1 (press 1) [_] ASAP: directory selector UI... [_] usable empty view -- w.o. data... [_] 0% Tablet UI @@ -218,9 +221,6 @@ Roadmap [X] image info [X] stub info dialog [_] detailed image info - [_] 0% gesture support - [_] up/down - shift - [_] left/right - navigate [_] 0% CSS [_] cleanup [_] split themes and layout @@ -236,9 +236,11 @@ Roadmap [_] caching config [_] BUG: jumping screen images does not load the adjacent ribbons... | positioning is OK but ribbons are not fully visible... - [_] BUG: BASE_URL seems to gain a new trailing '/' on each save... + [X] BUG: BASE_URL seems to gain a new trailing '/' on each save... | low priority as this does not affect anything... - [_] start/stop gif animations... + [X] 100% gesture support + [X] up/down - navigate + [X] left/right - navigate [X] make the marks in single image mode show in corner of viewer, not image | and think of a uniform indicator position... | diff --git a/ui/base.js b/ui/base.js index b47fa4b3..ca57591a 100755 --- a/ui/base.js +++ b/ui/base.js @@ -982,11 +982,14 @@ function resetToOriginalImage(image){ /********************************************************* Zooming ***/ function fitNImages(n, fixed_proportions){ + var viewer = $('.viewer') + + viewer.trigger('preFittingImages', [n]) + var image = getImage() var w = image.outerWidth(true) var h = image.outerHeight(true) - var viewer = $('.viewer') var W = viewer.innerWidth() var H = viewer.innerHeight() diff --git a/ui/data.js b/ui/data.js index fb61fc30..285bbfbc 100755 --- a/ui/data.js +++ b/ui/data.js @@ -401,6 +401,7 @@ Array.prototype.binSearch = function(target, cmp, get){ // NOTE: changing a base URL will trigger a baseURLChanged event... function setBaseURL(url){ var old_url = BASE_URL + url = url.replace(/\/*$/, '/') BASE_URL = url $('.viewer').trigger('baseURLChanged', [old_url, url]) } diff --git a/ui/keybindings.js b/ui/keybindings.js index 35d69917..3396d34d 100755 --- a/ui/keybindings.js +++ b/ui/keybindings.js @@ -424,6 +424,8 @@ var KEYBOARD_CONFIG = { // zooming... + '#1': doc('Fit image', function(){ fitNImages(1) }), + '-': doc('Zoom in', function(){ zoomOut() }), '=': doc('Zoom out', function(){ zoomIn() }), diff --git a/ui/localstorage.js b/ui/localstorage.js index acbcb170..d6e0344f 100755 --- a/ui/localstorage.js +++ b/ui/localstorage.js @@ -104,6 +104,7 @@ function saveLocalStorageSettings(attr){ function loadLocalStorage(attr){ attr = attr == null ? DATA_ATTR : attr var d = loadLocalStorageData(attr) + loadLocalStorageBaseURLHistory(attr) setBaseURL(d.base_url) DATA = d.data IMAGES = loadLocalStorageImages(attr) @@ -113,6 +114,7 @@ function saveLocalStorage(attr){ attr = attr == null ? DATA_ATTR : attr saveLocalStorageData(attr) saveLocalStorageImages(attr) + saveLocalStorageBaseURLHistory() } diff --git a/ui/modes.js b/ui/modes.js index 4fa5f510..c9ce6a2f 100755 --- a/ui/modes.js +++ b/ui/modes.js @@ -120,7 +120,7 @@ var toggleSingleImageMode = createCSSClassToggler( '.viewer', 'single-image-mode', function(action){ - // prevent reiniting... + // prevent reentering... if(action == toggleSingleImageMode('?')){ return false } @@ -265,12 +265,21 @@ var toggleImageProportions = createCSSClassToggler( 'none', 'fit-viewer' ], + function(action){ + // prevent reentering... + if(action == toggleImageProportions('?')){ + return false + } + }, function(action){ var image = $('.image') var h = image.outerHeight(true) var w = image.outerWidth(true) // viewer proportions... + // XXX going into here twice for a rotated 90/270 image will + // set it back to square... + // ...can't even begin to imagine what can affect this! if(action == 'fit-viewer'){ var viewer = $('.viewer') var W = viewer.innerWidth() diff --git a/ui/setup.js b/ui/setup.js index 9cd9ca5b..15306a7c 100755 --- a/ui/setup.js +++ b/ui/setup.js @@ -149,7 +149,6 @@ function setupDataBindings(viewer){ rollImages(gr.length, ribbon) }) - .on('fittingImages', function(evt, n){ // load correct amount of images in each ribbon!!! var screen_size = getScreenWidthInImages() @@ -168,16 +167,18 @@ function setupDataBindings(viewer){ } // update proportions... + // XXX for some magical reason this is stable for un-rotated + // images and does mad things for rotate 90/270 images... + // ...the only thing that is if(window.PROPORTIONS_RATIO_THRESHOLD != null && toggleSingleImageMode('?') == 'on'){ - var viewer = $('.viewer') - //var w = getVisibleImageSize('width') - var h = getVisibleImageSize('height') - //var W = viewer.innerWidth() - var H = viewer.innerHeight() - //var m = Math.min(W/w, H/h) - var m = H/h + var h = getVisibleImageSize('height') + var w = getVisibleImageSize('width') + var H = $('.viewer').innerHeight() + var W = $('.viewer').innerWidth() + + var m = Math.min(W/w, H/h) if(m < PROPORTIONS_RATIO_THRESHOLD){ toggleImageProportions('fit-viewer')