1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
6 saveState: function() {
7 var state = history.state || {}
8 state.bodyHeight = window.getComputedStyle(document.body)['height']
9 state.currentState = this.currentState()
10 history.replaceState(state, '')
12 oninit: function(vnode) {
13 vnode.state.currentState = vnode.attrs.currentState
14 var hstate = history.state || {}
16 if (vnode.attrs.saveBodyHeight && hstate.bodyHeight) {
17 document.body.style['min-height'] = hstate.bodyHeight
18 delete hstate.bodyHeight
21 if (hstate.currentState) {
22 vnode.attrs.currentState(hstate.currentState)
23 delete hstate.currentState
25 vnode.attrs.currentState(vnode.attrs.defaultState)
28 history.replaceState(hstate, '')
30 oncreate: function(vnode) {
31 vnode.state.saveState = vnode.state.saveState.bind(vnode.state)
32 window.addEventListener('beforeunload', vnode.state.saveState)
33 vnode.state.onupdate(vnode)
35 onupdate: function(vnode) {
36 if (vnode.attrs.saveBodyHeight && vnode.attrs.forgetSavedState) {
37 document.body.style['min-height'] = null
40 onremove: function(vnode) {
41 window.removeEventListener('beforeunload', vnode.state.saveState)
43 view: function(vnode) {