I have a button that will copy a link to the clipboard but it has been shortened using bit.ly. At the minute I have it so that it creates the bit.ly link on page load which seems a bit messy so I just wondered how I can make it only do it when it copies to the clipboard?
var client = new ZeroClipboard( document.getElementById("copy-link"), {
moviePath: "ZeroClipboard.swf"
} );
client.on( "load", function(client) {
// alert( "movie is loaded" );
client.on( "complete", function(client, args) {
// `this` is the element that was clicked
$.gritter.add({
// (string | mandatory) the heading of the notification
title: 'Link Copied',
// (string | mandatory) the text inside the notification
text: 'Link has been copied to your clipboard'
});
$('[data-toggle="dropdown"]').parent().removeClass('open');
} );
} );
This is my PHP
<?php
$url = Router::url(null, true);
if ($this->UserAuth->isLogged()) {
$url .= '?shareref=' . $var['User']['id'] . '';
}
$shortlink = bitly_v3_shorten($url, 'bit.ly');
?>