Created
June 23, 2017 20:08
-
-
Save dperussina/351ec789dd5c7cc723bd2674fb1af369 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
// Global VAR for current index of service level | |
var INDEX = 0; | |
// Where we place the description array from the MS | |
var descriptions = []; | |
// Monitor the select element | |
var heartbeat = setInterval(function () { | |
var newIndex = $("#SPNOrderDetails1_listServiceLevel").prop('selectedIndex'); | |
if (newIndex != INDEX) { | |
// if it detects the index changes it will set the new index | |
INDEX = newIndex; | |
// update the tool tip | |
setDescriptionByINdex(INDEX); | |
// add on change listener | |
$("#SPNOrderDetails1_listServiceLevel").on('change', function (e) { | |
// no anytime the user changes the select, we will capture the change | |
INDEX = $(this).prop('selectedIndex'); | |
// and update the tool tip | |
setDescriptionByINdex(INDEX); | |
}); | |
//We no longer need the heartbeat, so we clear the interval in place of the change event | |
clearInterval(heartbeat); | |
} | |
}, 1000); | |
function getQueryVariable(variable) { | |
var query = window.location.search.substring(1); | |
var vars = query.split("&"); | |
for (var i = 0; i < vars.length; i++) { | |
var pair = vars[i].split("="); | |
if (pair[0] == variable) { | |
return pair[1]; | |
} | |
} | |
return (false); | |
} | |
//get URL Var for PartnerIR | |
var PartnerID = getQueryVariable('pi'); | |
var url = 'http://ms1.agentgrid.net/api/tagnet/service_levelsByPartnerID?PartnerID=' + PartnerID; | |
// XHR Options | |
var options = { | |
type: 'GET', | |
url: url, | |
dataType: 'json', | |
success: success, | |
error: error | |
}; | |
// XHR Success | |
function success(res) { | |
// Handle JSON | |
// Check for SQL error | |
if (res.error == true) { | |
// Display error | |
// todo: handle error | |
return; | |
} | |
// Assign data to array variable | |
descriptions = res.data; | |
setDescriptionByINdex(INDEX); | |
} | |
// XHR Error | |
function error(err) { | |
// Handle XHR error | |
// todo: handle error | |
} | |
$.ajax(options); | |
function setDescriptionByINdex(index) { | |
// set the tool tip to he correct index | |
$(document).tooltip({ | |
items: "[title]", | |
content: function () { | |
var element = $(this); | |
if (element.attr("title") == "spn.ServiceLevelDetails") { | |
//fill tool tip with text | |
var x = descriptions[index].ServiceDescription; | |
return x; | |
} | |
} | |
}); | |
} | |
/* | |
Existing | |
*/ | |
var dialog; | |
dialog = $("#SPNControlNumberEditDialog").dialog({ | |
autoOpen: false, | |
width: $(window).width() - 40, | |
top: 50, | |
modal: true, | |
buttons: { | |
"Save Changes": saveChanges, | |
Cancel: function () { | |
$('#<%=txtSPNControlNumberEditWorkingNumber.ClientID %>').val(''); | |
dialog.dialog("close"); | |
__doPostBack('<%= txtSPNControlNumberEditWorkingNumber.ClientID %>', 'TextChanged'); | |
} | |
}, | |
close: function () { | |
//allFields.removeClass( "ui-state-error" ); | |
}, | |
open: function (type, data) { | |
//console.log('In dialog.open'); | |
} | |
}); | |
dialog.parent().appendTo(jQuery("form:first")); | |
function UpdateSetControlNumberLink() { | |
// console.log('In UpdateSetControlNumberLink') | |
$(".SPNControlNumberEditLink").button().on("click", function () { | |
//console.log('In UpdateSetControlNumberLink.SPNControlNumberEditLink') | |
$('#<%=txtSPNControlNumberEditWorkingNumber.ClientID %>').val($(this).html()); | |
$('#<%= listSPNControlNumberDetailJobType.ClientID %>').focus(); | |
dialog.dialog("open"); | |
__doPostBack('<%= txtSPNControlNumberEditWorkingNumber.ClientID %>', 'TextChanged'); | |
}); | |
} | |
UpdateSetControlNumberLink(); | |
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(UpdateSetControlNumberLink); | |
function OpenEditDialog() { | |
dialog.dialog("open"); | |
//console.log(' In OpenEditDialog'); | |
} | |
function CloseEditDialog() { | |
dialog.dialog("close"); | |
// console.log(' In CloseEditDialog'); | |
} | |
function saveChanges() { | |
$('#<%= btnSPNControlNumberDetailSave.ClientID %>').click(); | |
dialog.dialog('close'); | |
// console.log(' In saveChanges'); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment