Skip to content

Commit 3faba33

Browse files
authored
Merge pull request #89 from kaidesu/preview-navigation
Preview navigation
2 parents a699568 + 9b3aae9 commit 3faba33

5 files changed

Lines changed: 86 additions & 20 deletions

File tree

public/js/chunks/85.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/gravity.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"/js/gravity.js": "/js/gravity.js?id=e8b497ebf1dfed47876d",
2+
"/js/gravity.js": "/js/gravity.js?id=37103c1f3215c830f2b5",
33
"/css/gravity.css": "/css/gravity.css?id=88cf59977307f36f5f29"
44
}

resources/js/pages/Customize.vue

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,18 @@
5757
</div>
5858
</div>
5959

60-
<div class="preview__window">
60+
<div class="preview__window flex-col">
61+
<div class="w-full px-2 bg-white border-b border-gray-300 flex items-center py-1">
62+
<button class="mr-1 w-8 h-8 focus:outline-none hover:bg-gray-200 rounded-full" @click.prevent="navigateBack"><fa-icon :icon="['fas', 'arrow-left']" class="fa-fw text-gray-700"></fa-icon></button>
63+
<button class="mr-1 w-8 h-8 focus:outline-none hover:bg-gray-200 rounded-full" @click.prevent="navigateForward"><fa-icon :icon="['fas', 'arrow-right']" class="fa-fw text-gray-700"></fa-icon></button>
64+
<button class="mr-1 w-8 h-8 focus:outline-none hover:bg-gray-200 rounded-full" @click.prevent="navigateRefresh"><fa-icon :icon="['fas', 'redo']" class="fa-fw text-gray-700"></fa-icon></button>
65+
<button class="mr-1 w-8 h-8 focus:outline-none hover:bg-gray-200 rounded-full" @click.prevent="navigateHome"><fa-icon :icon="['fas', 'home']" class="fa-fw text-gray-700"></fa-icon></button>
66+
67+
<div class="px-6 py-2 bg-gray-200 rounded-full text-gray-700 flex flex-1 mr-2 items-center leading-none">
68+
<span>{{ prettyURL }}</span>
69+
</div>
70+
</div>
71+
6172
<div class="window" :class="'window--' + window">
6273
<iframe ref="iframe" @load="onLoadIframe"></iframe>
6374
</div>
@@ -88,6 +99,8 @@
8899
theme: {},
89100
form: null,
90101
url: '/customize',
102+
history: [],
103+
current: 0,
91104
window: 'desktop',
92105
showControls: true,
93106
}
@@ -105,6 +118,11 @@
105118
isMobile() {
106119
return this.window == 'mobile'
107120
},
121+
122+
prettyURL() {
123+
let url = this.url.replace(/([^:]\/)\/+/g, "$1")
124+
return this.parseURL(url)
125+
},
108126
},
109127
110128
watch: {
@@ -119,6 +137,41 @@
119137
},
120138
121139
methods: {
140+
navigateBack() {
141+
if (this.history.length > 0) {
142+
let current = this.current - 1
143+
let url = this.history[(this.history.length - 1) + current]
144+
145+
if (url) {
146+
this.current = current
147+
this.url = url
148+
this.update()
149+
}
150+
}
151+
},
152+
153+
navigateForward() {
154+
if (this.current !== 0) {
155+
let current = this.current + 1
156+
let url = this.history[(this.history.length - 1) + current]
157+
158+
if (url) {
159+
this.current = current
160+
this.url = url
161+
this.update()
162+
}
163+
}
164+
},
165+
166+
navigateRefresh() {
167+
this.update()
168+
},
169+
170+
navigateHome() {
171+
this.url = '/customize'
172+
this.update()
173+
},
174+
122175
update: _.debounce(function() {
123176
if (cancel != undefined) {
124177
cancel();
@@ -151,10 +204,36 @@
151204
const iframe = this.$refs.iframe
152205
const url = iframe.contentWindow.location.toString()
153206
154-
if (url != 'about:blank' && !_.endsWith(url, '/customize')) {
207+
if (url == 'about:blank') {
208+
this.url = '/customize'
209+
210+
if (this.history[this.history.length - 1] != this.url) {
211+
this.history.push(this.url)
212+
this.current = 0
213+
}
214+
215+
this.update()
216+
} else if (!_.endsWith(url, '/customize')) {
155217
this.url = url + '/customize'
218+
219+
if (this.history[this.history.length - 1] != this.url) {
220+
this.history.push(this.url)
221+
this.current = 0
222+
}
223+
156224
this.update()
157225
}
226+
227+
if (this.history[this.history.length + this.current] == this.url) {
228+
this.current = this.current + 1
229+
}
230+
},
231+
232+
parseURL(url) {
233+
let parser = document.createElement('a')
234+
parser.href = url
235+
236+
return parser
158237
},
159238
160239
submit() {

src/Http/Controllers/Web/CustomizeController.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,15 @@ class CustomizeController extends Controller
1111
public function show(Request $request)
1212
{
1313
$segments = $request->segments();
14-
array_pop($segments);
15-
$url = '/'.implode('/', $segments);
16-
17-
$previous = (object) parse_url(session()->get('_previous.url'));
1814

19-
if (
20-
(optional($previous)->path != '/'.config('fusion.path')) and
21-
(optional($previous)->path != '/'.config('fusion.path').'/customize') and
22-
(optional($previous)->path != $request->path()) and
23-
(optional($previous)->path)
24-
) {
25-
$url = $previous->path;
26-
}
15+
array_pop($segments);
2716

17+
$url = '/'.implode('/', $segments);
2818
$subRequest = $this->createNewRequest($request, $url);
2919

3020
$subRequest->session()->flash('customizing', true);
31-
3221
$subRequest->attributes->set('customize', $request->all());
3322

34-
$subRequest->flash();
35-
3623
return app()->handle($subRequest);
3724
}
3825

0 commit comments

Comments
 (0)