Making sure that the user can only create 1 client #49
Conversation
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
Of course they can still create it in one line |
return new ZeroClipboard.Client(); | ||
ZeroClipboard.destroy = function () { | ||
delete ZeroClipboard._client; | ||
$("#global-zeroclipboard-html-bridge").remove(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops this is wrong.
I'm a bit surprised by this one, I thought the intent was to still create multiple If we go with the direction you've set here instead, then I would say we also need to provide an |
@@ -9,10 +9,11 @@ | |||
"use strict"; | |||
var ZeroClipboard = {}; | |||
ZeroClipboard.Client = function(query) { | |||
if (ZeroClipboard._client) return; |
There was a problem hiding this comment.
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.
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
Good call on Overall I wanted your input on this one, because I was unsure if this was too much of a change. |
Ok, now we have 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"); |
Cool. 👍 |
Making sure that the user can only create 1 client
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.
This way we don't really have to worry about multiple clients, it'll all
be contained in one object.
@JamesMGreene
Pull Request: master