From d7714eb0b2d82333ce6c0541c29a98fffb0259f9 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 1 Jun 2013 18:43:14 +0400 Subject: [PATCH] some more refactoring... Signed-off-by: Alex A. Naanou --- ui/index.html | 9 ++++----- ui/modes.js | 8 +++++++- ui/ui.js | 23 ++++++++++++++++++++--- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/ui/index.html b/ui/index.html index 0d4a9530..d720ea6a 100755 --- a/ui/index.html +++ b/ui/index.html @@ -35,8 +35,11 @@ // setup... $(function(){ - + // defaults... toggleTheme('gray') + toggleImageInfo('on') + + autoHideCursor($('.viewer')) // NOTE: this is global so as to not to add any extra complexity to // the internal workings... @@ -45,10 +48,6 @@ $(function(){ // XXX for some reason this messes up alignment on initial view... //.dblclick(dblClickHandler) - - autoHideCursor($('.viewer')) - - $(window) .resize(function() { // XXX should this be animated or not? diff --git a/ui/modes.js b/ui/modes.js index 014aec23..ece8047c 100755 --- a/ui/modes.js +++ b/ui/modes.js @@ -66,7 +66,13 @@ var toggleTheme = createCSSClassToggler('.viewer', }) -var toggleImageInfo = createCSSClassToggler('.viewer', '.image-info-visible') +var toggleImageInfo = createCSSClassToggler('.viewer', + '.image-info-visible', + function(action){ + if(toggleSingleImageMode('?') == 'off'){ + SETTINGS['image-info-ribbon-mode'] = action + } + }) var toggleInlineImageInfo = createCSSClassToggler('.viewer', diff --git a/ui/ui.js b/ui/ui.js index 062251a3..aafc8da3 100755 --- a/ui/ui.js +++ b/ui/ui.js @@ -14,11 +14,13 @@ var CURSOR_HIDE_TIMEOUT = 2000 /*********************************************************************/ // XXX revise... +// NOTE: to catch the click event correctly while the cursor is hidden +// this must be the first to get the event... function autoHideCursor(elem){ elem = $(elem) elem .on('mousemove', function(evt){ - _cursor_pos = window._cursor_pos == null || $('.viewer').css('cursor') == 'auto' ? + _cursor_pos = window._cursor_pos == null || elem.css('cursor') == 'auto' ? [evt.clientX, evt.clientY] : _cursor_pos @@ -27,19 +29,34 @@ function autoHideCursor(elem){ if(window._cursor_timeout != null){ clearTimeout(_cursor_timeout) + _cursor_timeout = null } - $('.viewer').css('cursor', '') + elem.css('cursor', '') } else { _cursor_timeout = setTimeout(function(){ if(Math.abs(evt.clientX - _cursor_pos[0]) < CURSOR_SHOW_THRESHOLD || Math.abs(evt.clientY - _cursor_pos[1]) < CURSOR_SHOW_THRESHOLD){ - $('.viewer').css('cursor', 'none') + elem.css('cursor', 'none') } }, CURSOR_HIDE_TIMEOUT) } }) + .click(function(evt){ + if(elem.css('cursor') == 'none'){ + //event.stopImmediatePropagation() + //event.preventDefault() + + if(window._cursor_timeout != null){ + clearTimeout(_cursor_timeout) + _cursor_timeout = null + } + + elem.css('cursor', '') + //return false + } + }) return elem }