Created
July 17, 2017 23:57
-
-
Save dperussina/49a42e375540ab570aa41f9884bd68e4 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
// 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 | |
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); | |
var first = true; | |
function setDescriptionByINdex(index) { | |
$(".ui-tooltip").remove(); | |
$(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; | |
} | |
} | |
}); | |
} | |
/* | |
Existingf | |
*/ | |
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'); | |
var heartbeat = setInterval(function () { | |
var newIndex = $("#SPNOrderDetails1_listServiceLevel").prop('selectedIndex'); | |
//console.log(newIndex); | |
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 | |
} | |
}, 1000); | |
} | |
}); | |
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'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment