Skip to content

Commit

Permalink
simpler way to load jquery
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Jun 10, 2015
1 parent b55e6e9 commit d209076
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
22 changes: 11 additions & 11 deletions nikola/data/themes/base-jinja/templates/gallery.tmpl
Expand Up @@ -54,6 +54,15 @@
{% endblock %}

{% block extra_js %}

<script>
{% if use_cdn %}
window.jQuery || document.write("<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'>\x3C/script>")
{% else %}
window.jQuery || document.write("<script src='/assets/js/jquery.min.js'>\x3C/script>")
{% endif %}
</script>

<script>
function createGallery() {
jQuery.getScript("/assets/js/flowr.plugin.js");
Expand Down Expand Up @@ -93,16 +102,7 @@ function createGallery() {
});
})};

// Load JQuery if it's not there already
if(typeof jQuery=='undefined') {
var headTag = document.getElementsByTagName("head")[0];
var jqTag = document.createElement('script');
jqTag.type = 'text/javascript';
jqTag.src = '//code.jquery.com/jquery-1.11.3.min.js';
jqTag.onload = createGallery;
headTag.appendChild(jqTag);
} else {
createGallery();
}
createGallery();

</script>
{% endblock %}
26 changes: 11 additions & 15 deletions nikola/data/themes/base/templates/gallery.tmpl
Expand Up @@ -54,6 +54,15 @@ ${parent.extra_head()}
</%block>

<%block name="extra_js">

<script>
%if use_cdn:
window.jQuery || document.write("<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'>\x3C/script>")
%else:
window.jQuery || document.write("<script src='/assets/js/jquery.min.js'>\x3C/script>")
%endif
</script>

<script>
function createGallery() {
jQuery.getScript("/assets/js/flowr.plugin.js");
Expand Down Expand Up @@ -93,20 +102,7 @@ function createGallery() {
});
})};

// Load JQuery if it's not there already
if(typeof jQuery=='undefined') {
var headTag = document.getElementsByTagName("head")[0];
var jqTag = document.createElement('script');
jqTag.type = 'text/javascript';
% if use_cdn
jqTag.src = '//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js';
% else
jqTag.src = '/assets/js/jquery.min.js';
% endif
jqTag.onload = createGallery;
headTag.appendChild(jqTag);
} else {
createGallery();
}
createGallery();

</script>
</%block>

0 comments on commit d209076

Please sign in to comment.