/** * FH-Complete * * @package * @author * @copyright Copyright (c) 2016 fhcomplete.org * @license GPLv3 * @link https://fhcomplete.org * @since Version 1.0.0 */ /** * FHC_NavigationWidget */ var FHC_NavigationWidget = { //------------------------------------------------------------------------------------------------------------------ // Public methods /** * Renders the header menu (top horizontal menu) */ renderHeaderMenu: function() { // FHC_AjaxClient.ajaxCallGet( 'system/Navigation/header', { navigation_widget_called: FHC_NavigationWidget._getNavigationWidgetCalled() }, { successCallback: function(data, textStatus, jqXHR) { if (data != null) { jQuery.each(data, function(i, e) { $(".menu-header-items").append('' + i + ''); }); } } } ); }, /** * Renders the side left menu */ renderSideMenu: function() { // FHC_AjaxClient.ajaxCallGet( 'system/Navigation/menu', { navigation_widget_called: FHC_NavigationWidget._getNavigationWidgetCalled() }, { successCallback: function(data, textStatus, jqXHR) { if (data != null) { var strMenu = ''; FHC_NavigationWidget._printCollapseIcon(); jQuery.each(data, function(i, e) { strMenu += FHC_NavigationWidget._printNavItem(e); }); $("#side-menu").html(strMenu); $("#side-menu").metisMenu(); } if (typeof sideMenuHook == 'function') { sideMenuHook(); } } } ); }, //------------------------------------------------------------------------------------------------------------------ // Private methods /** * */ _printCollapseIcon: function() { // Hiding/showing navigation menu - works only with sb admin 2 template!! if(!$("#collapseicon").length) $("#side-menu").parent().append('
'); $("#collapseicon").click(function() { $("#page-wrapper").css('margin-left', '0px'); $("#side-menu").hide(); $("#collapseicon").hide(); $("#collapseinicon").show(); }); $("#collapseinicon").click(function() { $("#page-wrapper").css('margin-left', '250px'); $("#side-menu").show(); $("#collapseicon").show(); $("#collapseinicon").hide(); }); }, /** * */ _printNavItem: function(item, depth = 1) { strMenu = ""; var expanded = typeof item['expand'] != 'undefined' && item['expand'] === true ? ' active' : ''; strMenu += '
  • '; if (typeof item['subscriptLinkClass'] != 'undefined' && typeof item['subscriptDescription'] != 'undefined') { strMenu += ''; } // Handle fhc_controller_id var fhc_controller_id = FHC_AjaxClient.getUrlParameter('fhc_controller_id'); if (fhc_controller_id != null && fhc_controller_id != '' && item['link'] != '#') { if (item['link'].indexOf('?') != -1) { item['link'] += '&'; } else { item['link'] += '?'; } item['link'] += 'fhc_controller_id=' + fhc_controller_id; } strMenu += ''; if (item['icon'] != 'undefined') { strMenu += ' '; } strMenu += item['description']; if (typeof item['children'] != 'undefined' && Object.keys(item['children']).length > 0) { strMenu += ''; } strMenu += ''; if (typeof item['subscriptLinkClass'] != 'undefined' && typeof item['subscriptDescription'] != 'undefined') { strMenu += ' (' + item['subscriptDescription'] + ')'; strMenu += ''; } if (typeof item['children'] != 'undefined' && Object.keys(item['children']).length > 0) { var level = ''; if (depth === 1) { level = 'second'; } else if (depth > 1) { level = 'third'; } strMenu += ''; } strMenu += '
  • '; return strMenu; }, /** * Returns the URI of the caller */ _getNavigationWidgetCalled: function() { return FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method; } }; /** * When JQuery is up */ $(document).ready(function() { FHC_NavigationWidget.renderHeaderMenu(); FHC_NavigationWidget.renderSideMenu(); });