From fe0993537c68e95dcb9c18fc2c9030d5beb2ab58 Mon Sep 17 00:00:00 2001 From: Nitesh Sethia Date: Thu, 5 May 2016 19:24:05 +0530 Subject: [PATCH] Adding hook_help, configure link in info.yml and fixing indentation issue. --- addthis.info.yml | 5 +-- addthis.links.menu.yml | 1 + addthis.links.task.yml | 1 + addthis.module | 14 ++++++++ addthis.permissions.yml | 1 + addthis.routing.yml | 1 + config/schema/addthis.schema.yml | 6 +--- css/addthis.admin.css | 13 ++++---- js/addthis.js | 42 ++++++++++++------------ src/AddThis.php | 2 -- src/AddThisBasicButtonFormTrait.php | 5 +-- src/AddThisBasicToolboxFormTrait.php | 3 +- src/AddThisScriptManager.php | 12 ------- src/Form/AddThisSettingsAdvancedForm.php | 3 -- src/Form/AddThisSettingsForm.php | 2 -- 15 files changed, 50 insertions(+), 61 deletions(-) diff --git a/addthis.info.yml b/addthis.info.yml index e105d24..12ffe44 100644 --- a/addthis.info.yml +++ b/addthis.info.yml @@ -4,10 +4,7 @@ type: module package: Sharing core: 8.x -configure: admin/config/user-interface/addthis +configure: addthis.settings dependencies: - field - - - diff --git a/addthis.links.menu.yml b/addthis.links.menu.yml index 86a6d3a..3dd5d7e 100644 --- a/addthis.links.menu.yml +++ b/addthis.links.menu.yml @@ -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.' diff --git a/addthis.links.task.yml b/addthis.links.task.yml index bd96cb5..1c233af 100644 --- a/addthis.links.task.yml +++ b/addthis.links.task.yml @@ -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 diff --git a/addthis.module b/addthis.module index 02c123e..61feac2 100644 --- a/addthis.module +++ b/addthis.module @@ -1,5 +1,19 @@ ' . t('About') . ''; + $output .= '

'; + $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 AddThis.com.'); + $output .= '

'; + return $output; + } +} + /** * Implements hook_theme(). */ diff --git a/addthis.permissions.yml b/addthis.permissions.yml index dbd85af..1d01c2c 100644 --- a/addthis.permissions.yml +++ b/addthis.permissions.yml @@ -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.' \ No newline at end of file diff --git a/addthis.routing.yml b/addthis.routing.yml index 825b5db..fd03657 100644 --- a/addthis.routing.yml +++ b/addthis.routing.yml @@ -5,6 +5,7 @@ addthis.settings: _title: 'AddThis' requirements: _permission: 'administer addthis settings' + addthis.settings.advanced: path: '/admin/config/user-interface/addthis/advanced' defaults: diff --git a/config/schema/addthis.schema.yml b/config/schema/addthis.schema.yml index ca47f7b..4c657b5 100644 --- a/config/schema/addthis.schema.yml +++ b/config/schema/addthis.schema.yml @@ -155,8 +155,4 @@ block.settings.addthis_block: label: 'Counter Orientation' extra_css: type: string - label: 'Extra CSS' - - - - + label: 'Extra CSS' \ No newline at end of file diff --git a/css/addthis.admin.css b/css/addthis.admin.css index 818b0d7..be81423 100644 --- a/css/addthis.admin.css +++ b/css/addthis.admin.css @@ -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, diff --git a/js/addthis.js b/js/addthis.js index f08e008..cb1b1ce 100644 --- a/js/addthis.js +++ b/js/addthis.js @@ -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); diff --git a/src/AddThis.php b/src/AddThis.php index d80b115..c3177db 100644 --- a/src/AddThis.php +++ b/src/AddThis.php @@ -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); } - - } diff --git a/src/AddThisBasicButtonFormTrait.php b/src/AddThisBasicButtonFormTrait.php index 67987db..1a0df32 100644 --- a/src/AddThisBasicButtonFormTrait.php +++ b/src/AddThisBasicButtonFormTrait.php @@ -56,7 +56,4 @@ protected function addThisBasicButtonForm($options){ return $element; } - - - -} \ No newline at end of file +} diff --git a/src/AddThisBasicToolboxFormTrait.php b/src/AddThisBasicToolboxFormTrait.php index 15a6c23..ad7d97b 100644 --- a/src/AddThisBasicToolboxFormTrait.php +++ b/src/AddThisBasicToolboxFormTrait.php @@ -110,5 +110,4 @@ public static function addThisDisplayElementServicesValidate($element, $form_sta $form_state->setErrorByName($element['#title'], t('The declared services are incorrect or nonexistent.')); } } - -} \ No newline at end of file +} diff --git a/src/AddThisScriptManager.php b/src/AddThisScriptManager.php index 4a3351c..6f907ec 100644 --- a/src/AddThisScriptManager.php +++ b/src/AddThisScriptManager.php @@ -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, ]; - - } - - } - - - diff --git a/src/Form/AddThisSettingsAdvancedForm.php b/src/Form/AddThisSettingsAdvancedForm.php index 2a98785..48ce3ff 100644 --- a/src/Form/AddThisSettingsAdvancedForm.php +++ b/src/Form/AddThisSettingsAdvancedForm.php @@ -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); } @@ -131,6 +130,4 @@ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); } - } - diff --git a/src/Form/AddThisSettingsForm.php b/src/Form/AddThisSettingsForm.php index 3fa8ac4..d7e434e 100644 --- a/src/Form/AddThisSettingsForm.php +++ b/src/Form/AddThisSettingsForm.php @@ -349,6 +349,4 @@ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); } - } -