Subversion Repositories DevTools

Rev

Rev 7240 | Rev 7261 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5190 dpurdie 1
//  Vix specific Javascript for jquery use
2
//
3
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4
//  Generate a confirmation dialog
5
//  Args:   text - Body of the message
6
//          parms - A simple object of options - see defaults
5266 dpurdie 7
//                  Special: position of 'center' will place in center of visible screen.
5190 dpurdie 8
//  Note: will return BEFORE the user makes a selection
9
//        Can call a function and/or a URL if confirmed
10
//        Can 'show' a progress element
11
//        See 'defaults' below for bits that can be modified
12
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
13
function vixConfirm(text, parms){
14
     var defaults = {
15
        resizable: true,
16
        height: 'auto',
17
        width : 'auto',
18
        modal: true,
19
        position: { my: "top", at: "top+100", of: window },
20
        title: "Confirm",
21
        icon: "images/i_warning.gif",
22
        url : null,
23
        ok : null,
24
        post : null,
25
        button : "Confirm",
5598 dpurdie 26
        progress : "#ProgressBar",
6577 dpurdie 27
        cancel : true,
28
        timeout : null,
6697 dpurdie 29
        dlg : null,
30
        deferred : null,
5190 dpurdie 31
     };
32
     $.extend( defaults, parms);
33
 
34
     defaults.open = function() {
35
        $(this).siblings('.ui-dialog-buttonpane').find('button:eq(1)').focus(); 
6577 dpurdie 36
        var markup = "";
37
        if (defaults.icon != null ) {
38
            markup += '<img src="'+ defaults.icon+ '" style="float:left; margin:0 7px 20px 0;">';
39
            }
40
        markup += text;
5190 dpurdie 41
        $(this).html(markup);
6577 dpurdie 42
         if ( defaults.timeout != null ) {
43
             setTimeout(function(){
44
                 defaults.dlg.dialog("close");
45
                }, defaults.timeout);
46
         }
5190 dpurdie 47
     };
48
 
49
    defaults.close = function() {
50
        $(this).remove();
51
    };
52
 
6697 dpurdie 53
    if(typeof(defaults.deferred) == typeof(true)){
54
        if ( defaults.deferred ) {
55
            defaults.deferred = new $.Deferred();
56
        }
57
    }
58
 
6577 dpurdie 59
    defaults.buttons = [];
60
    if ( defaults.button != null ) {
61
        defaults.buttons.push({
62
            text : defaults.button,
63
            click : function (){
64
                    if (defaults.ok != null ){
65
                        defaults.ok(defaults);
66
                    }
67
                    if ( defaults.progress != null) {
68
                        $(defaults.progress).show().css("visibility", "visible");    
69
                    }
70
                    if (defaults.url != null ) {
71
                        window.location.href = defaults.url;
72
                    }
73
                    if (defaults.post != null ) {
74
                        $('form[name="'+defaults.post+'"]').submit();    
75
                    }
6697 dpurdie 76
                    if ( defaults.deferred != null ) {
77
                        defaults.deferred.resolve();
78
                    }
6577 dpurdie 79
                    $(this).dialog("close");
5190 dpurdie 80
                }
6577 dpurdie 81
        });
82
    }
83
 
84
    if(typeof(defaults.cancel) == 'boolean' && defaults.cancel) {
85
        defaults.buttons.push({
86
            text : 'Cancel',
87
            click : function (){
88
                $(this).dialog("close");
6697 dpurdie 89
                if ( defaults.deferred != null) {
90
                        defaults.deferred.reject();
91
                    }
5190 dpurdie 92
                }
6577 dpurdie 93
        });
94
    }
5190 dpurdie 95
 
96
     var dd = $( "<div>Confirm</div>" ).dialog(defaults);
6577 dpurdie 97
     defaults.dlg = dd;
5190 dpurdie 98
     // Once the dialog has been instantiated the autosize dimensions are known
5266 dpurdie 99
     // and the dialog can be correctly positioned
100
     if (defaults.position == 'center')
101
     {
102
         dd.dialog("widget").center();
5560 dpurdie 103
         //console.log("Center in Window");
5266 dpurdie 104
     }
105
     else
106
     {
107
         dd.dialog("widget").position(defaults.position);
5560 dpurdie 108
         //console.log("Original position");
5266 dpurdie 109
     }
6697 dpurdie 110
 
111
     // If using deferred objects
112
     if ( defaults.deferred ) {
113
         return defaults.deferred.promise();
114
     }
5266 dpurdie 115
 
5190 dpurdie 116
     // Return false incase this is used as an onClick
117
     return false;
118
}
119
 
