|
@@ -75,6 +75,7 @@ window.top.addEventListener('popstate', function (event) {
|
|
|
}, 0);
|
|
|
});
|
|
|
$(document).ready(function () {
|
|
|
+
|
|
|
if(window.location.href === window.top.location.href) {
|
|
|
window.location.href = '/mc' + window.location.pathname;
|
|
|
return;
|
|
@@ -105,12 +106,14 @@ $(document).ready(function () {
|
|
|
initIntakeEvents();
|
|
|
}
|
|
|
|
|
|
- // replace history on fresh load
|
|
|
+ // populate history on fresh load
|
|
|
var target = window.top.location.pathname;
|
|
|
if (target.indexOf('/mc') === 0) {
|
|
|
target = target.split('/mc')[1];
|
|
|
}
|
|
|
- window.top.history.pushState(target, null, '/mc' + target);
|
|
|
+ // window.top.history.pushState(target, null, '/mc' + target);
|
|
|
+ fastLoad(target, true, false);
|
|
|
+
|
|
|
});
|
|
|
function enableTimeSpecificFields(_checked, _valueClass, _rangeClass) {
|
|
|
if(_valueClass) $('.' + _valueClass).prop('disabled', _checked);
|
|
@@ -175,7 +178,6 @@ function initFastLoad(_parent = false) {
|
|
|
$(_a)
|
|
|
.off('click.fast-load')
|
|
|
.on('click.fast-load', function () {
|
|
|
- showMask();
|
|
|
fastLoad(this.href, true, true);
|
|
|
$('.dropdown-menu[aria-labelledby="practice-management"]')
|
|
|
.removeClass('show')
|
|
@@ -216,32 +218,37 @@ function onFastLoaded(_data, _href, _history) {
|
|
|
if(typeof initIntakeEvents !== 'undefined') {
|
|
|
initIntakeEvents();
|
|
|
}
|
|
|
-
|
|
|
- // push state
|
|
|
- if (_history) {
|
|
|
- var target = _href;
|
|
|
- if (target.indexOf('//') !== -1) {
|
|
|
- target = target.split('//')[1];
|
|
|
- if (target.indexOf('/') !== -1) {
|
|
|
- target = target.substr(target.indexOf('/') + 1);
|
|
|
- }
|
|
|
- }
|
|
|
- if(target[0] === '/') target = target.substr(1);
|
|
|
- window.top.history.pushState(target, null, '/mc/' + target);
|
|
|
- }
|
|
|
-
|
|
|
} else {
|
|
|
- console.warn('Target page not found: ' + _href);
|
|
|
- window.location.href = _href; // fallback
|
|
|
+ // fallback
|
|
|
+ console.warn('MC: Target page failed: ' + _href);
|
|
|
+ targetParent.html('<p class="text-danger p-3 small">Target page not found or returned error: <b>' + _href + '</b></p>');
|
|
|
}
|
|
|
- // hideMask();
|
|
|
+ hideMask();
|
|
|
}
|
|
|
function fastLoad(_href, _history = true, _useCache = true) {
|
|
|
+
|
|
|
+ showMask();
|
|
|
+
|
|
|
+ // push state
|
|
|
+ if (_history) {
|
|
|
+ var target = _href;
|
|
|
+ if (target.indexOf('//') !== -1) {
|
|
|
+ target = target.split('//')[1];
|
|
|
+ if (target.indexOf('/') !== -1) {
|
|
|
+ target = target.substr(target.indexOf('/') + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(target[0] === '/') target = target.substr(1);
|
|
|
+ window.top.history.pushState(target, null, '/mc/' + target);
|
|
|
+ }
|
|
|
+
|
|
|
if (_useCache && !!fastCache[_href]) {
|
|
|
onFastLoaded(fastCache[_href], _href, _history);
|
|
|
} else {
|
|
|
$.get(_href, function(_data) {
|
|
|
onFastLoaded(_data, _href, _history);
|
|
|
+ }).fail(function() {
|
|
|
+ onFastLoaded('error', _href, _history);
|
|
|
});
|
|
|
}
|
|
|
}
|