ZeroClipBoard + Wordpress + Javascript , need help

Discussion in 'JavaScript' started by Wp-Mod.Com, Oct 2, 2010.

  1. #1
    ok , i want to get zero clipboard working on my wordpress theme ,

    my main objective is to add a button 'copy to clipboard' in wordpress loop so that all content of post gets copied when clicked on it.

    now the issue is i got it working on wordpress comments
    here is the code

    <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/ZeroClipboard.js"></script>
    <script type="text/javascript">
    ZeroClipboard.setMoviePath( 'http://www.teddy-o-ted.com/wp-content/themes/Teddyrisationeta/js/ZeroClipboard.swf' );
    var clip = null;
    function init() {
    clip = new ZeroClipboard.Client();
    clip.addEventListener('mouseOver', my_mouse_over);
    clip.addEventListener( 'onComplete', my_complete );
    clip.glue( 'clipboard' );
    }
    function my_mouse_over(client) {
    clip.setText( document.getElementById('comment').value );
    }
    function my_complete(client) {
    document.getElementById('clipboard').innerHTML = "Comment copied";
    document.getElementById('comment').focus();
    setTimeout ( "resetbutton()", 3000 );
    }
    function hoverreposition() {
    clip.reposition();
    }
    function resetbutton() {
    document.getElementById('clipboard').innerHTML = "Copy to clipboard?";
    }
    </script>
    
    Code (markup):
    but need it to work in the wordpress loop , more of similar example like this http://bowser.macminicolo.net/~jhuckaby/zeroclipboard/multiple.html

    here is the multiple code

    <script language="JavaScript">
            var clip = null;
                    
            function init() {
                // setup single ZeroClipboard object for all our elements
                clip = new ZeroClipboard.Client();
                clip.setHandCursor( true );
                
                // assign a common mouseover function for all elements using jQuery
                $('div.multiple').mouseover( function() {
                    // set the clip text to our innerHTML
                    clip.setText( this.innerHTML );
                    
                    // reposition the movie over our element
                    // or create it if this is the first time
                    if (clip.div) {
                        clip.receiveEvent('mouseout', null);
                        clip.reposition(this);
                    }
                    else clip.glue(this);
                    
                    // gotta force these events due to the Flash movie
                    // moving all around.  This insures the CSS effects
                    // are properly updated.
                    clip.receiveEvent('mouseover', null);
                } );
            }
        </script>
    
    Code (markup):
    now some how i have to blend them both in so that , it works both for wordpress and will work on multiple at the same time , help would be greatly appreciated , if you help me out i will give you 5$ in paypal too . but need help as soon as possible
     
    Wp-Mod.Com, Oct 2, 2010 IP