Fix #121: Ui lost menu item icon when translate
This commit is contained in:
parent
513b65a377
commit
2ff910dd5c
|
@ -1,56 +1,19 @@
|
||||||
(function ($) {
|
(function ($) {
|
||||||
Drupal.behaviors.farm_theme_glyphicons = {
|
Drupal.behaviors.farm_theme_glyphicons = {
|
||||||
attach: function(context, settings) {
|
attach: function(context, settings) {
|
||||||
|
var glyphicons_text = settings['farm_theme']['glyphicons_text'];
|
||||||
$('#navbar ul li a', context).each(function(index) {
|
$('#navbar ul li a', context).each(function(index) {
|
||||||
Drupal.behaviors.farm_theme_glyphicons.glyphicon(this);
|
Drupal.behaviors.farm_theme_glyphicons.glyphicon(this, glyphicons_text);
|
||||||
});
|
});
|
||||||
$('ul.tabs--primary li a', context).each(function(index) {
|
$('ul.tabs--primary li a', context).each(function(index) {
|
||||||
Drupal.behaviors.farm_theme_glyphicons.glyphicon(this);
|
Drupal.behaviors.farm_theme_glyphicons.glyphicon(this, glyphicons_text);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
glyphicon: function(element) {
|
glyphicon: function(element, glyphicons_text) {
|
||||||
var link_text = $(element).clone().children().remove().end().text().trim();
|
var link_text = $(element).clone().children().remove().end().text().trim();
|
||||||
var icon = '';
|
var icon = '';
|
||||||
switch (link_text) {
|
if (glyphicons_text[link_text] !== undefined) {
|
||||||
case 'Dashboard':
|
icon = glyphicons_text[link_text]
|
||||||
icon = 'dashboard';
|
|
||||||
break;
|
|
||||||
case 'Calendar':
|
|
||||||
icon = 'calendar';
|
|
||||||
break;
|
|
||||||
case 'Help':
|
|
||||||
icon = 'question-sign';
|
|
||||||
break;
|
|
||||||
case 'Create new account':
|
|
||||||
icon = 'user';
|
|
||||||
break;
|
|
||||||
case 'My account':
|
|
||||||
icon = 'user';
|
|
||||||
break;
|
|
||||||
case 'Log out':
|
|
||||||
icon = 'log-out';
|
|
||||||
break;
|
|
||||||
case 'Log in':
|
|
||||||
icon = 'log-in';
|
|
||||||
break;
|
|
||||||
case 'Request new password':
|
|
||||||
icon = 'lock';
|
|
||||||
break;
|
|
||||||
case 'Areas':
|
|
||||||
icon = 'globe';
|
|
||||||
break;
|
|
||||||
case 'Assets':
|
|
||||||
icon = 'grain';
|
|
||||||
break;
|
|
||||||
case 'Logs':
|
|
||||||
icon = 'list';
|
|
||||||
break;
|
|
||||||
case 'People':
|
|
||||||
icon = 'user';
|
|
||||||
break;
|
|
||||||
case 'Plans':
|
|
||||||
icon = 'book';
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (icon) {
|
if (icon) {
|
||||||
$(element).prepend('<span class="icon glyphicon glyphicon-' + icon + '"></span> ');
|
$(element).prepend('<span class="icon glyphicon glyphicon-' + icon + '"></span> ');
|
||||||
|
|
|
@ -400,6 +400,22 @@ function farm_theme_page_alter(&$page) {
|
||||||
function farm_theme_preprocess_page(&$vars) {
|
function farm_theme_preprocess_page(&$vars) {
|
||||||
|
|
||||||
// Add JS for adding Bootstrap glyphicons throughout the UI.
|
// Add JS for adding Bootstrap glyphicons throughout the UI.
|
||||||
|
$glyphicons_text = array(
|
||||||
|
t('Dashboard') => 'dashboard',
|
||||||
|
t('Calendar') => 'calendar',
|
||||||
|
t('Help') => 'question-sign',
|
||||||
|
t('Create new account') =>'user',
|
||||||
|
t('My account') => 'user',
|
||||||
|
t('Log out') => 'log-out',
|
||||||
|
t('Log in') => 'log-in',
|
||||||
|
t('Request new password') => 'lock',
|
||||||
|
t('Areas') => 'globe',
|
||||||
|
t('Assets') => 'grain',
|
||||||
|
t('Logs') => 'list',
|
||||||
|
t('People') => 'user',
|
||||||
|
t('Plans') => 'book',
|
||||||
|
);
|
||||||
|
drupal_add_js(array('farm_theme' => array('glyphicons_text' => $glyphicons_text)), 'setting');
|
||||||
drupal_add_js(drupal_get_path('theme', 'farm_theme') . '/js/glyphicons.js');
|
drupal_add_js(drupal_get_path('theme', 'farm_theme') . '/js/glyphicons.js');
|
||||||
|
|
||||||
// Add Javascript to automatically collapse the help text.
|
// Add Javascript to automatically collapse the help text.
|
||||||
|
|
Loading…
Reference in New Issue