=metricPrefixes[i][1]){label=round(label/metricPrefixes[i][1])+metricPrefixes[i][0];break}}return label};var round=function(value,precision){var number=new Number(value);return number.toFixed(precision)};Tinycon.setOptions=function(custom){options={};for(var key in defaults){options[key]=custom.hasOwnProperty(key)?custom[key]:defaults[key]}return this};Tinycon.setImage=function(url){currentFavicon=url;refreshFavicon();return this};Tinycon.setBubble=function(label,colour){label=label||'';drawFavicon(label,colour);return this};Tinycon.reset=function(){setFaviconTag(originalFavicon)};Tinycon.setOptions(defaults);window.Tinycon=Tinycon})();
;
(function ($) {
Drupal.behaviors.environment_indicatorToolbar = {
attach: function (context, settings) {
if (typeof(Drupal.settings.environment_indicator) != 'undefined' && typeof(Drupal.settings.environment_indicator['toolbar-color']) != 'undefined') {
var environment_name = Drupal.settings.environment_indicator['environment-indicator-name'],
environment_color = Drupal.settings.environment_indicator['toolbar-color'],
environment_text_color = Drupal.settings.environment_indicator['toolbar-text-color'],
$name = $('').addClass('environment-indicator-name-wrapper').html(environment_name);
$('#toolbar div.toolbar-menu', context).once('environment_indicator').prepend($name);
$('#toolbar div.toolbar-menu', context).css('background-color', environment_color);
$('#toolbar div.toolbar-menu .item-list', context).css('background-color', changeColor(environment_color, 0.15, true));
$('#toolbar div.toolbar-menu ul li:not(.environment-switcher) a', context).css('background-color', environment_color).css('color', environment_text_color);
$('#toolbar div.toolbar-drawer', context).css('background-color', changeColor(environment_color, 0.25)).find('ul li a').css('color', changeColor(environment_text_color, 0.25));
$('#toolbar div.toolbar-menu ul li a', context).hover(function () {
$(this).css('background-color', changeColor(environment_color, 0.1)).css('color', changeColor(environment_text_color, 0.1));
}, function () {
$(this).css('background-color', environment_color).css('color', environment_text_color);
$('#toolbar div.toolbar-menu ul li.active-trail a', context).css('background-color', changeColor(environment_color, 0.1)).css('color', changeColor(environment_text_color, 0.1));
});
$('#toolbar div.toolbar-menu ul li.active-trail a', context).css('background-image', 'none').css('background-color', changeColor(environment_color, 0.1)).css('color', changeColor(environment_text_color, 0.1));
$('#toolbar div.toolbar-drawer ul li a', context).hover(function () {
$(this).css('background-color', changeColor(environment_color, 0.1, true)).css('color', changeColor(environment_text_color, 0.1, true));
}, function () {
$(this).css('background-color', changeColor(environment_color, 0.25)).css('color', changeColor(environment_text_color, 0.25));
$('#toolbar div.toolbar-drawer ul li.active-trail a', context).css('background-color', changeColor(environment_color, 0.1, true)).css('color', changeColor(environment_text_color, 0.1, true));
});
$('#toolbar div.toolbar-drawer ul li.active-trail a', context).css('background-image', 'none').css('background-color', changeColor(environment_color, 0.1, true)).css('color', changeColor(environment_text_color, 0.1, true));
// Move switcher bar to the top
var $switcher = $('#toolbar .environment-switcher-container').parent().clone();
$('#toolbar .environment-switcher-container').parent().remove();
$('#toolbar').prepend($switcher);
};
}
};
Drupal.behaviors.environment_indicatorTinycon = {
attach: function (context, settings) {
if (typeof(Drupal.settings.environment_indicator) != 'undefined' &&
typeof(Drupal.settings.environment_indicator.addFavicon) != 'undefined' &&
Drupal.settings.environment_indicator.addFavicon) {
//Draw favicon label
Tinycon.setBubble(Drupal.settings.environment_indicator.faviconLabel);
Tinycon.setOptions({
background: Drupal.settings.environment_indicator.faviconColor,
colour: Drupal.settings.environment_indicator.faviconTextColor
});
}
}
}
Drupal.behaviors.environment_indicatorAdminMenu = {
attach: function (context, settings) {
if (typeof(Drupal.admin) != 'undefined' && typeof(Drupal.settings.environment_indicator) != 'undefined' && typeof(Drupal.settings.environment_indicator['toolbar-color']) != 'undefined') {
// Add the restyling behavior to the admin menu behaviors.
Drupal.admin.behaviors['environment_indicator'] = function (context, settings) {
$('#admin-menu, #admin-menu-wrapper', context).css('background-color', Drupal.settings.environment_indicator['toolbar-color']);
$('#admin-menu, #admin-menu-wrapper > ul > li:not(.admin-menu-account) > a', context).css('color', Drupal.settings.environment_indicator['toolbar-text-color']);
$('#admin-menu .item-list', context).css('background-color', changeColor(Drupal.settings.environment_indicator['toolbar-color'], 0.15, true));
$('#admin-menu .item-list ul li:not(.environment-switcher) a', context).css('background-color', Drupal.settings.environment_indicator['toolbar-color']).css('color', Drupal.settings.environment_indicator['toolbar-text-color']);
};
};
}
};
Drupal.behaviors.environment_indicatorSwitcher = {
attach: function (context, settings) {
// Check that the links actually point to the current path, if not, fix them
$('.environment-switcher a', context).live('click', function (e) {
e.preventDefault();
var current_location = window.location;
window.location.href = current_location.protocol + '//' + e.currentTarget.hostname + current_location.pathname + current_location.search + current_location.hash;
});
$('#environment-indicator .environment-indicator-name, #toolbar .environment-indicator-name-wrapper', context).live('click', function () {
$('#environment-indicator .item-list, #toolbar .item-list', context).slideToggle('fast');
});
$('#environment-indicator.position-top.fixed-yes').once(function () {
$('body').css('margin-top', $('#environment-indicator.position-top.fixed-yes').height() + 'px');
});
$('#environment-indicator.position-bottom.fixed-yes').once(function () {
$('body').css('margin-bottom', $('#environment-indicator.position-bottom.fixed-yes').height() + 'px');
});
}
}
Drupal.behaviors.environment_indicator_admin = {
attach: function() {
// Add the farbtastic tie-in
if ($.isFunction($.farbtastic) && $('#environment-indicator-color-picker').length > 0) {
Drupal.settings.environment_indicator_color_picker = $('#environment-indicator-color-picker').farbtastic('#ctools-export-ui-edit-item-form #edit-color');
Drupal.settings.environment_indicator_text_color_picker = $('#environment-indicator-text-color-picker').farbtastic('#ctools-export-ui-edit-item-form #edit-text-color');
};
}
}
})(jQuery);
;
var pad = function(num, totalChars) {
var pad = '0';
num = num + '';
while (num.length < totalChars) {
num = pad + num;
}
return num;
};
// Ratio is between 0 and 1
var changeColor = function(color, ratio, darker) {
// Trim trailing/leading whitespace
color = color.replace(/^\s*|\s*$/, '');
// Expand three-digit hex
color = color.replace(
/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i,
'#$1$1$2$2$3$3'
);
// Calculate ratio
var difference = Math.round(ratio * 256) * (darker ? -1 : 1),
// Determine if input is RGB(A)
rgb = color.match(new RegExp('^rgba?\\(\\s*' +
'(\\d|[1-9]\\d|1\\d{2}|2[0-4][0-9]|25[0-5])' +
'\\s*,\\s*' +
'(\\d|[1-9]\\d|1\\d{2}|2[0-4][0-9]|25[0-5])' +
'\\s*,\\s*' +
'(\\d|[1-9]\\d|1\\d{2}|2[0-4][0-9]|25[0-5])' +
'(?:\\s*,\\s*' +
'(0|1|0?\\.\\d+))?' +
'\\s*\\)$'
, 'i')),
alpha = !!rgb && rgb[4] != null ? rgb[4] : null,
// Convert hex to decimal
decimal = !!rgb? [rgb[1], rgb[2], rgb[3]] : color.replace(
/^#?([a-f0-9][a-f0-9])([a-f0-9][a-f0-9])([a-f0-9][a-f0-9])/i,
function() {
return parseInt(arguments[1], 16) + ',' +
parseInt(arguments[2], 16) + ',' +
parseInt(arguments[3], 16);
}
).split(/,/),
returnValue;
// Return RGB(A)
return !!rgb ?
'rgb' + (alpha !== null ? 'a' : '') + '(' +
Math[darker ? 'max' : 'min'](
parseInt(decimal[0], 10) + difference, darker ? 0 : 255
) + ', ' +
Math[darker ? 'max' : 'min'](
parseInt(decimal[1], 10) + difference, darker ? 0 : 255
) + ', ' +
Math[darker ? 'max' : 'min'](
parseInt(decimal[2], 10) + difference, darker ? 0 : 255
) +
(alpha !== null ? ', ' + alpha : '') +
')' :
// Return hex
[
'#',
pad(Math[darker ? 'max' : 'min'](
parseInt(decimal[0], 10) + difference, darker ? 0 : 255
).toString(16), 2),
pad(Math[darker ? 'max' : 'min'](
parseInt(decimal[1], 10) + difference, darker ? 0 : 255
).toString(16), 2),
pad(Math[darker ? 'max' : 'min'](
parseInt(decimal[2], 10) + difference, darker ? 0 : 255
).toString(16), 2)
].join('');
};
var lighterColor = function(color, ratio) {
return changeColor(color, ratio, false);
};
var darkerColor = function(color, ratio) {
return changeColor(color, ratio, true);
};
;