Skip to content

Commit

Permalink
Merge pull request #4 from zydio/defect-1788-ie7-compatibility-problems
Browse files Browse the repository at this point in the history
[#1788][s]: Another fix for IE 6/7/8 compatibility that addresses h.url_for_static in conditional browser sections (thx to @zydio).
  • Loading branch information
rufuspollock committed Mar 1, 2012
2 parents 1e0030e + 52855c8 commit 730c0ac
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
19 changes: 19 additions & 0 deletions ckan/templates/_util.html
Original file line number Diff line number Diff line change
Expand Up @@ -480,4 +480,23 @@
</span>
</div>

<!--! jsConditionalForIe(ieVersion, tagContent, matchOperator): takes a
IE version number, a tag or other HTML code that will be wrapped inside
a IE conditional comment, and the comparison operator (lt, lte, etc..
see http://msdn.microsoft.com/en-us/library/ms537512%28v=vs.85%29.aspx)
returning Genshi stream ready to be shown in a template.
NOTE:
Internet Explorer Conditional Import are confused as Genshi comments
and python variables and method calls are not executed if inside them.
This function helps to output tags with Python code inside conditional
comments, eg ${h.url_for_static()} -->
<?python
from genshi import HTML
def jsConditionalForIe(ieVersion, tagContent, matchOperator = 'lt'):
html = HTML('<!--[if ' + matchOperator + ' IE ' + str(ieVersion) + ''']>
''' + tagContent + '''
<![endif]-->''')
return html
?>
</html>
8 changes: 2 additions & 6 deletions ckan/templates/layout_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@
<link rel="stylesheet" href="${h.url_for_static('/css/chosen.css')}" type="text/css" />
<link rel="stylesheet" href="${h.url_for_static('/css/blueprint/screen.css')}" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="${h.url_for_static('/css/blueprint/print.css')}" type="text/css" media="print" />
<!--[if lt IE 8]>
<link rel="stylesheet" href="${h.url_for_static('/css/blueprint/ie.css')}" type="text/css" media="screen, projection">
<![endif]-->
<!--[if lt IE 9]>
<script type="text/javascript" src="${h.url_for_static('/scripts/vendor/html5shiv/html5.js')}"></script>
<![endif]-->
${jsConditionalForIe(8, '&lt;link rel="stylesheet" href="' + h.url_for_static('/css/blueprint/ie.css') + '" type="text/css" media="screen, projection"&gt;')}
<link rel="stylesheet" href="${h.url_for_static('/css/style.css?v=2')}" />
${jsConditionalForIe(9, '&lt;script type="text/javascript" src=" + h.url_for_static('/scripts/vendor/html5shiv/html5.js') + "&gt;&lt;/script&gt;')}

<py:if test="defined('optional_head')">
${optional_head()}
Expand Down

0 comments on commit 730c0ac

Please sign in to comment.