| 1 |
/** |
| 2 |
* Customizer controls toggles |
| 3 |
* |
| 4 |
* @package Astra |
| 5 |
*/ |
| 6 |
|
| 7 |
( function( $ ) { |
| 8 |
|
| 9 |
/** |
| 10 |
* Helper class for the main Customizer interface. |
| 11 |
* |
| 12 |
* @since 1.0.0 |
| 13 |
* @class ASTCustomizer |
| 14 |
*/ |
| 15 |
AstraNotices = { |
| 16 |
|
| 17 |
/** |
| 18 |
* Initializes our custom logic for the Customizer. |
| 19 |
* |
| 20 |
* @since 1.0.0 |
| 21 |
* @method init |
| 22 |
*/ |
| 23 |
init: function() |
| 24 |
{ |
| 25 |
this._bind(); |
| 26 |
}, |
| 27 |
|
| 28 |
/** |
| 29 |
* Binds events for the Astra Portfolio. |
| 30 |
* |
| 31 |
* @since 1.0.0 |
| 32 |
* @access private |
| 33 |
* @method _bind |
| 34 |
*/ |
| 35 |
_bind: function() |
| 36 |
{ |
| 37 |
$( document ).on('click', '.astra-notice-close', AstraNotices._dismissNoticeNew ); |
| 38 |
$( document ).on('click', '.astra-notice .notice-dismiss', AstraNotices._dismissNotice ); |
| 39 |
}, |
| 40 |
|
| 41 |
_dismissNotice: function( event ) { |
| 42 |
event.preventDefault(); |
| 43 |
|
| 44 |
var repeat_notice_after = $( this ).parents('.astra-notice').data( 'repeat-notice-after' ) || ''; |
| 45 |
var notice_id = $( this ).parents('.astra-notice').attr( 'id' ) || ''; |
| 46 |
|
| 47 |
AstraNotices._ajax( notice_id, repeat_notice_after ); |
| 48 |
}, |
| 49 |
|
| 50 |
_dismissNoticeNew: function( event ) { |
| 51 |
event.preventDefault(); |
| 52 |
|
| 53 |
var repeat_notice_after = $( this ).attr( 'data-repeat-notice-after' ) || ''; |
| 54 |
var notice_id = $( this ).parents('.astra-notice').attr( 'id' ) || ''; |
| 55 |
|
| 56 |
var $el = $( this ).parents('.astra-notice'); |
| 57 |
$el.fadeTo( 100, 0, function() { |
| 58 |
$el.slideUp( 100, function() { |
| 59 |
$el.remove(); |
| 60 |
}); |
| 61 |
}); |
| 62 |
|
| 63 |
AstraNotices._ajax( notice_id, repeat_notice_after ); |
| 64 |
|
| 65 |
var link = $( this ).attr( 'href' ) || ''; |
| 66 |
var target = $( this ).attr( 'target' ) || ''; |
| 67 |
if( '' !== link && '_blank' === target ) { |
| 68 |
window.open(link , '_blank'); |
| 69 |
} |
| 70 |
}, |
| 71 |
|
| 72 |
_ajax: function( notice_id, repeat_notice_after ) { |
| 73 |
|
| 74 |
if( '' === notice_id ) { |
| 75 |
return; |
| 76 |
} |
| 77 |
|
| 78 |
$.ajax({ |
| 79 |
url: ajaxurl, |
| 80 |
type: 'POST', |
| 81 |
data: { |
| 82 |
action : 'astra-notice-dismiss', |
| 83 |
nonce : astraNotices._notice_nonce, |
| 84 |
notice_id : notice_id, |
| 85 |
repeat_notice_after : parseInt( repeat_notice_after, 10 ), |
| 86 |
}, |
| 87 |
}); |
| 88 |
|
| 89 |
} |
| 90 |
}; |
| 91 |
|
| 92 |
$( function() { |
| 93 |
AstraNotices.init(); |
| 94 |
} ); |
| 95 |
} )( jQuery ); |