Skip to content

Commit

Permalink
Removed 'pseudo' option (no longer needed), as also changed from JS t…
Browse files Browse the repository at this point in the history
…o CSS for better usage.
  • Loading branch information
Peter Anderson committed Jul 25, 2018
1 parent 1607670 commit 6036029
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 32 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You can use Font Awesome icons in your own module/theme with the following code:
``` php
if (module_exists('font_awesome')) {
// Add Font Awesome CSS classes to your HTML here.
// See http://fontawesome.io/examples/ for examples.
// See https://fontawesome.com/how-to-use/on-the-web/referencing-icons/basic-use for examples.
}
```

Expand Down Expand Up @@ -38,7 +38,7 @@ Credits
-------

- Ported to Backdrop CMS by Andy Martha (https://github.com/biolithic)
- Uses Dave Gandy's Font Awesome project (http://fontawesome.io)
- Uses Dave Gandy's Font Awesome project (https://fontawesome.com)

License
-------
Expand Down
3 changes: 1 addition & 2 deletions config/font_awesome.settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"_config_name": "font_awesome.settings",
"fontawesome": "v5",
"pseudo": false
"fontawesome": "v5"
}

17 changes: 3 additions & 14 deletions font_awesome.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,14 @@ function font_awesome_admin_form($form, &$form_state) {
$form['fontawesome'] = array(
'#type' => 'radios',
'#title' => t('Enable Font Awesome icons'),
'#description' => t('Load the necessary FontAwesome CSS/JS. See the provided links for examples of how to actualy add icons.'),
'#description' => t('Load the necessary FontAwesome CSS. See the provided links for examples of how to actually add icons.'),
'#options' => array(
'' => t('Disabled'),
'v4' => t('v4 (<a href="http://fontawesome.io/examples/" target="_blank">fontawesome.io</a>)'),
'v5' => t('v5 (<a href="https://fontawesome.com/how-to-use/svg-with-js" target="_blank">fontawesome.com</a>)'),
'v4' => t('<a href="https://fontawesome.com/v4.7.0/examples/" target="_blank">v4</a>'),
'v5' => t('<a href="https://fontawesome.com/how-to-use/on-the-web/referencing-icons/basic-use" target="_blank">v5</a>'),
),
'#default_value' => config_get('font_awesome.settings', 'fontawesome'),
);
$form['pseudo'] = array(
'#type' => 'checkbox',
'#title' => t('Use CSS pseudo-elements'),
'#description' => t("Add icons to pseudo-elements using CSS (for when you can't edit the HTML/markup directly). See <a href=\"https://fontawesome.com/how-to-use/svg-with-js#pseudo-elements\" target=\"_blank\">fontawesome.com</a> for details."),
'#default_value' => config_get('font_awesome.settings', 'pseudo'),
'#states' => array(
'visible' => array(
':input[name="fontawesome"]' => array('value' => 'v5'),
),
),
);

$form['#config'] = 'font_awesome.settings';
return system_settings_form($form);
Expand Down
7 changes: 7 additions & 0 deletions font_awesome.install
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
* Install, update, and uninstall functions for the Font Awesome module.
*/

/**
* Remove 'pseudo' config value.
*/
function font_awesome_update_1101(&$sandbox) {
config_clear('font_awesome.settings', 'pseudo');
}

/**
* Update config.
*/
Expand Down
16 changes: 2 additions & 14 deletions font_awesome.module
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,7 @@ function font_awesome_config_info() {
* Implements hook_init().
*/
function font_awesome_init() {
// Enable CSS pseudo-element icons.
if (config_get('font_awesome.settings', 'pseudo')) {
backdrop_add_js("jQuery(document).ready(function($) {
window.FontAwesomeConfig.searchPseudoElements = true;
/* Added for better performance. See https://fontawesome.com/how-to-use/font-awesome-api#configuration for details. */
window.FontAwesomeConfig.observeMutations = false;
});", array(
'type' => 'inline',
'every_page' => TRUE,
));
}

// Add FontAwesome CSS/JS.
// Add FontAwesome CSS.
$options = array(
'type' => 'external',
'every_page' => TRUE,
Expand All @@ -42,7 +30,7 @@ function font_awesome_init() {
backdrop_add_css('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css', $options);
break;
case 'v5':
backdrop_add_js('https://use.fontawesome.com/releases/v5.0.13/js/all.js', $options);
backdrop_add_css('https://use.fontawesome.com/releases/v5.2.0/css/all.css', $options);
break;
}
}
Expand Down

0 comments on commit 6036029

Please sign in to comment.