Subversion Repositories DevTools

Rev

Rev 6131 | Rev 6181 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6131 Rev 6146
Line 53... Line 53...
53
    var myClipHandler = function (event)
53
    var myClipHandler = function (event)
54
    {
54
    {
55
        // Get element to clip
55
        // Get element to clip
56
        var el = $(this).closest('.clip').eq(0);
56
        var el = $(this).closest('.clip').eq(0);
57
 
57
 
58
        // Blink the clipboard icon
-
 
59
        el.hide();
-
 
60
        el.fadeIn(100, function(){});
-
 
61
 
-
 
62
        // Copy to clipboard
58
        // Copy to clipboard
63
        var $temp = $("<input>");
59
        var $temp = $("<input>");
64
        $("body").append($temp);
60
        $("body").append($temp);
65
        $temp.val($.trim(el.text())).select();
61
        $temp.val($.trim(el.text())).select();
66
        document.execCommand("copy");
62
        document.execCommand("copy");
67
        $temp.remove();
63
        $temp.remove();
-
 
64
 
-
 
65
        // Highlight (the text that has been selected
-
 
66
        //  Appears to be no nice way to do this :(
-
 
67
        var doc = document, range, selection;    
-
 
68
        if (doc.body.createTextRange) {
-
 
69
            range = document.body.createTextRange();
-
 
70
            range.moveToElementText(el[0]);
-
 
71
            range.select();
-
 
72
        } else if (window.getSelection) {
-
 
73
            selection = window.getSelection();        
-
 
74
            range = document.createRange();
-
 
75
            range.selectNodeContents(el[0]);
-
 
76
            selection.removeAllRanges();
-
 
77
            selection.addRange(range);
-
 
78
        }
-
 
79
 
68
    }
80
    }
69
 
81
 
70
    $('.clip').append(
82
    $('.clip').append(
71
        $('<img />')
83
        $('<img />')
72
            .attr({
84
            .attr({