浏览代码

Mc feature: replace [target] only

Vijayakrishnan 3 年之前
父节点
当前提交
df2924b4d3
共有 1 个文件被更改,包括 21 次插入8 次删除
  1. 21 8
      public/js/mc.js

+ 21 - 8
public/js/mc.js

@@ -156,16 +156,17 @@ function initFastLoad(_parent = false) {
 
 }
 
-function onFastLoaded(_data, _href, _history) {
-    var targetParent = $('.stag-content');
+function onFastLoaded(_data, _href, _history, _target = null) {
+    var targetSelector = _target ? _target : '.stag-content';
+    var targetParent = $(targetSelector);
+    console.log('ALIX load target: ' + targetSelector);
     if (!Number.isInteger(_data)) {
         _data = '<div>' + _data + '</div>';
-        var content = $(_data).find('.stag-content');
+        var content = $(_data).find(targetSelector);
         if (content && content.length) {
             targetParent.html(content.html());
             hideMask();
             hideMoeFormMask();
-            targetParent.append('<script src="/js/yemi.js?_=7"></script>');
             window.setTimeout(function () {
                 initCreateNote();
                 initQuillEdit();
@@ -174,6 +175,7 @@ function onFastLoaded(_data, _href, _history) {
                 initPatientPresenceIndicator();
                 runMCInitializers();
                 initFileInputs();
+                initMoes();
                 if (window.top.currentMcUrl.split('?')[0] !== window.top.location.href.split('?')[0]) {
                     $(window).scrollTop(0);
                 }
@@ -218,7 +220,18 @@ function onFastLoaded(_data, _href, _history) {
     }
     $('html, body').removeClass('no-scroll');
 }
-function fastLoad(_href, _history = true, _useCache = true, _replaceState = false) {
+
+var fastReload = function(_target = null) {
+    var targetLocation = window.top.location.pathname + window.top.location.search;
+    if(targetLocation.indexOf('/mc') === 0) {
+        targetLocation = targetLocation.substr(3);
+    }
+    if(targetLocation === '' || targetLocation[0] !== '/') targetLocation = '/' + targetLocation;
+    fastLoad(targetLocation, false, false, false, _target);
+    return false;
+}
+
+function fastLoad(_href, _history = true, _useCache = true, _replaceState = false, _target = null) {
 
     let domPro = $(window.top.document.body).attr('data-pro-uid'),
         lsPro = window.top.localStorage.currentProUid;
@@ -256,7 +269,7 @@ function fastLoad(_href, _history = true, _useCache = true, _replaceState = fals
     }
 
     if (_useCache && !!fastCache[_href]) {
-        onFastLoaded(fastCache[_href], _href, _history);
+        onFastLoaded(fastCache[_href], _href, _history, _target);
     } else {
 
         let cleanedHREF = _href;
@@ -270,9 +283,9 @@ function fastLoad(_href, _history = true, _useCache = true, _replaceState = fals
         if(cleanedHREF.length > 0 && cleanedHREF[0] === '?') cleanedHREF = '/' + cleanedHREF;
 
         $.get(cleanedHREF, function (_data) {
-            onFastLoaded(_data, _href, _history);
+            onFastLoaded(_data, _href, _history, _target);
         }).fail(function (_jqXhr) {
-            onFastLoaded(_jqXhr.status, _href, _history);
+            onFastLoaded(_jqXhr.status, _href, _history, _target);
         });
     }
 }