Skip to content

Commit

Permalink
Added option for new_tab parameter, as per tschlienger
Browse files Browse the repository at this point in the history
  • Loading branch information
tomershvueli committed Jun 30, 2019
1 parent c79cf8e commit 3c9678e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ Copy the config.sample.json file and rename to config.json. Be sure to update th
- 'hover_color' => The CSS color for menu items when hovered over
- 'time_to_refresh_bg' => Time, in milliseconds, until it will fetch the next background image
- 'idle_timer' => Set a number of milliseconds here if you'd like to automatically hide the menu after a certain time of inactivity. Leave this attribute out entirely if you don't want an idle timer.
- 'items' => The menu will be in a grid of 3 icons per row on desktop. Insert any link you'd like, or {{cur}} for the current URL of the page. Choose icons from [Font Awesome](http://fontawesome.io/icons/)
- 'items' => Array of objects for links to be displayed. The menu will be in a grid of 3 icons per row on desktop. Object shape:
- 'link' => Insert any link you'd like, or {{cur}} for the current URL of the page, i.e. `{{cur}}:32400/web/`.
- 'icon' => Icon to be displayed, choose icons from [Font Awesome](http://fontawesome.io/icons/).
- 'alt' => Value for `title` of anchor tag.
- 'new_tab' => Optional boolean value for whether link should open in new tab or current tab.

__NOTE__: PHP cURL is required for fetching external images.

Expand Down
9 changes: 6 additions & 3 deletions config.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@
{
"alt" : "Facebook",
"icon" : "facebook",
"link" : "http://facebook.com"
"link" : "http://facebook.com",
"new_tab" : true
},
{
"alt" : "Twitter",
"icon" : "twitter",
"link" : "http://twitter.com"
"link" : "http://twitter.com",
"new_tab" : true
},
{
"alt" : "Trello",
"icon" : "trello",
"link" : "http://trello.com"
"link" : "http://trello.com",
"new_tab" : true
},
{
"alt" : "TTRSS",
Expand Down
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ function get_current_url() {
foreach ($config['items'] as $i => $item) {
$icon = $item['icon'];
$link = str_replace("{{cur}}", get_current_url(), $item['link']);
$target = $item['new_tab'] ? ' target="_blank" rel="noopener noreferrer"' : '';

echo '<div class="link col-md-4 col-sm-6 col-xs-12"><a href="' . $link . '" title="' . $item['alt'] . '"><i class="fa fa-' . $icon . '"></i></a></div>';
echo '<div class="link col-md-4 col-sm-6 col-xs-12"><a href="' . $link . '" title="' . $item['alt'] . '"' . $target . '><i class="fa fa-' . $icon . '"></i></a></div>';
}
?>
</div>
Expand Down

0 comments on commit 3c9678e

Please sign in to comment.