ImageGrid/ui/info.js
Alex A. Naanou 6c551b2426 some refactoring and cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2013-06-02 20:14:39 +04:00

147 lines
3.7 KiB
JavaScript
Executable File

/**********************************************************************
*
*
**********************************************************************/
/**********************************************************************
* Info & status...
*/
// XXX do we need a full rewrite here, or will it be better to just fill
// the slots...
function updateGlobalImageInfo(image){
image = image == null ? getImage() : $(image)
image = image.length == 0 ? getImage() : image
var elem = $('.global-image-info')
if(elem.length == 0){
elem = $('<div class="global-image-info"/>')
}
// no image no update...
if(image.length == 0){
return elem
}
var gid = getImageGID(image)
var r = getRibbonIndex(getRibbon(image))
var data = IMAGES[gid]
var date = new Date(data.ctime * 1000)
var meta = []
image.hasClass('marked') ? meta.push(
'<span class="shown">M</span>'+
'<span class="hidden"><b>M</b>arked</span>') : ''
var orientation = data.orientation
orientation = orientation == null ? 0 : orientation
orientation != 0 ? meta.push(
'<span class="shown">R</span>'+
'<span class="hidden"><b>R</b>otated: '+orientation+'&deg;CW</span>') : ''
meta = meta.join(', ')
meta = meta != '' ? '( '+ meta +' )' : ''
return updateInfo(elem,
// path...
'<span class="expanding-text path">'+
'<span class="shown">'+
data.path.split('/').pop() +
'</span>'+
'<span class="hidden" '+
'style="position:absolute;'+
'background: black;'+
'padding: 3px;'+
'top: 0px;'+
'left: 0px;'+
'width: 100%;'+
'height: 100%"'+
'>'+
normalizePath(data.path) +
'</span>'+
'</span> '+
// metadata...
'<span class="secondary expanding-text metadata">'+
meta + ' GID:'+
// XXX do we need to display a short gid?
//gid +
'<span class="shown">'+
gid.slice(gid.length-6) +
'</span>'+
'<span class="hidden"> '+
(gid.length >= 6 ?
(gid.slice(0, gid.length-6) +'<b>'+ gid.slice(gid.length-6) +'</b>')
: gid)+
'</span>'+
'</span> '+
// date...
'<span class="secondary expanding-text date">'+
'<span class="shown">TS:' + date.toShortDate() + '</span>'+
'<span class="hidden"><b>' + date.toString() + '</b></span>'+
'</span>'+
// position...
'<span class="float-right position">('+
(DATA.ribbons[r].indexOf(gid)+1) +'/'+ DATA.ribbons[r].length +
')<span/>')
}
function updateInlineImageInfo(image){
image = image == null ? getImage() : $(image)
image = image.length == 0 ? getImage() : image
var elem = $('.inline-image-info')
if(elem.length == 0){
elem = $('<div class="inline-image-info"/>')
}
// no image no update...
if(image.length == 0){
return elem
}
var gid = getImageGID(image)
var r = getRibbonIndex(getRibbon(image))
var data = IMAGES[gid]
var date = new Date(data.ctime * 1000)
var orientation = data.orientation
orientation = orientation == null ? 0 : orientation
return updateInfo(elem,
// name...
data.path.split('/').pop() +'<br>'+
// date...
'<span class="secondary expanding-text date">'+
//date.toShortDate() +
'<span class="shown">' + date.toShortDate() + '</span>'+
'<span class="hidden"><b>' + date.toString() + '</b></span>'+
'</span>'+
'',
image)
}
function inlineImageInfoHoverHandler(evt){
var img = $(evt.target).closest('.image')
if(img.length > 0){
if(img.find('.inline-image-info:visible').length == 0){
updateInlineImageInfo(img)
}
}
}
/**********************************************************************
* vim:set ts=4 sw=4 spell nowrap : */