120
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
121
// Compatability function
122
//      Confirm Deletion of an item
6873 dpurdie 123
//      Assumes that the item is within an 
124
//          - 'anchor' and that an href can be located
125
//          - other and that a 'data-href' will specify the 'url'
126
//  
5190 dpurdie 127
//      Uses VixConfirm to do the heavy lifting
128
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
129
function vixConfirmDelete (txt)
130
{
131
    var href = window.event.currentTarget.href;
6873 dpurdie 132
    if ( !href ) {
133
        href = $(event.currentTarget).data('href');
134
    }
135
    vixConfirm('Are you sure you want to delete ' + txt + '?', { url: href })
5190 dpurdie 136
    return false;
137
}
138
 
139
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
140
//  Similar to 'alert', but uses the jquery dialog mechnaism
141
//  Note: will return BEFORE the user makes a selection
142
//  Returns a Defereed object that will be rejected when the dialog is closed.
143
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
144
function vixAlert(text){
145
     var dbo = $.Deferred();
5207 dpurdie 146
     var dd = $( "<div>Alert</div>" ).dialog({
5190 dpurdie 147
        resizable: true,
148
        height: 'auto',
149
        width : 'auto',
150
        modal: true,
151
        title:'Alert',
5227 dpurdie 152
        position: { my: "top", at: "top+100", of: window },
5190 dpurdie 153
        open: function() {
154
            $(this).html('<img src="images/i_critical.gif" style="float:left; margin:0 7px 20px 0;">' + text);
155
        },
156
        close : function() {
157
            $(this).remove();
158
            dbo.reject();
159
        },
160
        buttons: {
161
            "Ok": function() {
162
                $(this).dialog("close");
163
            }
164
        }
165
     });
5207 dpurdie 166
     // Once the dialog has been instantiated the autosize dimensions are known
5266 dpurdie 167
     // and the dialog can be correctly positioned
5227 dpurdie 168
     // Note: Appears that we need to position it twice
169
     //       Once in the dialog creation, and once here
5207 dpurdie 170
     dd.dialog("widget").position({ my: "top", at: "top+100", of: window });
171
 
172
     return dbo;
5190 dpurdie 173
}
174
 
5266 dpurdie 175
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
176
//  jQuery extension function
177
//  Position an element inthe center of the visible window. Not the document and not the window(viewport).
178
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
179
jQuery.fn.center = function () {
5190 dpurdie 180
 
5266 dpurdie 181
    //  Support many browsers
182
    var w = window.innerWidth  || document.documentElement.clientWidth  || document.body.clientWidth;
183
    var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
184
 
185
    this.css("position","fixed");
186
    this.css("top", Math.max(0,  ((h - $(this).outerHeight()) / 2) ) + "px");
187
    this.css("left", Math.max(0, ((w - $(this).outerWidth()) / 2) ) + "px");
188
    return this;
189
}
190
 
191
//--------- Support to open modal dialog in an iFrame
5590 dpurdie 192
//  Example: <a class="vixIframeDialog" href="aaa.asp" title="Some Title">Link Text</a>
5266 dpurdie 193
//
7003 dpurdie 194
var vixIframe;
195
if (typeof vixIframe === 'undefined') {
196
    vixIframe = {};
197
}
5266 dpurdie 198
$(document).ready(function () {
7003 dpurdie 199
 
5560 dpurdie 200
    $('.vixIframeDialog').on('click', function(e){
5590 dpurdie 201
		if (!vixIframe.parent) {
202
			e.preventDefault();
203
			vixIframe.parent = this;
204
			vixIframe.pagetitle = $(this).attr("title");
205
			if (! vixIframe.pagetitle) {
206
				vixIframe.pagetitle = $(this).text();
207
			}
208
			vixIframe.url = $(this).attr("href");
209
			vixIframeDialogCommon();
210
		}
5560 dpurdie 211
	});
5266 dpurdie 212
 
213
    //
214
    // Prevent (at least control) the user from navigating within the iframe
215
    // If this invocation is within an iFrame, then close the iFrame if
216
    // the user attempt to navigate away from the iFrame.
217
    //      This means that the iFrame cannot replace itself
218
    // 
219
    if (typeof parent.vixIframe.pagetitle !== 'undefined')
220
    {
5560 dpurdie 221
        //console.log("DocumentReady within iframe");
5266 dpurdie 222
        window.onunload = function(){
5560 dpurdie 223
            //console.log("Unloading within iframe");
5266 dpurdie 224
        }
225
    }
226
 
227
});
228
 
