Skip to content

Commit

Permalink
#37 - Expose anchor setting and add selector anchor setting
Browse files Browse the repository at this point in the history
  • Loading branch information
johanjanssens committed Dec 30, 2018
1 parent dd34798 commit 13a9f02
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
15 changes: 9 additions & 6 deletions code/site/components/com_pages/template/filter/toc.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ protected function _initialize(KObjectConfig $config)
'max_level' => 6,
'anchor' => [
'enabled' => true,
'placement' => 'right',
'visibale' => 'hover',
'icon' => '🔗',
'class' => null,
'truncate' => null,
'arialabel' => 'Anchor',
'options' => [
'placement' => 'right',
'visibale' => 'hover',
'icon' => "",
'class' => null,
'truncate' => null,
'arialabel' => 'Anchor',
],
'selector' => null,
],
));

Expand Down
8 changes: 5 additions & 3 deletions code/site/components/com_pages/template/helper/behavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@ public function anchor($config = array())
'options' => array(
'placement' => 'right',
'visibale' => 'hover',
'icon' => '🔗',
'icon' => "",
'class' => null,
'truncate' => null,
'arialabel' => 'Anchor',
)
),
'selector' => null,
));

$html = '';
if (!static::isLoaded('anchor'))
{
$html .= '<ktml:script src="assets://com_pages/js/'.($config->debug ? 'build/' : 'min/').'anchor.js" />';
$html .= '<script>
anchors.options = '.$config->options.'
// Add anchors on DOMContentLoaded
document.addEventListener("DOMContentLoaded", function(event) {
anchors.add();if(document.querySelector(\'.no-anchor\')!==null){anchors.remove(\'.no-anchor\');}
anchors.add('.$config->selector.');if(document.querySelector(\'.no-anchor\')!==null){anchors.remove(\'.no-anchor\');}
}); </script>';

static::setLoaded('anchor');
Expand Down

0 comments on commit 13a9f02

Please sign in to comment.