Giter Site home page Giter Site logo

zeroclipboard / zeroclipboard Goto Github PK

View Code? Open in Web Editor NEW
6.6K 252.0 1.1K 3.16 MB

The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.

Home Page: http://zeroclipboard.github.io/

License: MIT License

JavaScript 82.68% ActionScript 11.36% HTML 5.96%
zeroclipboard javascript flash adobe-flash apache-flex clipboard dom web frontend adobe-flex

zeroclipboard's Introduction

⚠️ WARNING!

This library is no longer maintained as it is no longer necessary for modern web development. If you want your frontend JavaScript to manipulate the clipboard, please look into the new HTML Clipboard API (various docs available on MDN) or a small convenience wrapper around it like clipboard.js. Thanks for all your support, this project was a labor of love for many years. ❤️


Note:

This master branch contains the v2.x codebase for ZeroClipboard! For the v1.x codebase, see the 1.x-master branch instead.

ZeroClipboard

GitHub Latest Release Build Status GZip Size Coverage Status Dependency Status Dev Dependency Status

The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface. The "Zero" signifies that the library is invisible and the user interface is left entirely up to you.

This is achieved by automatically floating the invisible movie on top of a DOM element of your choice. Standard mouse events are even propagated out to your DOM element, so you can still have rollover and mousedown effects.

Suggestions welcome read over the contributing guidelines.

Setup

To setup the project for local development start with these commands in your terminal.

$ git clone https://github.com/zeroclipboard/zeroclipboard.git
$ cd zeroclipboard/
$ npm install -g grunt-cli
$ npm install
$ grunt

Development

Before submitting a pull request you'll need to validate, build, and test your code. Run the default grunt task in your terminal.

$ grunt

Testing

If you just want to run the tests, run grunt test.

$ grunt test

Limitations

User Interaction Required

Due to browser and Flash security restrictions, this clipboard injection can ONLY occur when the user clicks on the invisible Flash movie. A simulated click event from JavaScript will not suffice as this would enable clipboard poisoning.

Other Limitations

For a complete list of limitations, see docs/instructions.md#limitations.

On that page, you will also find an explanation of why ZeroClipboard will NOT work by default on code playground sites like JSFiddle, JSBin, and CodePen, as well as the appropriate "View" URLs to use on those sites in order to allow ZeroClipboard to work.

Simple Example

<html>
  <body>
    <button id="copy-button" data-clipboard-text="Copy Me!" title="Click to copy me.">Copy to Clipboard</button>
    <script src="ZeroClipboard.js"></script>
    <script src="main.js"></script>
  </body>
</html>
// main.js
var client = new ZeroClipboard( document.getElementById("copy-button") );

client.on( "ready", function( readyEvent ) {
  // alert( "ZeroClipboard SWF is ready!" );

  client.on( "aftercopy", function( event ) {
    // `this` === `client`
    // `event.target` === the element that was clicked
    event.target.style.display = "none";
    alert("Copied text to clipboard: " + event.data["text/plain"] );
  } );
} );

See docs/instructions.md for more advanced options in using the library on your site. See docs/api/ZeroClipboard.md for the complete API documentation.

Here is a working test page where you can try out ZeroClipboard in your browser.

Testing ZeroClipboard Locally

To test the page demo page locally, clone the website repo.

Support

This library is fully compatible with Flash Player 11.0.0 and above, which requires that the clipboard copy operation be initiated by a user click event inside the Flash movie. This is achieved by automatically floating the invisible movie on top of a DOM element of your choice. Standard mouse events are even propagated out to your DOM element, so you can still have rollover and mousedown effects with just a little extra effort.

ZeroClipboard v2.x is expected to work in IE9+ and all of the evergreen browsers. Although support for IE7 & IE8 was officially dropped in v2.0.0, it was actually still technically supported through v2.0.2.

Releases

Starting with version 1.1.7, ZeroClipboard uses semantic versioning.