5560 dpurdie 229
//
230
//	Callable function to instantiate an Iframe Dialog
5590 dpurdie 231
//  Used in a replacement for MM_openBrWindow called MM_openVixIFrame
5560 dpurdie 232
// 	Parameters:
233
// 		pthis	- The parent's context
6625 dpurdie 234
//		url		- URL of the window content
5590 dpurdie 235
//  	winName	- Title of the new Window
236
 
237
function vixIframeDialog2(pthis, url, winName)
238
{
5560 dpurdie 239
	vixIframe.parent = pthis;
5590 dpurdie 240
	vixIframe.pagetitle = winName;
241
	vixIframe.url = url;
242
	vixIframeDialogCommon();
243
}
244
 
245
function vixIframeDialogCommon()
246
{
7003 dpurdie 247
	var iframe = $('<iframe onload="IframeLoaded(this);" id="iframe" style="border:0px; overflow: scroll;" src="' + vixIframe.url + '" height="50px" width="100%"" ></iframe>');
5560 dpurdie 248
	var $dialog = $('<div></div>').html(iframe);
249
	var $dialog2 = $dialog.dialog({
250
		autoOpen: true,
251
		modal: true,
7003 dpurdie 252
		height : 'auto',
5590 dpurdie 253
		width : 'auto',
254
		resizable: false,
5560 dpurdie 255
		position : { my:'top', at: 'top+100', of : window },
256
		dialogClass: "rounded_box",
257
		title: 'Loading - ' + vixIframe.pagetitle,
258
		close: function(event, ui){
259
			//console.log('closing dialog');
260
			$(this).dialog("destroy");
261
			vixIframe = {};
262
			window.onbeforeunload = null;
263
			window.onunload = null;
264
			},
5590 dpurdie 265
		// Prevent Chrome from adding scrollbars when dragged
266
		dragStop: function( event, ui ){
267
			vixIframe.IFrame.parentElement.style.overflow = "";
268
			},
269
		dragStart: function( event, ui ){
270
			vixIframe.IFrame.parentElement.style.overflow = "hidden";
271
			}
5560 dpurdie 272
	});
273
	vixIframe.Dialog = $dialog;
5590 dpurdie 274
	vixIframe.DialogProps = $dialog2;
5560 dpurdie 275
	vixIframe.DialogWidget = $($dialog2).dialog('widget');
5597 dpurdie 276
 
5560 dpurdie 277
	return false;
278
}
5590 dpurdie 279
//
280
//	Called when the iframe is loaded or reloaded
281
//
282
function IframeLoaded(iframe) {
283
	// Save to resize iframe
284
	vixIframe.IFrame = iframe;
5560 dpurdie 285
 
5590 dpurdie 286
	// Reset the title
287
	vixIframe.Dialog.dialog('option','title', vixIframe.pagetitle);
5266 dpurdie 288
 
5590 dpurdie 289
	// Resize the frame
290
	resizeIframe();
5266 dpurdie 291
};
5590 dpurdie 292
//
293
//	This function can be called from within the iframe to have it resized
294
//	Used if the iframe is too dynamic and extends itself from time to time
295
//
296
function resizeIframe()
297
{
298
    if (vixIframe.IFrame != null) {
7003 dpurdie 299
        var iframe = vixIframe.IFrame;
5590 dpurdie 300
		iframe.height = iframe.contentWindow.document.body.scrollHeight + "px";
301
		$(vixIframe.Dialog).height(iframe.height);
302
		//console.log ("Resize Iframe:",iframe.height );
5266 dpurdie 303
 
5590 dpurdie 304
		iframe.width = iframe.contentWindow.document.body.scrollWidth + "px";
305
		$(vixIframe.Dialog).width(iframe.width);
306
		//console.log ("Resize Iframe:",iframe.width );
307
 
308
		// Reposition the dialog
309
		$(vixIframe.DialogWidget).position($(vixIframe.DialogProps).dialog("option").position);
310
	}
311
}
312
//
313
//	This function can be called from with the iframe to close the Iframe
314
//	Often wired up to the cancel button
315
function closeIFrame()
5266 dpurdie 316
{
317
    if (vixIframe.Dialog != null) {
5590 dpurdie 318
        //console.log('closing iframe');
5266 dpurdie 319
        vixIframe.Dialog.dialog('close');
320
        vixIframe = {};
321
    }
322
}
323
 
