directives.js
6.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/**
* 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: '<a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="" ng-click="minimalize()"><i class="fa fa-bars"></i></a>',
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);