see releases

Related

License

MIT © James M. Greene Jon Rohan

zeroclipboard's People

Contributors

adamyonk avatar afc163 avatar alexstrat avatar andrewraycode avatar andyluss avatar aroben avatar avlukanin avatar basarat avatar billgathen avatar bowsersenior avatar bundyo avatar cmtegner avatar donokuda avatar evanhahn avatar gabriel-bezerra avatar hallvors avatar huebs avatar ionicabizau avatar jamesmgreene avatar jonrohan avatar jrolfs avatar lhecker avatar maqnouch avatar rimian avatar robotdan avatar scintill avatar soluml avatar stereobit avatar thadseaver avatar tootallnate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zeroclipboard's Issues

Is there any way to manually set the clipboard?

I have a scenario whereby I want to set a value in the user's clipboard AND do something else when clicking on that element, which currently is not possible by only allowing click functionality. In this example, I want a user to have the login credentials in their clipboard, and then be directed to the service they're wanting to log into.

Any suggestions?

Programatically copy to your clipboard

Hi. I'm building an admin backoffice. So far ZeroClipboard works really good. However, I'm adding hotkeys to do certain actions in the admin, such as focusing the search field, or copying values (obviously made for power users).
So I'm asking if it's possible to copy a string to your clipboard without a Zeroclip client, or, triggering a mouseclick on an existing one (a clip with multiple glued elements)?

this.movie.setTitle is undefined

Hi,
I'm getting the following error in FF 15.0.1 "TypeError: this.movie.setTitle is not a function".
Specifically relating to line 276: this.movie.setTitle( this.title );
When looking at the line in Firebug the function is undefined.

I've had a look in both Chrome 21.0.1180.89 m and IE 9 and it's also happening in both (they are just silently failing).

Is the setTitle method missing from the flash movie?

Clipboard bugs on linux

GitHub is getting some bug reports about ZeroClipboard in linux.

Hello,

While trying copy git clone url or commit hash, I cannot paste it into a ubuntu's (gnome) terminal. Pasting into some empty field, then copy-pasting works again. I think, that can happen, because there are special chars (invisible, like some objects) in the copied string.

Hope for fixing an issue.

Thank you,
Really great service! Thumbs UP!

I can't reproduce the error, but maybe someone watching has some insight?

offsetLeft and offsetTop bug

It will cause the position in wrong place when use a graybox plugin like artDialog.
This issue can be fixed by modifying the following codes:

        if (obj && (obj != stopObj)) {
            /*
            info.left += obj.offsetLeft;
            info.top += obj.offsetTop;
            */
            jpos = $(obj).position();
            info.left += jpos.left;
            info.top += jpos.top;
        }

Get the "movie is loaded" alert - but nothing on any actionables.

<button id="copy-button" data-clipboard-text="YOYOYO" title="Copy Emails" class="lg-data-edit-button edit-info">
    Copy All Member Emails
</button>

I get the alert that the movie is loaded, however, when i click / hover / mouseout, etc --- none of the alerts work and the copying doesn't work either :/

JS::

// main.js
    var clip = new ZeroClipboard( jQuery('#copy-button'), {
      moviePath: "/wp-content/themes/lifegroups.theme/external/zeroclipboard/ZeroClipboard.swf"
    } );

    clip.on( 'load', function(client) {
      alert( "movie is loaded" );
    } );

    clip.on( 'complete', function(client, args) {
      this.style.display = 'none'; // "this" is the element that was clicked
      alert("Copied text to clipboard: " + args.text );
    } );

    clip.on( 'mouseover', function(client) {
      alert("mouse over");
    } );

    clip.on( 'mouseout', function(client) {
      alert("mouse out");
    } );

    clip.on( 'mousedown', function(client) {
      alert("mouse down");
    } );

    clip.on( 'mouseup', function(client) {
      alert("mouse up");
    } );

Time sensitive clipboard

