// Define dialog box pop-up
$bodyDiv.on('click', "a.pop", function(e){
var url = this.href;
var pagetitle = this.title;
//var dialogWidth = this.width;
var div = $("#dialog");
div.text(''); // clear out any contents
// Use query plugin to parse value from URL
$.query = $.query.load(url);
var dialogWidth = $.query.get('popwidth');
if (! dialogWidth) dialogWidth = 300;
var ajaxType = $.query.get('ajaxType');
if (! ajaxType) ajaxType = 'json';
var winht = $(window).height();
var dialogHeight = winht - 100;
// If invoice view then add a print button
var invNum = $.query.get('invoiceNumber');
var custNum = $.query.get('customerNumber');
// Start scrolling div
div.append('
');
// Make sure starts at top
//alert("pop2.3");
//$('#scrollDiv').show();
//$("#scrollDiv").animate({ scrollTop: 0 }, "fast");
//$('body, html, #scrollDiv').scrollTop(0);
//$('#scrollDiv').scrollTop(0);
//prevent the browser to follow the link
return false;
});
// Define dialog box pop-up for settings
$("body").on('click', "a.popSettings", function(e){
//var url = this.href;
var settingsUrl = "getdatamaster.php?module=setmonitor&screen=" + curScreen;
var url = settingsUrl + "&cmd=getsettings&ajaxType=html&format=html&popwidth=400";
//var pagetitle = this.title;
var pagetitle = "Your settings for this screen";
//var dialogWidth = this.width;
var div = $("#dialog");
div.text(''); // clear out any contents
// Use query plugin to parse value from URL
$.query = $.query.load(url);
var dialogWidth = $.query.get('popwidth');
if (! dialogWidth) dialogWidth = 400;
var ajaxType = $.query.get('ajaxType');
if (! ajaxType) ajaxType = 'json';
// Build buttons
var buttonObj = {};
buttonObj = {
'Submit': function() {
var params = '';
// Loop over all settings
$('.settings').each(function(index, item) {
params = params + this.id + ':' + $(item).val() + ';';
});
$(this).dialog('close');
// Save the selections in the database
saveSettings(settingsUrl + "&cmd=saveSettings¶ms=" + params);
},
'Close': function() {
$(this).dialog('close');
}
};
// load remote content
$.ajax({
url: url,
dataType: ajaxType,
//data: { debug: 'yes' },
success: function(data, textStatus, jqXHR) {
if (ajaxType == "json") {
//alert(JSON.stringify(data));
thedata=data.userdata.data.line;
var uldiv = $('', {
id: "infocontainer"
}).appendTo(div);
var ul = $('
').appendTo(uldiv);
infoLoop(thedata, ul);
}
else {
div.append(data);
// Make look of it match
$('.lbctablehead').removeClass("lbctablehead").addClass("ui-dialog-titlebar ui-widget-header ui-corner-all");
$('.lbctabcolhead').removeClass("lbctabcolhead").addClass("ui-state-default ui-th-column ui-th-ltr");
}
div.dialog({
modal: true,
title: pagetitle,
width: dialogWidth,
buttons: buttonObj
});
},
error: function(jqXHR, textStatus, errorThrown) {
var jsonValue = jQuery.parseJSON( jqXHR.responseText );
alert(textStatus);
//alert('an error occured');
},
complete: function(jqXHR, textStatus) {
// alert('all done');
},
});
//prevent the browser from following the link
return false;
});
// Function to save the settings
function saveSettings(url) {
//alert('url=' + url);
jQuery.ajax({
url: url,
async:false,
dataType: 'json',
success:function(data){
/*
// Refresh the grid
$listUNS2.setGridParam({
datatype:'json',
page:1,
url: stdUrl + '&cmd=getUNS2&dataType=griddata&id=' + UNS_id,
postData: {
theDB: function() {return $("#LOCdatabaseUNS").val();}
, NSdatabase: function() {return $("#NSdatabaseUNS").val();}
},
}).trigger('reloadGrid');
*/
}
});
}
/* I can't get this to work
// Bind an event listener to the dialogopen event
$("#dialog").on( "dialogopen", function( event, ui ) {
$('#dialog').show();
$('.scroll').show().scrollTop(0);
//$('#scrollDiv').show().scrollTop(0);
alert("pop2.13");
//$('#scrollDiv').scrollTop(0);
//$('body, html, #scrollDiv').scrollTop(0);
} );
*/