Skip to content

Commit

Permalink
Merged branch master into master
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslabbe committed Nov 3, 2016
2 parents 6609a1b + 4c6624a commit 6253c16
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/server/public/scripts/modules/EditorReload.js
Expand Up @@ -54,24 +54,26 @@ export default class Reload {

inject(str) {
var iframe = document.querySelector('#page-template')
var iframeBody = IframeDocument('#page-template').body
var scrollTop = iframeBody.scrollTop

var doc = iframe.contentWindow.document
str = str.replace(/<\/head>/, '<base href="/" /></head>')
var template = Handlebars.compile(str, {noEscape: true})
str = template(json)
doc.open()
doc.write(str)
doc.close()
iframe.onload = function() {
var iframeBody = IframeDocument('#page-template').body
var scrollTop = iframeBody.scrollTop

setTimeout(function () {
var iframeDoc = IframeDocument('#page-template')
if(typeof iframeDoc !== 'undefined' && iframeDoc !== null
&& typeof iframeDoc.body !== 'undefined' && iframeDoc.body !== null) {
iframeDoc.body.scrollTop = scrollTop
}
}, 1000)
var doc = iframe.contentWindow.document
str = str.replace(/<\/head>/, '<base href="/" /></head>')
var template = Handlebars.compile(str, {noEscape: true})
str = template(json)
doc.open()
doc.write(str)
doc.close()

setTimeout(function () {
var iframeDoc = IframeDocument('#page-template')
if(typeof iframeDoc !== 'undefined' && iframeDoc !== null
&& typeof iframeDoc.body !== 'undefined' && iframeDoc.body !== null) {
iframeDoc.body.scrollTop = scrollTop
}
}, 1000)
}
}

reload() {
Expand Down

0 comments on commit 6253c16

Please sign in to comment.