It would be interesting to add settings option to make the data copied time sensitive. Meaning after a x amount of time, the flash object will clear the data.

Memory leak

Client is being added to clients and never gets removed from it. So it just keeps growing.

Firefox 18 freezes when attempting to copy with ZeroClipboard 1.0.7

I confirmed that a user began having trouble using an existing, functional ZeroClipboard instance. The button copies a string of data (HTML), invokes a mail call to open an Email window, and the contents of the page are pasted in an email body using standard UI commands.

The problem happens when the button is clicked. Removing the email call does not fix. See test case further down for working example of problem.

What happens is the button is clicked, and Firefox freezes for 1-2 minutes before finally giving an 'Contents copied' alert which is triggered when the button is clicked.

The problem began as soon as the user updated Firefox from version 17 to 18.

Align event names with HTML5 DOM event names

Consider aligning event names with existing IE/HTML5 DOM event names, specifically:

  • onDataRequested → onBeforeCopy and/or onCopy
  • onComplete → "onAfterCopy" (this event is not actually present in any existing DOM APIs 😕)

SemVer-wise, we could either change the names with a major version rev or else alias them in a minor version rev.

Thoughts, @jonrohan?

Event handlers not fired when using AMD

Title edited by @JamesMGreene

  • Old: work with memory DOM element?
  • New: Event handlers not fired when using AMD

I'm trying to integrate ZeroClipboard with 1 of my backbone views.

Since I saw this line https://github.com/jonrohan/ZeroClipboard/blob/master/ZeroClipboard.js#L352 so I assume ZeroClipboard should function properly with RequreJS, right?

Here're what I'm doing in the render() of a view
render: function () {
this.$el.html( this.template({model: this.model.toJSON()}) );

    this.clip = new ZeroClipboard(this.$('.js-copy'), {
        moviePath: '/mmm/javascripts/libs/zeroclipboard/ZeroClipboard.swf' 
    });

    return this;
  },

And here's the corresponding view:


I have to use class instead of ID because they may have more than 1 row (each row per model, FYI) and I'm certain the path is correct since I can see the flash component overlays the DOM element ('.js-copy').

My question is: Is it because the DOM element is not fully rendered yet so I cannot make
ZeroClipboard to copy the content?
If so, any workarounds?

Please let me know if i'm doing anything wrong or missing something.
Thanks.

Copy to clipboard the contents of a file on the server.

I have this scenario in which I would like to let the users copy the contents of XML file to clipboard. Since I don't want to load the whole XML when the page loads, I believe the loading should be done from within the flash movie.

What do you think?

ZeroClipboard copy fail after first time in Firefox17

With following steps can depulicate this issue:
1)create a page with multiple checkboxes
2)use zeroclipboard to implement copy these checked checkboxes' id
3)after the first copy, uncheck some checkboxes, and press button to copy ids to clipboard again
observe: we can see the clipboard text keep the same as ids of the first time
btw, it can be duplicated in FF17, not chrome, ie

Release notes / Change log for project

Hi!

Could you please add the project release notes (change log) with list of main changes that was maked in the different versions of your library?

Because now is very hard to understand what changed in new version of the ZeroClipboard. Are library has any breaking change or just minor fixes. And should I update it as soon as posible or can wait for some major change.

setText API doesn't work

I wish zeroClipboard worked as a clipboard service. But the following code doesn't work:

window.zeroClipboard = new ZeroClipboard();

$('#some-button').click(function(){
  zeroClipboard.setText('foo bar baz');
});

Stop capturing unnecessary MouseEvents in Flash

You know, thinking back to my proprietary ClipboardInjector... if we didn't capture those other mouse events (everything except CLICK) in the ActionScript, the mouse events will naturally propagate down to the HTML below anyway (as they do in my web apps). Wouldn't that be preferable to our current model of capturing the events in Flash and then dispatching incomplete versions of them back to JavaScript?

