浏览代码

refactor to account for signup window and the location of the code

Nariman Jelveh 1 年之前
父节点
当前提交
509a6cbd31
共有 2 个文件被更改,包括 28 次插入15 次删除
  1. 0 15
      src/globals.js
  2. 28 0
      src/initgui.js

+ 0 - 15
src/globals.js

@@ -141,21 +141,6 @@ if (window.location !== window.parent.location) {
 window.desktop_height = window.innerHeight - window.toolbar_height - window.taskbar_height;
 window.desktop_width = window.innerWidth;
 
-// recalculate desktop height and width on window resize
-$( window ).on( "resize", function() {
-    const radio = window.desktop_width / window.innerWidth;
-    
-    window.desktop_height = window.innerHeight - window.toolbar_height - window.taskbar_height;
-    window.desktop_width = window.innerWidth;
-    
-    const { top } = $(".window-login").position();
-    const width = $(".window-login").width();
-    $(".window-login").css({
-      left: (window.desktop_width - width) / 2,
-      top: top / radio,
-    });
-});
-  
 // for now `active_element` is basically the last element that was clicked,
 // later on though (todo) `active_element` will also be set by keyboard movements 
 // such as arrow keys, tab key, ... and when creating new windows...

+ 28 - 0
src/initgui.js

@@ -1976,4 +1976,32 @@ function requestOpenerOrigin() {
 
 $(document).on('click', '.generic-close-window-button', function(e){
     $(this).closest('.window').close();
+});
+
+// Re-calculate desktop height and width on window resize and re-position the login and signup windows
+$(window).on("resize", function () {
+    // If host env is popup, don't continue because the popup window has its own resize requirements.
+    if (window.embedded_in_popup)
+        return;
+
+    const ratio = window.desktop_width / window.innerWidth;
+
+    window.desktop_height = window.innerHeight - window.toolbar_height - window.taskbar_height;
+    window.desktop_width = window.innerWidth;
+
+    // Re-center the login window
+    const top = $(".window-login").position()?.top;
+    const width = $(".window-login").width();
+    $(".window-login").css({
+        left: (window.desktop_width - width) / 2,
+        top: top / ratio,
+    });
+
+    // Re-center the create account window
+    const top2 = $(".window-signup").position()?.top;
+    const width2 = $(".window-signup").width();
+    $(".window-signup").css({
+        left: (window.desktop_width - width2) / 2,
+        top: top2 / ratio,
+    });
 });