forked from backdrop-contrib/simplei
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimplei.module
45 lines (40 loc) · 1.42 KB
/
simplei.module
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
<?php
/**
* @file
* Simple Environment indicator.
*/
/**
* Implements hook_init().
*/
function simplei_init() {
$simple_environment_indicator = settings_get('simple_environment_indicator');
if (!empty($simple_environment_indicator)) {
$indicator = explode(' ', str_replace(' ', ' ', $simple_environment_indicator), 2);
if (module_exists('admin_bar') and user_access('access administration bar')) {
$css = "#admin-bar { background: $indicator[0]; }";
if (!empty($indicator[1])) {
$css .= "#admin-bar .dropdown .admin-bar-icon > a span { display: none; }";
$css .= "#admin-bar .dropdown .admin-bar-icon > a:before { content: '$indicator[1]'; padding-right: 7px; }";
}
if (!empty($css)) {
backdrop_add_css($css, array('type' => 'inline', 'weight' => 10));
}
$js_settings = array(
'simplei' => array(
'addFavicon' => TRUE,
// Get the first letter out of the name.
'faviconLabel' => $indicator[1]{0},
'faviconColor' => $indicator[0],
'faviconTextColor' => '#ffffff',
),
);
backdrop_add_js($js_settings, 'setting');
backdrop_add_js(backdrop_get_path('module', 'simplei') . '/js/tinycon.min.js', array(
'every_page' => TRUE,
));
backdrop_add_js(backdrop_get_path('module', 'simplei') . '/js/simplei.js', array(
'every_page' => TRUE,
));
}
}
}