updated the way the cursor hiding stores data -- now element specific and reusable for multiple elements...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-06-08 20:04:27 +04:00
parent 90174366f7
commit 6f05e8a633
2 changed files with 37 additions and 16 deletions

View File

@ -171,6 +171,7 @@ function loadLatestFile(path, dfl, pattern, diff_pattern){
//
// NOTE: this depends on listDir(...)
// NOTE: this assumes that images contain ALL the images...
// NOTE: this assumes that all file names are unique...
function ribbonsFromFavDirs(path, images, cmp){
path = path == null ? getBaseURL() : path
images = images == null ? IMAGES : images
@ -198,16 +199,20 @@ function ribbonsFromFavDirs(path, images, cmp){
// collect the images...
$.each(files, function(i, e){
var _gid = index[e]
// filter out non-image files...
if(/.*\.(jpg|jpeg)$/i.test(e)){
ribbon.push(_gid)
}
// skip files not in index...
// NOTE: we do not need to filter the files by name as we
// trust the index...
if(_gid == null){
return
}
// remove the found item from each of the below ribbons...
$.each(ribbons, function(i ,e){
if(e.indexOf(_gid) != -1){
e.splice(e.indexOf(_gid), 1)
}
})
ribbon.push(_gid)
})
ribbons.push(ribbon)
}

View File

@ -20,25 +20,27 @@ var STATUS_QUEUE_TIME = 200
// XXX revise...
// NOTE: to catch the click event correctly while the cursor is hidden
// this must be the first to get the event...
// NOTE: this uses element.data to store the timer and cursor position...
function autoHideCursor(elem){
elem = $(elem)
var data = elem.data()
elem
.on('mousemove', function(evt){
var cursor = elem.css('cursor')
_cursor_pos = window._cursor_pos == null || cursor != 'none' ?
data._cursor_pos = data._cursor_pos == null || cursor != 'none' ?
[evt.clientX, evt.clientY]
: _cursor_pos
: data._cursor_pos
// cursor visible -- extend visibility...
if(cursor != 'none'){
if(window._cursor_timeout != null){
clearTimeout(_cursor_timeout)
if(data._cursor_timeout != null){
clearTimeout(data._cursor_timeout)
}
_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){
data._cursor_timeout = setTimeout(function(){
if(Math.abs(evt.clientX - data._cursor_pos[0]) < CURSOR_SHOW_THRESHOLD
|| Math.abs(evt.clientY - data._cursor_pos[1]) < CURSOR_SHOW_THRESHOLD){
elem.css('cursor', 'none')
}
@ -46,8 +48,8 @@ function autoHideCursor(elem){
// cursor hidden -- if outside the threshold, show...
} else if(Math.abs(evt.clientX - _cursor_pos[0]) > CURSOR_SHOW_THRESHOLD
|| Math.abs(evt.clientY - _cursor_pos[1]) > CURSOR_SHOW_THRESHOLD){
} else if(Math.abs(evt.clientX - data._cursor_pos[0]) > CURSOR_SHOW_THRESHOLD
|| Math.abs(evt.clientY - data._cursor_pos[1]) > CURSOR_SHOW_THRESHOLD){
elem.css('cursor', '')
}
@ -57,9 +59,9 @@ function autoHideCursor(elem){
//event.stopImmediatePropagation()
//event.preventDefault()
if(window._cursor_timeout != null){
clearTimeout(_cursor_timeout)
_cursor_timeout = null
if(data._cursor_timeout != null){
clearTimeout(data._cursor_timeout)
data._cursor_timeout = null
}
elem.css('cursor', '')
@ -70,6 +72,20 @@ function autoHideCursor(elem){
}
/*
// XXX does not work...
// ...does not show the cursor without moving it...
function showCursor(elem){
elem = $(elem)
var data = elem.data()
if(data._cursor_timeout != null){
clearTimeout(data._cursor_timeout)
}
elem.css('cursor', '')
}
*/
function flashIndicator(direction){
var cls = {
// shift up/down...