7003 dpurdie 324
//  Load a dialog into a dialog element
325
//  Like iFrame, but without the iFrame
7022 dpurdie 326
//  Useful options:
327
//      title   - Window Title
328
//      onLoad  - Function name to call after load
329
//      class   - Optional class to add to the dialog
6427 dpurdie 330
//
7022 dpurdie 331
function vixDialog( theURL, usrOptions ) {
332
 
7240 dpurdie 333
    $("body").addClass("cursor-wait");
7022 dpurdie 334
 
7240 dpurdie 335
    var options = $.extend({title : 'Dialog ', width : 300}, usrOptions,);
336
 
7003 dpurdie 337
	vixIframe.parent = this;
7022 dpurdie 338
	vixIframe.pagetitle = options.title;
7003 dpurdie 339
	vixIframe.url = theURL;
340
 
341
    var $dialog = $('<div></div>');
342
    $(document.body).append($dialog);
343
    $dialog.load( theURL, function(){
344
        var $dialog2 = $dialog.dialog({
345
            autoOpen: true,
346
            modal: true,
347
            height : 'auto', 
7240 dpurdie 348
            width : options.width,
7003 dpurdie 349
            resizable: true,
350
            position : { my:'top', at: 'top+100', of : window },
7022 dpurdie 351
            dialogClass: options.class,
352
            minHeight: 10,
7003 dpurdie 353
            title: 'Loading - ' + vixIframe.pagetitle,
354
            close: function(event, ui){
355
                //console.log('closing dialog');
356
                $(this).dialog("destroy");
357
                vixIframe = {};
358
                $(this).remove();
359
                window.onbeforeunload = null;
360
                window.onunload = null;
361
                },
362
            dragStop: function( event, ui ){
7022 dpurdie 363
                // Dragging adds a height which kill autosizing
364
                vixIframe.Dialog.closest('.ui-dialog').height('auto');
7003 dpurdie 365
                },
366
        });
367
        vixIframe.Dialog = $dialog;
368
        vixIframe.DialogProps = $dialog2;
369
 
370
        // Save to resize iframe
371
        vixIframe.IFrame = $dialog;
372
 
373
        // Reset the title
374
        vixIframe.Dialog.dialog('option','title', vixIframe.pagetitle);
375
 
376
        // Run init code for the frame
7022 dpurdie 377
        // Have a possible function name
378
        if ( options.onLoad ) {
379
            try {
380
                eval (options.onLoad + '();');
381
            } 
382
            catch (e) {
383
                console.log ("vixDialog failed to run the onLoad script:" + options.onLoad );
384
            }
385
        }
7243 dpurdie 386
        $("body").removeClass("cursor-wait");
7003 dpurdie 387
    });
388
}
389
 
390
//
6626 dpurdie 391
//  Copy the HTML from an element into the clipboard
392
//  Highlight the element clipped
393
//
394
function vixEl2Clip( el ) {
395
    // Get the text and clean it up
396
    var html = $.trim(el.html());
397
 
398
    var breakToken = '_______break_______';
399
    var lineBreakedHtml = html.replace(/<br\s?\/?>/gi, breakToken).replace(/<p\.*?>(.*?)<\/p>/gi, breakToken + '$1' + breakToken);
400
    var text = $('<div>').html(lineBreakedHtml).text().replace(new RegExp(breakToken, 'g'), '\r\n');
401
    text = $.trim(text);
402
 
403
    // Copy to clipboard
404
    var $temp = $("<textarea>");
405
    $(el).append($temp);
406
    $temp.val(text).select();
407
    document.execCommand("copy");
408
    $temp.remove();
409
 
410
 
411
    // Highlight the text that has been selected
412
    el.effect("highlight", {}, 1000);
413
    // el.css('background-color', 'rgba(0, 102, 255, .5)');
414
    // el.animate({backgroundColor: 'transparent'}, '1000');
415
 
416
    return el;
417
}
418
 
