import { AutoloadPage } from 'vj/misc/PageLoader';
import DomDialog from 'vj/components/dialog/DomDialog';
import responsiveCutoff from 'vj/breakpoints.json';
import { isAbove } from 'vj/utils/mediaQuery';

const signinDialogPage = new AutoloadPage('signinDialogPage', null, () => {
  const signInDialog = DomDialog.getOrConstruct($('.dialog--signin'), {
    cancelByClickingBack: true,
    cancelByEsc: true,
  });

  // don't show quick login dialog if in mobile
  if ($('[name="nav_login"]').length > 0 && isAbove(responsiveCutoff.mobile)) {
    // nav
    $('[name="nav_login"]').click((ev) => {
      if (ev.shiftKey || ev.metaKey || ev.ctrlKey) {
        return;
      }
      signInDialog.show();
      ev.preventDefault();
    });
  }

  if ($('.dialog--signin').length > 0) {
    // dialog
    $('[name="dialog--signin__close"]').on('click', () => {
      signInDialog.hide();
    });
  }

  window.showSignInDialog = () => {
    signInDialog.show();
  };
});

export default signinDialogPage;

@@ -163,21 +163,21 @@
 ort %7B is
-Above
+Below
  %7D from 
@@ -502,44 +502,8 @@
  %3E 0
- && isAbove(responsiveCutoff.mobile)
 ) %7B%0A
@@ -553,24 +553,94 @@
 k((ev) =%3E %7B%0A
+      if (isBelow(responsiveCutoff.mobile)) %7B%0A        return;%0A      %7D%0A
       if (ev
@@ -958,24 +958,215 @@
 g = () =%3E %7B%0A
+    if (isBelow(responsiveCutoff.mobile)) %7B%0A      if ($('%5Bname=%22nav_login%22%5D').length %3E 0) %7B%0A        window.location.href = $('%5Bname=%22nav_login%22%5D').attr('href');%0A        return;%0A      %7D%0A    %7D%0A
     signInDi

Fix login dialog in mobile mode (#369)