Skip to content

Commit

Permalink
Add config hidden_bottom
Browse files Browse the repository at this point in the history
Hidden Notify Cookies when scroll to bottom end
  • Loading branch information
magiccart committed Jul 14, 2021
1 parent a945866 commit daeaffc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
10 changes: 6 additions & 4 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
</depends>
<source_model>Magepow\Gdpr\Model\Config\Source\Position</source_model>
</field>


<field id="margin_left" translate="label comment" type="text" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="76" canRestore="1">
<label>Margin left</label>
Expand All @@ -88,12 +87,16 @@
<validate>validate-number</validate>
</field>


<field id="margin_bottom" translate="label comment" type="text" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="80" canRestore="1">
<label>Margin bottom</label>
<validate>validate-number</validate>
</field>


<field id="hidden_bottom" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label><![CDATA[Hidden Bottom End]]></label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[Hidden Notify Cookies when scroll to bottom end]]></comment>
</field>

<field id="font_size" translate="label comment" type="text" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="101" canRestore="1">
<label>Font size</label>
Expand All @@ -105,7 +108,6 @@
<source_model>Magepow\Gdpr\Model\Config\Source\Align</source_model>
</field>


<field id="box_shadow" translate="label comment" type="select" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="120" canRestore="1">
<label>Box shadow</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<margin_left>30</margin_left>
<margin_right>30</margin_right>
<margin_bottom>0</margin_bottom>
<hidden_bottom>1</hidden_bottom>
<box_shadow>1</box_shadow>
<text_align><![CDATA[center]]></text_align>
<font_size>15</font_size>
Expand Down
14 changes: 14 additions & 0 deletions view/frontend/templates/html/notices.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
<?php $fontSize = $configPopup['font_size']; ?>
<?php $textAlign = $configPopup['text_align']; ?>
<?php $identifier = $configPopup['identifier']; ?>
<?php $hiddenBottom = $configPopup['hidden_bottom']; ?>
<div role="alertdialog"
tabindex="-1"
data-hidden-bottom="<?php echo $hiddenBottom ?>"
class="magepow-gdpr-cookie-notice message global cookie text-align-<?php echo $textAlign ?><?php if($boxShadow): ?> gdpr-box-shadow<?php endif ?>"
id="notice-cookie-block"
style="display: none;<?php if($width == 'custom' && $widthCustom!=''): ?>width:<?php echo $widthCustom ?>px;<?php endif ?><?php if($marginBottom!=''): ?>bottom:<?php echo $marginBottom ?>px;<?php endif ?><?php if($width == 'custom' && $position=='left' && $marginLeft!=''): ?>left:<?php echo $marginLeft ?>px; right:unset;<?php endif ?><?php if($width == 'custom' && $position=='right' && $marginLeft!=''): ?>right:<?php echo $marginRight ?>px; left:unset;<?php endif ?><?php if($fontSize!=''): ?>font-size:<?php echo $fontSize ?>px;<?php endif ?>">
Expand Down Expand Up @@ -58,6 +60,18 @@
</div>
</div>
</div>
<script type="text/javascript">
require(['jquery'], function($){
$(window).scroll(function() {
var $body = $('body');
var $noticeCookie = $('#notice-cookie-block');
var y = $(this).scrollTop();
var isHidden = $noticeCookie.data('hidden-bottom') ? (y + $(this).height() == $(document).height()) : '';
if (isHidden) $body.addClass('cookie-hidden-bottom');
else $body.removeClass('cookie-hidden-bottom');
});
});
</script>
<script type="text/x-magento-init">
{
"#notice-cookie-block": {
Expand Down
3 changes: 3 additions & 0 deletions view/frontend/web/css/source/_module.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
& when (@media-common =true) {
.cookie-hidden-bottom #notice-cookie-block {
display: none;
}
.message.global.cookie.magepow-gdpr-cookie-notice{
bottom: 0;
left: 0;
Expand Down

0 comments on commit daeaffc

Please sign in to comment.