Commit 49f6f3bf authored by Steven Wittens's avatar Steven Wittens

Color.module tweaks:

- Remove tab characters
- Make sure GD2 is present before doing magic.
- Add requirement check for GD2
- Fix broken .png file
parent 79925058
......@@ -174,16 +174,16 @@ jQuery._farbtastic = function (container, callback) {
// Get coordinates relative to color picker center
var pos = fb.widgetCoords(event);
// Set new HSL parameters
// Set new HSL parameters
if (fb.circleDrag) {
var hue = Math.atan2(pos.x, -pos.y) / 6.28;
if (hue < 0) hue += 1;
fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]);
var hue = Math.atan2(pos.x, -pos.y) / 6.28;
if (hue < 0) hue += 1;
fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]);
}
else {
var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5));
var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5));
fb.setHSL([fb.hsl[0], sat, lum]);
var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5));
var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5));
fb.setHSL([fb.hsl[0], sat, lum]);
}
return false;
}
......@@ -257,20 +257,20 @@ jQuery._farbtastic = function (container, callback) {
var g = Math.round(rgb[1] * 255);
var b = Math.round(rgb[2] * 255);
return '#' + (r < 16 ? '0' : '') + r.toString(16) +
(g < 16 ? '0' : '') + g.toString(16) +
(b < 16 ? '0' : '') + b.toString(16);
(g < 16 ? '0' : '') + g.toString(16) +
(b < 16 ? '0' : '') + b.toString(16);
}
fb.unpack = function (color) {
if (color.length == 7) {
return [parseInt('0x' + color.substring(1, 3)) / 255,
parseInt('0x' + color.substring(3, 5)) / 255,
parseInt('0x' + color.substring(5, 7)) / 255];
return [parseInt('0x' + color.substring(1, 3)) / 255,
parseInt('0x' + color.substring(3, 5)) / 255,
parseInt('0x' + color.substring(5, 7)) / 255];
}
else if (color.length == 4) {
return [parseInt('0x' + color.substring(1, 2)) / 15,
parseInt('0x' + color.substring(2, 3)) / 15,
parseInt('0x' + color.substring(3, 4)) / 15];
return [parseInt('0x' + color.substring(1, 2)) / 15,
parseInt('0x' + color.substring(2, 3)) / 15,
parseInt('0x' + color.substring(3, 4)) / 15];
}
}
......@@ -280,8 +280,8 @@ jQuery._farbtastic = function (container, callback) {
m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s;
m1 = l * 2 - m2;
return [this.hueToRGB(m1, m2, h+0.33333),
this.hueToRGB(m1, m2, h),
this.hueToRGB(m1, m2, h-0.33333)];
this.hueToRGB(m1, m2, h),
this.hueToRGB(m1, m2, h-0.33333)];
}
fb.hueToRGB = function (m1, m2, h) {
......@@ -301,14 +301,14 @@ jQuery._farbtastic = function (container, callback) {
l = (min + max) / 2;
s = 0;
if (l > 0 && l < 1) {
s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
}
h = 0;
if (delta > 0) {
if (max == r && max != g) h += (g - b) / delta;
if (max == g && max != b) h += (2 + (b - r) / delta);
if (max == b && max != r) h += (4 + (r - g) / delta);
h /= 6;
if (max == r && max != g) h += (g - b) / delta;
if (max == g && max != b) h += (2 + (b - r) / delta);
if (max == b && max != r) h += (4 + (r - g) / delta);
h /= 6;
}
return [h, s, l];
}
......
......@@ -6,7 +6,7 @@
*/
function color_form_alter($form_id, &$form) {
// Insert the color changer into the theme settings page.
if ($form_id == 'system_theme_settings' && color_get_info(arg(4))) {
if ($form_id == 'system_theme_settings' && color_get_info(arg(4)) && function_exists('gd_info')) {
$form['color'] = array(
'#type' => 'fieldset',
'#title' => t('Color scheme'),
......@@ -502,8 +502,8 @@ function _color_hsl2rgb($hsl) {
$m2 = ($l <= 0.5) ? $l * ($s + 1) : $l + $s - $l*$s;
$m1 = $l * 2 - $m2;
return array(_color_hue2rgb($m1, $m2, $h + 0.33333),
_color_hue2rgb($m1, $m2, $h),
_color_hue2rgb($m1, $m2, $h - 0.33333));
_color_hue2rgb($m1, $m2, $h),
_color_hue2rgb($m1, $m2, $h - 0.33333));
}
/**
......@@ -530,14 +530,14 @@ function _color_rgb2hsl($rgb) {
$l = ($min + $max) / 2;
$s = 0;
if ($l > 0 && $l < 1) {
$s = $delta / ($l < 0.5 ? (2 * $l) : (2 - 2 * $l));
$s = $delta / ($l < 0.5 ? (2 * $l) : (2 - 2 * $l));
}
$h = 0;
if ($delta > 0) {
if ($max == $r && $max != $g) $h += ($g - $b) / $delta;
if ($max == $g && $max != $b) $h += (2 + ($b - $r) / $delta);
if ($max == $b && $max != $r) $h += (4 + ($r - $g) / $delta);
$h /= 6;
if ($max == $r && $max != $g) $h += ($g - $b) / $delta;
if ($max == $g && $max != $b) $h += (2 + ($b - $r) / $delta);
if ($max == $b && $max != $r) $h += (4 + ($r - $g) / $delta);
$h /= 6;
}
return array($h, $s, $l);
}
\ No newline at end of file
......@@ -19,7 +19,8 @@ function system_requirements($phase) {
$requirements['drupal'] = array(
'title' => $t('Drupal'),
'value' => VERSION,
'severity' => REQUIREMENT_INFO
'severity' => REQUIREMENT_INFO,
'weight' => -10,
);
}
......@@ -27,7 +28,7 @@ function system_requirements($phase) {
$software = $_SERVER['SERVER_SOFTWARE'];
$requirements['webserver'] = array(
'title' => $t('Web server'),
'value' => $software
'value' => $software,
);
// Use server info string, if present.
if ($software && preg_match('![0-9]!', $software)) {
......
......@@ -1793,6 +1793,7 @@ function system_status($check = FALSE) {
// Check run-time requirements and status information
$requirements = module_invoke_all('requirements', 'runtime');
usort($requirements, '_system_sort_requirements');
if ($check) {
return drupal_requirements_severity($requirements) == REQUIREMENT_ERROR;
......@@ -1801,6 +1802,13 @@ function system_status($check = FALSE) {
return theme('status_report', $requirements);
}
/**
* Helper function to sort requirements.
*/
function _system_sort_requirements($a, $b) {
return (isset($a['weight']) || isset($b['weight'])) ? $a['weight'] - $b['weight'] : strcmp($a['title'], $b['title']);
}
/**
* Theme status report
*/
......
This image diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment