| 1 |
(function($) { |
| 2 |
|
| 3 |
CopyTheCodeNotice = { |
| 4 |
|
| 5 |
/** |
| 6 |
* Init |
| 7 |
*/ |
| 8 |
init: function() |
| 9 |
{ |
| 10 |
this._bind(); |
| 11 |
}, |
| 12 |
|
| 13 |
_bind: function() |
| 14 |
{ |
| 15 |
$( document ).on('click', '.copy-the-code-allow-tracking', CopyTheCodeNotice.allow ); |
| 16 |
$( document ).on('click', '.copy-the-code-not-allow-tracking, .copy-the-code-notice .notice-dismiss', CopyTheCodeNotice.not_allow ); |
| 17 |
}, |
| 18 |
|
| 19 |
/** |
| 20 |
* Copy to Clipboard |
| 21 |
*/ |
| 22 |
allow: function( event ) { |
| 23 |
event.preventDefault(); |
| 24 |
|
| 25 |
$.ajax({ |
| 26 |
url: copy_the_code_notice.ajax_url, |
| 27 |
type: 'POST', |
| 28 |
data: { |
| 29 |
action: 'copy_the_code_allow_tracking', |
| 30 |
security: copy_the_code_notice.nonce, |
| 31 |
}, |
| 32 |
success: function( response ) { |
| 33 |
if( response.success ) { |
| 34 |
$('.copy-the-code-notice').remove(); |
| 35 |
} |
| 36 |
} |
| 37 |
}); |
| 38 |
}, |
| 39 |
|
| 40 |
/** |
| 41 |
* Copy to Clipboard |
| 42 |
*/ |
| 43 |
not_allow: function( event ) { |
| 44 |
event.preventDefault(); |
| 45 |
|
| 46 |
$.ajax({ |
| 47 |
url: copy_the_code_notice.ajax_url, |
| 48 |
type: 'POST', |
| 49 |
data: { |
| 50 |
action: 'copy_the_code_dont_allow_tracking', |
| 51 |
security: copy_the_code_notice.nonce, |
| 52 |
}, |
| 53 |
success: function( response ) { |
| 54 |
if( response.success ) { |
| 55 |
$('.copy-the-code-notice').remove(); |
| 56 |
} |
| 57 |
} |
| 58 |
}); |
| 59 |
} |
| 60 |
|
| 61 |
}; |
| 62 |
|
| 63 |
/** |
| 64 |
* Initialization |
| 65 |
*/ |
| 66 |
$(function() { |
| 67 |
CopyTheCodeNotice.init(); |
| 68 |
}); |
| 69 |
|
| 70 |
})(jQuery); |
| 71 |
|
| 72 |
|