summaryrefslogtreecommitdiff
path: root/inc/lib/notices/notices.js
diff options
context:
space:
mode:
authorZach van Rijn <me@zv.io>2021-07-21 14:54:07 -0500
committerZach van Rijn <me@zv.io>2021-07-21 14:54:07 -0500
commit9d4123cee1867ee7199b06bdc92d40611f547ecc (patch)
tree6d864e2725242863afed1f8ba12d9c7a9bc63a69 /inc/lib/notices/notices.js
downloadblog-ng-9d4123cee1867ee7199b06bdc92d40611f547ecc.tar.gz
blog-ng-9d4123cee1867ee7199b06bdc92d40611f547ecc.tar.bz2
blog-ng-9d4123cee1867ee7199b06bdc92d40611f547ecc.tar.xz
blog-ng-9d4123cee1867ee7199b06bdc92d40611f547ecc.zip
Initial unmodified import from Astra (Version: 3.6.5) @ /wp-content/themes/astra/.
Diffstat (limited to 'inc/lib/notices/notices.js')
-rw-r--r--inc/lib/notices/notices.js95
1 files changed, 95 insertions, 0 deletions
diff --git a/inc/lib/notices/notices.js b/inc/lib/notices/notices.js
new file mode 100644
index 0000000..3903b30
--- /dev/null
+++ b/inc/lib/notices/notices.js
@@ -0,0 +1,95 @@
+/**
+ * Customizer controls toggles
+ *
+ * @package Astra
+ */
+
+ ( function( $ ) {
+
+ /**
+ * Helper class for the main Customizer interface.
+ *
+ * @since 1.0.0
+ * @class ASTCustomizer
+ */
+ AstraNotices = {
+
+ /**
+ * Initializes our custom logic for the Customizer.
+ *
+ * @since 1.0.0
+ * @method init
+ */
+ init: function()
+ {
+ this._bind();
+ },
+
+ /**
+ * Binds events for the Astra Portfolio.
+ *
+ * @since 1.0.0
+ * @access private
+ * @method _bind
+ */
+ _bind: function()
+ {
+ $( document ).on('click', '.astra-notice-close', AstraNotices._dismissNoticeNew );
+ $( document ).on('click', '.astra-notice .notice-dismiss', AstraNotices._dismissNotice );
+ },
+
+ _dismissNotice: function( event ) {
+ event.preventDefault();
+
+ var repeat_notice_after = $( this ).parents('.astra-notice').data( 'repeat-notice-after' ) || '';
+ var notice_id = $( this ).parents('.astra-notice').attr( 'id' ) || '';
+
+ AstraNotices._ajax( notice_id, repeat_notice_after );
+ },
+
+ _dismissNoticeNew: function( event ) {
+ event.preventDefault();
+
+ var repeat_notice_after = $( this ).attr( 'data-repeat-notice-after' ) || '';
+ var notice_id = $( this ).parents('.astra-notice').attr( 'id' ) || '';
+
+ var $el = $( this ).parents('.astra-notice');
+ $el.fadeTo( 100, 0, function() {
+ $el.slideUp( 100, function() {
+ $el.remove();
+ });
+ });
+
+ AstraNotices._ajax( notice_id, repeat_notice_after );
+
+ var link = $( this ).attr( 'href' ) || '';
+ var target = $( this ).attr( 'target' ) || '';
+ if( '' !== link && '_blank' === target ) {
+ window.open(link , '_blank');
+ }
+ },
+
+ _ajax: function( notice_id, repeat_notice_after ) {
+
+ if( '' === notice_id ) {
+ return;
+ }
+
+ $.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ data: {
+ action : 'astra-notice-dismiss',
+ nonce : astraNotices._notice_nonce,
+ notice_id : notice_id,
+ repeat_notice_after : parseInt( repeat_notice_after ),
+ },
+ });
+
+ }
+ };
+
+ $( function() {
+ AstraNotices.init();
+ } );
+} )( jQuery );