419
//
6427 dpurdie 420
//  Add copy to clipboard icon to every element with a class of 'clip'
421
//
422
$( document ).ready(function() {
6626 dpurdie 423
    var myClipHandler = function (event) {
6427 dpurdie 424
        // Get element to clip
6626 dpurdie 425
        vixEl2Clip($(this).find('.clipSel').eq(0));
426
    }
5266 dpurdie 427
 
6626 dpurdie 428
    $('.clip').on("click", myClipHandler).on("dblclick", myClipHandler);
5266 dpurdie 429
 
6626 dpurdie 430
    // Add a clip image to every class of either .clip
431
    $('.clip').wrapInner('<span class=clipSel></span>').append(
6427 dpurdie 432
        $('<img />')
433
            .attr({
434
                title : "Copy to clipboard",
435
                src : "images/CopyToClipboard.ico",
436
                height : "12px",
437
                width : "12px",
438
                hspace : "0px",
439
                align : "absmiddle",
440
                border : "0"
441
                })
6626 dpurdie 442
    );
443
});
6427 dpurdie 444
 
6626 dpurdie 445
// Copy data from a named element to clipboard
446
// Supports multi-line data with <p> and <br> in it
447
//      Elements have a class of clipElement and have an attribute of data-target=elementId
448
$( document ).on('click', '.clipElement', function(event){
449
 
450
    var ename = $(this).data('target');
451
    var el = $('#' + ename);
452
    vixEl2Clip(el);
6427 dpurdie 453
});
454
 
6592 dpurdie 455
// Add a clipThis handler to each element with a clipThis class
6610 dpurdie 456
//      Will copy the text of the element to the clipboard
457
//      Add dynamically so that it will be invoked on dynamically created elements
6592 dpurdie 458
$( document ).on('click', '.clipThis', function(event){
459
    var txt = $(this).eq(0).text();
460
    vixTextToClipBoard(txt, {note : "Copied to Clipboard", duration : 1000});
461
});
462
 
6610 dpurdie 463
// Copy data from element to clipboard
464
//      Elements have a class of clipData and an attribute of data-clip=xxx
465
//  Add dynamically so that it will be invoked on dynamically created elements
466
$( document ).on('click', '.clipData', function(event){
467
    var txt = $(this).data('clip');
468
    vixTextToClipBoard(txt, {note : "Copied to Clipboard", duration : 1000});
469
});
470
 
471
 
472
// Invoke mailto on elements with a suitable class
473
//  Elements with class mailto. and a data item of email
474
// Add dynamically so that it will be invoked on newly created elements
475
$( document ).on('click', '.mailto', function(event){
476
    var email = $(this).data('email');
477
    var name =  $(this).data('name');
6623 dpurdie 478
    var uname =  $(this).data('uname');
6610 dpurdie 479
    if ( !name ) {
480
        name =  $(this).eq(0).text();
481
    }
482
 
483
    var menu = '<div class="rex_clm" >&nbsp;Select Operation</div>';
484
    if ( name ) {
485
        menu += '<div class="mmItem clipData" data-clip="' + name + '">Copy Name to Clipboard</div>';
486
    }
6623 dpurdie 487
    if ( uname ) {
488
        menu += '<div class="mmItem clipData" data-clip="' + uname + '">Copy Login Name to Clipboard</div>';
489
    }
6610 dpurdie 490
    menu += '<div class="mmItem clipData" data-clip="' + email + '">Copy Email Address to Clipboard</div>';
491
    menu += '<div onClick="window.open(\'mailto:' + email + '\', \'_blank\');" class="mmItem">Send Email</div>';
492
    showmenu(event,menu);
493
    event.stopImmediatePropagation();
494
    event.stopPropagation();
495
    return false;
496
});
497
 
6589 dpurdie 498
// Copy text to clipboard
6971 dpurdie 499
// Need to append a dummy eleemnt to a point inthe document that can be selected
500
// In a modal dialog, the 'body' cannot be used. Use 'clipRoot' if its available
6589 dpurdie 501
function vixTextToClipBoard(txt, options){
502
    if ( txt == null ) {
503
        return;
504
    }
505
    var opts  = {
506
        note : "Data copied to Clipboard",
507
        title: "Notification",
508
        notify : true,
509
        timeout : 100,
510
        duration: 2000,
511
    }
512
    $.extend(opts, options);
6427 dpurdie 513
 
6971 dpurdie 514
    var useEl = $('#clipRoot');
515
    if ( useEl.length === 0  ){
516
        useEl =$('body') ;
517
    }
518
 
6589 dpurdie 519
    var $temp = $("<textarea>");
6971 dpurdie 520
    useEl.prepend($temp);
6589 dpurdie 521
    $temp.val(txt).select();
522
    document.execCommand("copy");
523
    $temp.remove();
6427 dpurdie 524
 
6589 dpurdie 525
    if ( opts.notify ) {
526
        vixConfirm(opts.note, {
527
            title: opts.title,
6641 dpurdie 528
            icon : "images/i_info.png",
529
            cancel: false,
6589 dpurdie 530
            button: null,
531
            timeout : opts.timeout,
532
            modal : false,
6641 dpurdie 533
            minHeight: 10,
6589 dpurdie 534
            hide: { effect: 'fade', duration: opts.duration }
535
            });
536
    }
537
}
538
 
