/** * 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() { // Retrives the header menu array FHC_AjaxClient.ajaxCallGet( 'system/Navigation/header', { navigation_page: FHC_NavigationWidget._getNavigationWidgetCalled() }, { successCallback: function(data, textStatus, jqXHR) { if (FHC_AjaxClient.hasData(data)) { var strHeaderMenu = ''; jQuery.each(FHC_AjaxClient.getData(data), function(i, e) { if (e != null) strHeaderMenu += FHC_NavigationWidget._buildHeaderMenuStructure(e); }); $(".menu-header-items").html(strHeaderMenu); } } } ); }, /** * Renders the side left menu */ renderSideMenu: function() { // Retrives the left menu array FHC_AjaxClient.ajaxCallGet( 'system/Navigation/menu', { navigation_page: FHC_NavigationWidget._getNavigationWidgetCalled() }, { successCallback: function(data, textStatus, jqXHR) { if (FHC_AjaxClient.hasData(data)) { FHC_NavigationWidget._printCollapseIcon(); // Applies bootstrap SB Admin 2 theme elements to the left menu var strLeftMenu = ''; // Builds left menu jQuery.each(FHC_AjaxClient.getData(data), function(i, e) { if (e != null) strLeftMenu += FHC_NavigationWidget._buildLeftMenuStructure(e); }); $("#side-menu").html(strLeftMenu); // render left menu $("#side-menu").metisMenu(); // call the Bootstrap SB Admin 2 theme renderer } // If this global function is present... if (typeof sideMenuHook == 'function') { sideMenuHook(); // ...then call it } } } ); }, /** * Calls URL to retrive a refreshed menu array */ refreshSideMenuHook: function(url) { FHC_AjaxClient.ajaxCallGet( url, { navigation_page: FHC_NavigationWidget._getNavigationWidgetCalled() }, { successCallback: function(data, textStatus, jqXHR) { FHC_NavigationWidget.renderSideMenu(); }, errorCallback: function(jqXHR, textStatus, errorThrown) { alert(textStatus); } } ); }, //------------------------------------------------------------------------------------------------------------------ // Private methods /** * Applies bootstrap SB Admin 2 theme elements to the left menu */ _printCollapseIcon: function() { // Hiding/showing navigation menu - works only with sb admin 2 template!! if(!$("#collapseicon").length) $("#side-menu").parent().append( '