summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJani Palsamäki2011-06-29 09:11:24 (GMT)
committer Jani Palsamäki2011-06-29 09:11:24 (GMT)
commit57765925c392221d1123672ba479b5f10ad58665 (patch)
tree911126dcbfdf949b7b29e5eb7800364d1b37d2e9
parentc3b2b4dd33dea6163da5202a003c1fcae4903b05 (diff)
Made AddThis widget header text and background colors configurable.
-rw-r--r--addthis.admin.inc22
-rw-r--r--addthis.install2
-rw-r--r--addthis.test18
-rw-r--r--classes/AddThis.php31
4 files changed, 70 insertions, 3 deletions
diff --git a/addthis.admin.inc b/addthis.admin.inc
index 9a36909..0c5d5c7 100644
--- a/addthis.admin.inc
+++ b/addthis.admin.inc
@@ -17,13 +17,33 @@ function addthis_admin_settings_form($form_state) {
'#required' => FALSE,
'#description' => t('Profile ID at <a href="http://addthis.com/" target="_blank">AddThis.com</a>. Required for statistics.'),
);
- $form[AddThis::LARGE_ICONS_KEY] = array(
+ $form['visual_settings_fieldset'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Visual settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['visual_settings_fieldset'][AddThis::LARGE_ICONS_KEY] = array(
'#type' => 'checkbox',
'#title' => t('Use large toolbox icons'),
'#default_value' => AddThis::areLargeIconsEnabled(),
'#required' => FALSE,
'#description' => t('Use large 32x32 pixel toolbox icons instead of smaller 16x16 pixel icons.'),
);
+ $form['visual_settings_fieldset'][AddThis::UI_HEADER_COLOR_KEY] = array(
+ '#type' => 'textfield',
+ '#title' => t('AddThis user interface header text color'),
+ '#default_value' => AddThis::getUiHeaderColor(),
+ '#required' => FALSE,
+ '#description' => t('AddThis user interface header text color (like #ffffff).'),
+ );
+ $form['visual_settings_fieldset'][AddThis::UI_HEADER_BACKGROUND_COLOR_KEY] = array(
+ '#type' => 'textfield',
+ '#title' => t('AddThis user interface header background color'),
+ '#default_value' => AddThis::getUiHeaderBackgroundColor(),
+ '#required' => FALSE,
+ '#description' => t('AddThis user interface header background color (like #000000).'),
+ );
$form['service_urls_fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Service URLs'),
diff --git a/addthis.install b/addthis.install
index ec4e6bd..970abf1 100644
--- a/addthis.install
+++ b/addthis.install
@@ -38,5 +38,7 @@ function addthis_uninstall() {
variable_del(AddThis::PROFILE_ID_KEY);
variable_del(AddThis::SERVICES_CSS_URL_KEY);
variable_del(AddThis::SERVICES_JSON_URL_KEY);
+ variable_del(AddThis::UI_HEADER_BACKGROUND_COLOR_KEY);
+ variable_del(AddThis::UI_HEADER_COLOR_KEY);
variable_del(AddThis::WIDGET_JS_URL_KEY);
}
diff --git a/addthis.test b/addthis.test
index 74c249c..8016cc5 100644
--- a/addthis.test
+++ b/addthis.test
@@ -137,6 +137,12 @@ class AddThisFunctionalityTestCase extends DrupalWebTestCase {
$widgetJsUrl = AddThis::DEFAULT_WIDGET_JS_URL;
$edit[AddThis::WIDGET_JS_URL_KEY] = $widgetJsUrl;
+ $uiHeaderBackgroundColor = '#000000';
+ $edit[AddThis::UI_HEADER_BACKGROUND_COLOR_KEY] = $uiHeaderBackgroundColor;
+
+ $uiHeaderColor = '#ffffff';
+ $edit[AddThis::UI_HEADER_COLOR_KEY] = $uiHeaderColor;
+
$edit[AddThis::LARGE_ICONS_KEY] = TRUE;
$serviceName = '2linkme';
@@ -154,6 +160,10 @@ class AddThisFunctionalityTestCase extends DrupalWebTestCase {
$this->addThisWidgetJsUrlShouldBeAbleToBeSaved($widgetJsUrl);
+ $this->addThisUiHeaderBackgroundColorShouldBeAbleToBeSaved($uiHeaderBackgroundColor);
+
+ $this->addThisUiHeaderColorShouldBeAbleToBeSaved($uiHeaderColor);
+
$this->addThisLargeToolboxIconsSettingShouldBeAbleToBeSaved();
$this->addThisEnabledServicesShouldBeAbleToBeSaved($serviceName);
@@ -179,6 +189,14 @@ class AddThisFunctionalityTestCase extends DrupalWebTestCase {
$this->assertFieldChecked('edit-addthis-large-icons', 'AddThis large toolbox icons setting should be able to be saved.');
}
+ private function addThisUiHeaderColorShouldBeAbleToBeSaved($uiHeaderColor) {
+ $this->assertFieldByName(AddThis::UI_HEADER_COLOR_KEY, $uiHeaderColor, 'AddThis UI header color should be able to be saved.');
+ }
+
+ private function addThisUiHeaderBackgroundColorShouldBeAbleToBeSaved($uiHeaderBackgroundColor) {
+ $this->assertFieldByName(AddThis::UI_HEADER_BACKGROUND_COLOR_KEY, $uiHeaderBackgroundColor, 'AddThis UI header background color should be able to be saved.');
+ }
+
private function addThisEnabledServicesShouldBeAbleToBeSaved($serviceName) {
$this->assertFieldChecked('edit-addthis-enabled-services-' . $serviceName, 'AddThis enabled services should be able to be saved.');
}
diff --git a/classes/AddThis.php b/classes/AddThis.php
index 372b216..c54fc4c 100644
--- a/classes/AddThis.php
+++ b/classes/AddThis.php
@@ -21,10 +21,12 @@ class AddThis {
const BLOCK_WIDGET_TYPE_KEY = 'addthis_block_widget_type';
const BOOKMARK_URL_KEY = 'addthis_bookmark_url';
const ENABLED_SERVICES_KEY = 'addthis_enabled_services';
+ const LARGE_ICONS_KEY = 'addthis_large_icons';
const PROFILE_ID_KEY = 'addthis_profile_id';
const SERVICES_CSS_URL_KEY = 'addthis_services_css_url';
const SERVICES_JSON_URL_KEY = 'addthis_services_json_url';
- const LARGE_ICONS_KEY = 'addthis_large_icons';
+ const UI_HEADER_BACKGROUND_COLOR_KEY = 'addthis_ui_header_background_color';
+ const UI_HEADER_COLOR_KEY = 'addthis_ui_header_color';
const WIDGET_JS_URL_KEY = 'addthis_widget_js_url';
// External resources
@@ -151,13 +153,38 @@ class AddThis {
public static function addConfigurationOptionsJs() {
$enabledServices = self::getServiceNamesAsCommaSeparatedString();
- drupal_add_js("var addthis_config = {services_compact: '" . $enabledServices . "more'}", 'inline');
+ drupal_add_js(
+ "var addthis_config = {services_compact: '" . $enabledServices . "more'"
+ . self::getUiHeaderColorConfigurationOptions()
+ . '}', 'inline'
+ );
}
public static function areLargeIconsEnabled() {
return variable_get(self::LARGE_ICONS_KEY, FALSE);
}
+ public static function getUiHeaderColor() {
+ return variable_get(self::UI_HEADER_COLOR_KEY);
+ }
+
+ public static function getUiHeaderBackgroundColor() {
+ return variable_get(self::UI_HEADER_BACKGROUND_COLOR_KEY);
+ }
+
+ private static function getUiHeaderColorConfigurationOptions() {
+ $configurationOptions = ',';
+ $uiHeaderColor = self::getUiHeaderColor();
+ $uiHeaderBackgroundColor = self::getUiHeaderBackgroundColor();
+ if ($uiHeaderColor != NULL) {
+ $configurationOptions .= "ui_header_color: '$uiHeaderColor'";
+ }
+ if ($uiHeaderBackgroundColor != NULL) {
+ $configurationOptions .= ", ui_header_background: '$uiHeaderBackgroundColor'";
+ }
+ return $configurationOptions;
+ }
+
private static function getLargeButtonsClass() {
return self::areLargeIconsEnabled() ? ' addthis_32x32_style ' : '';
}