Prechádzať zdrojové kódy

added intialize calendar

Josh Kamau 5 rokov pred
rodič
commit
b5610d8d12
2 zmenil súbory, kde vykonal 47 pridanie a 48 odobranie
  1. 47 37
      public/js/mc.js
  2. 0 11
      resources/views/app/dashboard.blade.php

+ 47 - 37
public/js/mc.js

@@ -1,6 +1,6 @@
 var findEventHandlers = function (eventType, jqSelector) {
     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) {
         return $(array1).filter(function (index, element) {
@@ -16,7 +16,9 @@ var findEventHandlers = function (eventType, jqSelector) {
     var addEventHandlerInfo = function (element, event, $elementsCovered) {
         var extendedEvent = event;
         if ($elementsCovered !== void 0 && $elementsCovered !== null) {
-            $.extend(extendedEvent, { targets: $elementsCovered.toArray() });
+            $.extend(extendedEvent, {
+                targets: $elementsCovered.toArray()
+            });
         }
         var eventInfo;
         var eventsInfo = $.grep(results, function (evInfo, index) {
@@ -37,7 +39,7 @@ var findEventHandlers = function (eventType, 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);
     var $allElements = $("*").add(document);
 
@@ -45,7 +47,7 @@ var findEventHandlers = function (eventType, jqSelector) {
         var allElementEvents = $._data(element, "events");
         if (allElementEvents !== void 0 && allElementEvents[eventType] !== void 0) {
             var eventContainer = allElementEvents[eventType];
-            $.each(eventContainer, function(eventIndex, event){
+            $.each(eventContainer, function (eventIndex, event) {
                 var isDelegateEvent = event.selector !== void 0 && event.selector !== null;
                 var $elementsCovered;
                 if (isDelegateEvent) {
@@ -63,27 +65,28 @@ var findEventHandlers = function (eventType, jqSelector) {
     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;
-        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);
 });
-$(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');
-        }
-        else {
+        } else {
             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');
     }
     initFastLoad();
@@ -96,18 +99,17 @@ function initFastLoad(_parent = false) {
     fastCache = {};
 
     var allAs = $('a:not([onclick]):not([href="#"])');
-    if(_parent) {
+    if (_parent) {
         allAs = _parent.find('a:not([onclick]):not([href="#"])');
     }
     // 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);
-            }
-            else {
+            } else {
                 var handlers = findEventHandlers('click', this);
-                if(!handlers || !handlers.length) {
+                if (!handlers || !handlers.length) {
                     enableFastLoad(this);
                 }
             }
@@ -115,9 +117,9 @@ function initFastLoad(_parent = false) {
     });
 
     function enableFastLoad(_a, _menuItem = false) {
-        $(_a).on('click', function() {
+        $(_a).on('click', function () {
             fastLoad(this.href, true, true);
-            if(_menuItem) {
+            if (_menuItem) {
                 $(this).closest('.dropdown-menu')
                     .removeClass('show')
                     .prev('.dropdown-toggle').attr('aria-expanded', 'false');
@@ -129,7 +131,7 @@ function initFastLoad(_parent = false) {
 
     // fast cache
     allAs = $('a:not([onclick]):not([href="#"])');
-    allAs.each(function() {
+    allAs.each(function () {
         var a = this;
         $.get(a.href, function (_data) {
             fastCache[a.href] = _data;
@@ -137,44 +139,44 @@ function initFastLoad(_parent = false) {
     });
 
 }
+
 function fastLoad(_href, _history = true, _useCache = true) {
     function onData(_data) {
         var targetParent = $('.stag-content');
         _data = '<div>' + _data + '</div>';
         var content = $(_data).find('.stag-content');
-        if(content && content.length) {
+        if (content && content.length) {
             content = content.html();
             content += '<script src="/js/yemi.js"></script>';
             targetParent.html(content);
             initFastLoad(targetParent);
 
             // push state
-            if(_history) {
+            if (_history) {
                 var target = _href;
-                if(target.indexOf('//') !== -1) {
+                if (target.indexOf('//') !== -1) {
                     target = target.split('//')[1];
-                    if(target.indexOf('/') !== -1) {
+                    if (target.indexOf('/') !== -1) {
                         target = target.substr(target.indexOf('/') + 1);
                     }
                 }
                 window.top.history.pushState(target, null, '/mc/' + target);
             }
 
-        }
-        else {
+        } else {
             console.warn('Target page not found: ' + _href);
             window.location.href = _href; // fallback
         }
         hideMask();
     }
     showMask();
-    if(_useCache && !!fastCache[_href]) {
+    if (_useCache && !!fastCache[_href]) {
         onData(fastCache[_href]);
-    }
-    else {
+    } else {
         $.get(_href, onData);
     }
 }
+
 function openInRHS(_url) {
     window.top.showRHS();
     var icon = $('.stag_rhs_toggle i');
@@ -182,3 +184,11 @@ function openInRHS(_url) {
     window.top.openInRHS(_url);
     return false;
 }
+
+function initializeCalendar() {
+    var calendarEl = document.getElementById('calendar');
+    var calendar = new FullCalendar.Calendar(calendarEl, {
+        initialView: 'dayGridMonth'
+    });
+    calendar.render();
+}

+ 0 - 11
resources/views/app/dashboard.blade.php

@@ -71,15 +71,4 @@
             </div>
         </div>
     </div>
-    <script>
-
-        document.addEventListener('DOMContentLoaded', function() {
-          var calendarEl = document.getElementById('calendar');
-          var calendar = new FullCalendar.Calendar(calendarEl, {
-            initialView: 'dayGridMonth'
-          });
-          calendar.render();
-        });
-  
-      </script>
 @endsection