Not sure offhand if anyone is using those events in ZeroClipboard today. Alternatively, we could provide a either a loader parameter or another ExternalInterface callback to add those handlers (but default them to off), thus allowing any existing users that might utilize that functionality to still be able to use it.

Idea originated from #27 and was reiterated as desired by a user in #79.

Example not working, nothing happens

Hi,

I'm having the same problem as:

#5

What do you mean by "reverted to last working sha"?

That said, at least I'm able to load the ZeroClipboard.Client() fine... and my evenListeners also seem to be working properly. I'm able to trigger all the mouse events... o.O

Firefox freezes when alert() is used inside on complete callback

Hi,

today I implemented your latest Version (1.17 and 1.16) and experienced problems with Firefox 18.0 & 18.0.1 freezing inside the on-complete function. After some debugging it turned out, that flash is waiting for the on-complete function call to end but for whatever reason the alert is not shown and blocks the whole browser. Wrapping the alert call into an anonymous function and executing it via setTimeout solved the problem.

clip.on( 'complete', function(client, args) {
   setTimeout(function() {
     alert("Copied text to clipboard: " + args.text );
   }), 10);
});

If you want I can setup a demo-page if you can't reproduce it.

Cheers,
David

Example not working, nothing happens

I have uploaded the example (test.html, including other files) without changing anything in the code, but it doesn't work. Nothing happens, no error, no debugging, totally nothing.

Add a testing hook for the Flash object when compiled in debug mode

In order to test the Flash object from browser-based JavaScript unit tests (e.g. QUnit, etc.), we would need to add a hook method that can be directly invoked from the JavaScript side as we cannot simulate a click event on the Flash object (unless you used Selenium, perhaps, but that's a lot of overhead).

The Flash object should not be able to actually inject into the clipboard this way but it can at least still fire the "complete" event and send the text that it would've inserted back to JavaScript land for verification.

Example, basically adds another callback via ExternalInterface:
http://stackoverflow.com/questions/12129510/invoke-flash-click-event-from-javascript

And then we'd want to wrap that so that it is only produced when the SWF is compiled in debug mode.

XSS (cross site scripting) in ZeroClipboard swf files

The ZeroClipboard.swf and ZeroClipboard10.swf are vulnerable to XSS attack, example:
http://website/js/ZeroClipboard.swf#?id=\"))}catch(e){alert(/XSS/.source);}//&width=500&height=500
http://website/js/ZeroClipboard10.swf#?id=\"))}catch(e){alert(/XSS/.source);}//&width=500&height=500
http://website/js/ZeroClipboard.swf?id=\"))}catch(e){alert(/XSS/.source);}//&width=500&height=500
http://website/js/ZeroClipboard10.swf?id=\"))}catch(e){alert(/XSS/.source);}//&width=500&height=500

vulnerable code:

public function ZeroClipboard(){
....
var flashvars:Object = LoaderInfo(this.root.loaderInfo).parameters;
id = flashvars.id;
....
ExternalInterface.call("ZeroClipboard.dispatch", id, "load", null);

this files get a id parameter from url and passed it to second parameter inside ExternalInterface.call without any validation(only numbers) or proper escaping\encoding).
I reported the same issue here:
https://code.google.com/p/zeroclipboard/issues/detail?id=103

It'd be nice to be able to pass jquery selector results into Client

Sometimes the fields (button, text etc.) that a user wants to use are nested within a larger context where #ids are not used.

It would be nice to be able to pass in the results of a previous jquery to the Client constructor. I've made a simple 3 line patch to do this.

So now I can:
var q = $(element).find('button');
var clip = new ZeroClipboard.Client(copyButton);

This is particularly handy whenusing AngularJS to create reusable widgets(directives).

diff --git a/ZeroClipboard.js b/ZeroClipboard.js
index beeb428..d4d3068 100644
--- a/ZeroClipboard.js
+++ b/ZeroClipboard.js
@@ -325,6 +325,9 @@
result = ZeroClipboardSelect(query, document);
if (result.length === 0) result = [ document.getElementById(query) ];
}

  • if (query.jquery) {
  •   result = query;
    
  • }

