-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Radik Kurmanaev
committed
Jan 13, 2023
1 parent
dd560b6
commit 491887d
Showing
5 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Magenable | ||
* | ||
* @category Magenable | ||
* @package Magenable_TopBarNotification | ||
* @copyright Copyright (c) Magenable (https://magenable.com.au/) | ||
*/ | ||
--> | ||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" | ||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
<body> | ||
<referenceBlock name="breeze.js"> | ||
<arguments> | ||
<argument name="bundles" xsi:type="array"> | ||
<item name="default" xsi:type="array"> | ||
<item name="items" xsi:type="array"> | ||
<item name="notification" xsi:type="string">Magenable_TopBarNotification/js/breeze/notification</item> | ||
</item> | ||
</item> | ||
</argument> | ||
</arguments> | ||
</referenceBlock> | ||
</body> | ||
</page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Magenable | ||
* | ||
* @category Magenable | ||
* @package Magenable_TopBarNotification | ||
* @copyright Copyright (c) Magenable (https://magenable.com.au/) | ||
*/ | ||
.top-bar-notification { | ||
position: relative; | ||
|
||
&.tbn-type-text { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
text-align: center; | ||
padding: 15px 0; | ||
} | ||
&.tbn-type-html { | ||
min-height: 30px; | ||
} | ||
&.hidden { | ||
display: none; | ||
} | ||
.tbn-close-btn { | ||
background: url('@{baseDir}/Magenable_TopBarNotification/images/icon-close.png') no-repeat; | ||
background-size: cover; | ||
cursor: pointer; | ||
width: 20px; | ||
height: 20px; | ||
position: absolute; | ||
right: 5px; | ||
top: 5px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
function init(config, element) { | ||
if (!checkUrl(config.includePages, config.excludePages)) { | ||
return false; | ||
} | ||
if (!$.mage.cookies.get('top_bar_notification_closed')) { | ||
$(element).removeClass('hidden'); | ||
} | ||
$(config.closeBtnSelector).on('click', function() { | ||
$(element).fadeOut(300); | ||
$.mage.cookies.set('top_bar_notification_closed', true); | ||
}); | ||
} | ||
|
||
function checkUrl(includePages, excludePages) { | ||
function inArrayCheck(url) { | ||
return url === document.location.pathname; | ||
} | ||
if (includePages) { | ||
return includePages.split('\r\n').some(inArrayCheck); | ||
} | ||
if (excludePages) { | ||
return !excludePages.split('\r\n').some(inArrayCheck); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
$(document).on('breeze:mount:notification', (e, data) => { | ||
init(data.settings, data.el) | ||
}) | ||
})(); |