/** * acuefuel - Responsive Admin Theme * */ /** * pageTitle - Directive for set Page title - mata title */ function pageTitle($rootScope, $timeout) { return { link: function(scope, element) { var listener = function(event, toState, toParams, fromState, fromParams) { // Default title - load on Dashboard 1 var title = 'Acufuel'; // Create your own title pattern if (toState.data && toState.data.pageTitle) title = 'ACUFUEL | ' + toState.data.pageTitle; $timeout(function() { element.text(title); }); }; $rootScope.$on('$stateChangeStart', listener); } } }; /** * sideNavigation - Directive for run metsiMenu on sidebar navigation */ function sideNavigation($timeout) { return { restrict: 'A', link: function(scope, element) { // Call the metsiMenu plugin and plug it to sidebar navigation $timeout(function(){ element.metisMenu(); }); // Colapse menu in mobile mode after click on element var menuElement = $('#side-menu a:not([href$="\\#"])'); menuElement.click(function(){ if ($(window).width() < 769) { $("body").toggleClass("mini-navbar"); } }); // Enable initial fixed sidebar if ($("body").hasClass('fixed-sidebar')) { var sidebar = element.parent(); sidebar.slimScroll({ height: '100%', railOpacity: 0.9 }); } } }; }; /** * iboxTools - Directive for iBox tools elements in right corner of ibox */ function iboxTools($timeout) { return { restrict: 'A', scope: true, templateUrl: 'views/common/ibox_tools.html', controller: function ($scope, $element) { // Function for collapse ibox $scope.showhide = function () { var ibox = $element.closest('div.ibox'); var icon = $element.find('i:first'); var content = ibox.children('.ibox-content'); content.slideToggle(200); // Toggle icon from up to down icon.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down'); ibox.toggleClass('').toggleClass('border-bottom'); $timeout(function () { ibox.resize(); ibox.find('[id^=map-]').resize(); }, 50); }, // Function for close ibox $scope.closebox = function () { var ibox = $element.closest('div.ibox'); ibox.remove(); } } }; }; /** * minimalizaSidebar - Directive for minimalize sidebar */ function minimalizaSidebar($timeout) { return { restrict: 'A', template: '', controller: function ($scope, $element) { $scope.minimalize = function () { $("body").toggleClass("mini-navbar"); if (!$('body').hasClass('mini-navbar') || $('body').hasClass('body-small')) { // Hide menu in order to smoothly turn on when maximize menu $('#side-menu').hide(); // For smoothly turn on menu setTimeout( function () { $('#side-menu').fadeIn(400); }, 200); } else if ($('body').hasClass('fixed-sidebar')){ $('#side-menu').hide(); setTimeout( function () { $('#side-menu').fadeIn(400); }, 100); } else { // Remove all inline style from jquery fadeIn function to reset menu state $('#side-menu').removeAttr('style'); } } } }; }; /** * iboxTools with full screen - Directive for iBox tools elements in right corner of ibox with full screen option */ function iboxToolsFullScreen($timeout) { return { restrict: 'A', scope: true, templateUrl: 'views/common/ibox_tools_full_screen.html', controller: function ($scope, $element) { // Function for collapse ibox $scope.showhide = function () { var ibox = $element.closest('div.ibox'); var icon = $element.find('i:first'); var content = ibox.children('.ibox-content'); content.slideToggle(200); // Toggle icon from up to down icon.toggleClass('fa-chevron-up').toggleClass('fa-chevron-down'); ibox.toggleClass('').toggleClass('border-bottom'); $timeout(function () { ibox.resize(); ibox.find('[id^=map-]').resize(); }, 50); }; // Function for close ibox $scope.closebox = function () { var ibox = $element.closest('div.ibox'); ibox.remove(); }; // Function for full screen $scope.fullscreen = function () { var ibox = $element.closest('div.ibox'); var button = $element.find('i.fa-expand'); $('body').toggleClass('fullscreen-ibox-mode'); button.toggleClass('fa-expand').toggleClass('fa-compress'); ibox.toggleClass('fullscreen'); setTimeout(function() { $(window).trigger('resize'); }, 100); } } }; } /** * * Pass all functions into module */ angular .module('acuefuel') .directive('pageTitle', pageTitle) .directive('sideNavigation', sideNavigation) .directive('iboxTools', iboxTools) .directive('minimalizaSidebar', minimalizaSidebar) .directive('iboxToolsFullScreen', iboxToolsFullScreen);