Cannot 'destroy()' the clip.

'clip.destroy();' leads to :
TypeError: Object [object Object] has no method 'destroy'.
How exactly do I go about destroying the object?

Cannot have different event handlers for different instances of ZeroClipboard()

Using the following code:

/* MultiTest.js */
var copy = function(root) {
        var thisContext = this;
        this.message = root.data('message');
    this.text = root.data('clipboard-text');
        this.clip = new ZeroClipboard(root, {
                moviePath : 'ZeroClipboard.swf'
        });
        this.clip.on('complete', function() {
                thisContext.on_complete(arguments);
        });
};

copy.prototype.on_complete = function(client, args) {
        console.log(this.message);
        console.log(this.text);
};

$(document).ready(function() {
        var copyB = new copy($('#ButtonTwo'));
    var copyA = new copy($('#ButtonOne'));
});

And the following markup:

<!doctype html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="ZeroClipboard.js"></script>
<script src="MultiTest.js"></script>
</head>
<body>
<button id="ButtonOne" data-clipboard-text="Foo" data-message="Foo has been copied to your clipboard, maybe." />
<button id="ButtonTwo" data-clipboard-text="Bar" data-message="Bar has been copied to your clipboard, maybe." />
</body>
</html>

No matter which button you click, whichever was instantiated first is the object which is output to the console. Surprisingly, what is actually copied to the clipboard is what is correct.

Any suggestions/workarounds until a fix for this is issued? I may dive into your codebase in the next few days to fix it if not.

not button for clip

It is possible to use not button(html) element for clip?
I try to use link elemnt and when press ctrl+v it does not insert text, although in clip element
copy text exist.
As I understood it is because some security issue in flash, am I right?

Test positioning with inline elements

Test positioning with inline elements.

I am especially curious about spans that start near the end of 1 line but end on another line, i.e. elements that don't have a perfect rectangular "shape" (clipRect) on the page.

wrong top position

The code line bellow brokes the movie top position in my app:
1adc269#L0R177
When I hard comment this line it works. I am using bootstrap, does it mess things up?

Thanks

Copied HTML is not rendered when pasting from ZeroClipboard 1.1.6

Copied HTML is not rendered when pasting from ZeroClipboard.

STR

  1. Open testcase with ZC 1.1.6 http://170.140.138.214/zctests/ZeroClipboard-1.1.6/test_ZC-1.1.6.html
  2. Click on blue button "Copy To Clipboard"
  3. Paste in rich-text capable editor (Outlook, Word, CKEditor, ect)

Result: Copied HTML is pasted as raw markup, not rendered HTML.

Expected Result: Copied HTML is correctly rendered when pasting from Zero Clipboard.

See Also http://170.140.138.214/zctests/ZeroClipboard-1.0.7/test_ZC-1.0.7.html for an example of expected behavior. For this test case, you'll need to use Firefox 17 or lower, or Chrome. FF18+ freezes with this release of ZC ( Mozilla bug 829557 ).

Redirecting after copied the text...?

Hi,
Thanks for this awesome plugin, its helped me lot.
I've used this plugin in my drupal 7.14.

HTML:
<div class="field-item even">
<a href="http://example.com" target="_blank" class="link-box"> APPLE </a>
</div>

JS:
$.each($('.coupon-box'), function(index) {
Drupal.zeroClipboard.process(this, $(this).text());
});

Everthing works fine with above code, but its not loading/redirecting the which i've given in tag.

I've tried like this also, $('.coupon-box').click(function (){ }); But not working.!

How can i achive this...?

Thanks in advance,.

Need example for multiple elements

I can't figure out how to add multiple elements to a web page. I can get it to work if there is only one instance, but adding a second doesn't work. Below is my code.

