Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Making sure that the user can only create 1 client #49

Merged
merged 5 commits into from Dec 18, 2012
Merged

Conversation

jonrohan
Copy link
Contributor

I want to make it so that the user can only create one client. They can
use the clip to glue multiple elements as many times as they want.

var clip = new ZeroClipboard.Client();

clip.glue(".item1");
clip.glue(".item2");
clip.glue(".group-of-items");
clip.glue("a");
clip.glue("td");

This way we don't really have to worry about multiple clients, it'll all
be contained in one object.

@JamesMGreene

Pull Request: master

I want to make it so that the user can only create one client. They can
use the clip to glue multiple elements as many times as they want.

```js
var clip = new ZeroClipboard.Client();

clip.glue(".item1");
clip.glue(".item2");
clip.glue(".group-of-items");
clip.glue("a");
clip.glue("td");
```

This way we don't really have to worry about multiple clients, it'll all
be contained in one object.

@JamesMGreene

Pull Request: master
@jonrohan
Copy link
Contributor Author

Of course they can still create it in one line var clip = new ZeroClipboard.Client("#my-thing"); and glue more stuff to it later clip.glue("#another-thing");

return new ZeroClipboard.Client();
ZeroClipboard.destroy = function () {
delete ZeroClipboard._client;
$("#global-zeroclipboard-html-bridge").remove();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops this is wrong.

@JamesMGreene
Copy link
Member

I'm a bit surprised by this one, I thought the intent was to still create multiple ZeroClipboard.Client instances but that they would all share the same SWF object under the covers.

If we go with the direction you've set here instead, then I would say we also need to provide an unglue method as well.

@@ -9,10 +9,11 @@
"use strict";
var ZeroClipboard = {};
ZeroClipboard.Client = function(query) {
if (ZeroClipboard._client) return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be:

if (ZeroClipboard._client) return ZeroClipboard._client;

That would treat it as a singleton rather than a user trying to create a new ZeroClipboard.Client instance and instead getting undefined back.

@jonrohan
Copy link
Contributor Author

I'm a bit surprised by this one, I thought the intent was to still create multiple ZeroClipboard.Client instances but that they would all share the same SWF object under the covers.

I'm just unsure of the benefit of creating multiple clips.

The one thing I could think of is that the user could do is pin different events to different sets of clips. Because the handlers exists on the client prototype. however, for example, this is a nightmare when I want to signal noflash, because then i have to find all the clips and signal to each one that the page doesn't have flash.

If we go with the direction you've set here instead, then I would say we also need to provide an unglue method as well.

Good call on unglue. I do have a destroy which cleans up the object and dom from the page. Having unglue would be helpful for removing the actions from the elements.

Overall I wanted your input on this one, because I was unsure if this was too much of a change.

@jonrohan
Copy link
Contributor Author

Ok, now we have unglue

var clip = new ZeroClipboard.Client();

clip.glue(".item1");
clip.glue(".item2");
clip.glue(".group-of-items");
clip.glue("a");
clip.glue("td");

clip.unglue(".item2");

@JamesMGreene
Copy link
Member

Cool. 👍

jonrohan added a commit that referenced this pull request Dec 18, 2012
Making sure that the user can only create 1 client
@jonrohan jonrohan merged commit 87fe235 into master Dec 18, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants