Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Commit

Permalink
Update function and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Klemarewski committed Sep 29, 2014
1 parent 62e685e commit d82a238
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
19 changes: 9 additions & 10 deletions api/main.js
Expand Up @@ -211,6 +211,15 @@ the browser behave as if the templated HTML was the regular source.

// Positioning this after the last `document.write`.
document.close();

if (Mobify.studioJS) {
Mobify.studioJS.get('renderHTML', function(markup) {
oldEmitMarkup(markup);
});
}

// Bind `orientationchange` listener and add `html` classes.
Mobify.enhance();
};

if (Mobify.isIOS8_0()){
Expand All @@ -219,16 +228,6 @@ the browser behave as if the templated HTML was the regular source.
} else {
write();
}

if (Mobify.studioJS) {
Mobify.studioJS.get('renderHTML', function(markup) {
oldEmitMarkup(markup);
});
}

// Bind `orientationchange` listener and add `html` classes.
Mobify.enhance();

};
var oldEmitMarkup;
if (Mobify.studioJS) {
Expand Down
15 changes: 11 additions & 4 deletions api/util.js
Expand Up @@ -115,10 +115,17 @@
head.appendChild(meta);

if (callback) {
// Wait two paints for the meta tag to take effect.
window.requestAnimationFrame(function() {
window.requestAnimationFrame(callback);
});
// Wait two paints for the meta viewport tag to take effect. This is
// required for this fix to work, but guard against it being undefined
// anyway just in case.
if (window.requestAnimationFrame) {
window.requestAnimationFrame(function() {
window.requestAnimationFrame(callback);
});
}
else {
callback();
}
}
};

Expand Down
17 changes: 17 additions & 0 deletions test/util-test.html
Expand Up @@ -251,7 +251,24 @@ <h2 id="qunit-userAgent"></h2>

});

test("Mobify.ios8_0ScrollFix", function() {
var html = document.createElement('html');
var head = document.createElement('head');
html.appendChild(head);

Mobify.ios8_0ScrollFix(html, function() {
var meta = html.getElementsByTagName('meta')[0]

ok(true,
'meta tag is appended');
equal(meta.getAttribute('name'), 'viewport',
'meta name is viewport');
equal(meta.getAttribute('content'), 'width=device-width',
'content is width=device-width');

start();
});
});

</script>
<body>
Expand Down

0 comments on commit d82a238

Please sign in to comment.