Subversion Repositories DevTools

Rev

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

Rev 5603 Rev 6427
Line 277... Line 277...
277
        vixIframe.Dialog.dialog('close');
277
        vixIframe.Dialog.dialog('close');
278
        vixIframe = {};
278
        vixIframe = {};
279
    }
279
    }
280
}
280
}
281
 
281
 
-
 
282
//
-
 
283
//  Add copy to clipboard icon to every element with a class of 'clip'
-
 
284
//
-
 
285
$( document ).ready(function() {
-
 
286
    var myClipHandler = function (event)
-
 
287
    {
-
 
288
        // Get element to clip
-
 
289
        var el = $(this).closest('.clip').eq(0);
-
 
290
 
-
 
291
        // Get the text and clean it up
-
 
292
        var text = $.trim(el.text());
-
 
293
            text = text.replace(/\s+/g, ' '); 
-
 
294
 
-
 
295
        // Copy to clipboard
-
 
296
        var $temp = $("<input>");
-
 
297
        $("body").append($temp);
-
 
298
        $temp.val(text).select();
-
 
299
        document.execCommand("copy");
-
 
300
        $temp.remove();
-
 
301
 
-
 
302
        // Highlight (the text that has been selected
-
 
303
        //  Appears to be no nice way to do this :(
-
 
304
        var doc = document, range, selection;    
-
 
305
        if (window.getSelection) {
-
 
306
            selection = window.getSelection();        
-
 
307
            range = document.createRange();
-
 
308
            range.selectNodeContents(el[0]);
-
 
309
            selection.removeAllRanges();
-
 
310
            selection.addRange(range);
-
 
311
            setTimeout(function(){selection.removeAllRanges();},500);
-
 
312
        } else { 
-
 
313
            range = document.body.createTextRange();
-
 
314
            range.moveToElementText(el[0]);
-
 
315
            range.select();
-
 
316
            setTimeout(function(){document.selection.empty();},500);
-
 
317
        }
-
 
318
    }
-
 
319
 
-
 
320
    $('.clip').append(
-
 
321
        $('<img />')
-
 
322
            .attr({
-
 
323
                title : "Copy to clipboard",
-
 
324
                src : "images/CopyToClipboard.ico",
-
 
325
                height : "12px",
-
 
326
                width : "12px",
-
 
327
                hspace : "0px",
-
 
328
                align : "absmiddle",
-
 
329
                border : "0"
-
 
330
                })
-
 
331
            .on("click", myClipHandler)
-
 
332
        )
-
 
333
        .on("dblclick", myClipHandler);
-
 
334
 
-
 
335
});
-
 
336
 
-
 
337
 
282
 
338
 
283
 
339