<script type="text/javascript" src="../includes/ZeroClipboard.js"></script>
<input type=button id=d_clip_button1 data-clipboard-text="Copy Me! ONE" value=Button1>
<input type=button id=d_clip_button2 data-clipboard-text="Copy Me! TWO" value=Button2>
<script language="JavaScript">
var clip = new ZeroClipboard.Client('#d_clip_button1');
clip.on( 'complete', function(client, args) {alert("Copied text to clipboard: " + args.text );});
var zip = new ZeroClipboard.Client('#d_clip_button2');
zip.on( 'complete', function(client, args) {alert("Copied text to clipboard: " + args.text );});
</script>

Anyone have a link to a working example?

CDN hosting (1.1.7)

Script hosted on http://localhost with the movie on a CDN to test cross-domain issues I saw on our live site.

Is hosting the script/movie on a CDN broken?. Presumably, this is supposed to be handled by trustedDomains and allowScriptAccess but I can't get it to work.

ZeroClipboard.setDefaults {
      moviePath: "https://d2glos6gx2bw40.cloudfront.net/C8QpR9/images/flash/ZeroClipboard.swf",
      trustedDomains: ['localhost', '*'],
      allowScriptAccess: "always",
   }
clip = new ZeroClipboard($el)

Click on element

Expected: text copied to clipboard

Actual: no text is copied, when mousing over the movie the second time, this error occurs:

Uncaught Error: Error calling method on NPObject. zeroClipboard.js:178
ZeroClipboard.setSize zeroClipboard.js:178
ZeroClipboard.reposition zeroClipboard.js:256
ZeroClipboard.setCurrent zeroClipboard.js:162
_elementMouseOver zeroClipboard.js:36

Anyone see something wrong here? Anyone have a working example?
Thanks!

on('mousedown') event fired twice

I've implemented your plugin in my app. and each time I press the copy button, I get the "complete" event handler message twice. After some investigations, I've found that it was the on('mousedown') event that was called twice???

