Code Monkey home page Code Monkey logo

jquery.clipboard's Introduction

jQuery Clipboard

jQuery Clipboard plugin: copy any text to the user's clipboard. Implements ZeroClipboard over the jQuery plugin layer.

Usage

1. Before You Start

  • Due to Flash restrictions, jQuery Clipboard cannot be used on local domains (localhost, .dev), you need to serve it from a genuine Internet domain (.com, .net or so)
  • Please check that you are using at least jQuery 1.7 - jQuery Clipboard won't work with versions below!

2. Include Scripts

<script type="text/javascript" src="/path/to/javascripts/jquery.js"></script>
<script type="text/javascript" src="/path/to/javascripts/jquery.clipboard.js"></script>

3. Apply On An Element

$(document).ready(function() {
    var copy_sel = $('.code-block a.code-copy');

    // Disables other default handlers on click (avoid issues)
    copy_sel.on('click', function(e) {
        e.preventDefault();
    });

    // Apply clipboard click event
    copy_sel.clipboard({
        path: '/path/to/flashes/jquery.clipboard.swf',

        copy: function() {
            var this_sel = $(this);

            // Hide "Copy" and show "Copied, copy again?" message in link
            this_sel.find('.code-copy-first').hide();
            this_sel.find('.code-copy-done').show();

            // Return text in closest element (useful when you have multiple boxes that can be copied)
            return this_sel.closest('.code-block').text();
        }
    });
});

4. More Docs

More docs can be found on http://www.steamdev.com/zclip/

jQuery Clipboard is mostly based on jQuery.zClip, the plugin APIs remain almost the same.

jquery.clipboard's People

Contributors

valeriansaliou avatar gitter-badger avatar kavun avatar

Stargazers

Roman avatar Yasin ATEŞ avatar 爱吃猫的鱼 avatar entimm avatar Steven Du avatar Edward avatar 赵欢磊 avatar Brendo Marinho avatar Josh Sherman avatar Ahuing avatar  avatar Ren Ventura avatar Silas Ribas Martins avatar seaice avatar will-v-king avatar Ulrich Diedrichsen avatar Timothy Vandenbrande avatar Josh Lind avatar alkin kasap avatar Valentin Vichnal avatar Rothana Choun avatar yangyang avatar Seven Yu avatar Roberto Albornoz avatar Chris  avatar Billy D. avatar Charles Tang avatar Pascal Pflaum avatar zepp-cross avatar liaolliso avatar Tyler Longren avatar Bruno Guerreiro avatar Matt Danskine avatar Alex Espinoza avatar Johnny Eric Amancio avatar  avatar Rui Zhong avatar Zmmfly avatar Julien Le Coupanec avatar Aymen Fnayou avatar 魚魚 avatar Christopher Enytc avatar Vanya B. avatar Tim Case avatar Bharat Mandava avatar  avatar mecrazy avatar  avatar zilong.zhou avatar Murshed Ahmmad Khan avatar Jack Rivers avatar Delong_Gao avatar lemori avatar Jeremy Newman avatar David Benko avatar Jesse L.K. Overton avatar Jonathan Barratt avatar Uwe L. Korn avatar  avatar Julien Vernet avatar J.LEE avatar NiKu avatar Mathias Bogaert avatar 蔡正海 avatar  avatar Dmitri Maximovich avatar Bobby Allen avatar MichaelPfuetze avatar Francesco Marretta avatar Jon Thomas avatar Lucas Bonomi avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

jquery.clipboard's Issues

Click Twice To Copy

Seems that some users are encountering issues with copying, requiring them to click twice on the link to get the text copied.

This is abnormal, needs a fix.

Clipboards are stacking

Hello, great plugin!

But I have a problem.
I have three buttons that launch clipboard A, B and C.
After click on A - nothing copied.
After click on B - copied text that was targeted for A button.

And If I click A button twice - it copied right.

It stacking results somehow. The selectors are right and checked by console inside "copy: function() {}", but returned values (copied text) are late.

Have you seen this behavior before?

Thanks!

Set clipboard for hidden element

My all copy buttons on page are hidden with display:none. And it seems that copy_sel.clipboard() call doesn't have effect on hidden buttons.
Anyway to fix that issue? Thanks

Multiple Elements

Restore the original, deprecated, zclip's ability to be applied on multiple elements.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.