Created
February 21, 2017 15:49
-
-
Save jsmithdev/36979458025fb863686b6c8c9f423a28 to your computer and use it in GitHub Desktop.
This file contains 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
//##### BEFORE ##### | |
({ | |
openAttach : function(component, event, helper) { | |
var getUrlParameter = window.location.href; | |
var urlParts = getUrlParameter.split("/s/"); | |
console.log('aaa')+urlParts[0]; | |
var x =component.get("v.Atts"); | |
console.log(x[0][0]); | |
//alert(urlParts[0]); | |
//var tempId = urlParts[1]; | |
var url = urlParts[0]+'/servlet/servlet.FileDownload?file=00P21000000cKBOEA2'; | |
// var url = urlParts[0]+'/servlet/servlet.FileDownload?file='component.get("v.recordId"); | |
//alert(url); | |
window.location.href = url; | |
}, | |
fetchContactList : function(component, event, helper) { | |
// get id from url begin - marty added this | |
var getUrlParameter = window.location.href; | |
//var urlParts = getUrlParameter.split("/support-network/"); | |
//var tempId = urlParts[1]; | |
var tempId = getUrlParameter.substring(getUrlParameter.lastIndexOf("/") + 1, getUrlParameter.length); | |
//console.log('1mw tempId'+tempId); | |
component.set("v.Id", tempId); | |
//console.log('2mw tempId'+tempId); | |
// get id from url end - marty added this | |
var action = component.get("c.getContacts"); | |
action.setParams({ | |
"contactId": component.get("v.recordId") | |
}); | |
action.setCallback(this, function(response) { | |
var state = response.getState(); | |
if (component.isValid() && state === "SUCCESS") { | |
component.set("v.contacts", response.getReturnValue()); | |
} | |
}); | |
$A.enqueueAction(action); | |
// Get detail data begin - marty added this | |
console.log('mw tempId'+tempId); | |
action = component.get("c.getMeds"); //change here - match method name in apex | |
action.setParams({ | |
"contactId": tempId | |
}); | |
var self = this; | |
action.setCallback(this, function(response){ | |
state = response.getState(); | |
if (state === "SUCCESS") { | |
component.set("v.meds", response.getReturnValue()); | |
} else if (state === "ERROR") { | |
console.log('error building Medication table'); | |
} | |
}); | |
$A.enqueueAction(action); | |
// Get detail data end - marty added this | |
// Get detail data begin - marty added this | |
action = component.get("c.getConditions"); //change here - match method name in apex | |
action.setParams({ | |
"contactId": tempId | |
}); | |
var self = this; | |
action.setCallback(this, function(response){ | |
state = response.getState(); | |
if (state === "SUCCESS") { | |
component.set("v.conditions", response.getReturnValue()); | |
} else if (state === "ERROR") { | |
console.log('error building Medication table'); | |
} | |
}); | |
$A.enqueueAction(action); | |
// Get detail data end - marty added this getAtts | |
// Get detail data begin - marty added this | |
action = component.get("c.getAtts"); //change here - match method name in apex | |
var getUrlParameter = window.location.href; | |
var urlParts = getUrlParameter.split("k/"); | |
var tempId = urlParts[1]; | |
//var tempId = component.get("v.Id"); | |
action.setParams({ | |
"contactId": tempId | |
}); | |
var self = this; | |
action.setCallback(this, function(response){ | |
state = response.getState(); | |
if (state === "SUCCESS") { | |
component.set("v.Atts", response.getReturnValue()); | |
} else if (state === "ERROR") { | |
console.log('error building Medication table'); | |
} | |
}); | |
$A.enqueueAction(action); | |
} | |
}) | |
({ | |
setOutput : function(component, event, helper) { | |
var cmpMsg = component.find("msg"); | |
$A.util.removeClass(cmpMsg, 'hide'); | |
var email = component.find("email").get("v.value"); | |
var oEmail = component.find("oEmail"); | |
oEmail.set("v.value", email); | |
} | |
}) | |
({ | |
getresults: function(component, event, helper) { | |
console.log(component.get("v.recordId"));//print the Id | |
} | |
}) | |
$('a[href*="#"]:not([href="#"])').click(function() { | |
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { | |
var target = $(this.hash); | |
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); | |
if (target.length) { | |
$('html, body').animate({ | |
scrollTop: target.offset().top | |
}, 1000); | |
return false; | |
} | |
} | |
}); | |
//##### AFTER ##### | |
/* global $ */ //jme | |
/* global location */ //jme | |
({ | |
openAttach: function(component, event, helper) { | |
var getUrlParameter = window.location.href; | |
var urlParts = getUrlParameter.split("/s/"); | |
console.log('aaa') + urlParts[0]; | |
var x = component.get("v.Atts"); | |
console.log(x[0][0]); | |
//alert(urlParts[0]); | |
//var tempId = urlParts[1]; | |
var url = urlParts[0] + '/servlet/servlet.FileDownload?file=00P21000000cKBOEA2'; | |
// var url = urlParts[0]+'/servlet/servlet.FileDownload?file='component.get("v.recordId"); | |
//alert(url); | |
window.location.href = url; | |
}, | |
fetchContactList: function(component, event, helper) { | |
// get id from url begin - marty added this | |
var getUrlParameter = window.location.href; | |
//var urlParts = getUrlParameter.split("/support-network/"); | |
//var tempId = urlParts[1]; | |
var tempId = getUrlParameter.substring(getUrlParameter.lastIndexOf("/") + 1, getUrlParameter.length); | |
//console.log('1mw tempId'+tempId); | |
component.set("v.Id", tempId); | |
//console.log('2mw tempId'+tempId); | |
// get id from url end - marty added this | |
var action = component.get("c.getContacts"); | |
action.setParams({ | |
"contactId": component.get("v.recordId") | |
}); | |
action.setCallback(this, function(response) { | |
var state = response.getState(); | |
if (component.isValid() && state === "SUCCESS") { | |
component.set("v.contacts", response.getReturnValue()); | |
} | |
}); | |
$A.enqueueAction(action); | |
// Get detail data begin - marty added this | |
console.log('mw tempId' + tempId); | |
action = component.get("c.getMeds"); //change here - match method name in apex | |
action.setParams({ | |
"contactId": tempId | |
}); | |
var self = this; | |
action.setCallback(this, function(response) { | |
let state = response.getState(); //jme | |
if (state === "SUCCESS") { | |
component.set("v.meds", response.getReturnValue()); | |
} | |
else if (state === "ERROR") { | |
console.log('error building Medication table'); | |
} | |
}); | |
$A.enqueueAction(action); | |
// Get detail data end - marty added this | |
// Get detail data begin - marty added this | |
action = component.get("c.getConditions"); //change here - match method name in apex | |
action.setParams({ | |
"contactId": tempId | |
}); | |
var self = this; | |
action.setCallback(this, function(response) { | |
let state = response.getState(); //jme | |
if (state === "SUCCESS") { | |
component.set("v.conditions", response.getReturnValue()); | |
} | |
else if (state === "ERROR") { | |
console.log('error building Medication table'); | |
} | |
}); | |
$A.enqueueAction(action); | |
// Get detail data end - marty added this getAtts | |
// Get detail data begin - marty added this | |
action = component.get("c.getAtts"); //change here - match method name in apex | |
var getUrlParameter = window.location.href; | |
var urlParts = getUrlParameter.split("k/"); | |
var tempId = urlParts[1]; | |
//var tempId = component.get("v.Id"); | |
action.setParams({ | |
"contactId": tempId | |
}); | |
var self = this; | |
action.setCallback(this, function(response) { | |
let state = response.getState(); //jme | |
if (state === "SUCCESS") { | |
component.set("v.Atts", response.getReturnValue()); | |
} | |
else if (state === "ERROR") { | |
console.log('error building Medication table'); | |
} | |
}); | |
$A.enqueueAction(action); | |
} | |
}) | |
({ | |
setOutput: function(component, event, helper) { | |
var cmpMsg = component.find("msg"); | |
$A.util.removeClass(cmpMsg, 'hide'); | |
var email = component.find("email").get("v.value"); | |
var oEmail = component.find("oEmail"); | |
oEmail.set("v.value", email); | |
} | |
}) | |
({ | |
getresults: function(component, event, helper) { | |
console.log(component.get("v.recordId")); //print the Id | |
} | |
}) | |
// jme | |
const elem = $('a[href*="#"]:not([href="#"])'); | |
elem.addEventListener('click', $A.getCallback(handleResp(), false)); | |
function handleResp(){ | |
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { | |
var target = $(this.hash); | |
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); | |
if (target.length) { | |
$('html, body').animate({ | |
scrollTop: target.offset().top | |
}, 1000); | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment