tweaking and minor tweaks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-11-29 20:49:38 +03:00
parent 811ed21223
commit 901683bcca
2 changed files with 26 additions and 20 deletions

View File

@ -2093,21 +2093,22 @@ object.Constructor('pWikiPageElement', Page, {
// XXX CACHE...
__last_refresh_location: undefined,
refresh: async function(full=false){
// drop cache if re-refreshing or when full refresh requested...
// XXX CACHE...
;(full
|| this.__last_refresh_location == this.location)
&& this.cache
&& (this.cache = null)
this.__last_refresh_location = this.location
var dom = this.dom
dom.innerHTML = await this.text
for(var filter of Object.values(this.domFilters)){
filter
&& filter.call(this, dom) }
this.trigger('onLoad')
return this },
refresh: types.event.Event('refresh',
async function(full=false){
// drop cache if re-refreshing or when full refresh requested...
// XXX CACHE...
;(full
|| this.__last_refresh_location == this.location)
&& this.cache
&& (this.cache = null)
this.__last_refresh_location = this.location
var dom = this.dom
dom.innerHTML = await this.text
for(var filter of Object.values(this.domFilters)){
filter
&& filter.call(this, dom) }
this.trigger('onLoad')
return this }),
// handle dom as first argument...
__init__: function(dom, ...args){

View File

@ -374,6 +374,7 @@ var logTime = async function(promise, msg=''){
REFRESH_DELAY = 20
var refresh = async function(){
pwiki.__prev_path = pwiki.path
startSpinner()
setTimeout(function(){
logTime(
@ -381,6 +382,9 @@ var refresh = async function(){
pwiki.location) }, REFRESH_DELAY) }
history.scrollRestoration = 'manual'
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// start loading pWiki...
require(['./browser'], function(browser){
@ -425,6 +429,7 @@ require(['./browser'], function(browser){
pwiki
.onBeforeNavigate(function(){
this.__prev_path = this.path
saveAll() })
.navigate(async function(){
// NOTE: we do not need to directly update location.hash here as
@ -471,11 +476,11 @@ require(['./browser'], function(browser){
.querySelector('#'+ this.hash)
.scrollIntoView()
// restore history position...
// XXX HACK this will work only on full page...
: (document.scrollingElement.scrollTop = this.__scroll ?? 0)
// XXX MediumEditor...
//setupMediumEditor()
// NOTE: only on navigate to new page...
// XXX HACK this will work only on full page pWiki and
// not on a element/nested pWiki...
: (this.__prev_path != this.path
&& (document.scrollingElement.scrollTop = this.__scroll ?? 0))
// handle refresh...
// NOTE: we need to do this as hashchange is only triggered