|
let curDomain = window.location.hostname.split('.').slice(-2).join('.') |
|
if (curDomain === 'acornfinance.com') { |
|
document.domain = 'acornfinance.com' |
|
} |
|
new Vue({ |
|
el: '#q-app', |
|
data: function () { |
|
return { |
|
version: Quasar.version, |
|
iframeUrl: 'https://qa.pr.acornfinance.com/app-page-1?dealerid=1001&hf=0', |
|
iframeClass: 'iframe-desktop' |
|
}; |
|
}, |
|
methods: { |
|
loadApply() { |
|
this.iframeUrl = ''; |
|
this.iframeUrl = 'https://qa.pr.acornfinance.com/app-page-1?dealerid=1001&hf=0'; |
|
this.$q.notify({ |
|
message: '<b>Loading Apply</b><br> ' + this.iframeUrl, |
|
html: true, |
|
multiLine: true, |
|
position: 'top', |
|
timeout: 5000, |
|
color: 'blue' |
|
}); |
|
}, |
|
loadOffers() { |
|
this.iframeUrl = |
|
'https://pr.acornfinance.com/offers?dealerid=JL92Z&applicationid=68059&hf=0'; |
|
this.$q.notify({ |
|
message: '<b>Loading Offers</b><br> ' + this.iframeUrl, |
|
html: true, |
|
multiLine: true, |
|
position: 'top', |
|
timeout: 5000, |
|
color: 'blue' |
|
}); |
|
}, |
|
receiveIframeMessage(event) { |
|
let message = event.data; |
|
if ( |
|
typeof message === 'string' && |
|
message.substr(0, 13) === 'Resize Height' |
|
) { |
|
console.log('Resize Height', message); |
|
let newHeight = message.substr(14, 10); |
|
this.setIframeHeight('applyIframeId', newHeight); |
|
} else if ( |
|
typeof message === 'string' && |
|
message.substr(0, 8) === 'Continue' |
|
) { |
|
console.log('Continue', message); |
|
this.hideForInput = true; |
|
this.$root.$emit('hide-tabs'); |
|
} |
|
}, |
|
getDocHeight (doc) { |
|
doc = doc || document |
|
// stackoverflow.com/questions/1145850/ |
|
var body = doc.body, html = doc.documentElement |
|
var height = Math.max(body.scrollHeight, body.offsetHeight, |
|
html.clientHeight, html.scrollHeight, html.offsetHeight) |
|
this.prevHeight = height |
|
// console.log('getDocHeight', height) |
|
return height |
|
}, |
|
setIframeHeight(id, height) { |
|
var ifrm = document.getElementById(id); |
|
var doc = ifrm.contentDocument |
|
? ifrm.contentDocument |
|
: ifrm.contentWindow.document; |
|
// var prevHeight = ifrm.style.height |
|
ifrm.style.height = '10px'; // reset to minimal height ... |
|
// IE opt. for bing/msn needs a bit added or scrollbar appears |
|
var newHeight = this.getDocHeight(doc) + 4; |
|
if (height > newHeight) { |
|
newHeight = height; |
|
} |
|
if (newHeight !== this.prevHeight) { |
|
ifrm.style.visibility = 'hidden'; |
|
ifrm.style.height = newHeight + 'px'; |
|
ifrm.style.visibility = 'visible'; |
|
} |
|
// console.log('setIframeHeight', prevHeight, newHeight, height) |
|
}, |
|
onResize(size) { |
|
if ( |
|
window.location.protocol !== 'https:' && |
|
window.location.hostname !== 'localhost' |
|
) { |
|
this.setIframeHeight('applyIframeId', 0); |
|
} |
|
if (this.$q.platform.is.desktop) { |
|
this.iframeClass = 'iframe-desktop'; |
|
} else { |
|
this.iframeClass = 'iframe-mobile'; |
|
} |
|
// console.log('Personal onResize', size, this.iframeClass) |
|
} |
|
} |
|
}); |