- {(name) ? : }
+ {(name) ? : }
diff --git a/src/components/windows/popUpAvailable.js b/src/components/windows/popUpAvailable.js
index 1e6dc0f..4724ca5 100644
--- a/src/components/windows/popUpAvailable.js
+++ b/src/components/windows/popUpAvailable.js
@@ -7,6 +7,22 @@ export const argsTypes = {
CHAT: ['chatChannel'],
};
+const availablePopups = [
+ 'HELP',
+ 'SETTINGS',
+ 'USERAREA',
+ 'CHAT',
+ 'CANVAS_SELECTION',
+ 'ARCHIVE',
+ 'REGISTER',
+ 'FORGOT_PASSWORD',
+];
+
+export function isPopUp() {
+ const fPath = window.location.pathname.split('/')[1];
+ return fPath && availablePopups.includes(fPath.toUpperCase());
+}
+
export function buildPopUpUrl(windowType, argsIn) {
const args = { ...argsIn };
let path = `/${windowType.toLowerCase()}`;
@@ -33,11 +49,4 @@ export function buildPopUpUrl(windowType, argsIn) {
return path;
}
-export default [
- 'HELP',
- 'SETTINGS',
- 'USERAREA',
- 'CHAT',
- 'CANVAS_SELECTION',
- 'ARCHIVE',
-];
+export default availablePopups;
diff --git a/src/core/popUps.js b/src/core/popUps.js
index e9582f5..609a9f8 100644
--- a/src/core/popUps.js
+++ b/src/core/popUps.js
@@ -51,37 +51,4 @@ class PopUps {
}
const popUps = new PopUps();
-
-export function openPopUp(url, xPos, yPos, width, height) {
- let left;
- let top;
- try {
- if (window.innerWidth <= 604) {
- width = window.innerWidth;
- height = window.innerHeight;
- left = window.top.screenX;
- top = window.top.screenY;
- } else {
- left = Math.round(window.top.screenX + xPos);
- top = Math.round(window.top.screenY + yPos);
- }
- if (Number.isNaN(left) || Number.isNaN(top)) {
- throw new Error('NaN');
- }
- } catch {
- left = 0;
- top = 0;
- }
- try {
- return window.open(
- url,
- url,
- // eslint-disable-next-line max-len
- `popup=yes,width=${width},height=${height},left=${left},top=${top},toolbar=no,status=no,directories=no,menubar=no`,
- );
- } catch {
- return null;
- }
-}
-
export default popUps;
diff --git a/src/popup.js b/src/popup.js
index 5e23387..eceb9aa 100644
--- a/src/popup.js
+++ b/src/popup.js
@@ -72,7 +72,7 @@ persistStore(store, {}, () => {
}
});
-(function () {
+(function load() {
const onLoad = () => {
renderAppPopUp(document.getElementById('app'), store);
document.removeEventListener('DOMContentLoaded', onLoad);
diff --git a/src/store/actions/popup.js b/src/store/actions/popup.js
index e19f736..582fe7e 100644
--- a/src/store/actions/popup.js
+++ b/src/store/actions/popup.js
@@ -15,3 +15,17 @@ export function setWindowTitle(title) {
title,
};
}
+
+export function changeWindowType(
+ windowType,
+ title = '',
+ args = null,
+) {
+ return {
+ type: 'CHANGE_WIN_TYPE',
+ windowType,
+ title,
+ args,
+ };
+}
+
diff --git a/src/store/actions/windows.js b/src/store/actions/windows.js
index c24210b..62425be 100644
--- a/src/store/actions/windows.js
+++ b/src/store/actions/windows.js
@@ -2,8 +2,6 @@
* Actions that are exclusively used by windows
*/
-import { t } from 'ttag';
-
export function openWindow(
windowType,
title = '',
@@ -40,35 +38,12 @@ export function setWindowArgs(
};
}
-function showFullscreenWindow(modalType, title) {
- return openWindow(
- modalType,
- title,
- null,
- true,
- );
-}
-
export function closeFullscreenWindows() {
return {
type: 'CLOSE_FULLSCREEN_WINS',
};
}
-export function showSettingsModal() {
- return showFullscreenWindow(
- 'SETTINGS',
- '',
- );
-}
-
-export function showUserAreaModal() {
- return showFullscreenWindow(
- 'USERAREA',
- '',
- );
-}
-
export function changeWindowType(
windowId,
windowType,
@@ -92,40 +67,6 @@ export function setWindowTitle(windowId, title) {
};
}
-export function showRegisterModal() {
- return showFullscreenWindow(
- 'REGISTER',
- t`Register New Account`,
- );
-}
-
-export function showForgotPasswordModal() {
- return showFullscreenWindow(
- 'FORGOT_PASSWORD',
- t`Restore my Password`,
- );
-}
-
-export function showHelpModal() {
- return showFullscreenWindow(
- 'HELP',
- t`Welcome to PixelPlanet.fun`,
- );
-}
-export function showArchiveModal() {
- return showFullscreenWindow(
- 'ARCHIVE',
- t`Look at past Canvases`,
- );
-}
-
-export function showCanvasSelectionModal() {
- return showFullscreenWindow(
- 'CANVAS_SELECTION',
- '',
- );
-}
-
export function closeWindow(windowId) {
return {
type: 'CLOSE_WIN',
diff --git a/src/store/reducers/popup.js b/src/store/reducers/popup.js
index 36a281d..f431987 100644
--- a/src/store/reducers/popup.js
+++ b/src/store/reducers/popup.js
@@ -42,7 +42,6 @@ const initialState = {
windowType: 'SETTINGS',
title: '',
args: {},
- isPopup: window.opener && !window.opener.closed,
...getWinDataFromURL(),
};
@@ -67,6 +66,22 @@ export default function popup(
};
}
+ case 'CHANGE_WIN_TYPE': {
+ const {
+ windowType,
+ title,
+ args,
+ } = action;
+ return {
+ ...state,
+ windowType,
+ title,
+ args: {
+ ...args,
+ },
+ };
+ }
+
default:
return state;
}
diff --git a/src/store/sharedReducers.js b/src/store/sharedReducers.js
index e0d5d43..cdfc9a7 100644
--- a/src/store/sharedReducers.js
+++ b/src/store/sharedReducers.js
@@ -11,6 +11,7 @@ import gui from './reducers/gui';
import ranks from './reducers/ranks';
import chatRead from './reducers/chatRead';
import user from './reducers/user';
+import canvas from './reducers/canvas';
import chat from './reducers/chat';
import fetching from './reducers/fetching';
@@ -52,6 +53,7 @@ export default {
ranks: ranksPersist,
chatRead: chatReadPersist,
user,
+ canvas,
chat,
fetching,
};
diff --git a/src/store/store.js b/src/store/store.js
index 47e3a06..dc66186 100644
--- a/src/store/store.js
+++ b/src/store/store.js
@@ -18,7 +18,6 @@ import sharedReducers, {
* reducers
*/
import windows from './reducers/windows';
-import canvas from './reducers/canvas';
import alert from './reducers/alert';
/*
@@ -43,7 +42,6 @@ const windowsPersist = persistReducer({
const reducers = combineReducers({
...sharedReducers,
windows: windowsPersist,
- canvas,
alert,
});
diff --git a/src/store/storePopUp.js b/src/store/storePopUp.js
index 2efaa80..b405fbc 100644
--- a/src/store/storePopUp.js
+++ b/src/store/storePopUp.js
@@ -13,7 +13,6 @@ import thunk from 'redux-thunk';
* reducers
*/
import sharedReducers from './sharedReducers';
-import canvas from './reducers/canvas';
import popup from './reducers/popup';
/*
@@ -25,7 +24,6 @@ import title from './middleware/titlePopUp';
const reducers = combineReducers({
...sharedReducers,
- canvas,
popup,
});