|
@@ -1,6 +1,6 @@
|
|
var findEventHandlers = function (eventType, jqSelector) {
|
|
var findEventHandlers = function (eventType, jqSelector) {
|
|
var results = [];
|
|
var results = [];
|
|
- var $ = jQuery;// to avoid conflict between others frameworks like Mootools
|
|
|
|
|
|
+ var $ = jQuery; // to avoid conflict between others frameworks like Mootools
|
|
|
|
|
|
var arrayIntersection = function (array1, array2) {
|
|
var arrayIntersection = function (array1, array2) {
|
|
return $(array1).filter(function (index, element) {
|
|
return $(array1).filter(function (index, element) {
|
|
@@ -16,7 +16,9 @@ var findEventHandlers = function (eventType, jqSelector) {
|
|
var addEventHandlerInfo = function (element, event, $elementsCovered) {
|
|
var addEventHandlerInfo = function (element, event, $elementsCovered) {
|
|
var extendedEvent = event;
|
|
var extendedEvent = event;
|
|
if ($elementsCovered !== void 0 && $elementsCovered !== null) {
|
|
if ($elementsCovered !== void 0 && $elementsCovered !== null) {
|
|
- $.extend(extendedEvent, { targets: $elementsCovered.toArray() });
|
|
|
|
|
|
+ $.extend(extendedEvent, {
|
|
|
|
+ targets: $elementsCovered.toArray()
|
|
|
|
+ });
|
|
}
|
|
}
|
|
var eventInfo;
|
|
var eventInfo;
|
|
var eventsInfo = $.grep(results, function (evInfo, index) {
|
|
var eventsInfo = $.grep(results, function (evInfo, index) {
|
|
@@ -37,7 +39,7 @@ var findEventHandlers = function (eventType, jqSelector) {
|
|
|
|
|
|
|
|
|
|
var $elementsToWatch = $(jqSelector);
|
|
var $elementsToWatch = $(jqSelector);
|
|
- if (jqSelector === "*")//* does not include document and we might be interested in handlers registered there
|
|
|
|
|
|
+ if (jqSelector === "*") //* does not include document and we might be interested in handlers registered there
|
|
$elementsToWatch = $elementsToWatch.add(document);
|
|
$elementsToWatch = $elementsToWatch.add(document);
|
|
var $allElements = $("*").add(document);
|
|
var $allElements = $("*").add(document);
|
|
|
|
|
|
@@ -45,7 +47,7 @@ var findEventHandlers = function (eventType, jqSelector) {
|
|
var allElementEvents = $._data(element, "events");
|
|
var allElementEvents = $._data(element, "events");
|
|
if (allElementEvents !== void 0 && allElementEvents[eventType] !== void 0) {
|
|
if (allElementEvents !== void 0 && allElementEvents[eventType] !== void 0) {
|
|
var eventContainer = allElementEvents[eventType];
|
|
var eventContainer = allElementEvents[eventType];
|
|
- $.each(eventContainer, function(eventIndex, event){
|
|
|
|
|
|
+ $.each(eventContainer, function (eventIndex, event) {
|
|
var isDelegateEvent = event.selector !== void 0 && event.selector !== null;
|
|
var isDelegateEvent = event.selector !== void 0 && event.selector !== null;
|
|
var $elementsCovered;
|
|
var $elementsCovered;
|
|
if (isDelegateEvent) {
|
|
if (isDelegateEvent) {
|
|
@@ -63,27 +65,28 @@ var findEventHandlers = function (eventType, jqSelector) {
|
|
return results;
|
|
return results;
|
|
};
|
|
};
|
|
|
|
|
|
-window.top.addEventListener('popstate', function(event) {
|
|
|
|
- window.setTimeout(function() {
|
|
|
|
- if(!event) return;
|
|
|
|
|
|
+window.top.addEventListener('popstate', function (event) {
|
|
|
|
+ window.setTimeout(function () {
|
|
|
|
+ if (!event) return;
|
|
var state = event.state;
|
|
var state = event.state;
|
|
- if(state === '') state = '/';
|
|
|
|
- if(state[0] !== '/') state = '/' + state;
|
|
|
|
- if(!!state) fastLoad(state, false, true);
|
|
|
|
|
|
+ if (state === '') state = '/';
|
|
|
|
+ if (state[0] !== '/') state = '/' + state;
|
|
|
|
+ if (!!state) fastLoad(state, false, true);
|
|
}, 0);
|
|
}, 0);
|
|
});
|
|
});
|
|
-$(document).ready(function() {
|
|
|
|
- $(document).on('click', '.stag_rhs_toggle', function() {
|
|
|
|
- var state = window.top.toggleRHS(), icon = $(this).find('i');
|
|
|
|
- if(state === 'collapsed') {
|
|
|
|
|
|
+$(document).ready(function () {
|
|
|
|
+ $(document).on('click', '.stag_rhs_toggle', function () {
|
|
|
|
+ var state = window.top.toggleRHS(),
|
|
|
|
+ icon = $(this).find('i');
|
|
|
|
+ if (state === 'collapsed') {
|
|
icon.removeClass().addClass('fa fa-arrow-left');
|
|
icon.removeClass().addClass('fa fa-arrow-left');
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
icon.removeClass().addClass('fa fa-arrow-right');
|
|
icon.removeClass().addClass('fa fa-arrow-right');
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- var body = $(window.top.document.body), icon = $('.stag_rhs_toggle i');
|
|
|
|
- if(body.is('.stag_rhs_collapsed')) {
|
|
|
|
|
|
+ var body = $(window.top.document.body),
|
|
|
|
+ icon = $('.stag_rhs_toggle i');
|
|
|
|
+ if (body.is('.stag_rhs_collapsed')) {
|
|
icon.removeClass().addClass('fa fa-arrow-left');
|
|
icon.removeClass().addClass('fa fa-arrow-left');
|
|
}
|
|
}
|
|
initFastLoad();
|
|
initFastLoad();
|
|
@@ -96,18 +99,17 @@ function initFastLoad(_parent = false) {
|
|
fastCache = {};
|
|
fastCache = {};
|
|
|
|
|
|
var allAs = $('a:not([onclick]):not([href="#"])');
|
|
var allAs = $('a:not([onclick]):not([href="#"])');
|
|
- if(_parent) {
|
|
|
|
|
|
+ if (_parent) {
|
|
allAs = _parent.find('a:not([onclick]):not([href="#"])');
|
|
allAs = _parent.find('a:not([onclick]):not([href="#"])');
|
|
}
|
|
}
|
|
// find links without event handlers
|
|
// find links without event handlers
|
|
- allAs.each(function() {
|
|
|
|
- if(!$(this).closest('[moe]').length) {
|
|
|
|
- if($(this).closest('.dropdown-menu[aria-labelledby="practice-management"]').length) {
|
|
|
|
|
|
+ allAs.each(function () {
|
|
|
|
+ if (!$(this).closest('[moe]').length) {
|
|
|
|
+ if ($(this).closest('.dropdown-menu[aria-labelledby="practice-management"]').length) {
|
|
enableFastLoad(this, true);
|
|
enableFastLoad(this, true);
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
var handlers = findEventHandlers('click', this);
|
|
var handlers = findEventHandlers('click', this);
|
|
- if(!handlers || !handlers.length) {
|
|
|
|
|
|
+ if (!handlers || !handlers.length) {
|
|
enableFastLoad(this);
|
|
enableFastLoad(this);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -115,9 +117,9 @@ function initFastLoad(_parent = false) {
|
|
});
|
|
});
|
|
|
|
|
|
function enableFastLoad(_a, _menuItem = false) {
|
|
function enableFastLoad(_a, _menuItem = false) {
|
|
- $(_a).on('click', function() {
|
|
|
|
|
|
+ $(_a).on('click', function () {
|
|
fastLoad(this.href, true, true);
|
|
fastLoad(this.href, true, true);
|
|
- if(_menuItem) {
|
|
|
|
|
|
+ if (_menuItem) {
|
|
$(this).closest('.dropdown-menu')
|
|
$(this).closest('.dropdown-menu')
|
|
.removeClass('show')
|
|
.removeClass('show')
|
|
.prev('.dropdown-toggle').attr('aria-expanded', 'false');
|
|
.prev('.dropdown-toggle').attr('aria-expanded', 'false');
|
|
@@ -129,7 +131,7 @@ function initFastLoad(_parent = false) {
|
|
|
|
|
|
// fast cache
|
|
// fast cache
|
|
allAs = $('a:not([onclick]):not([href="#"])');
|
|
allAs = $('a:not([onclick]):not([href="#"])');
|
|
- allAs.each(function() {
|
|
|
|
|
|
+ allAs.each(function () {
|
|
var a = this;
|
|
var a = this;
|
|
$.get(a.href, function (_data) {
|
|
$.get(a.href, function (_data) {
|
|
fastCache[a.href] = _data;
|
|
fastCache[a.href] = _data;
|
|
@@ -137,44 +139,44 @@ function initFastLoad(_parent = false) {
|
|
});
|
|
});
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
function fastLoad(_href, _history = true, _useCache = true) {
|
|
function fastLoad(_href, _history = true, _useCache = true) {
|
|
function onData(_data) {
|
|
function onData(_data) {
|
|
var targetParent = $('.stag-content');
|
|
var targetParent = $('.stag-content');
|
|
_data = '<div>' + _data + '</div>';
|
|
_data = '<div>' + _data + '</div>';
|
|
var content = $(_data).find('.stag-content');
|
|
var content = $(_data).find('.stag-content');
|
|
- if(content && content.length) {
|
|
|
|
|
|
+ if (content && content.length) {
|
|
content = content.html();
|
|
content = content.html();
|
|
content += '<script src="/js/yemi.js"></script>';
|
|
content += '<script src="/js/yemi.js"></script>';
|
|
targetParent.html(content);
|
|
targetParent.html(content);
|
|
initFastLoad(targetParent);
|
|
initFastLoad(targetParent);
|
|
|
|
|
|
// push state
|
|
// push state
|
|
- if(_history) {
|
|
|
|
|
|
+ if (_history) {
|
|
var target = _href;
|
|
var target = _href;
|
|
- if(target.indexOf('//') !== -1) {
|
|
|
|
|
|
+ if (target.indexOf('//') !== -1) {
|
|
target = target.split('//')[1];
|
|
target = target.split('//')[1];
|
|
- if(target.indexOf('/') !== -1) {
|
|
|
|
|
|
+ if (target.indexOf('/') !== -1) {
|
|
target = target.substr(target.indexOf('/') + 1);
|
|
target = target.substr(target.indexOf('/') + 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
window.top.history.pushState(target, null, '/mc/' + target);
|
|
window.top.history.pushState(target, null, '/mc/' + target);
|
|
}
|
|
}
|
|
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
console.warn('Target page not found: ' + _href);
|
|
console.warn('Target page not found: ' + _href);
|
|
window.location.href = _href; // fallback
|
|
window.location.href = _href; // fallback
|
|
}
|
|
}
|
|
hideMask();
|
|
hideMask();
|
|
}
|
|
}
|
|
showMask();
|
|
showMask();
|
|
- if(_useCache && !!fastCache[_href]) {
|
|
|
|
|
|
+ if (_useCache && !!fastCache[_href]) {
|
|
onData(fastCache[_href]);
|
|
onData(fastCache[_href]);
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
$.get(_href, onData);
|
|
$.get(_href, onData);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
function openInRHS(_url) {
|
|
function openInRHS(_url) {
|
|
window.top.showRHS();
|
|
window.top.showRHS();
|
|
var icon = $('.stag_rhs_toggle i');
|
|
var icon = $('.stag_rhs_toggle i');
|
|
@@ -182,3 +184,11 @@ function openInRHS(_url) {
|
|
window.top.openInRHS(_url);
|
|
window.top.openInRHS(_url);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+function initializeCalendar() {
|
|
|
|
+ var calendarEl = document.getElementById('calendar');
|
|
|
|
+ var calendar = new FullCalendar.Calendar(calendarEl, {
|
|
|
|
+ initialView: 'dayGridMonth'
|
|
|
|
+ });
|
|
|
|
+ calendar.render();
|
|
|
|
+}
|