mirror of
https://github.com/apankrat/nullboard.git
synced 2025-07-31 10:20:25 +02:00
rm conf.size, add conf.fs/lh, make them persistent
This commit is contained in:
123
nullboard.html
123
nullboard.html
@@ -198,12 +198,6 @@
|
|||||||
--lw: calc(22 * var(--fs) + 40); /* .list width */
|
--lw: calc(22 * var(--fs) + 40); /* .list width */
|
||||||
}
|
}
|
||||||
|
|
||||||
/***/
|
|
||||||
html.fsize-z1 {
|
|
||||||
--fs: 13;
|
|
||||||
--lh: 17;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***/
|
/***/
|
||||||
html, body, h1, textarea, input {
|
html, body, h1, textarea, input {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@@ -932,15 +926,6 @@
|
|||||||
transition: padding 250ms;
|
transition: padding 250ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***/
|
|
||||||
.fsize-z1 .config a.switch-fsize i {
|
|
||||||
display: inline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fsize-z1 .config a.switch-fsize b {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***/
|
/***/
|
||||||
.config a.switch-font.active:before {
|
.config a.switch-font.active:before {
|
||||||
content: '\2022 ';
|
content: '\2022 ';
|
||||||
@@ -1410,9 +1395,11 @@
|
|||||||
{
|
{
|
||||||
this.format = NB.confVersion;
|
this.format = NB.confVersion;
|
||||||
this.max_undo = 50; // board revisions to keep
|
this.max_undo = 50; // board revisions to keep
|
||||||
this.theme = null; // default or 'dark'
|
|
||||||
this.fsize = null; // default or 'z1'
|
|
||||||
this.fname = null; // font name
|
this.fname = null; // font name
|
||||||
|
this.fs = null; // font-size
|
||||||
|
this.lh = null; // line-height
|
||||||
|
this.theme = null; // default or 'dark'
|
||||||
|
this.fsize = null; // default or 'z1' -- deprecated
|
||||||
this.board = null; // active board
|
this.board = null; // active board
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1466,15 +1453,15 @@
|
|||||||
return this.setJson('config', this.conf);
|
return this.setJson('config', this.conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
setFsize(fsize)
|
setFontName(fname)
|
||||||
{
|
{
|
||||||
this.conf.fsize = fsize;
|
this.conf.fname = fname;
|
||||||
return this.setJson('config', this.conf);
|
return this.setJson('config', this.conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
setFname(fname)
|
setFontSize(fs)
|
||||||
{
|
{
|
||||||
this.conf.fname = fname;
|
this.conf.fs = fs;
|
||||||
return this.setJson('config', this.conf);
|
return this.setJson('config', this.conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1724,9 +1711,14 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.conf.theme = this.getItem('theme');
|
this.conf.theme = this.getItem('theme');
|
||||||
this.conf.fsize = this.getItem('fsize');
|
|
||||||
this.conf.board = this.getItem('last_board');
|
this.conf.board = this.getItem('last_board');
|
||||||
|
|
||||||
|
if (this.getItem('fsize') == 'z1')
|
||||||
|
{
|
||||||
|
this.conf.fs = 13;
|
||||||
|
this.conf.lh = 17;
|
||||||
|
}
|
||||||
|
|
||||||
if (! this.setJson('config', this.conf))
|
if (! this.setJson('config', this.conf))
|
||||||
{
|
{
|
||||||
this.conf = null;
|
this.conf = null;
|
||||||
@@ -3212,12 +3204,18 @@
|
|||||||
|
|
||||||
if (conf.fname && ! NB.fonts.hasOwnProperty(conf.fname))
|
if (conf.fname && ! NB.fonts.hasOwnProperty(conf.fname))
|
||||||
{
|
{
|
||||||
NB.storage.setFname(null);
|
NB.storage.setFontName(null);
|
||||||
selectFont(null);
|
selectFont(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
selectFont(conf.fname || 'barlow');
|
selectFont(conf.fname || 'barlow');
|
||||||
|
|
||||||
|
if (conf.fs)
|
||||||
|
setFontSize(conf.fs);
|
||||||
|
|
||||||
|
if (conf.lh)
|
||||||
|
setLineHeight(conf.lh);
|
||||||
|
|
||||||
updateFontSize();
|
updateFontSize();
|
||||||
updateLineHeight();
|
updateLineHeight();
|
||||||
}
|
}
|
||||||
@@ -3238,9 +3236,6 @@
|
|||||||
fv.fs = fv.fs || fv_defs.fs;
|
fv.fs = fv.fs || fv_defs.fs;
|
||||||
fv.lh = fv.lh || fv_defs.lh;
|
fv.lh = fv.lh || fv_defs.lh;
|
||||||
|
|
||||||
fv.fs_cust = null;
|
|
||||||
fv.lh_cust = null;
|
|
||||||
|
|
||||||
NB.fonts[f_name] = fv;
|
NB.fonts[f_name] = fv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3281,9 +3276,6 @@
|
|||||||
|
|
||||||
var f = NB.fonts[NB.font];
|
var f = NB.fonts[NB.font];
|
||||||
|
|
||||||
$('html').css('--fs', (f.fs_cust || '') + '' );
|
|
||||||
$('html').css('--lh', (f.lh_cust || '') + '' );
|
|
||||||
|
|
||||||
updateFontSize();
|
updateFontSize();
|
||||||
updateLineHeight();
|
updateLineHeight();
|
||||||
}
|
}
|
||||||
@@ -3319,6 +3311,8 @@
|
|||||||
$val.html( val.toFixed(1) );
|
$val.html( val.toFixed(1) );
|
||||||
if (val == def) $val.parent().removeClass('custom');
|
if (val == def) $val.parent().removeClass('custom');
|
||||||
else $val.parent().addClass('custom');
|
else $val.parent().addClass('custom');
|
||||||
|
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateLineHeight()
|
function updateLineHeight()
|
||||||
@@ -3330,51 +3324,46 @@
|
|||||||
$val.html( val.toFixed(1) );
|
$val.html( val.toFixed(1) );
|
||||||
if (val == def) $val.parent().removeClass('custom');
|
if (val == def) $val.parent().removeClass('custom');
|
||||||
else $val.parent().addClass('custom');
|
else $val.parent().addClass('custom');
|
||||||
|
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
function setFontSize(fs)
|
function setFontSize(fs)
|
||||||
{
|
{
|
||||||
if (fs < 9 || fs > 24)
|
if (9 <= fs && fs <= 24)
|
||||||
return;
|
{
|
||||||
|
$('html').css('--fs', fs + '');
|
||||||
|
updateFontSize();
|
||||||
|
|
||||||
$('html').css('--fs', fs + '');
|
if (getLineHeight() < fs)
|
||||||
NB.fonts[NB.font].fs_cust = fs;
|
setLineHeight(fs);
|
||||||
|
}
|
||||||
updateFontSize();
|
return getFontSize();
|
||||||
|
|
||||||
if (getLineHeight() < fs)
|
|
||||||
setLineHeight(fs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLineHeight(lh)
|
function setLineHeight(lh)
|
||||||
{
|
{
|
||||||
var fs = getFontSize();
|
var fs = getFontSize();
|
||||||
|
if (fs <= lh && lh <= 3*fs)
|
||||||
if (lh < fs || lh >= 3*fs)
|
{
|
||||||
return;
|
$('html').css('--lh', lh + '');
|
||||||
|
updateLineHeight();
|
||||||
$('html').css('--lh', lh + '');
|
}
|
||||||
NB.fonts[NB.font].lh_cust = lh;
|
return getLineHeight();
|
||||||
|
|
||||||
updateLineHeight();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
function resetFontSize()
|
function resetFontSize()
|
||||||
{
|
{
|
||||||
$('html').css('--fs', '');
|
$('html').css('--fs', '');
|
||||||
NB.fonts[NB.font].fs_cust = null;
|
return updateFontSize();
|
||||||
updateFontSize();
|
|
||||||
return getFontSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetLineHeight()
|
function resetLineHeight()
|
||||||
{
|
{
|
||||||
$('html').css('--lh', '');
|
$('html').css('--lh', '');
|
||||||
NB.fonts[NB.font].lh_cust = null;
|
return updateLineHeight();
|
||||||
updateLineHeight();
|
|
||||||
return getLineHeight();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3678,23 +3667,17 @@
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.config').on('click', '.switch-fsize', function(){
|
|
||||||
var $html = $('html');
|
|
||||||
$html.toggleClass('fsize-z1');
|
|
||||||
NB.storage.setFsize($html.hasClass('fsize-z1') ? 'z1' : '');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.config').on('click', '.switch-font', function(){
|
$('.config').on('click', '.switch-font', function(){
|
||||||
var font = $(this).attr('font');
|
var font = $(this).attr('font');
|
||||||
selectFont(font);
|
selectFont(font);
|
||||||
NB.storage.setFname(font);
|
NB.storage.setFontName(font);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
//
|
//
|
||||||
$('.config .f-prefs .ui-fs .less').on('click', function(){
|
$('.config .f-prefs .ui-fs .less').on('click', function(){
|
||||||
setFontSize( getFontSize() - 0.5 );
|
var fs = setFontSize( getFontSize() - 0.5 );
|
||||||
|
NB.storage.setFontSize(fs);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -3702,16 +3685,20 @@
|
|||||||
var fs = resetFontSize();
|
var fs = resetFontSize();
|
||||||
if (getLineHeight() < fs)
|
if (getLineHeight() < fs)
|
||||||
setLineHeight(fs);
|
setLineHeight(fs);
|
||||||
|
NB.storage.setFontSize(null);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.config .f-prefs .ui-fs .more').on('click', function(){
|
$('.config .f-prefs .ui-fs .more').on('click', function(){
|
||||||
setFontSize( getFontSize() + 0.5 );
|
var fs = setFontSize( getFontSize() + 0.5 );
|
||||||
|
NB.storage.setFontSize(fs);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//
|
||||||
$('.config .f-prefs .ui-lh .less').on('click', function(){
|
$('.config .f-prefs .ui-lh .less').on('click', function(){
|
||||||
setLineHeight( getLineHeight() - 0.5 );
|
var lh = setLineHeight( getLineHeight() - 0.5 );
|
||||||
|
NB.storage.setLineHeight(lh);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -3719,11 +3706,13 @@
|
|||||||
var lh = resetLineHeight();
|
var lh = resetLineHeight();
|
||||||
if (lh < getFontSize())
|
if (lh < getFontSize())
|
||||||
setFontSize(lh);
|
setFontSize(lh);
|
||||||
|
NB.storage.setLineHeight(null);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.config .f-prefs .ui-lh .more').on('click', function(){
|
$('.config .f-prefs .ui-lh .more').on('click', function(){
|
||||||
setLineHeight( getLineHeight() + 0.5 );
|
var lh = setLineHeight( getLineHeight() + 0.5 );
|
||||||
|
NB.storage.setLineHeight(lh);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -3787,8 +3776,7 @@
|
|||||||
|
|
||||||
console.log( `Active: [${conf.board}]` );
|
console.log( `Active: [${conf.board}]` );
|
||||||
console.log( `Theme: [${conf.theme}]` );
|
console.log( `Theme: [${conf.theme}]` );
|
||||||
console.log( `FSize: [${conf.fsize}]` );
|
console.log( `Font: [${conf.fname}], size [${conf.fs || '-'}], line-height [${conf.lh || '-'}]` );
|
||||||
console.log( `FName: [${conf.fname}]` );
|
|
||||||
|
|
||||||
//
|
//
|
||||||
initFonts();
|
initFonts();
|
||||||
@@ -3799,9 +3787,6 @@
|
|||||||
if (conf.theme)
|
if (conf.theme)
|
||||||
$('html').addClass('theme-' + conf.theme);
|
$('html').addClass('theme-' + conf.theme);
|
||||||
|
|
||||||
if (conf.fsize)
|
|
||||||
$('html').addClass('fsize-' + conf.fsize);
|
|
||||||
|
|
||||||
if (conf.board)
|
if (conf.board)
|
||||||
openBoard(conf.board)
|
openBoard(conf.board)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user