6651 dpurdie 539
//  Export Table as CSV support functions
540
//      Allow a table that has been tagged with a class of etable to be exported
541
// 
542
// Global variable for use of the table to CSV widget
543
// Used to convey info though the selection callback
544
//
545
var vixEtableData;
546
 
547
$( document ).ready(function() {
548
    vixEtableInit();
549
});
550
 
551
//      vixPostPageLoad is called when dynamic DOM elements are loaded 
552
function vixPostPageLoad(){
553
    vixEtableInit();
554
}
555
 
556
//  Init all elements marked with a class of 'etable'
557
//      Insert an icon
558
//      Remove original class so that the DOM can be scanned again
559
function vixEtableInit(){
560
    $('.etable').css('position', 'relative');
561
    $('.etable th:last-child').append(
562
            $('<img />')
563
                .attr({
564
                    title : "Export table as CSV",
565
                    src : "images/CopyToClipboard.ico",
566
                    height : "12px",
567
                    width : "12px",
568
                    hspace : "0px",
569
                    align : "absmiddle",
570
                    border : "0"
571
                    })
572
                .css({position : 'absolute', top : '0px', right : '0px'})
573
                .click(function(event){
574
                    vixEtableData =  $(this).closest('table');
575
                    var menu = '<div class="rex_clm" >&nbsp;Select Operation</div>';
6695 dpurdie 576
                    menu += '<div class="mmItem" onClick="vixEtableProc(\'popup\');">Show&nbsp;in&nbsp;New&nbsp;Window</div>';
577
                    menu += '<div class="mmItem" onClick="vixEtableProc(\'modal\');">Show in Dialog</div>';
6651 dpurdie 578
                    menu += '<div class="mmItem" onClick="vixEtableProc(\'download\');">Download File</div>';
579
                    menu += '<div class="mmItem" onClick="vixEtableProc(\'clip\');">Copy to Clipboard</div>';
580
                    showmenu(event,menu);
581
                    event.stopImmediatePropagation();
582
                    event.stopPropagation();
583
                    return false;
584
                    })
585
        );
586
    $('.etable').addClass('etable-done').removeClass('etable');
587
}
588
 
589
//  Global function to support post-selection processing of CSV data
590
function vixEtableProc(mode) {
591
    var tdata = vixEtableData.data('etable')
592
    var defData = {
593
        delivery: mode,
594
        filename: 'data.csv',
595
        rowFilter: '.csvData'
596
        };
597
    $.extend(defData, tdata) ;
598
    var data = vixEtableData.TableCSVExport(defData);
599
    if ( mode == 'clip' ) {
600
        vixTextToClipBoard(data, {note : "CSV copied to Clipboard", duration : 1000});
601
    }
602
}
603
 
6695 dpurdie 604
// Create a new window in the center of the current screen
605
//  A wrapper for window.open(), with a few smarts
606
//  Does not position correctly on Widows-Edge
607
function PopupCenter(url, title, w, h) {
608
    // Fixes dual-screen position                         Most browsers      Firefox
609
    var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : window.screenX;
610
    var dualScreenTop = window.screenTop != undefined ? window.screenTop : window.screenY;
6651 dpurdie 611
 
6695 dpurdie 612
    var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
613
    var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
6651 dpurdie 614
 
6695 dpurdie 615
    var left = ((width / 2) - (w / 2)) + dualScreenLeft;
616
    var top = ((height / 2) - (h / 2)) + dualScreenTop;
617
    var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
6651 dpurdie 618
 
6695 dpurdie 619
    // Puts focus on the newWindow
620
    if (window.focus) {
621
        newWindow.focus();
622
    }
6651 dpurdie 623
 
6695 dpurdie 624
    return newWindow;
625
}
6651 dpurdie 626
 
627
 
628
 
6695 dpurdie 629
 
630
 
631
 
632
 
633
 
634