glib-web 0.5.77 → 0.5.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -0
- package/action.js +167 -167
- package/actions/analytics/logEvent.js +0 -0
- package/actions/cables/push.js +0 -0
- package/actions/dialogs/notification.js +0 -0
- package/actions/http/patch.js +0 -0
- package/actions/panels/scrollTo.js +18 -18
- package/actions/panels/scrollToBottom.js +0 -0
- package/actions/timeouts/set.js +20 -20
- package/actions/windows/close.js +0 -0
- package/actions/windows/closeAll.js +0 -0
- package/actions/windows/closeWithReload.js +0 -0
- package/actions/windows/refreshState.js +5 -5
- package/actions/windows/reload.js +0 -0
- package/actions/ws/push.js +0 -0
- package/app.vue +180 -180
- package/components/_button.vue +101 -101
- package/components/_dropdownMenu.vue +76 -76
- package/components/_icon.vue +50 -50
- package/components/avatar.vue +16 -16
- package/components/banners/alert.vue +0 -0
- package/components/banners/select.vue +82 -82
- package/components/component.vue +222 -222
- package/components/fields/_patternText.vue +61 -61
- package/components/fields/_select.vue +86 -86
- package/components/fields/autocomplete.vue +73 -73
- package/components/fields/check.vue +104 -104
- package/components/fields/creditCard.vue +0 -0
- package/components/fields/dynamicGroup.vue +0 -0
- package/components/fields/hidden.vue +0 -0
- package/components/fields/location.vue +0 -0
- package/components/fields/newRichText.vue +0 -0
- package/components/fields/phone/countries.js +315 -315
- package/components/fields/phone/field.vue +348 -348
- package/components/fields/phone/sprite.css +1071 -1071
- package/components/fields/radio.vue +64 -64
- package/components/fields/radioGroup.vue +0 -0
- package/components/fields/rating.vue +0 -0
- package/components/fields/richText.vue +0 -0
- package/components/fields/select.vue +17 -17
- package/components/fields/stripe/stripeFields.vue +93 -93
- package/components/fields/stripe/stripeIndividualFields.vue +207 -207
- package/components/fields/stripeExternalAccount.vue +135 -135
- package/components/fields/text.vue +0 -0
- package/components/fields/textarea.vue +0 -0
- package/components/fields/timeZone.vue +22 -22
- package/components/fields/timer.vue +83 -83
- package/components/h1.vue +28 -28
- package/components/h2.vue +20 -20
- package/components/h3.vue +22 -22
- package/components/h4.vue +20 -20
- package/components/h5.vue +20 -20
- package/components/h6.vue +20 -20
- package/components/icon.vue +25 -25
- package/components/label.vue +62 -62
- package/components/map.vue +0 -0
- package/components/mixins/events.js +178 -178
- package/components/mixins/generic.js +0 -0
- package/components/mixins/list/autoload.js +0 -0
- package/components/mixins/styles.js +221 -221
- package/components/mixins/table/autoload.js +0 -0
- package/components/mixins/text.js +20 -20
- package/components/mixins/ws/actionCable.js +48 -48
- package/components/mixins/ws/phoenixSocket.js +0 -0
- package/components/panels/carousel.vue +55 -55
- package/components/panels/flow.vue +81 -81
- package/components/panels/form.vue +126 -126
- package/components/panels/list.vue +0 -0
- package/components/panels/scroll.vue +0 -0
- package/components/panels/table.vue +0 -0
- package/components/panels/ul.vue +34 -34
- package/components/panels/vertical.vue +0 -0
- package/components/panels/web.vue +11 -11
- package/components/spacer.vue +0 -0
- package/components/switch.vue +42 -42
- package/extensions/string.js +21 -21
- package/index.js +195 -195
- package/nav/content.vue +0 -0
- package/nav/dialog.vue +127 -127
- package/nav/snackbar.vue +0 -0
- package/package.json +42 -42
- package/static/plugins/alignment/alignment.js +0 -0
- package/static/plugins/alignment/alignment.min.js +0 -0
- package/static/plugins/beyondgrammar/beyondgrammar.js +0 -0
- package/static/plugins/beyondgrammar/beyondgrammar.min.js +0 -0
- package/static/plugins/blockcode/blockcode.js +0 -0
- package/static/plugins/blockcode/blockcode.min.js +0 -0
- package/static/plugins/clips/clips.js +0 -0
- package/static/plugins/clips/clips.min.js +0 -0
- package/static/plugins/counter/counter.js +0 -0
- package/static/plugins/counter/counter.min.js +0 -0
- package/static/plugins/definedlinks/definedlinks.js +0 -0
- package/static/plugins/definedlinks/definedlinks.min.js +0 -0
- package/static/plugins/handle/handle.js +0 -0
- package/static/plugins/handle/handle.min.js +0 -0
- package/static/plugins/icons/icons.js +0 -0
- package/static/plugins/icons/icons.min.js +0 -0
- package/static/plugins/imageposition/imageposition.js +0 -0
- package/static/plugins/imageposition/imageposition.min.js +0 -0
- package/static/plugins/inlineformat/inlineformat.js +0 -0
- package/static/plugins/inlineformat/inlineformat.min.js +0 -0
- package/static/plugins/removeformat/removeformat.js +0 -0
- package/static/plugins/removeformat/removeformat.min.js +0 -0
- package/static/plugins/selector/selector.js +0 -0
- package/static/plugins/selector/selector.min.js +0 -0
- package/static/plugins/specialchars/specialchars.js +0 -0
- package/static/plugins/specialchars/specialchars.min.js +0 -0
- package/static/plugins/textdirection/textdirection.js +0 -0
- package/static/plugins/textdirection/textdirection.min.js +0 -0
- package/static/plugins/textexpander/textexpander.js +0 -0
- package/static/plugins/textexpander/textexpander.min.js +0 -0
- package/static/plugins/underline/underline.js +0 -0
- package/static/plugins/underline/underline.min.js +0 -0
- package/static/redactorx.css +0 -0
- package/static/redactorx.js +0 -0
- package/static/redactorx.min.css +0 -0
- package/static/redactorx.min.js +0 -0
- package/static/redactorx.usm.min.js +0 -0
- package/templates/_menu.vue +38 -38
- package/templates/comment.vue +202 -202
- package/templates/featured.vue +32 -32
- package/templates/thumbnail.vue +138 -138
- package/templates/unsupported.vue +12 -12
- package/utils/app.js +0 -0
- package/utils/hash.js +0 -0
- package/utils/helper.js +0 -0
- package/utils/history.js +70 -70
- package/utils/http.js +209 -209
- package/utils/launch.js +135 -135
- package/utils/private/ws.js +0 -0
package/templates/thumbnail.vue
CHANGED
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<v-list-item
|
|
3
|
-
v-longclick="$onLongPress"
|
|
4
|
-
:href="$href()"
|
|
5
|
-
style="padding-left: 0"
|
|
6
|
-
@[clickCondition]="$onClick()"
|
|
7
|
-
>
|
|
8
|
-
<v-icon v-if="spec.onReorder" class="handle">drag_indicator</v-icon>
|
|
9
|
-
|
|
10
|
-
<div class="left-universal">
|
|
11
|
-
<template v-for="(item, index) in spec.leftButtons">
|
|
12
|
-
<common-button
|
|
13
|
-
:key="index"
|
|
14
|
-
:spec="buttonSpec(item)"
|
|
15
|
-
:disabled="$isBusy"
|
|
16
|
-
/>
|
|
17
|
-
</template>
|
|
18
|
-
</div>
|
|
19
|
-
|
|
20
|
-
<v-list-item-avatar
|
|
21
|
-
v-if="$type.isString(spec.imageUrl)"
|
|
22
|
-
:tile="!spec.avatar"
|
|
23
|
-
class="left-thumbnail"
|
|
24
|
-
>
|
|
25
|
-
<img :src="spec.imageUrl" />
|
|
26
|
-
</v-list-item-avatar>
|
|
27
|
-
<!-- <v-list-item-avatar v-else-if="$type.isObject(spec.icon)">
|
|
28
|
-
<common-icon :spec="spec.icon" />
|
|
29
|
-
</v-list-item-avatar> -->
|
|
30
|
-
<div v-else class="left-icon">
|
|
31
|
-
<v-list-item-avatar v-if="$type.isObject(spec.icon)">
|
|
32
|
-
<common-icon :spec="spec.icon" />
|
|
33
|
-
</v-list-item-avatar>
|
|
34
|
-
</div>
|
|
35
|
-
|
|
36
|
-
<v-list-item-content>
|
|
37
|
-
<v-list-item-title>{{ spec.title }}</v-list-item-title>
|
|
38
|
-
<v-list-item-subtitle v-if="spec.subtitle">{{
|
|
39
|
-
spec.subtitle
|
|
40
|
-
}}</v-list-item-subtitle>
|
|
41
|
-
<v-list-item-subtitle v-if="spec.subsubtitle">{{
|
|
42
|
-
spec.subsubtitle
|
|
43
|
-
}}</v-list-item-subtitle>
|
|
44
|
-
|
|
45
|
-
<div>
|
|
46
|
-
<template v-for="(item, index) in chips">
|
|
47
|
-
<v-chip :key="index" class="ma-1" :color="item.color" small>
|
|
48
|
-
{{ item.text }}
|
|
49
|
-
</v-chip>
|
|
50
|
-
</template>
|
|
51
|
-
</div>
|
|
52
|
-
|
|
53
|
-
<!-- NOTE: Experimental -->
|
|
54
|
-
<panels-responsive :spec="accessory" />
|
|
55
|
-
</v-list-item-content>
|
|
56
|
-
|
|
57
|
-
<template v-for="(item, index) in spec.rightButtons">
|
|
58
|
-
<common-button
|
|
59
|
-
:key="index"
|
|
60
|
-
:spec="buttonSpec(item)"
|
|
61
|
-
:disabled="$isBusy"
|
|
62
|
-
/>
|
|
63
|
-
</template>
|
|
64
|
-
|
|
65
|
-
<templates-menu :edit-buttons="editButtons" />
|
|
66
|
-
</v-list-item>
|
|
67
|
-
</template>
|
|
68
|
-
|
|
69
|
-
<script>
|
|
70
|
-
export default {
|
|
71
|
-
props: {
|
|
72
|
-
spec: { type: Object, required: true }
|
|
73
|
-
},
|
|
74
|
-
data() {
|
|
75
|
-
return {
|
|
76
|
-
accessory: {},
|
|
77
|
-
editButtons: []
|
|
78
|
-
// chips: []
|
|
79
|
-
};
|
|
80
|
-
},
|
|
81
|
-
computed: {
|
|
82
|
-
clickCondition() {
|
|
83
|
-
if (this.spec.onClick || this.spec.onLongPress) {
|
|
84
|
-
// This will show the clickable indication
|
|
85
|
-
return "click";
|
|
86
|
-
}
|
|
87
|
-
return null;
|
|
88
|
-
},
|
|
89
|
-
// Implemented as computed so that it gets reflected when reordering
|
|
90
|
-
chips() {
|
|
91
|
-
return (this.spec.chips || []).map(item => {
|
|
92
|
-
var color = null;
|
|
93
|
-
this.$type.ifArray(item.styleClasses, classes => {
|
|
94
|
-
for (const val of ["success", "info", "warning", "error"]) {
|
|
95
|
-
if (classes.includes(val)) {
|
|
96
|
-
color = val;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
return Object.assign({}, item, { color: color });
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
methods: {
|
|
105
|
-
$ready() {
|
|
106
|
-
this.accessory = { childViews: this.spec.accessoryViews };
|
|
107
|
-
this.editButtons = this.spec.editButtons || [];
|
|
108
|
-
},
|
|
109
|
-
buttonSpec(item) {
|
|
110
|
-
return Object.assign({}, item, {
|
|
111
|
-
view: "button-v1",
|
|
112
|
-
styleClasses: item.text ? ["text"] : ["icon"]
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
</script>
|
|
118
|
-
|
|
119
|
-
<style lang="scss" scoped>
|
|
120
|
-
@media (min-width: 600px) {
|
|
121
|
-
.left-thumbnail.v-avatar.v-list-item__avatar {
|
|
122
|
-
margin: 6px 6px 6px 6px;
|
|
123
|
-
width: 60px;
|
|
124
|
-
height: 60px;
|
|
125
|
-
}
|
|
126
|
-
.left-icon {
|
|
127
|
-
// margin-left: 16px;
|
|
128
|
-
margin-left: 4px;
|
|
129
|
-
}
|
|
130
|
-
.left-universal {
|
|
131
|
-
padding-left: 16px;
|
|
132
|
-
}
|
|
133
|
-
.handle {
|
|
134
|
-
margin-left: 10px;
|
|
135
|
-
cursor: move;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<v-list-item
|
|
3
|
+
v-longclick="$onLongPress"
|
|
4
|
+
:href="$href()"
|
|
5
|
+
style="padding-left: 0"
|
|
6
|
+
@[clickCondition]="$onClick()"
|
|
7
|
+
>
|
|
8
|
+
<v-icon v-if="spec.onReorder" class="handle">drag_indicator</v-icon>
|
|
9
|
+
|
|
10
|
+
<div class="left-universal">
|
|
11
|
+
<template v-for="(item, index) in spec.leftButtons">
|
|
12
|
+
<common-button
|
|
13
|
+
:key="index"
|
|
14
|
+
:spec="buttonSpec(item)"
|
|
15
|
+
:disabled="$isBusy"
|
|
16
|
+
/>
|
|
17
|
+
</template>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<v-list-item-avatar
|
|
21
|
+
v-if="$type.isString(spec.imageUrl)"
|
|
22
|
+
:tile="!spec.avatar"
|
|
23
|
+
class="left-thumbnail"
|
|
24
|
+
>
|
|
25
|
+
<img :src="spec.imageUrl" />
|
|
26
|
+
</v-list-item-avatar>
|
|
27
|
+
<!-- <v-list-item-avatar v-else-if="$type.isObject(spec.icon)">
|
|
28
|
+
<common-icon :spec="spec.icon" />
|
|
29
|
+
</v-list-item-avatar> -->
|
|
30
|
+
<div v-else class="left-icon">
|
|
31
|
+
<v-list-item-avatar v-if="$type.isObject(spec.icon)">
|
|
32
|
+
<common-icon :spec="spec.icon" />
|
|
33
|
+
</v-list-item-avatar>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<v-list-item-content>
|
|
37
|
+
<v-list-item-title>{{ spec.title }}</v-list-item-title>
|
|
38
|
+
<v-list-item-subtitle v-if="spec.subtitle">{{
|
|
39
|
+
spec.subtitle
|
|
40
|
+
}}</v-list-item-subtitle>
|
|
41
|
+
<v-list-item-subtitle v-if="spec.subsubtitle">{{
|
|
42
|
+
spec.subsubtitle
|
|
43
|
+
}}</v-list-item-subtitle>
|
|
44
|
+
|
|
45
|
+
<div>
|
|
46
|
+
<template v-for="(item, index) in chips">
|
|
47
|
+
<v-chip :key="index" class="ma-1" :color="item.color" small>
|
|
48
|
+
{{ item.text }}
|
|
49
|
+
</v-chip>
|
|
50
|
+
</template>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<!-- NOTE: Experimental -->
|
|
54
|
+
<panels-responsive :spec="accessory" />
|
|
55
|
+
</v-list-item-content>
|
|
56
|
+
|
|
57
|
+
<template v-for="(item, index) in spec.rightButtons">
|
|
58
|
+
<common-button
|
|
59
|
+
:key="index"
|
|
60
|
+
:spec="buttonSpec(item)"
|
|
61
|
+
:disabled="$isBusy"
|
|
62
|
+
/>
|
|
63
|
+
</template>
|
|
64
|
+
|
|
65
|
+
<templates-menu :edit-buttons="editButtons" />
|
|
66
|
+
</v-list-item>
|
|
67
|
+
</template>
|
|
68
|
+
|
|
69
|
+
<script>
|
|
70
|
+
export default {
|
|
71
|
+
props: {
|
|
72
|
+
spec: { type: Object, required: true }
|
|
73
|
+
},
|
|
74
|
+
data() {
|
|
75
|
+
return {
|
|
76
|
+
accessory: {},
|
|
77
|
+
editButtons: []
|
|
78
|
+
// chips: []
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
computed: {
|
|
82
|
+
clickCondition() {
|
|
83
|
+
if (this.spec.onClick || this.spec.onLongPress) {
|
|
84
|
+
// This will show the clickable indication
|
|
85
|
+
return "click";
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
},
|
|
89
|
+
// Implemented as computed so that it gets reflected when reordering
|
|
90
|
+
chips() {
|
|
91
|
+
return (this.spec.chips || []).map(item => {
|
|
92
|
+
var color = null;
|
|
93
|
+
this.$type.ifArray(item.styleClasses, classes => {
|
|
94
|
+
for (const val of ["success", "info", "warning", "error"]) {
|
|
95
|
+
if (classes.includes(val)) {
|
|
96
|
+
color = val;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
return Object.assign({}, item, { color: color });
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
methods: {
|
|
105
|
+
$ready() {
|
|
106
|
+
this.accessory = { childViews: this.spec.accessoryViews };
|
|
107
|
+
this.editButtons = this.spec.editButtons || [];
|
|
108
|
+
},
|
|
109
|
+
buttonSpec(item) {
|
|
110
|
+
return Object.assign({}, item, {
|
|
111
|
+
view: "button-v1",
|
|
112
|
+
styleClasses: item.text ? ["text"] : ["icon"]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
</script>
|
|
118
|
+
|
|
119
|
+
<style lang="scss" scoped>
|
|
120
|
+
@media (min-width: 600px) {
|
|
121
|
+
.left-thumbnail.v-avatar.v-list-item__avatar {
|
|
122
|
+
margin: 6px 6px 6px 6px;
|
|
123
|
+
width: 60px;
|
|
124
|
+
height: 60px;
|
|
125
|
+
}
|
|
126
|
+
.left-icon {
|
|
127
|
+
// margin-left: 16px;
|
|
128
|
+
margin-left: 4px;
|
|
129
|
+
}
|
|
130
|
+
.left-universal {
|
|
131
|
+
padding-left: 16px;
|
|
132
|
+
}
|
|
133
|
+
.handle {
|
|
134
|
+
margin-left: 10px;
|
|
135
|
+
cursor: move;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
</style>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>Unsupported template: {{ name }}</div>
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script>
|
|
6
|
-
export default {
|
|
7
|
-
props: {
|
|
8
|
-
spec: { type: Object, required: true },
|
|
9
|
-
name: { type: String, required: true }
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div>Unsupported template: {{ name }}</div>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
export default {
|
|
7
|
+
props: {
|
|
8
|
+
spec: { type: Object, required: true },
|
|
9
|
+
name: { type: String, required: true }
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
</script>
|
package/utils/app.js
CHANGED
|
File without changes
|
package/utils/hash.js
CHANGED
|
File without changes
|
package/utils/helper.js
CHANGED
|
File without changes
|
package/utils/history.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import Vue from "vue";
|
|
2
|
-
|
|
3
|
-
export default class {
|
|
4
|
-
static saveInitialContent(content) {
|
|
5
|
-
// History only handles document's scroll position. It doesn't handle our body div's position
|
|
6
|
-
this.bodyScrollTops = [];
|
|
7
|
-
// This differs from window.history.length in that this only counts internal navigation
|
|
8
|
-
this.navigationCount = 0;
|
|
9
|
-
// Set initial state so we can go back to it
|
|
10
|
-
window.history.replaceState(this._data(content), "", window.location.href);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
static get _pageBody() {
|
|
14
|
-
return document.getElementById("page_body");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static _data(content) {
|
|
18
|
-
return { content: content, navigationCount: this.navigationCount };
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static pushPage(content, url) {
|
|
22
|
-
// Save scroll position of the current page when navigating to the next page
|
|
23
|
-
this.bodyScrollTops[this.navigationCount] = this._pageBody.scrollTop;
|
|
24
|
-
|
|
25
|
-
this.navigationCount++;
|
|
26
|
-
|
|
27
|
-
// Save data of the next page (page getting pushed)
|
|
28
|
-
window.history.pushState(this._data(content), "", url);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
static resetScroll() {
|
|
32
|
-
this._pageBody.scrollTop = 0;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static restoreOnBackOrForward() {
|
|
36
|
-
const vm = this;
|
|
37
|
-
window.onpopstate = event => {
|
|
38
|
-
// Save scroll position of the current page when navigating through back/forward button
|
|
39
|
-
this.bodyScrollTops[this.navigationCount] = this._pageBody.scrollTop;
|
|
40
|
-
|
|
41
|
-
const data = event.state;
|
|
42
|
-
data.content.__poppedState = true;
|
|
43
|
-
window.vueApp.page = data.content;
|
|
44
|
-
vm.navigationCount = data.navigationCount;
|
|
45
|
-
|
|
46
|
-
Vue.nextTick(() => {
|
|
47
|
-
const scrollTop = this.bodyScrollTops[this.navigationCount];
|
|
48
|
-
this._pageBody.scrollTop = scrollTop;
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
static isPoppedState(page) {
|
|
54
|
-
return page.__poppedState == true;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
static updatePage(url = window.location.href) {
|
|
58
|
-
window.history.replaceState(this._data(window.vueApp.page), "", url);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
static back() {
|
|
62
|
-
if (this.navigationCount > 0) {
|
|
63
|
-
window.history.back();
|
|
64
|
-
return true;
|
|
65
|
-
} else {
|
|
66
|
-
console.log("Reached beginning of navigation stack");
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
1
|
+
import Vue from "vue";
|
|
2
|
+
|
|
3
|
+
export default class {
|
|
4
|
+
static saveInitialContent(content) {
|
|
5
|
+
// History only handles document's scroll position. It doesn't handle our body div's position
|
|
6
|
+
this.bodyScrollTops = [];
|
|
7
|
+
// This differs from window.history.length in that this only counts internal navigation
|
|
8
|
+
this.navigationCount = 0;
|
|
9
|
+
// Set initial state so we can go back to it
|
|
10
|
+
window.history.replaceState(this._data(content), "", window.location.href);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static get _pageBody() {
|
|
14
|
+
return document.getElementById("page_body");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static _data(content) {
|
|
18
|
+
return { content: content, navigationCount: this.navigationCount };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static pushPage(content, url) {
|
|
22
|
+
// Save scroll position of the current page when navigating to the next page
|
|
23
|
+
this.bodyScrollTops[this.navigationCount] = this._pageBody.scrollTop;
|
|
24
|
+
|
|
25
|
+
this.navigationCount++;
|
|
26
|
+
|
|
27
|
+
// Save data of the next page (page getting pushed)
|
|
28
|
+
window.history.pushState(this._data(content), "", url);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static resetScroll() {
|
|
32
|
+
this._pageBody.scrollTop = 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static restoreOnBackOrForward() {
|
|
36
|
+
const vm = this;
|
|
37
|
+
window.onpopstate = event => {
|
|
38
|
+
// Save scroll position of the current page when navigating through back/forward button
|
|
39
|
+
this.bodyScrollTops[this.navigationCount] = this._pageBody.scrollTop;
|
|
40
|
+
|
|
41
|
+
const data = event.state;
|
|
42
|
+
data.content.__poppedState = true;
|
|
43
|
+
window.vueApp.page = data.content;
|
|
44
|
+
vm.navigationCount = data.navigationCount;
|
|
45
|
+
|
|
46
|
+
Vue.nextTick(() => {
|
|
47
|
+
const scrollTop = this.bodyScrollTops[this.navigationCount];
|
|
48
|
+
this._pageBody.scrollTop = scrollTop;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static isPoppedState(page) {
|
|
54
|
+
return page.__poppedState == true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static updatePage(url = window.location.href) {
|
|
58
|
+
window.history.replaceState(this._data(window.vueApp.page), "", url);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static back() {
|
|
62
|
+
if (this.navigationCount > 0) {
|
|
63
|
+
window.history.back();
|
|
64
|
+
return true;
|
|
65
|
+
} else {
|
|
66
|
+
console.log("Reached beginning of navigation stack");
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|