diff --git a/assets/js-src/rdta/rundiz-template-admin.js b/assets/js-src/rdta/rundiz-template-admin.js index 591b8e7..2b07010 100644 --- a/assets/js-src/rdta/rundiz-template-admin.js +++ b/assets/js-src/rdta/rundiz-template-admin.js @@ -7,6 +7,19 @@ class RundizTemplateAdmin { + /** + * Check if jQuery is loaded or not. + * + * @returns {Boolean} Return `true` if it is loaded, `false` for otherwise. + */ + #isjQueryLoaded() { + if (typeof(window.jQuery) === 'function' && window.jQuery) { + return true; + } + return false; + }// isjQueryLoaded + + /** * Listen to button dropdown or button group with dropdown. * @@ -235,6 +248,11 @@ class RundizTemplateAdmin { * @returns {Boolean} */ dataTableToggleRow() { + if (!this.#isjQueryLoaded()) { + // if jQuery is not loaded. + console.warn('jQuery is not loaded.'); + return ; + } let $ = jQuery.noConflict(); document.addEventListener('click', function(event) { @@ -262,7 +280,13 @@ class RundizTemplateAdmin { * @return {undefined} */ hotfixLongSidebarSubmenus() { + if (!this.#isjQueryLoaded()) { + // if jQuery is not loaded. + console.warn('jQuery is not loaded.'); + return ; + } let $ = jQuery.noConflict(); + let $navbar = $('.rd-navbar'); if (!$navbar || $('.rd-sidebar-item-list').length <= 0) { // if not found sidebar. @@ -348,6 +372,11 @@ class RundizTemplateAdmin { * @returns {Boolean} */ sidebarExpandToggler() { + if (!this.#isjQueryLoaded()) { + // if jQuery is not loaded. + console.warn('jQuery is not loaded.'); + return ; + } let $ = jQuery.noConflict(); let togglerButton = document.querySelector('.rd-sidebar-expand-collapse-controls a'); @@ -385,7 +414,13 @@ class RundizTemplateAdmin { * @returns {undefined} */ sidebarStickyMenu() { + if (!this.#isjQueryLoaded()) { + // if jQuery is not loaded. + console.warn('jQuery is not loaded.'); + return ; + } let $ = jQuery.noConflict(); + if ($('.rd-sidebar').length <= 0) { // if not found sidebar. return ; @@ -440,8 +475,18 @@ class RundizTemplateAdmin { * @returns {undefined} */ smartMenusNavbar() { + if (!this.#isjQueryLoaded()) { + // if jQuery is not loaded. + console.warn('jQuery is not loaded.'); + return ; + } let $ = jQuery.noConflict(); + if ($('.sm-rdta.navbar').length <= 0) { + // if not found navbar. + return ; + } + // tweak to show only one menu at a time. ( https://www.smartmenus.org/forums/topic/accordion-failed/#post-2660 ) // this problem occur on small screen navbar menu. so, this can fix it. $('.sm-rdta.navbar').bind('click.smapi', function (e, item) { @@ -503,9 +548,15 @@ class RundizTemplateAdmin { * @returns {undefined} */ smartMenusSidebar() { + if (!this.#isjQueryLoaded()) { + // if jQuery is not loaded. + console.warn('jQuery is not loaded.'); + return ; + } let $ = jQuery.noConflict(); + if ($('.sm-vertical').length <= 0) { - // if not found smart menu selector. + // if not found sidebar. return ; } diff --git a/assets/js/rdta/rundiz-template-admin.js b/assets/js/rdta/rundiz-template-admin.js index 4d5db48..ce01954 100644 --- a/assets/js/rdta/rundiz-template-admin.js +++ b/assets/js/rdta/rundiz-template-admin.js @@ -11,6 +11,19 @@ License: MIT class RundizTemplateAdmin { + /** + * Check if jQuery is loaded or not. + * + * @returns {Boolean} Return `true` if it is loaded, `false` for otherwise. + */ + #isjQueryLoaded() { + if (typeof(window.jQuery) === 'function' && window.jQuery) { + return true; + } + return false; + }// isjQueryLoaded + + /** * Listen to button dropdown or button group with dropdown. * @@ -239,6 +252,11 @@ class RundizTemplateAdmin { * @returns {Boolean} */ dataTableToggleRow() { + if (!this.#isjQueryLoaded()) { + // if jQuery is not loaded. + console.warn('jQuery is not loaded.'); + return ; + } let $ = jQuery.noConflict(); document.addEventListener('click', function(event) { @@ -266,7 +284,13 @@ class RundizTemplateAdmin { * @return {undefined} */ hotfixLongSidebarSubmenus() { + if (!this.#isjQueryLoaded()) { + // if jQuery is not loaded. + console.warn('jQuery is not loaded.'); + return ; + } let $ = jQuery.noConflict(); + let $navbar = $('.rd-navbar'); if (!$navbar || $('.rd-sidebar-item-list').length <= 0) { // if not found sidebar. @@ -352,6 +376,11 @@ class RundizTemplateAdmin { * @returns {Boolean} */ sidebarExpandToggler() { + if (!this.#isjQueryLoaded()) { + // if jQuery is not loaded. + console.warn('jQuery is not loaded.'); + return ; + } let $ = jQuery.noConflict(); let togglerButton = document.querySelector('.rd-sidebar-expand-collapse-controls a'); @@ -389,7 +418,13 @@ class RundizTemplateAdmin { * @returns {undefined} */ sidebarStickyMenu() { + if (!this.#isjQueryLoaded()) { + // if jQuery is not loaded. + console.warn('jQuery is not loaded.'); + return ; + } let $ = jQuery.noConflict(); + if ($('.rd-sidebar').length <= 0) { // if not found sidebar. return ; @@ -444,8 +479,18 @@ class RundizTemplateAdmin { * @returns {undefined} */ smartMenusNavbar() { + if (!this.#isjQueryLoaded()) { + // if jQuery is not loaded. + console.warn('jQuery is not loaded.'); + return ; + } let $ = jQuery.noConflict(); + if ($('.sm-rdta.navbar').length <= 0) { + // if not found navbar. + return ; + } + // tweak to show only one menu at a time. ( https://www.smartmenus.org/forums/topic/accordion-failed/#post-2660 ) // this problem occur on small screen navbar menu. so, this can fix it. $('.sm-rdta.navbar').bind('click.smapi', function (e, item) { @@ -507,9 +552,15 @@ class RundizTemplateAdmin { * @returns {undefined} */ smartMenusSidebar() { + if (!this.#isjQueryLoaded()) { + // if jQuery is not loaded. + console.warn('jQuery is not loaded.'); + return ; + } let $ = jQuery.noConflict(); + if ($('.sm-vertical').length <= 0) { - // if not found smart menu selector. + // if not found sidebar. return ; } diff --git a/assets/js/rdta/rundiz-template-admin.min.js b/assets/js/rdta/rundiz-template-admin.min.js index 5552366..e0d40e0 100644 --- a/assets/js/rdta/rundiz-template-admin.min.js +++ b/assets/js/rdta/rundiz-template-admin.min.js @@ -6,5 +6,5 @@ License: MIT * https://rundiz.com * @license MIT */ -class RundizTemplateAdmin{buttonDropdown(){document.addEventListener("click",(function(e){let t=document.querySelectorAll(".rd-dropdown"),n=0,r=t.length;for(;n