-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_quote_button.js
50 lines (39 loc) · 1.67 KB
/
create_quote_button.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// We have this as a custom button on the zqu__Quote__c object
var buttonScope = buttonScope || {};
(function() {
function generateQuote(url) {
var iframe = document.createElement("iframe");
iframe.src = url;
iframe.style.height = "185px";
iframe.style.width = "100%";
iframe.style.marginTop = "15px";
iframe.style.display = "block";
iframe.style.border = "none";
var divFrame = document.getElementById("divForPdfFrame");
divFrame.appendChild(iframe);
// Listens to event from IFrame to reload quote page when done
window.addEventListener('message', function(event) {
if( event.data == 'pdfcomplete')
window.location.reload();
}, false);
}
var pageURL = window.location.hostname;
function addDivForFrame() {
var divForFrame = document.createElement('div');
divForFrame.id = "divForPdfFrame";
divForFrame.style.width = "30%";
divForFrame.style.height = "200px";
divForFrame.style.background = "white";
divForFrame.style.margin = "auto";
divForFrame.style.position = "fixed";
divForFrame.style.top = "25%";
divForFrame.style.left = "35%";
divForFrame.style.border = "thin solid black";
document.getElementsByTagName('body')[0].appendChild(divForFrame);
}
buttonScope.onClickGenerateQuotePdf = function() {
addDivForFrame();
generateQuote('https://'+pageURL+'/apex/ZuoraGenerateQuotePdf?quoteId={!zqu__Quote__c.Id}');
}
})();
buttonScope.onClickGenerateQuotePdf();