Here's my code found the JS file :

  // Clipboard management
  // Set path
  ZeroClipboard.setMoviePath('js/ZeroClipboard.swf');
  // Create client
  var zclip = new ZeroClipboard.Client();
  // Copy text
  zclip.on('mousedown', function (client, args) {
      zclip.setText(copy_items($(this)));
  });

  // Notification of success
  zclip.on('complete', function(client, args) {
    alert("Items copied to clipboard, you can now paste them on an other document.)
  });

and the one found in the php file

      ...
      <tr>
        <td ><input id="copy_btn" name="copy_btn" data-clipboard-text="" type=button value="Copy"></td>
      </tr>
    </tbody>
  </table>
<script type="text/javascript">
  //glue it to the button
  zclip.glue('#copy_btn');   // I use glue here because this page is not created yet when zclip is created 
</script>

It seems to be a pretty strait forward implementation (with version 1.1.6, using Chrome), but it still send double notifications.
Does anyone have an idea?

Accessibility: Make ZeroClipboard work for Enter key presses

Currently, ZeroClipboard attaches itself to glued elements on mouseover and injects into the user's clipboard on click. This is awesome.

However, everything I've read about the Flash clipboard API suggests that we can also trigger the injection on keyboard events, e.g. the user pressing the Enter key. Not necessarily a high priority feature but it is something I'd like us to attempt to get working at some point in the future....

Note: We may not succeed. 😕

Requirements:

  1. Glued HTML elements now need a "focus" handler, which would then focus on the Flash object instead.
  2. The ActionScript would need a new KEY_DOWN event handler listening for the Enter key.

Possible points of failure:

  1. Some sources speculate that this is only possible if we change wmode to opaque. I believe doing so would make the ZC object a visible layer, which would be unacceptable.
  2. Stealing focus to the Flash object will probably cause issues if someone was trying to tab/arrow past the element that ZC is glued to (rather than trying to tab/arrow to it to use ZC). Possible workarounds:

TypeError: this.flashBridge.setText is not a function

I see the following error:

TypeError: this.flashBridge.setText is not a function

When I use the following code:

<script src="../includes/ZeroClipboard.js"></script> <script> var clip = new ZeroClipboard.Client(); clip.setText("foobear"); </script>

Mouseover problems

I read the source code and found a bug which will be triggered when I called reposition method or other methods before fire mouseover events. Everything will be OK when I fire mouseover events on the linking dom to the flash movie. Because in mouseover events you set gluing dom.

IE6/7/8 mouseup and mousedown bug

There is no action when the mouseup and mousedown event is triggered in IE6/7/8,but the load event can trigger normaly in IE6/7/8 (Sizzle has been used in this example so I have got the instance of ZeroClipboard Client Successfully)eg:

<div id="d_clip_button" data-clipboard-text="Copy Me!">Copy To Clipboard</div>

<script language="JavaScript">
  var clip = new ZeroClipboard.Client('#d_clip_button');
  clip.on( 'load', function(client) {
     // In IE6/7/8 can trigger this message 
     alert( "movie is loaded" );
  } );

  clip.on( 'mouseup', function(client) {
     // In IE6/7/8 can not trigger this message
     alert("mouse up");
  } );

</script>

Make a build that works on Windows (+ Mac + Linux)

I can't seem to get the build working on Windows.

I have...

  1. Installed GnuMake and all of its dependencies
  2. Installed the Flex SDK 4.6
  3. Set the "SWF_COMPILER" environment variable: /c/Program\ Files\ (x86)/Adobe/Flex\ SDK\ 4.6/bin/mxmlc -static-link-runtime-shared-libraries=true

... but it still seems to die a horrible death! 💀

Running in the Git Bash shell (yes, the leading unpaired " is accurate):

$ make
"c:\Program: Interrupt/Exception caught (code = 0xc00000fd, addr = 0x4227d3)

Running in the Windows cmd prompt (or VS2010 cmd prompt):

make
process_begin: CreateProcess(NULL, rm -f LICENSE, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [LICENSE] Error 2

noflash passes window rather than element

I am tinkering with implementing ZeroClipboard for several buttons on page with Bootstrap tooltips for feedback. I've got to implementing noflash case and for some reason unlike mouseover, mouseout and complete it passes window to callback rather than specific button.

It doesn't seem to be documented differently in docs, am I doing something wrong here or this is how it is [not] supposed to work?

var copy_buttons = $(".btn-copy-link");
var clip = new ZeroClipboard(copy_buttons);

clip.on("noflash", function (client) {

    // fails because this contains window rather than button
    $(this).addClass('disabled').tooltip('destroy').tooltip({'placement':'right', 'title':'copy to clipboard needs flash'});
});

Zero Clipboard Does Not Work From Local Disk

The README states that ZeroClipboard doesn't work from local disk. Rather than developing on file:// it's super simple to setup a local web server with Python (installed by default on Mac and most Linux distros).

In a terminal navigate to the project directory and run:

python -m SimpleHTTPServer

At that point you are able to access the site on http://localhost:8000

Rename the `addEventListener` method to `on` or add `on` as a synonym

I would like to either rename the addEventListener method to on or else at least add on as a synonym. The usage of on fits better with both Node.js and jQuery, and is much shorter to boot. :)

Today's code:

myClient.addEventListener("onComplete", function(data) {
    // Yay, injected into the clipboard!
});

Preferred code:

myClient.on("complete", function(data) {
    // Yay, injected into the clipboard!
});

If we're doing it as a synonym, the basic implementation would be as follows:

ZeroClipboard.Client.prototype.on = function(eventName, callback) {
    // TODO: Basic input argument validation

    var oldEventName = "on" + eventName.slice(0, 1).toUpperCase() + eventName.slice(1);
    this.addEventListener(oldEventName, callback);
};

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.