|
1 | | -var LocationDispatcher = require('../dispatchers/LocationDispatcher'); |
2 | | -var isAbsoluteURL = require('../utils/isAbsoluteURL'); |
3 | | -var makePath = require('../utils/makePath'); |
4 | | - |
5 | | -function loadURL(url) { |
6 | | - window.location = url; |
7 | | -} |
8 | | - |
9 | 1 | /** |
10 | 2 | * Actions that modify the URL. |
11 | 3 | */ |
12 | 4 | var LocationActions = { |
13 | 5 |
|
14 | | - PUSH: 'push', |
15 | | - REPLACE: 'replace', |
16 | | - POP: 'pop', |
17 | | - UPDATE_SCROLL: 'update-scroll', |
18 | | - |
19 | 6 | /** |
20 | | - * Transitions to the URL specified in the arguments by pushing |
21 | | - * a new URL onto the history stack. |
| 7 | + * Indicates a location is being setup for the first time. |
22 | 8 | */ |
23 | | - transitionTo: function (to, params, query) { |
24 | | - if (isAbsoluteURL(to)) { |
25 | | - loadURL(to); |
26 | | - } else { |
27 | | - LocationDispatcher.handleViewAction({ |
28 | | - type: LocationActions.PUSH, |
29 | | - path: makePath(to, params, query) |
30 | | - }); |
31 | | - } |
32 | | - }, |
| 9 | + SETUP: 'setup', |
33 | 10 |
|
34 | 11 | /** |
35 | | - * Transitions to the URL specified in the arguments by replacing |
36 | | - * the current URL in the history stack. |
| 12 | + * Indicates a new location is being pushed to the history stack. |
37 | 13 | */ |
38 | | - replaceWith: function (to, params, query) { |
39 | | - if (isAbsoluteURL(to)) { |
40 | | - loadURL(to); |
41 | | - } else { |
42 | | - LocationDispatcher.handleViewAction({ |
43 | | - type: LocationActions.REPLACE, |
44 | | - path: makePath(to, params, query) |
45 | | - }); |
46 | | - } |
47 | | - }, |
| 14 | + PUSH: 'push', |
48 | 15 |
|
49 | 16 | /** |
50 | | - * Transitions to the previous URL. |
| 17 | + * Indicates the current location should be replaced. |
51 | 18 | */ |
52 | | - goBack: function () { |
53 | | - LocationDispatcher.handleViewAction({ |
54 | | - type: LocationActions.POP |
55 | | - }); |
56 | | - }, |
| 19 | + REPLACE: 'replace', |
57 | 20 |
|
58 | 21 | /** |
59 | | - * Updates the window's scroll position to the last known position |
60 | | - * for the current URL path. |
| 22 | + * Indicates the most recent entry should be removed from the history stack. |
61 | 23 | */ |
62 | | - updateScroll: function () { |
63 | | - LocationDispatcher.handleViewAction({ |
64 | | - type: LocationActions.UPDATE_SCROLL |
65 | | - }); |
66 | | - } |
| 24 | + POP: 'pop' |
67 | 25 |
|
68 | 26 | }; |
69 | 27 |
|
|
0 commit comments