rename methods
This commit is contained in:
parent
87394c2955
commit
73c7c471ea
|
@ -77,12 +77,12 @@ export default class Builder {
|
||||||
enableHotReload(node=null, historySave=true) {
|
enableHotReload(node=null, historySave=true) {
|
||||||
if(historySave)
|
if(historySave)
|
||||||
this.historySave(document.location, true)
|
this.historySave(document.location, true)
|
||||||
node.addEventListener('click', event => this._onPageChange(event), true)
|
node.addEventListener('click', event => this.pageChanged(event), true)
|
||||||
node.addEventListener('submit', event => this._onPageChange(event), true)
|
node.addEventListener('submit', event => this.pageChanged(event), true)
|
||||||
node.addEventListener('popstate', event => this._onPopState(event), true)
|
node.addEventListener('popstate', event => this.statePopped(event), true)
|
||||||
}
|
}
|
||||||
|
|
||||||
_onPageChange(event) {
|
pageChanged(event) {
|
||||||
let submit = event.type == 'submit';
|
let submit = event.type == 'submit';
|
||||||
let target = submit || event.target.tagName == 'A'
|
let target = submit || event.target.tagName == 'A'
|
||||||
? event.target : event.target.closest('a');
|
? event.target : event.target.closest('a');
|
||||||
|
@ -91,8 +91,12 @@ export default class Builder {
|
||||||
|
|
||||||
let url = submit ? target.getAttribute('action') || ''
|
let url = submit ? target.getAttribute('action') || ''
|
||||||
: target.getAttribute('href');
|
: target.getAttribute('href');
|
||||||
if(url===null || !(url === '' || url.startsWith('/') || url.startsWith('?')))
|
let domain = window.location.protocol + '//' + window.location.hostname
|
||||||
|
let stay = (url === '' || url.startsWith('/') || url.startsWith('?') ||
|
||||||
|
url.startsWith(domain)) && url.indexOf('wp-admin') == -1
|
||||||
|
if(url===null || !stay) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let options = {};
|
let options = {};
|
||||||
if(submit) {
|
if(submit) {
|
||||||
|
@ -107,10 +111,11 @@ export default class Builder {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
_onPopState(event) {
|
statePopped(event) {
|
||||||
if(event.state && event.state.content)
|
const state = event.state
|
||||||
|
if(state && state.content)
|
||||||
// document.title = this.title;
|
// document.title = this.title;
|
||||||
this.historyLoad(event.state);
|
this.historyLoad(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Save application state into browser history
|
/// Save application state into browser history
|
||||||
|
|
Loading…
Reference in New Issue
Block a user