Skip to content

Commit

Permalink
Corrected HTMLPreparser logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahume committed May 14, 2013
1 parent d4fe100 commit 8c9c62d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
3 changes: 1 addition & 2 deletions common/app/common/BrowserSupport.scala
Expand Up @@ -5,8 +5,7 @@ import play.api.mvc.RequestHeader
class Browser extends Logging {

def HTMLPreparser(request: RequestHeader): Boolean = {
log.warn(request.headers.get("X-Gu-Feature-HTMLPreparser").getOrElse("nothing"))
!request.headers.get("X-Gu-Feature-HTMLPreparser").isDefined
request.headers.get("X-Gu-Feature-HTMLPreparser").isDefined
}

}
7 changes: 0 additions & 7 deletions common/app/views/fragments/commonCssSetup.scala.html
Expand Up @@ -8,13 +8,6 @@
.is-updating { background-image: url(@Static("images/auto-update-activity.gif")); }
</style>

@if(BrowserSupport.HTMLPreparser(request)) {

Win goes here.
} else {
No Win goes here.
}

<style class="initial" data-cache-name="WebEgyptian" data-cache-file-woff="@Static("fonts/WebEgyptian.woff.js")" data-cache-file-ttf="@Static("fonts/WebEgyptian.ttf.js")"></style>

<style class="initial" data-cache-name="WebEgyptianNav" data-cache-file-woff="@Static("fonts/WebEgyptianNav.woff.js")" data-cache-file-ttf="@Static("fonts/WebEgyptianNav.ttf.js")" data-min-width="300"></style>
29 changes: 17 additions & 12 deletions common/app/views/fragments/commonJavaScriptSetup.scala.html
Expand Up @@ -13,7 +13,8 @@
gallery: '@Static("stylesheets/gallery.min.css")',
story: '@Static("stylesheets/story.min.css")',
video: '@Static("stylesheets/video.min.css")'
}
},
config: @fragments.javaScriptConfig(item, switches)
},
curl = {
baseUrl: '@{Configuration.assets.path}javascripts',
Expand Down Expand Up @@ -62,18 +63,22 @@
}
})();

(function(isModern) {

if (!isModern) { return false; }
</script>

guardian.config = @fragments.javaScriptConfig(item, switches);
@if(BrowserSupport.HTMLPreparser(request)) {
<script src="@Static("javascripts/bootstraps/app.js")" async defer></script>
} else {
<script>
(function(isModern) {

var script = document.createElement('script');
script.async = 'async';
script.src = '@Static("javascripts/bootstraps/app.js")';
if (!isModern) { return false; }

document.getElementsByTagName("head")[0].appendChild(script);

})(guardian.isModernBrowser);
var script = document.createElement('script');
script.async = 'async';
script.src = '@Static("javascripts/bootstraps/app.js")';

</script>
document.getElementsByTagName("head")[0].appendChild(script);

})(guardian.isModernBrowser);
</script>
}

0 comments on commit 8c9c62d

Please sign in to comment.