Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions addthis.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ type: module
package: Sharing
core: 8.x

configure: admin/config/user-interface/addthis
configure: addthis.settings

dependencies:
- field



1 change: 1 addition & 0 deletions addthis.links.menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ addthis.settings:
parent: system.admin_config_ui
route_name: addthis.settings
weight: 1

addthis.settings.advanced:
title: AddThis - Advanced Settings
description: 'Manage your site''s advanced AddThis settings.'
Expand Down
1 change: 1 addition & 0 deletions addthis.links.task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ addthis.settings:
title: 'Basic'
route_name: addthis.settings
base_route: addthis.settings

addthis.settings.advanced:
title: 'Advanced'
route_name: addthis.settings.advanced
Expand Down
14 changes: 14 additions & 0 deletions addthis.module
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
<?php

/**
* Implements hook_help().
*/
function addthis_help($route_name) {
switch ($route_name) {
case 'help.page.addthis':
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>';
$output .= t('The AddThis module defines AddThis field type for the Field module. A AddThis field may contain a button, toolbox, sharecount or customized sharing tool using <a href="http://addthis.com/">AddThis.com</a>.');
$output .= '</p>';
return $output;
}
}

/**
* Implements hook_theme().
*/
Expand Down
1 change: 1 addition & 0 deletions addthis.permissions.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
administer addthis settings:
title: 'Administer AddThis Settings'
description: 'Perform configuration tasks for AddThis.'

administer advanced addthis settings:
title: 'Administer Advanced AddThis Settings'
description: 'Perform advanced configuration tasks for AddThis.'
1 change: 1 addition & 0 deletions addthis.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ addthis.settings:
_title: 'AddThis'
requirements:
_permission: 'administer addthis settings'

addthis.settings.advanced:
path: '/admin/config/user-interface/addthis/advanced'
defaults:
Expand Down
6 changes: 1 addition & 5 deletions config/schema/addthis.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,4 @@ block.settings.addthis_block:
label: 'Counter Orientation'
extra_css:
type: string
label: 'Extra CSS'




label: 'Extra CSS'
13 changes: 7 additions & 6 deletions css/addthis.admin.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
.addthis_service_icon {
display: inline-block;
padding-left: 20px;
display: inline-block;
padding-left: 20px;
}

#edit-addthis-enabled-services .form-item, #edit-addthis-excluded-services .form-item {
float: left;
width: 20%;
#edit-addthis-enabled-services .form-item,
#edit-addthis-excluded-services .form-item {
float: left;
width: 20%;
}

#edit-addthis-enabled-services .form-item .description {
clear: both;
clear: both;
}

#edit-addthis-excluded-services label.option,
Expand Down
42 changes: 21 additions & 21 deletions js/addthis.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
// AddThis requires a global variable

var addthis_config,
addthis_share;
addthis_share;

(function ($, Drupal, window, document, undefined) {
Drupal.behaviors.addThisWidget = {
Drupal.behaviors.addThisWidget = {

//@TODO Need to support domready and async loading. See http://support.addthis.com/customer/portal/articles/1338006-url-parameters
//@TODO Need to support domready and async loading. See http://support.addthis.com/customer/portal/articles/1338006-url-parameters

attach: function (context, settings) {
if (context === document) { // only fires on document load
attach: function (context, settings) {
if (context === document) { // only fires on document load

// Because we cannot dynamically add JS
if (typeof settings.addThisWidget.widgetScript !== 'undefined') {
$.getScript(settings.addThisWidget.widgetScript)
.done(function (script, textStatus) {
}).fail(function (jqxhr, settings, exception) {
// TODO: check for fail msg
});
}
if (typeof settings.addThisWidget.config !== 'undefined') {
addthis_config = settings.addThisWidget.config;
}
if (typeof settings.addThisWidget.share !== 'undefined') {
addthis_share = settings.addThisWidget.share;
}
}
// Because we cannot dynamically add JS
if (typeof settings.addThisWidget.widgetScript !== 'undefined') {
$.getScript(settings.addThisWidget.widgetScript)
.done(function (script, textStatus) {
}).fail(function (jqxhr, settings, exception) {
// TODO: check for fail msg
});
}
};
if (typeof settings.addThisWidget.config !== 'undefined') {
addthis_config = settings.addThisWidget.config;
}
if (typeof settings.addThisWidget.share !== 'undefined') {
addthis_share = settings.addThisWidget.share;
}
}
}
};

})(jQuery, Drupal, this, this.document);
2 changes: 0 additions & 2 deletions src/AddThis.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,4 @@ public function getServicesJsonUrl() {
$service_json_url_key = isset($service_json_url_key) ? $service_json_url_key : 'http://cache.addthiscdn.com/services/v1/sharing.en.json';
return check_url($service_json_url_key);
}


}
5 changes: 1 addition & 4 deletions src/AddThisBasicButtonFormTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,4 @@ protected function addThisBasicButtonForm($options){

return $element;
}



}
}
3 changes: 1 addition & 2 deletions src/AddThisBasicToolboxFormTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,4 @@ public static function addThisDisplayElementServicesValidate($element, $form_sta
$form_state->setErrorByName($element['#title'], t('The declared services are incorrect or nonexistent.'));
}
}

}
}
12 changes: 0 additions & 12 deletions src/AddThisScriptManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,34 +159,22 @@ public function attachJsToElement(&$element) {
//Always load the script with domready flag.
$fragment[] = 'domready=1';


$element['#attached']['library'][] = 'addthis/addthis.widget';
$addThisConfig = $this->getAddThisConfig();
$addThisShareConfig = $this->getAddThisShareConfig();



$options = [
'fragment' => implode('&', $fragment),
'external' => TRUE,
];


$widget_url = $adv_config->get('addthis_widget_js_url');
$widgetURL = URL::fromUri($widget_url, $options)->toString();


$element['#attached']['drupalSettings']['addThisWidget'] = [
'widgetScript' => $widgetURL,
'config' => $addThisConfig,
'share' => $addThisShareConfig,
];


}


}



3 changes: 0 additions & 3 deletions src/Form/AddThisSettingsAdvancedForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#default_value' => $config->get('addthis_widget_include'),
);


return parent::buildForm($form, $form_state);
}

Expand All @@ -131,6 +130,4 @@ public function submitForm(array &$form, FormStateInterface $form_state) {

parent::submitForm($form, $form_state);
}

}

2 changes: 0 additions & 2 deletions src/Form/AddThisSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,4 @@ public function submitForm(array &$form, FormStateInterface $form_state) {

parent::submitForm($form, $form_state);
}

}