/**
* Astra Theme Customizer Style Guide
*
* @package Astra
* @since x.x.x
*/
(function($, api) {
/**
* Style Guide navigation.
*/
jQuery(document).ready(function($) {
let headerContainer = jQuery('#customize-header-actions'),
button = jQuery('');
let indicatorDot = $('');
headerContainer.append(indicatorDot);
headerContainer.append(button);
// Added function to check visit count and show/hide the red dot.
function checkVisitCount() {
let visitCount = localStorage.getItem('customizerVisitCount');
visitCount = visitCount ? parseInt(visitCount, 10) : 0;
if (visitCount < 5) {
indicatorDot.show();
visitCount++;
localStorage.setItem('customizerVisitCount', visitCount);
} else {
indicatorDot.hide();
}
}
checkVisitCount();
button.on('click', function(event) {
event.preventDefault();
event.stopPropagation();
// Access the iframe's content
var iframeBody = $('#customize-preview').find('iframe').contents().find('body');
// Apply the custom class to the iframe's body
iframeBody.toggleClass('ast-sg-loaded');
// Creating new state for restricting the preview refresh.
api.state.create('astra-style-guide-status');
api.state('astra-style-guide-status').set('loaded');
});
});
// development code.
$('#customize-preview iframe').on('load', function() {
// Access the iframe's content
var iframeBody = $('#customize-preview').find('iframe').contents().find('body');
// Apply the custom class to the iframe's body
iframeBody.addClass('ast-sg-loaded');
});
})(jQuery, wp.customize);