Files
igny8/plugins/wordpress/source/igny8-wp-bridge/templates/assets/js/igny8-content-template.js
2026-01-09 22:45:30 +00:00

63 lines
1.9 KiB
JavaScript

/**
* IGNY8 Content Template JavaScript
* Optional JavaScript enhancements
*/
(function($) {
'use strict';
// Wait for DOM ready
$(document).ready(function() {
// Add smooth scroll to section anchors
$('.igny8-content-section').each(function() {
var sectionId = $(this).attr('id');
if (sectionId && window.location.hash === '#' + sectionId) {
$('html, body').animate({
scrollTop: $(this).offset().top - 100
}, 500);
}
});
// Optional: Add copy functionality to code blocks
$('.igny8-prose pre code').each(function() {
var $code = $(this);
var $pre = $code.parent();
// Add copy button
var $copyBtn = $('<button class="igny8-copy-code" title="Copy code">Copy</button>');
$pre.css('position', 'relative');
$copyBtn.css({
'position': 'absolute',
'top': '0.5rem',
'right': '0.5rem',
'padding': '0.25rem 0.75rem',
'font-size': '0.75rem',
'background': 'rgba(0, 0, 0, 0.1)',
'border': 'none',
'border-radius': '4px',
'cursor': 'pointer'
});
$copyBtn.on('click', function(e) {
e.preventDefault();
var code = $code.text();
// Copy to clipboard
if (navigator.clipboard) {
navigator.clipboard.writeText(code).then(function() {
$copyBtn.text('Copied!');
setTimeout(function() {
$copyBtn.text('Copy');
}, 2000);
});
}
});
$pre.append($copyBtn);
});
});
})(jQuery);