(function ($) {
const CTCCore = {
/**
* Init
*/
init: function () {
this._bind();
},
/**
* Binds events
*/
_bind: function () {
$( document ).on( 'click', '.ctc-block-copy', this.doCopy );
},
/**
* Do Copy to Clipboard
*/
doCopy: function (event) {
event.preventDefault();
let btn = $(this),
btnText = btn.find( '.ctc-button-text' ),
oldText = btnText.text(),
copiedText = btn.attr( 'data-copied' ) || 'Copied',
copyAsRaw = btn.attr( 'copy-as-raw' ) || '',
block = btn.parents('.ctc-block'),
content = block.find('.ctc-copy-content').val();
if ( ! copyAsRaw ) {
// Convert the
tags into new line.
content = content.replace(/
/gi, "\n");
// Convert the
tags into new line. content = content.replace(/
/gi, "\n\n"); // Convert the