jQuery Code Box Copy Demos

Usage

Sources

Put the following lines below to the head section. Do not forget to use the copy function :)

<!-- Cod Box Copy begin -->
<link href="prism/prism.min.css" rel="stylesheet">
<link href="code-box-copy/css/code-box-copy.css" rel="stylesheet">
<script src="js/jquery.min.js"></script>
<script src="prism/prism.min.js"></script>
<script src="clipboard/clipboard.min.js"></script>
<script src="code-box-copy/js/code-box-copy.js"></script>
<!-- Cod Box Copy end -->

Content you want to copy

Test it with a simple HTML code like below:

<div class="code-box-copy">
    <button class="code-box-copy__btn" data-clipboard-target="#example-html" title="Copy"></button>
    <pre><code class="language-html" id="example-html">&lt;div class=&quot;example&quot;&gt;
        Lorem ipsum
    &lt;/div&gt;</code></pre>
</div>

Plugin initialization

Put in the head section the plugin initialization's code or in the end of the body section:

<script>
$(document).ready(function () {
    $('.code-box-copy').codeBoxCopy();
});
</script>

Plugin initialization with parameters:

<script>
$(document).ready(function () {
    $('.code-box-copy').codeBoxCopy({
        tooltipText: 'Copied',
        tooltipShowTime: 1000,
        tooltipFadeInTime: 300,
        tooltipFadeOutTime: 300
    });
});
</script>

Parameters

Third-party libraries (MIT Licence)

Licence

The MIT Licence

Copyright 2017 © jablonczay.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.