Skip to content

Commit

Permalink
almost done with toggle offset settings
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsguides committed Apr 14, 2024
1 parent bbcb97a commit deaad34
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 20 deletions.
17 changes: 6 additions & 11 deletions media/plg_system_autoscrollspy/css/default.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion media/plg_system_autoscrollspy/css/default.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion media/plg_system_autoscrollspy/css/default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ ul.autoss-nav{

}

.autoss-float-toggle{
.autoss-float-toggle.btn{
position: fixed;
padding: 5px;
cursor: pointer;
Expand All @@ -154,6 +154,11 @@ ul.autoss-nav{

}

display: flex;
align-items: center;
justify-content: center;



}

Expand Down
6 changes: 1 addition & 5 deletions media/plg_system_autoscrollspy/js/autoscrollspy.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,8 @@ document.addEventListener("DOMContentLoaded", function(event) {
if (floatContainer) {

let floatToggler = document.querySelector('.autoss-float-toggle');
//calculate actual height of floatToggler from its top to its bottom
let floatTogglerHeight = floatToggler.offsetHeight + parseFloat(getComputedStyle(floatToggler).marginTop) + parseFloat(getComputedStyle(floatToggler).marginBottom);

console.log('floatTogglerHeight is ' + floatTogglerHeight);
//the top of floatToggler needs to be the top of the floatContainer minus the height of floatToggler
floatToggler.style.top = (floatContainer.offsetTop - floatTogglerHeight) + 'px';
floatToggler.style.top = floatPanelToggleOffsetTop;

const autoCollapseWidth = nav.getAttribute('data-collapsewidth');
//if it's 0px, we always collapse it
Expand Down
4 changes: 3 additions & 1 deletion plugins/system/autoscrollspy/autoscrollspy.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function onContentBeforeDisplay($context, &$article, &$params, $limitstar
$plugin_path = URI::base().'plugins/system/autoscrollspy';
$wam->useStyle('plg_system_autoscrollspy.default');
if($enable_scrollspy == 1){
$wam->useScript('plg_system_autoscrollspy.autoscrollspy');
$wam->useScript('plg_system_autoscrollspy.autoscrollspy', ['defer' => true]);
}

/* floatpanel props*/
Expand All @@ -54,11 +54,13 @@ public function onContentBeforeDisplay($context, &$article, &$params, $limitstar
$floatpanel_autocollapse_width = $this->params->get('floatpanel_autocollapse_width', '768');
$floatpanel_collapse_toggler_type = $this->params->get('floatpanel_collapse_toggler_type', 'fa-button');
$toggletext = $this->params->get('floatpanel_collapse_toggler_text', '');
$floatpanel_toggle_offset_top = $this->params->get('floatpanel_toggle_offset_top', '200px');

// handle offset of scroll to heading (pass to js)
$scroll_offset_top = $this->params->get('scroll_offset_top', '0');
$wam->addInlineScript('
const scrollOffsetTop = '.$scroll_offset_top.';
const floatPanelToggleOffsetTop = "'.$floatpanel_toggle_offset_top.'";
', ['type' => 'text/javascript']);


Expand Down
10 changes: 10 additions & 0 deletions plugins/system/autoscrollspy/autoscrollspy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<folder>js</folder>
<folder>css</folder>
<folder>images</folder>
<filename>joomla.asset.json</filename>
</media>

<languages>
Expand Down Expand Up @@ -176,13 +177,22 @@
showon="render_location:floatpanel"
/>
<field
name="floatpanel_toggle_offset_top"
type="text"
label="PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_TOGGLE_OFFSET_TOP"
description="PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_TOGGLE_OFFSET_TOP_DESC"
default="200px"
showon="render_location:floatpanel"
/>
<field
name="floatpanel_offset_top"
type="text"
label="PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_OFFSET_TOP"
description="PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_OFFSET_TOP_DESC"
default="250px"
showon="render_location:floatpanel"
/>

<field
name="floatpanel_paneltitle"
type="text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_POSITION_DESC = "Where to put the panel. De
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_WIDTH = "Float Panel Width (px)"
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_WIDTH_DESC = "The width of the panel. Default is 200px."
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_OFFSET_TOP = "Float Panel Offset Top"
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_OFFSET_TOP_DESC = "How far down on the page to put this, in pixels, %, or vh. So you MUST include the px, %, or vh unit after the number for this one."
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_OFFSET_TOP_DESC = "How far down the page to put the open floating menu panel. Should be HIGHER than the toggle offset top. Default is 200px."
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_PANELTITLE = "Float Panel Title"
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_PANELTITLE_DESC = "The title to show above a floating panel. If blank, no title is shown."
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_AUTOCOLLAPSE_WIDTH = "Float Panel Auto Collapse Width (px)"
Expand All @@ -47,3 +47,5 @@ PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_COLLAPSE_TOGGLER_TEXT_DESC="The text to sho
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_COLLAPSE_TOGGLER_TYPE_LOADED_SVG_ICON="Loaded Menu Icon"
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_COLLAPSE_TOGGLER_TYPE_LOADED_SVG_ICON_WITH_TEXT="Loaded Menu Icon with Text"

PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_TOGGLE_OFFSET_TOP="Toggle Offset Top"
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_TOGGLE_OFFSET_TOP_DESC="Offset from top of the page to put the toggle button. Should be LESS than the panel offset top itself. Default is 200px."

0 comments on commit deaad34

Please sign in to comment.