Subversion Repositories DevTools

Rev

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

Rev 6592 Rev 6610
Line 346... Line 346...
346
        .on("dblclick", myClipHandler);
346
        .on("dblclick", myClipHandler);
347
 
347
 
348
});
348
});
349
 
349
 
350
// Add a clipThis handler to each element with a clipThis class
350
// Add a clipThis handler to each element with a clipThis class
351
// Will copy the text of the element to the clipboard
351
//      Will copy the text of the element to the clipboard
352
// Add dynamically so that it will be invoked on newly created elements
352
//      Add dynamically so that it will be invoked on dynamically created elements
353
$( document ).on('click', '.clipThis', function(event){
353
$( document ).on('click', '.clipThis', function(event){
354
    var txt = $(this).eq(0).text();
354
    var txt = $(this).eq(0).text();
355
    vixTextToClipBoard(txt, {note : "Copied to Clipboard", duration : 1000});
355
    vixTextToClipBoard(txt, {note : "Copied to Clipboard", duration : 1000});
356
});
356
});
357
 
357
 
-
 
358
// Copy data from element to clipboard
-
 
359
//      Elements have a class of clipData and an attribute of data-clip=xxx
-
 
360
//  Add dynamically so that it will be invoked on dynamically created elements
-
 
361
$( document ).on('click', '.clipData', function(event){
-
 
362
    var txt = $(this).data('clip');
-
 
363
    vixTextToClipBoard(txt, {note : "Copied to Clipboard", duration : 1000});
-
 
364
});
-
 
365
 
-
 
366
// Copy data from a named element to clipboard
-
 
367
// Supports multi-line data with <p> and <br> in it
-
 
368
//      Elements have a class of clipElement and an attribute of data-target=elementId
-
 
369
$( document ).on('click', '.clipElement', function(event){
-
 
370
    var ename = $(this).data('target');
-
 
371
    var html = $('#' + ename).eq(0).html();
-
 
372
    var breakToken = '_______break_______';
-
 
373
    var lineBreakedHtml = html.replace(/<br\s?\/?>/gi, breakToken).replace(/<p\.*?>(.*?)<\/p>/gi, breakToken + '$1' + breakToken);
-
 
374
    var txt = $('<div>').html(lineBreakedHtml).text().replace(new RegExp(breakToken, 'g'), '\r\n');
-
 
375
 
-
 
376
    vixTextToClipBoard(txt.trim(), {note : "Copied to Clipboard", duration : 1000});
-
 
377
});
-
 
378
 
-
 
379
 
-
 
380
// Invoke mailto on elements with a suitable class
-
 
381
//  Elements with class mailto. and a data item of email
-
 
382
// Add dynamically so that it will be invoked on newly created elements
-
 
383
$( document ).on('click', '.mailto', function(event){
-
 
384
    var email = $(this).data('email');
-
 
385
    var name =  $(this).data('name');
-
 
386
    if ( !name ) {
-
 
387
        name =  $(this).eq(0).text();
-
 
388
    }
-
 
389
    
-
 
390
    var menu = '<div class="rex_clm" >&nbsp;Select Operation</div>';
-
 
391
    if ( name ) {
-
 
392
        menu += '<div class="mmItem clipData" data-clip="' + name + '">Copy Name to Clipboard</div>';
-
 
393
    }
-
 
394
    menu += '<div class="mmItem clipData" data-clip="' + email + '">Copy Email Address to Clipboard</div>';
-
 
395
    menu += '<div onClick="window.open(\'mailto:' + email + '\', \'_blank\');" class="mmItem">Send Email</div>';
-
 
396
    showmenu(event,menu);
-
 
397
    event.stopImmediatePropagation();
-
 
398
    event.stopPropagation();
-
 
399
    return false;
-
 
400
});
-
 
401
 
358
// Copy text to clipboard
402
// Copy text to clipboard
359
function vixTextToClipBoard(txt, options){
403
function vixTextToClipBoard(txt, options){
360
    if ( txt == null ) {
404
    if ( txt == null ) {
361
        return;
405
        return;
362
    }
406
    }
Line 380... Line 424...
380
            title: opts.title,
424
            title: opts.title,
381
            icon : "images/i_info.png", 
425
            icon : "images/i_info.png", 
382
            cancel: false, 
426
            cancel: false, 
383
            button: null,
427
            button: null,
384
            timeout : opts.timeout,
428
            timeout : opts.timeout,
385
            position : 'center', 
429
            not_on_firefox_position : {my: 'center', at: 'top', of: event},
386
            modal : false,
430
            modal : false,
387
            minHeight: 10, 
431
            minHeight: 10, 
388
            hide: { effect: 'fade', duration: opts.duration }
432
            hide: { effect: 'fade', duration: opts.duration }
389
            });
433
            });
390
 
434