1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{% load i18n extra_tags %}
<p>
{% blocktrans %}
Would you like to copy the permanent link to your clipboard?
{% endblocktrans %}
</p>
{% spaceless %}
<p><label for="permanent_link_url" style="font-size: 13px;">{% trans "Permanent link" %}:</label></p>
<p><textarea id="permanent_link_url" name="permanent_link_url" style="font-size: 12px;" readonly="readonly">{{ url }}</textarea></p>
{% endspaceless %}
<script type="text/javascript" src="{% media "/media/js/ZeroClipboard.js" %}"></script>
<script type="text/javascript">
$(document).ready(function() {
// We highlight the content of the text field on click event
$('#permanent_link_url').click(function() {
$(this).select();
});
// We use ZeroClipboard to copy the URL
ZeroClipboard.setMoviePath('{% media '/media/js/ZeroClipboard.swf' %}');
// Create the Client Clip
var clip = new ZeroClipboard.Client();
// Create the glue when on mouse-over event
$('#copy_clip_button').live('mouseover', function() {
// Take the URL from the input
clip.setText($('#permanent_link_url').val());
// Create the glue
clip.glue('copy_clip_button');
// Simulate click on the OK button when we hear a moseDown event on the glue
clip.addEventListener('mouseDown', function() {
$('#copy_clip_button').click();
});
// Reposition the clip
clip.addEventListener('complete', function() {
clip.reposition();
});
});
// Hide the clip if someone clicks on the cancel button
$('.dialog-no').live('click', function() {
clip.hide();
});
});
</script>