Explorar o código

MC - don't auto-scroll to top if fastReload target === current url

Vijayakrishnan %!s(int64=4) %!d(string=hai) anos
pai
achega
488917b2d9
Modificáronse 3 ficheiros con 7 adicións e 4 borrados
  1. 5 3
      public/js/mc.js
  2. 1 0
      public/js/yemi.js
  3. 1 1
      resources/views/layouts/template.blade.php

+ 5 - 3
public/js/mc.js

@@ -1,3 +1,4 @@
+window.top.currentMcUrl = '';
 window.top.addEventListener('popstate', function (event) {
     window.setTimeout(function () {
         hideMask();
@@ -162,7 +163,10 @@ function onFastLoaded(_data, _href, _history) {
             initPrimaryForm();
             initPatientPresenceIndicator();
             runMCInitializers();
-            $(window).scrollTop(0);
+            if(window.top.currentMcUrl !== window.top.location.href) {
+                $(window).scrollTop(0);
+            }
+            window.top.currentMcUrl = window.top.location.href;
         }, 50);
         // if(typeof initializeCalendar !== 'undefined') {
         //     initializeCalendar();
@@ -183,8 +187,6 @@ function fastLoad(_href, _history = true, _useCache = true, _replaceState = fals
 
     let domPro = $(window.top.document.body).attr('data-pro-uid'),
         lsPro = window.top.localStorage.currentProUid;
-    console.log('ALIX DOM: ', domPro);
-    console.log('ALIX LS: ', lsPro);
     if(lsPro && domPro && lsPro !== domPro) {
         console.warn('ALIX Looks like you have a session as another pro on another tab. Refreshing window.top...');
         window.top.location.href = _href;

+ 1 - 0
public/js/yemi.js

@@ -201,6 +201,7 @@ var fastReload = function() {
     }
     if(targetLocation === '' || targetLocation[0] !== '/') targetLocation = '/' + targetLocation;
     fastLoad(targetLocation, false, false);
+    return false;
 }
 
 if (typeof String.prototype.startsWith != 'function') {

+ 1 - 1
resources/views/layouts/template.blade.php

@@ -134,7 +134,7 @@
             <div class="current-work mr-2">
                 @include('app/current-work')
             </div>
-            <a href="#" class="mr-2 text-white small" onclick="fastReload()"><i class="fa fa-sync"></i></a>
+            <a href="#" class="mr-2 text-white small" onclick="return fastReload()"><i class="fa fa-sync"></i></a>
             <div class="d-inline-flex pr-2 mcp-theme-1 position-relative">
                 <input id="patient-search" type="search" class="form-control form-control-sm outline-0" autocomplete="off" placeholder="Search Patients">
                 <div class="suggestions-outer position-absolute d-none">