The Gallery is deprecated. No new Gallery components may be submitted, and modifying existing components is disabled. For more information please read the Gallery Deprecation blog post. This is a static snapshot of the Gallery for archive purposes.
Created: 08/23/11
Last CDN Push: 09/14/11
Build Tag: gallery-2011.09.14-20-40
Project: YUI 3
License: YUI BSD
YUI Version: 3.4.0
Free for use.
node.plug(Y.ClipBoard, {
page : Y.one(".container"),
moviepath : "../assets/"
}).on("clipboard:load", function(e){
/* Clipboard ready, your code goes in here */
});
In the above code snippet, moviepath is the path to the ClipBoardCopy.swf file on your server. This can be a URL or a relative path. Since swf files are not allowed on the YUI CDN, please download the .as file and generate the swf movie or download the movie from github.com/rmsguhan/gallery-clipboard/tree/master/assets
<script src="http://yui.yahooapis.com/3.4.0/build/yui/yui-min.js"></script>
var MOVIE_PATH = '../../../build/gallery-clipboard/assets/';
YUI({
//Last Gallery Build of this module
gallery: 'gallery-2011.09.14-20-40'
}).use('gallery-clipboard', function(Y) {
var logit = function(str) {
var log = Y.one("#log"),
m = Y.Node.create("<div>"+str+"</div>");
log.appendChild(m);
log.set("scrollTop", log.get("offsetHeight")+10)
};
var node1 = Y.one(".b1"),
node2 = Y.one(".b2");
/* Make sure that the flash interface callback is within a known global name space */
window.My = {
Global : {
foo : "bar"
}
};
Y.ClipBoard.setCallBackGlobal( "My.Global" );
/* Set up Copy on Node 1 */
node1.plug(Y.ClipBoard, {
page : Y.one(".container"),
moviepath : MOVIE_PATH
}).on("clipboard:load", function(e){
logit("Flash Movie Loaded for :"+e.currentTarget.get("className"));
this.on("mouseover", function(ev) {
this.setAttribute("copy", this.get("innerHTML"));
logit("String set for copy " + this.getAttribute("copy"));
});
this.clipboard.setEvent("enter", function(ev) {
logit("Clipboard set for : "+this.get("className")+":'"+ev.clipboard+"'");
this.clipboard.hide();
}, true);
});
Y.on("clipboard:error", function(e) {
logit("ERROR :"+e.error);
});
/* Set up Copy on Node 2 */
node2.plug(Y.ClipBoard, {
page : Y.one(".container"),
moviepath : MOVIE_PATH
}).on("clipboard:load", function(e){
logit("Flash Movie Loaded for :"+e.currentTarget.get("className"));
this.on("mouseover", function(ev) {
this.setAttribute("copy", this.get("innerHTML"));
logit("String set for copy " + this.getAttribute("copy"));
});
this.clipboard.setEvent("click", function(ev) {
this.clipboard.hide();
logit("Clipboard set for : "+this.get("className")+":'"+ev.clipboard+"'");
}, true);
});
/* Set up actions */
Y.all(".control input").on("click", function(e) {
var tr = e.target,nd,cl,event;
if(tr.get("type") === "button") {
nd = Y.one("."+tr.getAttribute("node"));
cl = tr.get("className");
if(cl === "set-text") {
nd.set("innerHTML", Y.one("#copy-text").get("value"));
} else if(cl === "clear") {
Y.one("#log").set("innerHTML", "");
} else if(cl.indexOf("-") < 0) {
nd.clipboard.setEvent(cl, function(ev) {
logit("Flash '"+ev.event+"' fired for node "+
Y.one("#"+ev.transaction).get("className"));
});
} else {
/* Remove case */
event = cl.substring(cl.indexOf("-")+1);
nd.clipboard.removeEvent(event);
logit("Flash '"+event+"' removed for "+nd.get("className"));
}
}
});
});
All code on this site is licensed under the BSD License unless stated otherwise.