minor tweaks and refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-08-22 20:48:36 +03:00
parent f7ea76ec6e
commit 1489ba0c0a

View File

@ -10,13 +10,13 @@
//
//=====================================================================
// This compansates for any resize rounding errors in patchFlexRows(..).
var PATCH_MARGIN = 2
//---------------------------------------------------------------------
// Generic stuff...
// This compansates for any resize rounding errors in patchFlexRows(..).
var PATCH_MARGIN = 2
var patchFlexRows =
function(elems,
prevent_row_expansion=false,
@ -127,20 +127,20 @@ function(elem) {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var ruler
var _ruler
var px2rem = function(px){
if(!ruler){
ruler = document.createElement('div')
document.body.append(ruler) }
ruler.style.width = '1rem'
var c = ruler.offsetWidth
if(!_ruler){
_ruler = document.createElement('div')
document.body.append(_ruler) }
_ruler.style.width = '1rem'
var c = _ruler.offsetWidth
return px / c }
var rem2px = function(rem){
if(!ruler){
ruler = document.createElement('div')
document.body.append(ruler) }
ruler.style.width = rem + 'em'
var px = ruler.offsetWidth
if(!_ruler){
_ruler = document.createElement('div')
document.body.append(_ruler) }
_ruler.style.width = rem + 'em'
var px = _ruler.offsetWidth
return px }
@ -905,6 +905,7 @@ var Gallery = {
img.classList.toggle('marked') }
return this.updateMarkers() },
// XXX should this be an interface to something like .splash???
get loading(){
return !this.dom.classList.contains('ready') },
showLoading: function(){
@ -917,14 +918,10 @@ var Gallery = {
this.dom.classList.toggle('ready')
return this },
// show current image in lightbox...
show: function(){
return this.showLightbox() },
showLightbox: function(){
this.lightbox.show()
return this },
showDetails: function(){
this.details.show()
return this },
__update_grid_size_timeout: undefined,
__update_grid_size_running: false,
@ -1333,6 +1330,7 @@ var Toolbar = {
toolbar_autohide: 2000,
// XXX make these generic...
// XXX rename .toggle(..) to something like .toggleExpanded(..)
toggle: function(action='toggle'){
var toolbar = this.dom?.classList
toolbar
@ -1352,6 +1350,16 @@ var Toolbar = {
: toolbar.remove('fixed'))
return this },
get shown(){
return this.dom.style.display != 'none' },
show: function(){
// XXX
this.dom.style.display = ''
return this },
hide: function(){
this.dom.style.display = 'none'
return this },
setup: function(dom, gallery){
var that = this
this.dom = dom
@ -1542,7 +1550,7 @@ var Overlay = {
evt.stopPropagation()
if(that.__clicks_canceled){
return }
that.gallery.showDetails() })
that.gallery.details.show() })
this.dom.querySelector('.prev')
?.addEventListener('click', function(evt){
evt.stopPropagation()