3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00

Add Bootstrap icons to dashboard tabs.

This commit is contained in:
Michael Stenta 2017-10-16 11:42:03 -04:00
parent 082e5f0fe2
commit dd85b5ffde
2 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,16 @@
(function ($) {
Drupal.behaviors.farm_theme_dashboard = {
attach: function(context, settings) {
$('ul.tabs--primary li a', context).each(function(index) {
var link_text = $(this).clone().children().remove().end().text();
var icon = 'leaf';
switch (link_text) {
case 'Dashboard':
icon = 'dashboard';
break;
}
$(this).prepend('<span class="icon glyphicon glyphicon-' + icon + '"></span> ');
});
}
}
})(jQuery);

View file

@ -305,6 +305,12 @@ function farm_theme_preprocess_page(&$vars) {
drupal_add_js(drupal_get_path('theme', 'farm_theme') . '/js/help.js');
}
// If we are on a page that shows the Dashboard tabs, add Bootstrap icons to
// them via JS.
if (!empty($vars['tabs']['#primary'][0]['#link']['path']) && $vars['tabs']['#primary'][0]['#link']['path'] == 'farm/dashboard') {
drupal_add_js(drupal_get_path('theme', 'farm_theme') . '/js/dashboard.js');
}
// When the farm_areas map is displayed on a page...
if (!empty($vars['page']['content']['farm_areas'])) {